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); }
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); } }
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(); } }