msd
Members-
Content Count
79 -
Joined
-
Last visited
Everything posted by msd
-
Hello, In peak time, it can be 5–10 times per second (it is not as heavy as it looks in my description). I have one more method, which is to create a response, and it must be thread-safe. I'll post it here as part of this message. The whole system has two parts: the first is communication with counters, and the other is information about which counter needs to show which number. So, all counters are 100% online with an open connection, and after the system receives new data from another side of the system, it must search all connected counters and pass new data. This is another important part of the code. function TFServer.cliSendData(cliIP: string; cliCMD: string = ''; cliAddress: string = ''; cliValue: string = ''): Boolean; var i: integer; cliList: TList; byteMsg: TidBytes; cntClient: TIdContext; function SetCounter(dspAddress, dspValue: string): TidBytes; begin SetLength(bytes, 8); bytes[0] := BYTE_START; bytes[1] := BYTE_DATA; bytes[2] := $31; bytes[3] := $00; case StrToInt(Copy(cntValue, 1, 2)) of 00: bytes[4] := $00; 01: bytes[4] := $01; 02: bytes[4] := $02; 03: end; bytes[5] := $00; case StrToInt(cntValue[3]) of 0: bytes[6] := $00; 1: bytes[6] := $01; 2: bytes[6] := $02; end; bytes[7] := BYTE_STOP; result := bytes; end; begin byteMsg := SetCounter(cliAddress, cliValue); try cliList := DisplayServer.Contexts.LockList; for i := 0 to cliList.Count - 1 do begin cntClient := TIdContext(cliList); // AContext.Connection.Disconnect if cntClient <> nil then try if (cliIP = 'ALL') or (cliIP = cntClient.Binding.PeerIP) then begin cntClient.Connection.IOHandler.Write(byteMsg); cliInfoMessage(dspLog, 'SERVER', cliLogDateTime() + ' - Send: ' + cliCMD + ' to Client: - ' + cntClient.Binding.PeerIP); end; except end; end; finally DisplayServer.Contexts.UnlockList; end; result := true; end; Thanks to all developers for their help and assistance.
-
Hello. I have one TCP/IP server by the Indy component and one memo field for some kind of monitoring. Indy component accepts connection, sends identification request to client, and opens and keeps openend connection. I'm using three events: OnConnect, OnDisconnect, and, of course, OnExecute. The first two just accept and log connection status and details; everything else is on the OnExecute event. I can represent the function that updates the monitoring memo component. function TFServer.cliInfoMessage(info: TMemo; send, msg: string): Boolean; begin TThread.Queue(nil, procedure begin info.Lines.Append('/' + send + '/' + msg); end); result := true; end; Another function is the response function, which can be bad coded because it does not generate a response for client activity on an open connection. P.S. Yes my app is freeze from r time to time and power up CPU to 100% for few minutes. Thanks again for all...
-
Hello, I would like to develop a KBMMW-based Windows Service Application. So I need a little assistance with this idea, with code for starting and monitoring KBMMW components. KBMMW is some kind of middleware framework that connects to databases and provides server connections to clients. So, I need to develop a classic Windows service application, which has a part where I need to register services and start the KBMMW Server listener to true. Do I need to execute the main thread of the service app because the KBMMW server is a listener on the port by itself, and is it ok to put this part of the code (registration services) in the service start event handler? Thanks in advance...
-
Hello, I have a problem with failed printer jobs. When I have one failed printer job, all the rest are on hold, and there are no prints. So, I need some ideas on how to empty all or just failed printer jobs from the printer to free a new one. I'm using Fats Report from Delphi, and if there are ideas from the Fast Report API, that is okay also. Thanks in advance...
-
Hello, If I want to set all params of Delphi function to be const (because of small amount of memory) do I need to define it as: function FnName(const varA: string; const varB: integer; const varC: boolean = false): boolean; OR function FnName(const varA: string; varB: integer; varC: boolean = false): boolean; Thanks in advance...
-
Hello,, I was installing a fresh new version of RAD Studio 11.2 and on some packages I get this error (for example, I show it on kbmMW): [dcc64 fatal error] kbmMWGlobal.pas(34): E2213 Bad packaged unit format: [dcc64 Fatal Error] kbmMWGlobal.pas(34): E2213 Bad packaged unit format: C:\Users\Public\Documents\Embarcadero\Studio\22.0\Dcp\kbmMemRunD110Pro.dcp.kbmList - Expected version: 35.0, Windows Unicode(x64) Found version: 35.0, Windows Unicode(x86) I have this error in a few cases for different VCLs. Thanks in advance...
-
Solved 😉 Add $(BDSCOMMONDIR)\Dcp\Win64, before $(BDSCOMMONDIR)\Dcp in Library Path and everything works fine...
-
Hello, On the form OnFormKey UP or DWN, we can use the entire keyboard, but for the numeric part, we have VK_ADD, VK_MULTIPLY,... I need some advice for using those keys in OnFormKeyDown, Up, or Press like this sample below: When a user searches for data in the TEdit VCL by typing letters and numbers and then clicking on the numeric + key VK_ADD, the app does something BUT WITHOUT adding +char to the TEdit VCL control. Simple: I need to use those keys but without the characters they represent: +, -, /, and *. Thanks for the advice in advance...
-
Hello, I would like to add some extra features to standard Delphi VCL components. For example, I want to expand the TEdit class with some properties and evets. When I create class TmyEdit = class(TEdit) in runtime, it works fine. I call the create method and I can use it. But! I need to have a TmyEdit as a VCL component which can be put in a form at design time and configure some properties and connect some events at design time. I tried with Initialization RegisterClass(TmyEdit), but the same error is there. The error is: class TMyEdit is not found. Ignoring this error will delete this component... Thanks for any info and advice in advance...
-
Hello, I need some unique hardware ID code generator which will be a piece of Delphi code or some VCL library without any external dll's or libraries. The idea is that I have all computers in my catalog by hardware id, and when a user has some requests, I find his client computer in my catalog and send him a repair script. The main goal is to provide each client with a unique id across the entire system. Thanks in advance for any tips or samples...
-
Hello, I have one big project and I migrated it from older versions of Delphi to the latest Delphi 11.1. High-DPI is one of the unsolved issues. When I start the app on a computer which has activated zoom over 100% (High-DPI screen), the whole components are in a mess on all forms. So, how to solve this scenario so that my app can keep resolution and aspect ratio every time in every zoom factor on the client's PC? Thanks for the help and support in advance.
-
Hello Uwe, Delphi is not a problem; it works fine. The problem is compiled applications and distributed on computers with high-DPI screens. I need to solve deployed applications... Thanks anyway for the advice.
-
Hello, I have a class which is a representation of some API communication with a REST server and that class has methods that exchange data with the server. Because this class has communication with REST, I can't wait for every response and I would like to add threat functionality to this class. My idea is that when I call the create method of my class, it will start in a separate thread and the whole class will work in its own thread and every method call to this class will be async. The response class (thread in class) informs the main thread that it contains some data and the app can use it. Thanks for the tips and advices in advance...
-
Hello, I made my custom solution and I got the hardware fingerprint I wanted (for example, 1805-AD75-1308-150F) and it is definitely unique because I'm using 3-5 hardware components when I plan to generate this fingerprint. This is a similar solution to popular DLL components, which return some code to represent a unique hardware id, but in my dev factory. Thank you for all of the professional responses and information:-)
-
Hello, We need to create an XML document file for an online document exchange system, and that XML file must include attachments. I can show you how it appears, but I'm not sure how to add/encode documents into a string that will be used to represent documents in an XML file (like attachment). In other words, how to encode a file into a string that may be used to represent it in an XML structure. Thank you very much...
-
Encode (pdf, jpg, ...) in to XML
msd replied to msd's topic in Algorithms, Data Structures and Class Design
I was made function that works the job 🙂 if someone need it... function EncodePDF(const AFileName: string): string; var inStream: TStream; outStream: TStringStream; begin inStream := TFileStream.Create(AFileName, fmOpenRead); try outStream := TStringStream.Create; try TNetEncoding.Base64.Encode(inStream, outStream); finally Result := outStream.DataString; outStream.Free; end; finally inStream.Free; end; end; if someone has better idea, please post it here 😉 -
Encode (pdf, jpg, ...) in to XML
msd replied to msd's topic in Algorithms, Data Structures and Class Design
This is a link: https://base64.guru/converter/encode/pdf where you can find how to encode PDF and the correct way to add it to XML. This link was given to us by the developer, and when we use this online tool and generate an XML tag, everything works fine:-) It looks like a simple Base64 encode from Delphi is OK, so if you can give me a sample (only encode/decode part of code). -
Encode (pdf, jpg, ...) in to XML
msd replied to msd's topic in Algorithms, Data Structures and Class Design
Because I only work on the client side, I have no experience with server-side encoding. I'm aware that the documentation specifies that nodes with attachments must be document/pdf in binary format. My initial question was about how to convert PDF files to binary and then put it into XML. I'll try Base64 Encoding first, and if it works, I'll put a bit of code here for the other members to see. Thank you for your suggestions... -
Encode (pdf, jpg, ...) in to XML
msd replied to msd's topic in Algorithms, Data Structures and Class Design
I wrote that this is a universal doc exchange web app. I'm from the client side. I need to push XML to the web app in XML format with an embedded PDF document. -
Encode (pdf, jpg, ...) in to XML
msd replied to msd's topic in Algorithms, Data Structures and Class Design
Hello, This is an example from an existing document... <cbc:EmbeddedDocumentBinaryObject mimeCode="application/pdf" filename="document_name.pdf">JVBERi0xLjcNCiW.....EmbeddedDocumentBinaryObject> This is a universal app, so there is no specific need for some encoding or decoding, just a simple representation of the binary representation of the document... -
Hello, I'm working now on Latest RAD Studio and I version incompatibility of my source which is generating some unique HardwareID function InternalGetHardwareID(Hdd: AnsiChar): AnsiString; var pdw: pDWord; mc, fl: dword; ID_1: AnsiString; ID_1L: dword; ID_2: Cardinal; ID_3: Cardinal; ID_5: AnsiString; CPUID: TCPUID; I: Integer; AddOn: Longword; TempStr: AnsiString; TempByte: Byte; Index: Integer; FUniqueID: AnsiString; begin Result := ''; FUniqueID := '{61AF17B9-4EDB-4849-93CD-113C14E139F7}'; try New(pdw); GetVolumeInformation(PChar(Hdd + ':'), nil, 0, pdw, mc, fl, nil, 0); ID_1L := pdw^; ID_1 := IntToHex(pdw^, 8); Dispose(pdw); except exit; end; for I := Low(CPUID) to High(CPUID) do CPUID[I] := -1; if IsCPUIDAvailable then begin CPUID := GetCPUID; ID_2 := CPUID[1] + CPUID[2] + CPUID[3] + CPUID[4]; // First chance exception at $7631ED42. Exception class EIntOverflow with message 'Integer overflow' ID_3 := (CPUID[1] shr 12 and 3) * (CPUID[1] shr 8 and $F) * (CPUID[1] shr 4 and $F) * (CPUID[1] and $F); ID_5 := GetCPUVendor; {$WARNINGS OFF} AddOn := Longword(ID_1L + ID_2 * ID_3); for I := 1 to Length(ID_5) do AddOn := (AddOn xor Ord(ID_5[I])); TempStr := IntToHex(AddOn, 8); Index := 1; for I := 1 to Length(TempStr) do begin {$R-} TempByte := ((Ord(TempStr[I]) xor (AddOn div I)) + Ord(ID_1[I])) div 5; {$R+} {$WARNINGS ON} if poUniqueHardwareID in Options then // This is error line begin TempByte := Ord(FUniqueID[Index]) xor TempByte; Inc(Index); if Index > Length(FUniqueID) then Index := 1; end; Result := Result + IntToHex(TempByte, 2); end; if Length(Result) > 16 then Result := Copy(Result, 1, 16); if Length(Result) < 16 then for I := Length(Result) + 1 to 16 do Result := '0' + Result; end else begin if Assigned(FOnUnknownHardware) then FOnUnknownHardware(Self); // This is error line end; end;
-
Hello, I have a little bit specific situation with one web service, It receives HTTP requests over the HTTP 1.0 protocol but the problem is when TransferEncoding is Chunked. Can I force TidHTTP not to send TransferEncoding is Chunked? I try with HTTPClient.Request.TransferEncoding := 'gzip, deflate, br'; but I get chunked on the webserver side.
-
Hello Angus, Could you please, if you have little free time, put here some sample pieces of source code for posting data / JSON in a way that you were described with ICS? Thanks for any assistance and support in advance...
-
Hello, I found that Delphi has a nice classes for JSON objects TJsonTextReader & TJsonTextWriter and I have one quesion for the TJsonTextReader. How to extract only search node from bottom JSON sample (or columns node or colors node, I need only one node for processing out of whole JSON) { "columns":[ { "column":"AccountID", "caption":"Account", "width":"100" }, { "column":"Name", "caption":"Account Name", "width":"250" }, { "column":"IsActive", "caption":"A", "width":"30" } ], "search":[ { "column":"Account", "rules":"Asc" }, { "column":"Name", "rules":"Asc;Part" } ], "colors":[ { "column":"Account", "rules":"Red;White" }, { "column":"Name", "rules":"Blue;Black" } ] } Thanks for the help and assistance in the advance 🙂
-
Hello Remy Lebeau, Two very good ideas :-) I plan to use JsonReader because of memory usage and it is fresh tech in RAD Studio, but you give me very good tip. Thanks once again for the all advices...