void back_CheckReg_DoWork(object sender, DoWorkEventArgs e) { //OpAppRegClass opReg = new OpAppRegClass(); //curRegInfoStruct = opReg.CurRegInfoStruct; curRegInfoStruct = OpAppRegClass.Instance.CurRegInfoStruct; }
public void BeginWriteLog(RegInfoStruct curRegInfoStruct) { this.curRegInfoStruct = curRegInfoStruct; BackgroundWorker bg_Log = new BackgroundWorker(); bg_Log.WorkerSupportsCancellation = true; bg_Log.DoWork += bg_Log_DoWork; bg_Log.RunWorkerAsync(); }
private void WriteLog(RegInfoStruct curRegInfoStruct) { try { if (string.IsNullOrEmpty(curRegInfoStruct.CPUID)) { curRegInfoStruct.CPUID = MyMethod.GetCPUID(); } if (string.IsNullOrEmpty(curRegInfoStruct.HDDID)) { curRegInfoStruct.HDDID = MyMethod.GetHddID(); } //登录日志 string strSql = "insert into 系统使用日志(编号,所属单位,注册人姓名,采油厂标识,版本,日志时间,日志状态,授权类型,CPU编号,硬盘编号,用户IP,使用截止时间,软件可运行次数,软件已运行次数,备注) values('"; strSql += MyMethod.GetGUID() + "','"; strSql += curRegInfoStruct.RegUnit + "','"; strSql += curRegInfoStruct.RegUser + "','"; strSql += curRegInfoStruct.CYCID + "','"; strSql += curRegInfoStruct.RegInfoVer + "',#"; strSql += DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") + "#,"; strSql += "0,'"; strSql += GetCheckResultStr(curRegInfoStruct.curRegCheckResult) + "','"; strSql += curRegInfoStruct.CPUID + "','"; strSql += curRegInfoStruct.HDDID + "','"; strSql += curRegInfoStruct.CurIP + "',#"; strSql += curRegInfoStruct.TrialLimiteTime.ToString("yyyy-MM-dd") + "#,"; strSql += curRegInfoStruct.TrialLimiteCount + ","; strSql += curRegInfoStruct.AlreadyUseCount + ",'"; strSql += "登录" + "')"; if (!opWeb.ExecSql(strSql, ref ErrMsg)) { int a = 1; } } catch (Exception E) { ErrMsg = E.Message; } }
private void UpdateRegInfoToServer(RegInfoStruct curRegInfoStruct) { string strSql = "select * from 注册码管理 where CPU编号='" + curRegInfoStruct.CPUID + "' and 硬盘编号='" + curRegInfoStruct.HDDID + "'"; DataSet curSet = new DataSet(); try { curSet = opWeb.GetDataSet(strSql); if (!string.IsNullOrEmpty(opWeb.ErrMsg)) { return; } if (curSet.Tables[0].Rows.Count > 0) { return; } DataRow newRow = curSet.Tables[0].NewRow(); newRow["编号"] = MyMethod.GetGUID(); newRow["所属单位"] = curRegInfoStruct.RegUnit; newRow["注册人姓名"] = curRegInfoStruct.RegUser; newRow["注册时间"] = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"); if (curRegInfoStruct.curRegCheckResult == RegCheckResult.UnlimitedVer) { newRow["授权类型"] = 1; } else { newRow["授权类型"] = 0; } newRow["使用截止时间"] = curRegInfoStruct.TrialLimiteTime; newRow["软件可运行次数"] = curRegInfoStruct.TrialLimiteCount; if (curRegInfoStruct.LimiteDataUpdateFromServer) { newRow["数据获取限制"] = 1; } else { newRow["数据获取限制"] = 0; } if (!string.IsNullOrEmpty(curRegInfoStruct.CYCID)) { newRow["采油厂标识"] = curRegInfoStruct.CYCID; } newRow["注册码"] = MyMethod.FileToStr(Application.StartupPath + "\\AppRun.dll"); if (curRegInfoStruct.curBindType == RegBindHDType.CPU) { newRow["绑定硬件"] = 0; } else { newRow["绑定硬件"] = 1; } newRow["版本"] = curRegInfoStruct.CurAppVer; newRow["CPU编号"] = curRegInfoStruct.CPUID; newRow["硬盘编号"] = curRegInfoStruct.HDDID; newRow["用户IP"] = curRegInfoStruct.CurIP; newRow["记录来源"] = "自动补充"; curSet.Tables[0].Rows.Add(newRow); if (!opWeb.UpdateDataSet(curSet, strSql)) { string ErrMsg = opWeb.ErrMsg; } } catch (Exception E) { ErrMsg = E.Message; } }
//1.0版加密串解析 private void PareseRegStrV1(string RegInfoStr) { curRegInfoStruct = new RegInfoStruct(); string Spec = "#"; string[] RegList = RegInfoStr.Split(Spec.ToCharArray()); if (RegList.Length < 10) { curRegInfoStruct.str_Err = "配置被非法修改!"; //curResult = RegCheckResult.RegFileBeCracked; curRegInfoStruct.curRegCheckResult = RegCheckResult.RegFileBeCracked; return; } /* * 第一位:加密串版本号 * 第二位:授权单位 * 第三位:授权用户 * 第四位:1正式片,0,试用版 * 第五位:试用截止时间 * 第六位:试用次数 * 第七位:硬件绑定类型 * 第八位:硬件ID * 第九位:存储是否限制用户从服务器只能拉取本厂数据 * 第十位:存储软件运行次数 */ string tempValue = ""; try { curRegInfoStruct.RegInfoVer = RegList[0]; curRegInfoStruct.RegUnit = RegList[1]; curRegInfoStruct.RegUser = RegList[2]; tempValue = RegList[3]; if (tempValue == "1") { curRegInfoStruct.curRegCheckResult = RegCheckResult.UnlimitedVer; //curResult = RegCheckResult.UnlimitedVer; } else if (tempValue == "2") { //锁定用户软件 curRegInfoStruct.curRegCheckResult = RegCheckResult.Lock; //return; } else { curRegInfoStruct.curRegCheckResult = RegCheckResult.TrialVer; //curResult = RegCheckResult.TrialVer; curRegInfoStruct.TrialLimiteTime = DateTime.Parse(RegList[4]); curRegInfoStruct.TrialLimiteCount = int.Parse(RegList[5]); } tempValue = RegList[6]; if (tempValue == "0") { curRegInfoStruct.curBindType = RegBindHDType.CPU; } else { curRegInfoStruct.curBindType = RegBindHDType.HDD; } curRegInfoStruct.HDMarkCode = RegList[7]; tempValue = RegList[8]; if (string.IsNullOrEmpty(tempValue)) { curRegInfoStruct.LimiteDataUpdateFromServer = false; } else { curRegInfoStruct.LimiteDataUpdateFromServer = true; curRegInfoStruct.CYCID = tempValue; } curRegInfoStruct.AlreadyUseCount = int.Parse(RegList[9]); } catch (Exception E) { curRegInfoStruct.str_Err = E.Message; curRegInfoStruct.curRegCheckResult = RegCheckResult.Error; //curResult = RegCheckResult.Error; return; } }