FrmMainF.cpp.~39~ 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
  1. //---------------------------------------------------------------------------
  2. #include <vcl.h>
  3. #include "EncryptionF.h"
  4. #pragma hdrstop
  5. #include "FrmMainF.h"
  6. //---------------------------------------------------------------------------
  7. #pragma package(smart_init)
  8. #pragma link "cxContainer"
  9. #pragma link "cxControls"
  10. #pragma link "cxEdit"
  11. #pragma link "cxGraphics"
  12. #pragma link "cxLookAndFeelPainters"
  13. #pragma link "cxLookAndFeels"
  14. #pragma link "cxMaskEdit"
  15. #pragma link "cxSpinEdit"
  16. #pragma link "cxTextEdit"
  17. #pragma link "dxSkinBlack"
  18. #pragma link "dxSkinMcSkin"
  19. #pragma link "dxSkinsCore"
  20. #pragma link "cxButtons"
  21. #pragma link "cxDropDownEdit"
  22. #pragma resource "*.dfm"
  23. TFrmMain *FrmMain;
  24. //---------------------------------------------------------------------------
  25. __fastcall TFrmMain::TFrmMain(TComponent* Owner)
  26. : TForm(Owner)
  27. {
  28. }
  29. //---------------------------------------------------------------------------
  30. void __fastcall TFrmMain::cboLicenseTypePropertiesChange(TObject *Sender)
  31. {
  32. bool isVisible = false;
  33. if (cboLicenseType->ItemIndex == 0) {
  34. isVisible = true;
  35. }
  36. //lblIssueDays->Enabled = isVisible;
  37. seIssueDays->Enabled = isVisible;
  38. }
  39. //---------------------------------------------------------------------------
  40. void __fastcall TFrmMain::btnHostNameClick(TObject *Sender)
  41. {
  42. char szNom[512];
  43. DWORD size = 512;
  44. GetComputerName(szNom, &size);
  45. txtHostName->Text = String(szNom);
  46. }
  47. //---------------------------------------------------------------------------
  48. void __fastcall TFrmMain::btnLicenseGenerateXmlClick(TObject *Sender)
  49. {
  50. moLicenseXml->Lines->Clear();
  51. GUID guid;
  52. CoCreateGuid(&guid);
  53. //UUID uuid;
  54. //UuidCreateSequential(&uuid);
  55. String product = "AIP Gateway";
  56. String serialId = GUIDToString(guid);
  57. serialId = StringReplace(serialId, "{", "", TReplaceFlags() << rfReplaceAll);
  58. serialId = StringReplace(serialId, "}", "", TReplaceFlags() << rfReplaceAll);
  59. String issueDay = Now().FormatString("YYYY-MM-DD");
  60. String licensee = txtHostName->Text.Trim();
  61. String edition = cboProductType->ItemIndex == 0 ? "standard" : "enterprise";
  62. String type = cboLicenseType->ItemIndex == 0 ? "demo" : "product";
  63. String accounts = String((int)seLicenseCnt->Value);
  64. String identifiedHost = txtHostName->Text.Trim();
  65. AnsiString endKey = product.UpperCase() + "hanteinfo12#$!" + serial_id.LowerCase() + issue_day + edition.UpperCase() + type.LowerCase() + AnsiString((int)seLicenseCnt->Value + 10000) + identified_host.LowerCase();
  66. String signature = ITSSHA256_Encrpyt(endKey);;
  67. String demo_duration = String((int)seIssueDays->Value);
  68. moLicenseXml->Lines->Add("<?xml version=\"1.0\" encoding=\"UTF-8\"?>");
  69. moLicenseXml->Lines->Add("<aip_license>");
  70. moLicenseXml->Lines->Add(" <license version=\"1.0\">");
  71. moLicenseXml->Lines->Add(" <product version=\"2\">" + product + "</product>");
  72. moLicenseXml->Lines->Add(" <serialId>" + serialId + "</serialId>");
  73. moLicenseXml->Lines->Add(" <issueDay>" + issueDay + "</issueDay>");
  74. //moLicenseXml->Lines->Add(" <licensee>" + licensee + "</licensee>");
  75. moLicenseXml->Lines->Add(" <edition>" + edition + "</edition>");
  76. moLicenseXml->Lines->Add(" <type>" + type + "</type>");
  77. moLicenseXml->Lines->Add(" <accounts>" + accounts + "</accounts>");
  78. moLicenseXml->Lines->Add(" <identifiedHost>" + identifiedHost + "</identifiedHost>");
  79. moLicenseXml->Lines->Add(" <signature>" + signature + "</signature>");
  80. if (type == "demo") {
  81. moLicenseXml->Lines->Add(" <demoDuration>" + demoDuration + "</demoDuration>");
  82. }
  83. moLicenseXml->Lines->Add(" </license>");
  84. moLicenseXml->Lines->Add("</aip_license>");
  85. moLicenseXml->Lines->Add("");
  86. }
  87. //---------------------------------------------------------------------------