public static string GetMachineCodeString() { string machineCodeString = string.Empty; if (machineCode == null) { machineCode = new MachineCode(); } machineCodeString = "PC." + machineCode.GetCpuInfo() + "." + machineCode.GetHDid() + "." + machineCode.GetMoAddress(); return(machineCodeString); }
public static string GetShortMachineCodeString() { string machineCodeString = string.Empty; if (machineCode == null) { machineCode = new MachineCode(); } machineCodeString = (machineCode.GetCpuInfo() + machineCode.GetHDid() + machineCode.GetMoAddress()).Replace(":", "").Replace("-", "").Replace(" ", ""); return(machineCodeString); }
//初始化 private void Form1_Load(object sender, EventArgs e) { try { userPhoto.SizeMode = PictureBoxSizeMode.StretchImage; if (!LoginFrm.VerifyCheckCode(MachineCode.GetShortMachineCodeString(), CfgMgr.GetValue("CheckCode"))) { //登陆校验 LoginFrm loginFrm = new LoginFrm(); if (loginFrm.ShowDialog() != DialogResult.OK) { this.Close(); } ; } #region 注册微博用户客户端 weBoUserClient = new WeiBoUserClient(); weBoUserClient.ErrorMessagNotice = delegate(Exception ex) { MessageBox.Show($"程序运行异常,请检查网络是否正常!异常信息:{ex.Message}", "错误提示", MessageBoxButtons.OK); }; weBoUserClient.QrCodeImageChange = delegate(string imageUrl) { userPhoto.Invoke(new MethodInvoker(delegate() { userPhoto.Load(imageUrl); })); }; weBoUserClient.UserInfoChange = delegate(WeiBoUser user) { userPhoto.Invoke(new MethodInvoker(delegate() { userPhoto.Load(user.avatar_large); })); SetControlText(userName, user.nick); BeginOn.Invoke(new MethodInvoker(delegate() { BeginOn.Enabled = true; })); BeginDown.Invoke(new MethodInvoker(delegate() { BeginDown.Enabled = true; })); }; weBoUserClient.NumberRunsChange = delegate(int value) { SetControlText(runNumber, value.ToString()); }; weBoUserClient.LastSendMessageTimeChange = delegate(DateTime? date) { SetControlText(label7, date.Value.ToString("yyyy-MM-dd HH:mm:ss")); }; weBoUserClient.LastSendMessageUserChange = delegate(Fans fans) { SetControlText(lastUserName, fans.nick); }; weBoUserClient.OldFansSendMessageStartUserChange = delegate(Fans fans) { SetControlText(beginSite, fans.nick); }; weBoUserClient.TodaySendMessageCountChange = delegate(int value) { SetControlText(runNumberToday, value.ToString()); }; weBoUserClient.IsSendMessageNewFansRunChange = delegate(bool value) { SetControlText(BeginDown, value ? "停止" : "开始"); BeginOn.Invoke(new MethodInvoker(delegate() { BeginOn.Enabled = !value; })); BeginDown.Invoke(new MethodInvoker(delegate() { BeginDown.Enabled = !value; })); }; weBoUserClient.IsSendMeesageToOldFansRunChange = delegate(bool value) { SetControlText(BeginOn, value ? "停止" : "开始"); BeginOn.Invoke(new MethodInvoker(delegate() { BeginOn.Enabled = !value; })); BeginDown.Invoke(new MethodInvoker(delegate() { BeginDown.Enabled = !value; })); }; #endregion weBoUserClient.StartQrcodeLogin(); //默认给页面的配置赋值,数据从配置中读取 weBoUserClient.SetDefalutConfig(); BeginOn.Enabled = false; BeginDown.Enabled = false; weBoUserClient.SentsMessageListByNew = new List <Fans>(); weBoUserClient.SentsMessageListByOld = new List <Fans>(); } catch (Exception ex) { log.Error("启动异常!", ex); MessageBox.Show(ex.Message); } }