Jump to content

Leaderboard


Popular Content

Showing content with the highest reputation on 02/08/23 in all areas

  1. Anders Melander

    Move objects to a second Data Module

  2. programmerdelphi2k

    Move objects to a second Data Module

    You could try something along these lines: you create a new "DataModule in your project" (thus, Delphi already creates the .PAS unit and the .DFM file! = more easy way! Now, you can use a procedure like the one below to read the components you want to remove from the source-datamodule and insert them into your new datamodule created above! Remembering that "InsertComponent()" will automatically try to remove the component from the source to insert it in the target! type TMyArrayOfThisComponents = TArray<string>; procedure MyInsertAllComponentsOnDM(const ADMsource, ADMtarget: TDataModule); begin while (ADMsource.ComponentCount > 0) do ADMtarget.InsertComponent(ADMsource.Components[0]); // "remove" from source and "insert" on target! end; procedure MyInsertThisComponentsOnDM(const ADMsource, ADMtarget: TDataModule; const AComponents: TMyArrayOfThisComponents); begin for var C in AComponents do // all list of components names... begin for var i: integer := 0 to (ADMsource.ComponentCount - 1) do if (ADMsource.Components[i].Name = C) then // if exists on DMsource... begin ADMtarget.InsertComponent(ADMsource.Components[i]); // "remove" from source and "insert" on target // break; // next components-name... end; end; end; procedure TForm1.BtnUsingDMonProjectClick(Sender: TObject); begin try // DataModule3/Unit3 is a DataModule created on this project, for example! // // MyInsertAllComponentsOnDM(DataModule2, DataModule3); MyInsertThisComponentsOnDM(DataModule2, DataModule3, ['FDQuery1', 'FDConnection', 'dsQuery1', '...']); // WriteComponentResFile('Unit3.dfm', DataModule3); // Unit3.pas and Unit3.DFM "already" exists in your project!!! except // ??? end; end; procedure TForm1.BtnCreatingAnewDMfileClick(Sender: TObject); var MyNewDM: TDataModule; begin MyNewDM := TDataModule.Create(nil); try MyNewDM.Name := 'MyNewDM'; try // MyInsertAllComponentsOnDM(DataModule2, MyNewDM); MyInsertThisComponentsOnDM(DataModule2, MyNewDM, ['FDQuery1', 'FDConnection', 'dsQuery1', '...']); // WriteComponentResFile('MyNewDM.dfm', MyNewDM); // // now, you needs create your "UNIT.pas" for this "MyNewDM.DFM file" like IDE do it! except // ??? end; finally MyNewDM.Free; end; end; now, you'll have your components inserted in your "new datamodule", then, you can just "ADD it" in your project, and create your "event" (or copy it from old datamodule) in the tests, the properties are kept as in the source! you would can automatizate this, but needs much more code to verify each object and your events, ...read source, write target ...
  3. Stano

    Move objects to a second Data Module

    I would try another way. To gradually create individual objects dynamically if necessary. One of the possibilities is to find out where a specific object is used everywhere. Then decide accordingly. If it is used only in one place, then there is nothing to think about. But it is a very laborious procedure. It is estimated that there are around 500 objects It is not normal!
  4. I solved this thanks to the kind collaboration of the nSoftware assistance service (SecureBlackBox's developer). There were many challenges to solve to achieve the goal and very little can be found online. It is my understanding that this type of security is not used much in the Delphi environment. However I solved by combining several components provided with the SecurityBlackBox suite: TsbxCertificateStorage to read JKS file to reach public key (used to encrypt the request and verify the signed response) and private key (used to sign the request and decrypt the response) TsbxSOAPSigner to sign the SOAP request (to produce a WSSSignature) TsbxXMLEncryptor to embed in the request the encryption key (transported with RSA-OAEP sha1) and to crypt the SOAP request body (with AES128 algorithm) TsbxXMLDecryptor to decrypt the response (two items encrypted in the response: the sign and the body) TsbxSOAPVerifier to verifiy the sign in the response I've injected this encryption/decryption stuff in THTTPRio events, somthing like this; procedure TMultyAssociativeServiceWrapper.SOAPOnBeforeExecute(const MethodName: String; SOAPRequest: TStream); begin // save the original request (created by THTTPRio) for debug purpose SOAPRequest.Seek(0,0); (SOAPRequest as TMemoryStream).SaveToFile(FFileRequestOriginal); // sign and encrypt the original request SBBSoapSignAndEncryptWithJKS(FFileRequestOriginal, FFileRequestToSend, FCertificateFileJKS, OnPasswordNeeded); // ... do some other stuff ? // update the outcoming request with the signed crypted version SOAPRequest.Seek(0,0); (SOAPRequest as TMemoryStream).LoadFromFile(FFileRequestToSend); end; procedure TMultyAssociativeServiceWrapper.SOAPOnAfterExecute(const MethodName: String; SOAPResponse: TStream); begin // save te orginal response arrived from service for debug purpose SOAPResponse.Seek(0,0); (SOAPResponse as TMemoryStream).SaveToFile(FFileResponseOriginal); // decrypt and verify sign of response SBBSoapDecryptAndVerifyWithJKS(FFileResponseOriginal, FFileResponseDecoded, FCertificateFileJKS, OnPasswordNeeded); //... do some other stuff? // update the incoming response with the decrypted data SOAPResponse.Seek(0,0); (SOAPResponse as TMemoryStream).LoadFromFile(FFileResponseDecoded); end; SBBSoapSignAndEncryptWithJKS does sign + encryption stuff. SBBSoapDecryptAndVerifyWithJKS does decrypt and verify sign stuff. I hope this can be helpful for someone else who runs into this need. If you need the code of the two SBB procedures described above please ask me. I've used SecureBlackBox components but I think that same stuff could be reached also with ChilKat library. I did some tests with the demo library, it works at a lower level of SBB but there are several examples online that could be combined to reach the goal.
  5. Incus J

    Puzzled by StrToDate

    I agree FMX tends to change more between versions, and it can be a challenge to keep up. But to clarify (hopefully) - my development system is HiDPI and I find when I open any existing VCL form in Alexandria it modifies the position and dimension values (the actual stored x/y/width/height) of all objects on the form. The forms then no longer work on older versions of Windows (e.g. 7/8) - so I avoid Alexandria for VCL projects. Don't get me wrong - I love the look of the HiDPI IDE in Alexandria, and FMX forms behave fine in it, but feel I can not use it for VCL projects. I may have strayed off topic.
  6. Lajos Juhász

    Puzzled by StrToDate

    If you are looking how the Delphi is converting the month names you can search for @AFormatSettings.ShortMonthNames in the System.SysUtils.
  7. aehimself

    Puzzled by StrToDate

    This is the method I ended up using: Procedure FixDateSeparator; Var Buffer: Array[0..2] Of Char; Begin If GetLocaleInfo(GetThreadLocale, LOCALE_SDATE, Buffer, 3) > 0 Then Begin FormatSettings.DateSeparator := Buffer[0]; FormatSettings.ShortDateFormat := FormatSettings.ShortDateFormat.Replace(FormatSettings.DateSeparator, '/'); End Else FormatSettings.DateSeparator := '/'; End; It's a close copy to Delphi 11.2's GetLocaleChar implementation which will fix the buffer underrun in prior versions. Add a TFormatSettings parameter and call it with "fmt" before you call StrToDate. This is the good news. The bad news is, parsing strings as dates was heavily refactored in D11. If the above won't fix your problem, you'll have to start playing around. For me the date format was "yyyy. mm. dd." D10.4 was happy to parse "2023. 02. 07" but D11 required the final dot.
  8. mytbo

    Enable protocol TLS 1.3 on Windows 7

    No, you are using the wrong libcurl DLL. Please download the file only from the official site and do not use any other source. Here is the link to the Windows download. The file for curl for 32-bit has the name curl-7.87.0_4-win32-mingw.zip and SHA256: ef8730e31245ef138aba1e3f02ae02e3fce435ec89177d7c8b05de5ce3c07891. The libcurl DLL has the modification date: Wednesday, December 21, 2022, 07:05:38. File size is 4,405,320 bytes. With best regards Thomas
  9. programmerdelphi2k

    Puzzled by StrToDate

    using mask "MMM/d/yyyy" it's works! = no exception! Now, "Names" = month-names short! MSWindows Datetime formats: MM = nn MMM = Sss NOTE: in my RAD11.2 "mmm" works too!
  10. Patrick PREMARTIN

    Need a "Delphi programming guideline"

    Good luck to them. Managers don't realize what they do. The problem is not only a "Delphi is old idea" but also "Internet is beautiful, you can do anything with React" marketing.
  11. I was just going to write something similar.
  12. Astounding that people here apparently followed these links
  13. A profile in GitHub created 11, forum account 10 hours ago (1 post, no rating). Only a RAR file is uploaded, based on the screenshots containing binaries. Contact info is a free Yahoo E-mail address, installations are blocked by AV and there's no real description of what FPDelphi is. Online searches show fuel pump related stuff. I really mean no offence and it can be me living under the rocks, but for someone who has no prior knowledge this is way too suspicious to check out.
  14. Attila Kovacs

    Move objects to a second Data Module

    1. Crerate a list of the components on thedataset 2. Clone the datamodul with a filemanagaer (copy pas and dfm, rename unit name and datamodul class in the pas and at the top of the dfm) 3. now pick a group from the list and keep only them on the 2nd datamodul, delete the others 4. start refactoring the project 5. goto 2.
  15. Attila Kovacs

    Puzzled by StrToDate

    11.x pfffff.... #forbes I can't see any month name parsing up to version 20.
×