private void simpleButton1_Click(object sender, EventArgs e) { ISecurity md5 = new MD5Security(); ISecurity sec = FT.Commons.Security.SecurityFactory.GetSecurity(); if (this.txtCompany.Text.Trim().Length == 0) { MessageBoxHelper.Show("必须输入授权用户!"); return; } if (this.txtKeyCode.Text.Trim().Length > 0) { if (this.txtKeyCode.Text.Trim() != md5.Encrypt(sec.Encrypt(this.txtMachineCode.Text + this.txtCompany.Text.Trim() + this.txtMachineCode.Text))) { this.txtKeyCode.Focus(); MessageBoxHelper.Show("注册码错误,请重新输入!"); return; } } else { MessageBoxHelper.Show("没有注册码,将使用试用版!"); this.DialogResult = DialogResult.OK; } ProgramRegConfig config = StaticCacheManager.GetConfig <ProgramRegConfig>(); config.RegDate = System.DateTime.Now; loader.SaveConfig(); MessageBoxHelper.Show("保存成功!"); this.DialogResult = DialogResult.OK; }
private void BaseMainForm_FormClosing(object sender, FormClosingEventArgs e) { if (MessageBoxHelper.Confirm("确定退出本系统吗?")) { ProgramRegConfig config = StaticCacheManager.GetConfig <ProgramRegConfig>(); if (config.LastDate > System.DateTime.Now) { MessageBoxHelper.Show("对不起,当前时间被篡改!"); e.Cancel = true; } else { config.LastDate = System.DateTime.Now; config.UseCount++; StaticCacheManager.SaveConfig <ProgramRegConfig>(config); FileHelper.WriteLastLog(Application.ProductName); DbAutoBakConfig dbconfig = StaticCacheManager.GetConfig <DbAutoBakConfig>(); if (dbconfig.AutoBak) { dbconfig.BakDb(); } } } else { e.Cancel = true; } }
private void ProgramRegConfigForm_Load(object sender, EventArgs e) { if (!this.DesignMode) { ProgramRegConfig config = StaticCacheManager.GetConfig <ProgramRegConfig>(); FormHelper.SetDataToForm(this, config); } }
/// <summary> /// 计算条码数据 /// </summary> /// <returns></returns> private string ComputeDimension() { CompanyInfo comp = StaticCacheManager.GetConfig <CompanyInfo>(); ProgramRegConfig reg = StaticCacheManager.GetConfig <ProgramRegConfig>(); string idtypecode = this.cbIdCardType.SelectedValue.ToString(); string areacode = this.cbBelongArea.SelectedValue.ToString(); string car = this.cbNewCarType.SelectedValue.ToString(); int sexcode = (this.cbSex.SelectedIndex + 1); string id = StudentHelper.TransIdCard(idtypecode, this.txtIdCard.Text.Trim()); StringBuilder sb = new StringBuilder("jsyxx"); StudentHelper.AppendString(sb, StudentHelper.Encode(id + car + areacode)); StudentHelper.AppendString(sb, id); StudentHelper.AppendString(sb, idtypecode); StudentHelper.AppendString(sb, this.txtName.Text.Trim()); StudentHelper.AppendString(sb, sexcode.ToString()); StudentHelper.AppendString(sb, this.dateBirthday.Value.ToString("yyyy-MM-dd")); StudentHelper.AppendString(sb, this.cbNation.SelectedValue.ToString()); StudentHelper.AppendString(sb, this.cbRegArea.SelectedValue.ToString()); StudentHelper.AppendString(sb, this.txtRegAddress.Text.Trim()); StudentHelper.AppendString(sb, areacode); StudentHelper.AppendString(sb, this.txtConnAddress.Text.Trim()); StudentHelper.AppendString(sb, this.txtPostCode.Text.Trim()); StudentHelper.AppendString(sb, this.txtPhone.Text.Trim()); StudentHelper.AppendString(sb, areacode); StudentHelper.AppendString(sb, car); StudentHelper.AppendString(sb, this.cbComeFrom.SelectedValue.ToString()); StudentHelper.AppendString(sb, this.txtTempId.Text.Trim()); StudentHelper.AppendString(sb, comp.No); //38?学校代号 jxmc 驾校名称 StudentHelper.AppendString(sb, this.cbCoachName.Text); //这个的作用? 教练员1 StudentHelper.AppendString(sb, this.txtHeight.Text.Trim()); StudentHelper.AppendString(sb, this.txtLeftEye.Text.Trim()); StudentHelper.AppendString(sb, this.txtRightEye.Text.Trim()); //0为不合格,1 为合格 合格的combox索引是1 StudentHelper.AppendString(sb, this.cbColor.SelectedIndex.ToString()); StudentHelper.AppendString(sb, this.cbListen.SelectedIndex.ToString()); StudentHelper.AppendString(sb, this.cbTopBody.SelectedIndex.ToString()); StudentHelper.AppendString(sb, this.cbLeftDownBody.SelectedIndex.ToString()); StudentHelper.AppendString(sb, this.cbRightDownBody.SelectedIndex.ToString()); StudentHelper.AppendString(sb, this.cbMainBody.SelectedIndex.ToString()); StudentHelper.AppendString(sb, this.cbHospital.Text);//医院编号还是医院具体信息? 体检医院名称 StudentHelper.AppendString(sb, this.dateCheckDate.Value.ToString("yyyy-MM-dd")); StudentHelper.AppendString(sb, this.txtMobile.Text.Trim()); StudentHelper.AppendString(sb, this.txtDescription.Text.Trim()); StudentHelper.AppendString(sb, reg.RightCode.Replace("-", "").Replace("-", "")); Console.WriteLine("二维条码数据:" + sb.ToString()); return(sb.ToString()); }
private void Form1_Load(object sender, EventArgs e) { regconfig = StaticCacheManager.GetConfig <ProgramRegConfig>(); SystemConfig config = StaticCacheManager.GetConfig <SystemConfig>(); if (config.AutoUpload) { timer1.Interval = config.MonitorTimes; timer1.Tick += new EventHandler(timer1_Tick); timer1.Start(); } this.CreateLog("系统初启动"); }
private static void GetProgramState() { //log4net.LogManager.ResetConfiguration(); log4net.Config.XmlConfigurator.ConfigureAndWatch(new System.IO.FileInfo("log.xml")); ProgramRegConfig config = StaticCacheManager.GetConfig <ProgramRegConfig>(); if (config.KeyCode != null && config.KeyCode.Length > 0) { ISecurity md5 = new MD5Security(); ISecurity sec = FT.Commons.Security.SecurityFactory.GetSecurity(); string[] macs = FT.Commons.Tools.HardwareManager.GetMacArray(); string hardwarecode = string.Empty; for (int i = 0; i < macs.Length; i++) { hardwarecode = md5.Encrypt(macs[i]); if (config.KeyCode == md5.Encrypt(sec.Encrypt(hardwarecode + config.Company + hardwarecode))) { productState = ProgramState.Registed; break; } else if (i == macs.Length - 1) { productState = ProgramState.None; } } } else if (config.RightCode.Length != 0) { productState = ProgramState.Trial; } else { productState = ProgramState.None; } }
public static void StartLimitDays(string key, Image bg, int limit, string phone, bool needregister, Type panelType, string panelText) { if (CheckMutex(key)) { GetProgramState(); string text = Application.ProductName + Application.ProductVersion; if (needregister && productState != ProgramState.Registed) { string lastfiledate = FileHelper.ReadLastLog(Application.ProductName); //第一次使用,如果是重装系统后就移除注册信息和使用单位信息 if (lastfiledate == null || lastfiledate == string.Empty) { StaticCacheManager.RemoveConfig <ProgramRegConfig>(); //StaticCacheManager.RemoveConfig<CompanyInfo>(); Register(bg, text, panelType, panelText); } else//如果重新装新版本会启动不了 { ProgramRegConfig config = StaticCacheManager.GetConfig <ProgramRegConfig>(); //如果有最后使用日期,但是没有注册信息的时候自动退出 if (config.RegDate == null || config.RegDate.ToString().StartsWith("0001")) { //MessageBoxHelper.Show("系统注册文件被损坏,请重新安装或修复本系统!"); //Application.Exit(); Register(bg, text, panelType, panelText); } else//已填写过注册信息了,要判断是否篡改系统时间或者是否超出试用时间了 { DateTime regdate = config.RegDate; DateTime lastdate = config.LastDate; DateTime now = System.DateTime.Now; if (lastdate > now || regdate > now || regdate > lastdate) { MessageBoxHelper.Show("系统时间发生变化,请重新安装!"); Application.ExitThread(); return; } else if (now > regdate.AddDays(limit)) { MessageBoxHelper.Show("超出试用时间" + limit.ToString() + "天限制,请联系产品销售商!" + (phone.Length > 0 ? "\r\n联系电话:" + phone : "")); Application.ExitThread(); return; } else { TimeSpan ts = now - regdate; if (AppicationHelper.ProductState != ProgramState.Registed) { text += "(" + limit + "天试用版本,剩下" + (limit - ts.Days) + "天)"; } Run(bg, text, panelType, panelText); } } } } else { productState = ProgramState.Registed; Run(bg, text, panelType, panelText); } //判断是否有使用文件配置存在 //二如果发生时间 //把需要附加到Winform的text的信息传递过去 } else { MessageBoxHelper.Show("已经运行了一个这样的程序!"); } }