예제 #1
0
        internal static bool ValidateSK(SerialKey key)
        {
            string HashCode = ComputerSKHash(key._KeyPartA, key._KeyPartB, key._KeyPartC, key._KeyPartD, key._BusinessName);

            if ((!string.IsNullOrEmpty(HashCode)) && key._KeyHashCode == HashCode)
            {
                return(true);
            }
            return(false);
        }
예제 #2
0
 private void button1_Click(object sender, RoutedEventArgs e)
 {
     if (!string.IsNullOrEmpty(textBox1.Text) &&
         !string.IsNullOrEmpty(textBox2.Text) &&
         !string.IsNullOrEmpty(textBox3.Text))
     {
         string[] skey = textBox2.Text.Split('-');
         if (skey.Length == 4 && textBox2.Text.Length == 23)
         {
             SerialKey key = new SerialKey();
             key._BusinessName = textBox1.Text;
             key._KeyPartA     = skey[0];
             key._KeyPartB     = skey[1];
             key._KeyPartC     = skey[2];
             key._KeyPartD     = skey[3];
             key._KeyHashCode  = textBox3.Text;
             if (ValidateSerialKey.ValidateSK(key))
             {
                 try
                 {
                     string LicenseFile = System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location) + "\\ExpressTaxi.lic";
                     string sKey        = string.Format("{0}-{1}-{2}-{3}", key._KeyPartA, key._KeyPartB, key._KeyPartC, key._KeyPartD);
                     using (System.IO.StreamWriter file = new System.IO.StreamWriter(LicenseFile))
                     {
                         file.WriteLine(string.Format("BusinessName:{0}:ExpressTaxi:1.1", key._BusinessName));
                         file.WriteLine(string.Format("SerialKey:{0}:ExpressTaxi:1.1", sKey));
                         file.WriteLine(string.Format("ActivationCode:{0}:ExpressTaxi:1.1", key._KeyHashCode));
                     }
                     Config.ShowInfoMessage("License successfully validated, Please restart ExpressTaxi for it to take effect.");
                     this.Close();
                 }
                 catch (Exception ex)
                 {
                     log.Error(ex);
                     Config.ShowErrorMessage("Failed to save license file.");
                 }
             }
             else
             {
                 Config.ShowErrorMessage("Validation Failed. The information entered is not valid to activate ExpressTaxi.");
             }
         }
         else
         {
             Config.ShowErrorMessage("Invalid Serial Key Entered.");
         }
     }
     else
     {
         Config.ShowErrorMessage("The information entered is not valid to activate ExpressTaxi.");
     }
 }
예제 #3
0
        internal static bool LoadAppRegInfo()
        {
            try
            {
                string   LicenseFile  = System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location) + "\\ExpressTaxi.lic";
                string[] LicenseArray = new string[3];
                using (StreamReader reader = new StreamReader(LicenseFile))
                {
                    string   line1    = reader.ReadLine();
                    string   line2    = reader.ReadLine();
                    string   line3    = reader.ReadLine();
                    string[] tmpArray = line1.Split(':');
                    if (tmpArray[0] == "BusinessName")
                    {
                        LicenseArray[0] = tmpArray[1];
                    }
                    else if (tmpArray[0] == "SerialKey")
                    {
                        LicenseArray[1] = tmpArray[1];
                    }
                    else if (tmpArray[0] == "ActivationCode")
                    {
                        LicenseArray[2] = tmpArray[1];
                    }

                    tmpArray = line2.Split(':');
                    if (tmpArray[0] == "BusinessName")
                    {
                        LicenseArray[0] = tmpArray[1];
                    }
                    else if (tmpArray[0] == "SerialKey")
                    {
                        LicenseArray[1] = tmpArray[1];
                    }
                    else if (tmpArray[0] == "ActivationCode")
                    {
                        LicenseArray[2] = tmpArray[1];
                    }

                    tmpArray = line3.Split(':');
                    if (tmpArray[0] == "BusinessName")
                    {
                        LicenseArray[0] = tmpArray[1];
                    }
                    else if (tmpArray[0] == "SerialKey")
                    {
                        LicenseArray[1] = tmpArray[1];
                    }
                    else if (tmpArray[0] == "ActivationCode")
                    {
                        LicenseArray[2] = tmpArray[1];
                    }

                    string[]  sKey = LicenseArray[1].Split('-');
                    SerialKey key  = new SerialKey();
                    key._BusinessName = LicenseArray[0];
                    key._KeyHashCode  = LicenseArray[2];
                    key._KeyPartA     = sKey[0];
                    key._KeyPartB     = sKey[1];
                    key._KeyPartC     = sKey[2];
                    key._KeyPartD     = sKey[3];

                    ExpTmsRSet = ValidateSerialKey.ValidateSK(key);
                    return(true);
                }
            }
            catch (Exception ex)
            {
                log.Error(ex);
            }
            return(false);
        }