//保存时间相关的配置信息
 private void saveConfig_Click(object sender, EventArgs e)
 {
     //string file = Application.ExecutablePath;
     //Configuration config = ConfigurationManager.OpenExeConfiguration(file);
     CfgMgr.SaveValue("NewFansRefresh_Begin", NewFansRefresh_Begin.Text);
     CfgMgr.SaveValue("NewFansRefresh_End", NewFansRefresh_End.Text);
     CfgMgr.SaveValue("NewFansCall_Begin", NewFansCall_Begin.Text);
     CfgMgr.SaveValue("NewFansCall_End", NewFansCall_End.Text);
     CfgMgr.SaveValue("OldRefresh_Begin", OldRefresh_Begin.Text);
     CfgMgr.SaveValue("OldRefresh_End", OldRefresh_End.Text);
     CfgMgr.SaveValue("OldFansCall_Begin", OldFansCall_Begin.Text);
     CfgMgr.SaveValue("OldFansCall_End", OldFansCall_End.Text);
     CfgMgr.SaveValue("moreOffInterTime_begin", moreOffInterTime_begin.Text);
     CfgMgr.SaveValue("moreOffInterTime_end", moreOffInterTime_end.Text);
     //config.Save(ConfigurationSaveMode.Modified);
     //ConfigurationManager.RefreshSection("appSettings");
     weBoUserClient.NewFansRefresh_Begin   = int.Parse(NewFansRefresh_Begin.Text);
     weBoUserClient.NewFansRefresh_End     = int.Parse(NewFansRefresh_End.Text);
     weBoUserClient.NewFansCall_Begin      = int.Parse(NewFansCall_Begin.Text);
     weBoUserClient.NewFansCall_End        = int.Parse(NewFansCall_End.Text);
     weBoUserClient.OldRefresh_Begin       = int.Parse(OldRefresh_Begin.Text);
     weBoUserClient.OldRefresh_End         = int.Parse(OldRefresh_End.Text);
     weBoUserClient.OldFansCall_Begin      = int.Parse(OldFansCall_Begin.Text);
     weBoUserClient.OldFansCall_End        = int.Parse(OldFansCall_End.Text);
     weBoUserClient.moreOffInterTime_begin = int.Parse(moreOffInterTime_begin.Text);
     weBoUserClient.moreOffInterTime_end   = int.Parse(moreOffInterTime_end.Text);
     this.Close();
 }
Beispiel #2
0
 private void btnOk_Click(object sender, EventArgs e)
 {
     if (!VerifyCheckCode(tbxUniqueCode.Text.Trim(), tbxCheckCode.Text.Trim()))
     {
         MessageBox.Show("校验失败!");
     }
     else
     {
         this.DialogResult = DialogResult.OK;
         CfgMgr.SaveValue("CheckCode", tbxCheckCode.Text.Trim());
     }
 }
 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);
            }
        }