public static bool ModifyHardWare(HardWare model) { string sql = string.Format(@"update {0} set [IsDeleted]=@IsDeleted,[ModifyDate]=getdate(),[WorkGuid]=@WorkGuid,[Infos]=@Infos where Id=@Id", TableName); return(DBAccess.ExecuteSqlWithEntity(sql, model)); }
public static void InitClient() { UserInfo.InitUserInfo(); SoftWare.InitSoftWare(); HardWare.InitHardWare(); Language.InitLanguage(); }
public static void InitClient() { UserInfo.InitUserInfo(); HardWare.InitHardWare(); Language.InitLanguage(); SettingConfig.InitSetting(); }
private bool IsValidSoftKey() { try { if (globalVariables.IsValidLicense) { return(true); } string sRegKey = getRegKeyBasedOnSCPLicense(); //var appKey = new MHardKey("XFW", 5, false); //string giaima = Decrypt(sRegKey, false ); string genKey = HardWare.Value("XFW"); string regKey = HardWare.GetKey(genKey); globalVariables.IsValidLicense = sRegKey == regKey; if (!globalVariables.IsValidLicense) { LogAction.LogSCPService( string.Format(DateTime.Now.ToString("dd/MM/yyyy HH:mm:ss") + "-->Kiểm tra khóa mềm không hợp lệ.")); return(false); } LogAction.LogSCPService(DateTime.Now.ToString("dd/MM/yyyy HH:mm:ss") + "-->Kiểm tra khóa mềm hợp lệ..."); return(true); } catch (Exception ex) { LogAction.LogSCPService(DateTime.Now.ToString("dd/MM/yyyy HH:mm:ss") + "-->Lỗi khi kiểm tra khóa mềm-->" + ex.Message); return(false); } }
public void Delete() { HardWare hard = db.HardWare.FirstOrDefault(); db.HardWare.Remove(hard); db.SaveChanges(); }
public void Load([FromBody] HardWare hard) { if (db.GetHardWares().Count() > 0) { db.Update(hard); } else { db.Create(hard); } }
public void Update(HardWare hard) { HardWare hard_m = db.HardWare.FirstOrDefault(); hard_m.pc_name = hard.pc_name; hard_m.manufacturer = hard.manufacturer; hard_m.users = hard.users; hard_m.cpu = hard.cpu; hard_m.ram = hard.ram; hard_m.date = hard.date; db.Entry(hard_m).State = System.Data.Entity.EntityState.Modified; db.SaveChanges(); }
private void SendOneDatagram() { int maxLength = int.Parse(cb_MaxDatagramSize.Text) * 10240; Random rnd = new Random(); int datagramLength = rnd.Next(1, maxLength); //就这里,弄个类的序列化。 DbTools db = new DbTools(); ModelMember m = new ModelMember(); m.email = "赵钦@sina.com"; m.hdinfo = HardWare.getHardCode(); m.logintime = DateTime.Now; string datagramText = db.ClasstoString(m, "VCDS"); datagramText = "<" + datagramText + ">"; //if (ck_ErrorDatagram.Checked && datagramLength < maxLength * 0.20) // 产生一个无 > 的包 //{ // datagramText = "<" + tb_ClientName.Text.Trim() + ",".PadRight(datagramLength, 'a'); //} else if (ck_ErrorDatagram.Checked && datagramLength > maxLength * 0.80) // 产生一个无 < 的包 //{ // datagramText = tb_ClientName.Text.Trim() + ",".PadRight(datagramLength, 'a') + ">"; //} else // 正常包 //{ // string header = "<" + tb_ClientName.Text.Trim() + ","; // string tailer = ",".PadRight(datagramLength, 'a') + ">"; // datagramText = header + (header.Length + tailer.Length + 10).ToString("0000000000") + tailer; // 第二个字节是长度 //} byte[] datagram = Encoding.ASCII.GetBytes(datagramText); try { m_socketClient.Client.Send(datagram); this.RefreshSendCount(); this.AddInfo("send text len = " + datagramText.Length.ToString()); if (ck_AsyncReceive.Checked) // 异步接收回答 { m_socketClient.Client.BeginReceive(m_receiveBuffer, 0, m_receiveBuffer.Length, SocketFlags.None, this.EndReceiveDatagram, this); } else { this.Receive(); } } catch (Exception err) { this.AddInfo("send exception: " + err.Message); this.CloseClientSocket(); } }
/// <summary> /// 窗体加载时 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void X_Form_Login_Load(object sender, EventArgs e) { wait.ShowMsg("1/10 加载登录窗口中..."); TabC_Login_SelectedIndexChanged(sender, e); EchoHelper.Echo("窗体加载完成!请输入忍者X2的论坛账户,论坛密码,然后登录!", null, 0); txtHardInfo.Text = HardWare.getHardCode(); FileInfo file = new FileInfo(Application.ExecutablePath); cVer.Text = file.LastWriteTime.ToLocalTime().ToString(); Text_PID.Text = ini.re("登录账户密码", "PID"); Text_PWD.Text = ini.re("登录账户密码", "PWD"); btn_Login.Enabled = false; btn_Login.Text = "补丁探测..."; try { ck提示更新.Checked = Convert.ToBoolean(ini.re("软件更新", "提示更新")); if (ck提示更新.Checked) { EchoHelper.Echo("系统正在检查是否有新版本,请您耐心等候...", "软件更新", EchoHelper.EchoType.任务信息); //软件更新. Thread th = SearchThread("th_update"); if (th == null) { th = new Thread(new ThreadStart(checkUpdate)); th.Name = "th_update"; th.IsBackground = true; } th.Start(); } } catch (Exception ex) { EchoHelper.Echo(ex.Message, "加载INI出错", EchoHelper.EchoType.异常信息); } Text_PID.Focus(); //wait.CloseMsg(); Version v = System.Environment.Version; cVer.Text = v.ToString(); }
/// <summary> /// 获取数据库的创建时间,并生成机器码,如果是单机数据库则获取机器CPUID,并MD5加密,默认取机本地CPUID码 /// </summary> /// <returns></returns> public virtual string getMachineCode() { string cpuID = HardWare.GetCpuID(); return(cpuID.Equals("") ? "" : CryptUtil.GetMd5Hash(cpuID, true)); }
public void Create(HardWare hard) { db.HardWare.Add(hard); db.SaveChanges(); }
public void Post([FromBody] HardWare value) { db.Create(value); }
public void Put([FromBody] HardWare value) { db.Update(value); }
public static bool AddAccount(CustomerCompany company, CustomerMember member, Account account, ProjectManage projectManage, HardWare hardWare, List <PersonSetting> personSettings) { string companySql = string.Format("insert into {0}([CompanyId],[CompanyName],[Name],[City],[Address],[Status],[Infos],[IsDeleted],[CreateDate],[CreateBy],[TeamDesc],[CompanyStatus],[PartInfo]) " + "values(@CompanyId,@CompanyName,@Name,@City,@Address,@Status,@Infos,0,getdate(),@CreateBy,@TeamDesc,@CompanyStatus,@PartInfo);SELECT @@IDENTITY ", CompanyTableName); string memberSql = string.Format("insert into {0}([CompanyId],[CompanyName],[CusCompanyId],[Name],[ImgUrl],[Mobile],[Email],[Infos],[IsDeleted],[CreateDate],[CreateBy]) " + " values(@CompanyId,@CompanyName,@CusCompanyId,@Name,@ImgUrl,@Mobile,@Email,@Infos,0,getdate(),@CreateBy);SELECT @@IDENTITY", MemberTableName); string sql = string.Format("insert into {0}([Mobile],[Email],[Password],[IsDeleted],[CreateDate],[CreateBy],[Role],[AccountName],[AccountId]) values" + "(@Mobile,@Email,@Password,0,getdate(),@CreateBy,@Role,@AccountName,@AccountId);SELECT @@IDENTITY", TableName); string Projectsql = string.Format("insert into {0}([Name],[FullName],[PayWay],[Money],[Status],[Infos],[CompanyId],[CreateDate],[CreateBy],[IsDeleted]," + "[CusMemberId],[CusCompanyId],[Source],[OpereateType],[DevType],[NowStatus],[DevLanguate],[MarketProspect],[Month])" + " values(@Name,@FullName,@PayWay,@Money,@Status,@Infos,@CompanyId,getdate(),@CreateBy,0,@CusMemberId,@CusCompanyId,@Source,@OpereateType,@DevType,@NowStatus,@DevLanguate,@MarketProspect,@Month);SELECT @@IDENTITY", ProjectTableName); string HardWareSql = string.Format("insert into {0}([IsDeleted],[CreateDate],[CreateBy],[WorkGuid],[Infos],[ProjectId]) values(0,getdate(),@CreateBy,@WorkGuid,@Infos,@ProjectId)", HardWareTableName); string PersonSettingSql = string.Format("insert into {0}([IsDeleted],[CreateDate],[CreateBy],[WorkGuid],[Price],[DepartId],[DepartName],[Infos],[Month],[TotalPrice],[Discount],[ProjectId]) values(0,getdate(),@CreateBy,@WorkGuid,@Price,@DepartId,@DepartName,@Infos,@Month,@TotalPrice,@Discount,@ProjectId)", PersonSettingTableName); using (SqlConnection con = new SqlConnection(ConfigSetting.DataConnection)) { con.Open(); var companyId = con.Query <int>(companySql, company).FirstOrDefault(); member.CusCompanyId = companyId; var memberId = con.Query <int>(memberSql, member).FirstOrDefault(); account.AccountId = memberId; var accountId = con.Query <int>(sql, account).FirstOrDefault(); projectManage.CusCompanyId = companyId; projectManage.CusMemberId = memberId; projectManage.CreateBy = account.AccountName; if (personSettings != null && personSettings.Count() > 0) { projectManage.Money = personSettings.Sum(a => a.TotalPrice); } var projectId = con.Query <int>(Projectsql, projectManage).FirstOrDefault(); hardWare.ProjectId = projectId; personSettings.ForEach(a => { a.ProjectId = projectId; }); if (personSettings != null && personSettings.Count() > 0) { con.Execute(PersonSettingSql, personSettings); } return(con.Execute(HardWareSql, hardWare) > 0); } return(true); //string sql = string.Format("insert into {0}([Mobile],[Email],[Password],[IsDeleted],[CreateDate],[CreateBy],[Role],[AccountName]) values(@Mobile,@Email,@Password,0,getdate(),@CreateBy,@Role,@AccountName)", TableName); //return DBAccess.ExecuteSqlWithEntity(sql, model); }
/// <summary> /// 验证用户,通过网络 /// </summary> /// <param name="netname"></param> /// <param name="netpass"></param> /// <param name="hdinfo"></param> /// <returns></returns> protected ModelMember getUser(string netname, string netpass, string hdinfo) { #if DEBUG member.netname = "调试模式"; member.group = "商业授权用户"; member.sitenum = 9999; member.IS_X_WordPressBuild = true; member.IS_X_PostKing = true; member.userMoney = 9999; return(Login_Base.member); #endif string path = Application.StartupPath + "\\Config\\RenZheMember.txt"; string html = ""; DbTools db = new DbTools(); CookieCollection cookies = new CookieCollection(); try { object obj = db.Read(path, "VCDS"); if (obj != null) { member = (ModelMember)obj; } EchoHelper.Echo("连接【忍者软件】用户服务端,进行通信。此过程稍慢,请稍候...", "系统登录", EchoHelper.EchoType.任务信息); //发现有不符的情况,将进行登录验证。 if (member.logintime.Date < DateTime.Now.Date || member.netpass != netpass || member.netname != netname || member.hdinfo != HardWare.getHardCode()) { string purl = "http://www.renzhe.org/member.php?mod=logging&action=login&loginsubmit=yes&infloat=yes&lssubmit=yes&inajax=1"; string pdata = "fastloginfield=username&username="******"&password="******"&quickforward=yes&handlekey=ls"; html = new xkHttp().httpPost(purl, pdata, ref cookies, purl, Encoding.GetEncoding("utf-8")); if (html.Contains(">window.location.href='")) { wait.ShowMsg("4/10 您的账户、密码验证成功!"); EchoHelper.Echo("论坛账户、密码验证成功!", "系统登录", EchoHelper.EchoType.任务信息); purl = "http://www.renzhe.org/home.php?mod=spacecp&ac=credit"; html = new xkHttp().httpGET(purl, ref cookies); if (html.Contains("[ 点击这里返回上一页 ]")) { EchoHelper.Echo("忍者服务端维护,暂时关闭,请稍后再试...", "系统登录", EchoHelper.EchoType.错误信息); return(member); } if (html.Contains("您需要先登录才能继续本操作")) { EchoHelper.Echo("您的账号异常,请手工登录论坛检查账户问题!", "系统登录", EchoHelper.EchoType.错误信息); return(member); } if (html.Contains("抱歉,您的 IP 地址不在被允许,或您的账号被禁用,无法访问本站点")) { EchoHelper.Echo("抱歉,您的 IP 地址不在被允许,或您的账号被禁用,无法访问本站点!", "系统登录", EchoHelper.EchoType.错误信息); return(member); } wait.ShowMsg("5/10 您的用户基本信息,获取成功!"); EchoHelper.Echo("您的用户基本信息,获取成功!", "系统登录", EchoHelper.EchoType.任务信息); member.UID = RegexHelper.getHtmlRegexText(html, "{discuz_uid = '(.*?)'}"); member.netname = RegexHelper.getHtmlRegexText(html, "{title=\"访问我的空间\">(.*?)</a>}"); member.sitenum = Convert.ToInt32(RegexHelper.getHtmlRegexText(html, "{站点数:</em>(.*?) </li>}")); member.group = RegexHelper.getHtmlRegexText(html, "{showUpgradeinfo\\)\">(.*?)</a>}"); member.userMoney = Convert.ToInt32(RegexHelper.getHtmlRegexText(html, "{金币:</em>(.*?) }")); member.formhash = RegexHelper.getHtmlRegexText(html, "{formhash=(.*?)\">退出</a>}"); member.cookies = cookies; member.netpass = netpass; member.logintime = DateTime.Now; member.hdinfo = HardWare.getHardCode(); member.IS_X_PostKing = true; EchoHelper.Echo("链接服务端,判断应用授权状态...", "系统登录", EchoHelper.EchoType.任务信息); wait.ShowMsg("6/10 链接服务端,判断应用授权状态!"); } else { wait.ShowMsg("用户验证失败..."); string result = "未知,请重试,登录论坛联系管理员。www.renzhe.org"; if (html.Contains("登录失败")) { result = "请核对您的用户名密码!登录论坛联系管理员。www.renzhe.org"; } if (html.Contains("showWindow('login', 'member.php?mod=logging&action=")) { result = "发现安全问题,清除您的安全问题后,再尝试!www.renzhe.org"; } if (html.Contains("密码错误次数过多")) { result = "密码错误次数过多,稍后再试!登录论坛联系管理员。www.renzhe.org"; } if (html.Contains("无法解析此远程名称")) { result = "无法解析www.renzhe.org,请检查您的网络,稍后再试"; } member.IS_X_PostKing = false; member.IS_X_WordPressBuild = false; EchoHelper.Echo("登录失败:" + result, "系统登录", EchoHelper.EchoType.错误信息); return(member); } } else { wait.ShowMsg("7/10 发现本地密钥,进行快捷登录..."); EchoHelper.Echo("发现本地登录密钥文件,进行验证,请稍后...", "系统登录", EchoHelper.EchoType.任务信息); } #if !DEBUG //向服务端提交member序列化的类,然后验证是否为登录成功的状态。 ValidateUser(ref member); #else //ValidateUser(ref member); #endif ini.up("登录账户密码", "INFO", member.netname); if (member.IS_X_PostKing == false) { member.logintime = DateTime.Now.AddDays(-111); FilesHelper.DeleteFile(path); } else { wait.ShowMsg("8/10 恭喜,您的密钥经服务端验证成功!"); EchoHelper.Echo("恭喜,您的本地密钥,经服务端验证成功,通信一切正常!", "系统登录", EchoHelper.EchoType.任务信息); } } catch (Exception ex) { FilesHelper.DeleteFile(path); EchoHelper.Echo("与服务端通信失败!" + ex.Message, "系统登录", EchoHelper.EchoType.异常信息); } finally { if (member.group.Contains("商业")) { member.IS_X_WordPressBuild = true; } if (member.IS_X_PostKing == true) { wait.ShowMsg("9/10 密钥已保存,下次可快捷登录!"); Thread.Sleep(1200); EchoHelper.Echo("您的本地密钥已保存,下次可快捷登录!", "系统登录", EchoHelper.EchoType.任务信息); db.Save(path, "VCDS", member); } } return(Login_Base.member); }
public static bool AddHardWare(HardWare model) { string sql = string.Format("insert into {0}([IsDeleted],[CreateDate],[CreateBy],[WorkGuid],[Infos]) values(0,getdate(),@CreateBy,@WorkGuid,@Infos)", TableName); return(DBAccess.ExecuteSqlWithEntity(sql, model)); }
private void txtHardInfo_Click(object sender, EventArgs e) { StringHelper.stringCopy(HardWare.getHardCode()); EchoHelper.Show("复制成功:" + HardWare.getHardCode(), EchoHelper.MessageType.提示); }