private void ConfigFrom_Load(object sender, EventArgs e)
 {
     //赋值
     NewFansRefresh_Begin.Text   = CfgMgr.GetValue("NewFansRefresh_Begin");
     NewFansRefresh_End.Text     = CfgMgr.GetValue("NewFansRefresh_End");
     NewFansCall_Begin.Text      = CfgMgr.GetValue("NewFansCall_Begin");
     NewFansCall_End.Text        = CfgMgr.GetValue("NewFansCall_End");
     OldRefresh_Begin.Text       = CfgMgr.GetValue("OldRefresh_Begin");
     OldRefresh_End.Text         = CfgMgr.GetValue("OldRefresh_End");
     OldFansCall_Begin.Text      = CfgMgr.GetValue("OldFansCall_Begin");
     OldFansCall_End.Text        = CfgMgr.GetValue("OldFansCall_End");
     moreOffInterTime_begin.Text = CfgMgr.GetValue("moreOffInterTime_begin");
     moreOffInterTime_end.Text   = CfgMgr.GetValue("moreOffInterTime_end");
 }
 public void SetDefalutConfig()
 {
     //赋值
     NewFansRefresh_Begin   = int.Parse(CfgMgr.GetValue("NewFansRefresh_Begin"));
     NewFansRefresh_End     = int.Parse(CfgMgr.GetValue("NewFansRefresh_End"));
     NewFansCall_Begin      = int.Parse(CfgMgr.GetValue("NewFansCall_Begin"));
     NewFansCall_End        = int.Parse(CfgMgr.GetValue("NewFansCall_End"));
     OldRefresh_Begin       = int.Parse(CfgMgr.GetValue("OldRefresh_Begin"));
     OldRefresh_End         = int.Parse(CfgMgr.GetValue("OldRefresh_End"));
     OldFansCall_Begin      = int.Parse(CfgMgr.GetValue("OldFansCall_Begin"));
     OldFansCall_End        = int.Parse(CfgMgr.GetValue("OldFansCall_End"));
     moreOffInterTime_begin = int.Parse(CfgMgr.GetValue("moreOffInterTime_begin"));
     moreOffInterTime_end   = int.Parse(CfgMgr.GetValue("moreOffInterTime_end"));
     PrintMsg(PrintType.info, "SetDefalutConfig 初始化配置完成!");
 }
        //初始化
        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);
            }
        }