Ejemplo n.º 1
0
        public LicenseConfirmation()
        {
            if (File.Exists(Application.StartupPath + "\\license.lic"))
            {
                string json = EncrpytionTool.Decrypt(File.ReadAllText(Application.StartupPath + "\\license.lic"));
                license = JsonConvert.DeserializeObject <LicenseManager.LicenseInformations.Tables.License>(json);
                LoadSystemInfo();
                int onlineConfirmedInfo = 0;
                if (license.OnlineLisans)
                {
                    License onlineLicense = GetOnlineLicense(license.Id);

                    for (int i = 0; i < 6; i++)
                    {
                        var infoType = license.SystemInfos[i].InfoType;

                        if (onlineLicense.SystemInfos[i].Info == systemInfo.Where(c => c.InfoType == infoType).FirstOrDefault().Info)
                        {
                            onlineConfirmedInfo += 1;
                        }
                    }
                }


                int confirmedInfo = 0;
                for (int i = 0; i < 6; i++)
                {
                    var infoType = license.SystemInfos[i].InfoType;

                    if (license.SystemInfos[i].Info == systemInfo.Where(c => c.InfoType == infoType).FirstOrDefault().Info)
                    {
                        confirmedInfo += 1;
                    }
                }
                if (confirmedInfo > 3)
                {
                    if (license.OnlineLisans)
                    {
                        if (onlineConfirmedInfo > 3)
                        {
                            confirmLicense = true;
                        }
                        else
                        {
                            confirmLicense = false;
                        }
                    }
                    else
                    {
                        confirmLicense = true;
                    }
                }
            }
        }
Ejemplo n.º 2
0
        public License GetOnlineLicense(Guid id)
        {
            RestClient  client  = new RestClient("http://localhost:53633/");
            RestRequest request = new RestRequest("api/license/getlicense");

            request.AddParameter("id", id);
            var response = client.Get(request);
            var result   = JsonConvert.DeserializeObject <ApiResponseResult>(EncrpytionTool.Decrypt(response.Content.Trim('\"')));

            if (result.returnType == ReturnType.Error)
            {
                MessageBox.Show(result.Value.ToString());
            }
            else if (result.returnType == ReturnType.Confirm)
            {
                License returnLicense = JsonConvert.DeserializeObject <License>(result.Value.ToString());
                return(returnLicense);
            }
            return(null);
        }