public static TrialAuthenticationObject fromJsonString(string jsonString)
        {
            if (jsonString != null)
            {
                try
                {
                    JavaScriptSerializer      jsonSerializer = new JavaScriptSerializer();
                    TrialAuthenticationObject authObj        = jsonSerializer.Deserialize <TrialAuthenticationObject>(jsonString);
                    return(authObj);
                }
                catch (Exception ex)
                {
                }
            }

            return(null);
        }
        public static TrialAuthenticationObject getAuthenticationObject()
        {
            TrialAuthenticationObject authObj = new TrialAuthenticationObject();

            authObj.motherboardid = findMotherboardId(); //getHash(findMotherboardId());
            authObj.harddriveid   = findHardDriveId();   //getHash(findHardDriveId());
            authObj.processorid   = findProcessorId();   //getHash(findProcessorId());
            authObj.macaddress    = findMACaddress();    //getHash(findMACaddress());
            authObj.biosid        = findBiosId();        //getHash(findBiosId());

            authObj.motherboardid = "unknown";
            authObj.harddriveid   = "unknown";
            authObj.processorid   = "unknown";
            authObj.macaddress    = ReplaceSpecialCharacters(authObj.macaddress);
            authObj.biosid        = "unknown";

            authObj.registrationstate = "2018";

            return(authObj);
        }
Esempio n. 3
0
        public static int doOperation(string operationURL)
        {
            if (operationURL != null)
            {
                try
                {
                    HttpClient client = new HttpClient();
                    TrialAuthenticationObject authObject = TrialComputerInfo.getAuthenticationObject();

                    string authJson = authObject.toJsonString();
                    //MessageBox.Show("compinfo=" + authJson);
                    StringContent content = new StringContent(authJson, Encoding.UTF8, "application/json");

                    System.Net.ServicePointManager.ServerCertificateValidationCallback = (senderX, certificate, chain, sslPolicyErrors) => { return(true); };
                    System.Threading.Tasks.Task <HttpResponseMessage> task = client.PostAsync((TrialSettings.trialLicenseServicesURL + operationURL), content);


                    HttpResponseMessage response = task.Result;
                    if (response.IsSuccessStatusCode)
                    {
                        HttpContent responseContent = response.Content;
                        if (response != null)
                        {
                            string message = responseContent.ReadAsStringAsync().Result;

                            if (message != null)
                            {
                                if (!message.StartsWith("error"))
                                {
                                    try
                                    {
                                        int expDays = Convert.ToInt32(message);

                                        return(expDays);
                                    }
                                    catch (Exception ex3)
                                    {
                                        return(-70000007);
                                    }
                                }
                                else
                                {
                                    MessageBox.Show(message);
                                    return(-60000006);
                                }
                            }
                            else
                            {
                                return(-50000005);
                            }
                        }
                        else
                        {
                            return(-40000004);
                        }
                    }
                    else
                    {
                        return(-30000003);
                    }
                }
                catch (Exception ex2)
                {
                    return(-20000002);
                }
            }

            return(-10000001);
        }