Пример #1
0
        public async Task <Dictionary <string, string> > GetClientData(string req)
        {
            Dictionary <string, string> clientData = new Dictionary <string, string>();

            try
            {
                ProductMaster prod = new Commands.ProductMaster();
                string        cid  = prod.GetMacAddress();
                clientData.Add("clientID", cid.Encrypt("ms1*&tyu1Y5y90o8uiop%@#^!m"));
                string             resourcePath = System.Web.Hosting.HostingEnvironment.MapPath("~/ProductMaster.resx");
                ResXResourceReader rsxr         = new ResXResourceReader(resourcePath);
                foreach (DictionaryEntry d in rsxr)
                {
                    if (d.Key.ToString() == "ExtendedTrial")
                    {
                        clientData.Add("ExtendedTrial", d.Value.ToString());
                    }
                    if (d.Key.ToString() == "Licensed")
                    {
                        clientData.Add("Licensed", d.Value.ToString());
                    }
                }
            }
            catch
            {
                clientData = null;
            }
            return(clientData);
        }
Пример #2
0
        private string IsAllowed()
        {
            string result = string.Empty;

            try
            {
                Dictionary <string, string> dict = new Dictionary <string, string>();
                dict = GetProductData();
                ProductMaster prod = new Commands.ProductMaster();

                //ErrorHelper.SendExcepToDB(dict["Licensed"].ToString(), "Licensed Name","");
                if (dict["Licensed"].ToString() != "")
                {
                    //License found. check for valid
                    //get mac address
                    string clientID = prod.GetMacAddress();
                    //ErrorHelper.SendExcepToDB(clientID, "Mac name", "");
                    //decrypt license key
                    string availableClientID = dict["Licensed"].ToString().Decrypt("ms1*&tyu1Y5y90o8uiop%@#^!m");
                    //ErrorHelper.SendExcepToDB(availableClientID, "availableClientID", "");
                    availableClientID = availableClientID.Split('_')[1].ToString();
                    if (availableClientID == clientID)
                    {
                        //ErrorHelper.SendExcepToDB("succeed", "matching", "");
                        result = "Valid";
                        int dayExist = 0;

                        string availableExtendedTrial = dict["Licensed"].ToString().Decrypt("ms1*&tyu1Y5y90o8uiop%@#^!m");
                        availableExtendedTrial = availableExtendedTrial.Split('_')[3].ToString();
                        dayExist = dayExist + Convert.ToInt32(availableExtendedTrial);

                        DateTime start      = Convert.ToDateTime(dict["FirstLogin"].ToString().Decrypt("ms1*&tyu1Y5y90o8uiop%@#^!m"));
                        DateTime end        = DateTime.Now;
                        TimeSpan difference = end - start;
                        if (difference.Days <= dayExist)
                        {
                            if ((dayExist - difference.Days) <= 7)
                            {
                                result += "|Your License is going to be expired in " + (dayExist - difference.Days) + " days.";
                            }
                        }
                    }
                    else
                    {
                        result = "Invalid";
                    }
                }
                if (result == "Invalid" || result == string.Empty)
                {
                    int dayExist = 0;
                    if (dict["BasicTrial"].ToString() != "")
                    {
                        string availableBasicTrial = dict["BasicTrial"].ToString().Decrypt("ms1*&tyu1Y5y90o8uiop%@#^!m");
                        availableBasicTrial = availableBasicTrial.Split('_')[3].ToString();
                        dayExist            = Convert.ToInt32(availableBasicTrial);
                    }
                    if (dict["ExtendedTrial"].ToString() != "")
                    {
                        string availableExtendedTrial = dict["ExtendedTrial"].ToString().Decrypt("ms1*&tyu1Y5y90o8uiop%@#^!m");
                        availableExtendedTrial = availableExtendedTrial.Split('_')[3].ToString();
                        dayExist = dayExist + Convert.ToInt32(availableExtendedTrial);
                    }
                    if (dict["FirstLogin"].ToString() != "")
                    {
                        DateTime start      = Convert.ToDateTime(dict["FirstLogin"].ToString().Decrypt("ms1*&tyu1Y5y90o8uiop%@#^!m"));
                        DateTime end        = DateTime.Now;
                        TimeSpan difference = end - start;
                        if (difference.Days <= dayExist)
                        {
                            result = "Valid";
                            if ((dayExist - difference.Days) <= 7)
                            {
                                result += "|Your trial period is going to be expired in " + (dayExist - difference.Days) + " days.";
                            }
                        }
                        else
                        {
                            result = "Expired";
                        }
                    }
                    else
                    {
                        result = "Expired";
                    }
                }
            }
            catch
            {
                result = "Expired";
            }
            return(result);
        }