Пример #1
0
 private bool IsValidSoftKey()
 {
     try
     {
         if (globalVariables.IsValidLicense)
         {
             return(true);
         }
         string sRegKey = getRegKeyBasedOnSCPLicense();
         //var appKey = new MHardKey("XFW", 5, false);
         //string giaima = Decrypt(sRegKey, false );
         string genKey = HardWare.Value("XFW");
         string regKey = HardWare.GetKey(genKey);
         globalVariables.IsValidLicense = sRegKey == regKey;
         if (!globalVariables.IsValidLicense)
         {
             LogAction.LogSCPService(
                 string.Format(DateTime.Now.ToString("dd/MM/yyyy HH:mm:ss") +
                               "-->Kiểm tra khóa mềm không hợp lệ."));
             return(false);
         }
         LogAction.LogSCPService(DateTime.Now.ToString("dd/MM/yyyy HH:mm:ss") + "-->Kiểm tra khóa mềm hợp lệ...");
         return(true);
     }
     catch (Exception ex)
     {
         LogAction.LogSCPService(DateTime.Now.ToString("dd/MM/yyyy HH:mm:ss") + "-->Lỗi khi kiểm tra khóa mềm-->" +
                                 ex.Message);
         return(false);
     }
 }
Пример #2
0
 private bool IsValidLicenseType()
 {
     try
     {
         if (globalVariables.IsValidLicenseType)
         {
             return(true);
         }
         string   sRegKey   = GetRegKeyBasedOnScpLicenseType();
         byte[]   bytes     = Convert.FromBase64String(sRegKey);
         string   str       = Encoding.UTF8.GetString(bytes);
         string   regkey    = DateTime.Now.ToString("ddMMyyyy");
         DateTime sDateTime = DateTime.ParseExact(str, "ddMMyyyy", CultureInfo.GetCultureInfo("tr-TR"));
         globalVariables.IsValidLicenseType = sDateTime.Date > DateTime.Now.Date;
         if (!globalVariables.IsValidLicenseType)
         {
             LogAction.LogSCPService(string.Format(DateTime.Now.ToString("dd/MM/yyyy HH:mm:ss") + "-->Hạn sử dụng phần mềm đã hết."));
             return(false);
         }
         LogAction.LogSCPService(DateTime.Now.ToString("dd/MM/yyyy HH:mm:ss") + "-->Kiểm tra hạn sử dụng phần mềm hợp lệ...");
         return(true);
     }
     catch (Exception ex)
     {
         LogAction.LogSCPService(DateTime.Now.ToString("dd/MM/yyyy HH:mm:ss") + "-->Lỗi khi kiểm tra hạn dùng phần mềm-->" +
                                 ex.Message);
         return(false);
     }
 }