Beispiel #1
0
        private bool ValidateLicense(string _pathLicense)
        {
            BUS.CommonControl ctr  = new CommonControl();
            object            data = ctr.executeScalar(@"SELECT SUN_DATA  FROM SSINSTAL WHERE INS_TB='LCS' and INS_KEY='QD'");

            if (data != null)//File.Exists(_pathLicense.Replace("file:\\", ""))
            {
                //StreamReader reader = new StreamReader(_pathLicense);
                //string result = reader.ReadLine();
                string      kq      = RC2.DecryptString(data.ToString(), Form_QD._key, Form_QD._iv, Form_QD._padMode, Form_QD._opMode);
                string[]    tmp     = kq.Split(';');
                DTO.License license = new DTO.License();
                license.CompanyName  = tmp[0];
                license.ExpiryDate   = Convert.ToInt32(tmp[1]);
                license.Modules      = tmp[2];
                license.NumUsers     = Convert.ToInt32(tmp[3]);
                license.SerialNumber = tmp[4];
                license.Key          = tmp[5];
                //license.SerialCPU = tmp[6];
                //BUS.CommonControl ctr = new BUS.CommonControl();
                license.SerialCPU = ctr.executeScalar(@"SELECT   CONVERT(varchar(200), SERVERPROPERTY('servername'))").ToString(); //"BFEBFBFF000006FD";
                //reader.Close();


                string param = license.CompanyName + license.SerialNumber + license.NumUsers.ToString() + license.Modules + license.ExpiryDate.ToString() + license.SerialCPU;


                string temp = RC2.EncryptString(param, Form_QD._key, Form_QD._iv, Form_QD._padMode, Form_QD._opMode);
                string key  = Convert.ToBase64String(new System.Security.Cryptography.SHA1CryptoServiceProvider().ComputeHash(Encoding.ASCII.GetBytes(temp)));
                if (key == license.Key)
                {
                    int now = Convert.ToInt32(DateTime.Now.Year.ToString() + DateTime.Now.Month.ToString("00") + DateTime.Now.Day.ToString("00"));
                    //BUS.CommonControl ctr = new CommonControl();
                    object dt = ctr.executeScalar("select getdate()", _strConnect);
                    if (dt != null && dt is DateTime)
                    {
                        now = Convert.ToInt32(((DateTime)dt).Year.ToString() + ((DateTime)dt).Month.ToString("00") + ((DateTime)dt).Day.ToString("00"));
                    }
                    if (now > license.ExpiryDate)
                    {
                        _sErr = "Your license is expired!";
                    }
                    else
                    {
                        //if (license.Modules.Length == 4 && license.Modules.Substring(3) == "Y")
                        return(true);
                        //else _flagQDADD = false;
                    }
                }
                else
                {
                    _sErr = "Application have not license!";
                }
            }
            else
            {
                _sErr = "Application have not license!";
            }
            return(false);
        }
Beispiel #2
0
 public void LoadConfig(string filename)
 {
     if (File.Exists(filename))
     {
         Clear();
         StreamReader sr     = new StreamReader(filename);
         string       result = sr.ReadToEnd();
         sr.Close();
         string       kq           = RC2.DecryptString(result, Form_QD._key, Form_QD._iv, Form_QD._padMode, Form_QD._opMode);
         StringReader stringReader = new StringReader(kq);
         ReadXml(stringReader);
         stringReader.Close();
     }
     if (DTB.Rows.Count == 0)
     {
         DTB.AddDTBRow("", "");
     }
     if (DIR.Rows.Count == 0)
     {
         DIR.AddDIRRow("", "");
     }
     if (SYS.Rows.Count == 0)
     {
         SYS.AddSYSRow("", "", "", false);
     }
 }
Beispiel #3
0
        public void SaveConfig(string filename)
        {
            StringBuilder sb = new StringBuilder();
            StringWriter  sw = new StringWriter(sb);

            WriteXml(sw);
            sw.Close();
            string       temp    = RC2.EncryptString(sb.ToString(), Form_QD._key, Form_QD._iv, Form_QD._padMode, Form_QD._opMode);
            StreamWriter streamw = new StreamWriter(filename);

            streamw.Write(temp);
            streamw.Close();
        }
Beispiel #4
0
        private void btnOK_Click(object sender, EventArgs e)
        {
            DTO.License license = GetDataFromForm();
            string      param   = license.CompanyName + license.SerialNumber + license.NumUsers.ToString() + license.Modules + license.ExpiryDate.ToString() + license.SerialCPU;


            string tmp = RC2.EncryptString(param, _key, _iv, _padMode, _opMode);
            string key = Convert.ToBase64String(new System.Security.Cryptography.SHA1CryptoServiceProvider().ComputeHash(Encoding.ASCII.GetBytes(tmp)));

            if (key == license.Key)
            {
                String kq = license.CompanyName + ";" +
                            license.ExpiryDate + ";" +
                            license.Modules + ";" +
                            license.NumUsers + ";" +
                            license.SerialNumber + ";" +
                            license.Key + ";" +
                            license.SerialCPU;


                BUS.CommonControl ctr    = new BUS.CommonControl();
                string            query  = @"if EXISTS(SELECT INS_KEY  FROM SSINSTAL WHERE INS_TB='LCS' and INS_KEY='QD') 
UPDATE SSINSTAL SET SUN_DATA = '{0}' WHERE INS_TB='LCS' and INS_KEY='QD'
else 
INSERT INTO SSINSTAL(INS_TB ,INS_KEY ,SUN_DATA) VALUES ( 'LCS' ,'QD' ,'{0}')";
                string            result = RC2.EncryptString(kq, _key, _iv, _padMode, _opMode);
                query = string.Format(query, result);
                ctr.executeNonQuery(query);
                //StreamWriter writerStream = new StreamWriter(_pathLicense.Replace("file:\\", ""));
                //writerStream.WriteLine(result);
                //writerStream.Close();

                Close();
                DialogResult = DialogResult.OK;
            }
            else
            {
                lbErr.Text = "Registry fail";
            }
        }
Beispiel #5
0
        private void FrmLicense_Load(object sender, EventArgs e)
        {
            lbErr.Text = "";
            BUS.CommonControl ctr  = new BUS.CommonControl();
            object            data = ctr.executeScalar(@"SELECT SUN_DATA  FROM SSINSTAL WHERE INS_TB='LCS' and INS_KEY='QD'");

            if (data != null)// if (File.Exists(_pathLicense.Replace("file:\\", "")))
            {
                //StreamReader reader = new StreamReader(_pathLicense.Replace("file:\\", ""));
                string      result  = data.ToString();
                string      kq      = RC2.DecryptString(result, _key, _iv, _padMode, _opMode);
                string[]    tmp     = kq.Split(';');
                DTO.License license = new DTO.License();
                license.CompanyName  = tmp[0];
                license.ExpiryDate   = Convert.ToInt32(tmp[1]);
                license.Modules      = tmp[2];
                license.NumUsers     = Convert.ToInt32(tmp[3]);
                license.SerialNumber = tmp[4];
                license.Key          = tmp[5];
                license.SerialCPU    = tmp[6];
                SetDataToForm(license);
                //reader.Close();
            }
        }