Esempio n. 1
0
        static void RequireInitProxy()
        {
            MessageDialog.Information("阿门", "欢迎使用订票助手.NET。为了保证您能更快速更顺利地运行助手,现在需要咨询下阁下的网络设置。\n\n在这之后,您可以随时通过选项来修改设置。");

            var nc = NetworkConfiguration.Current;

            if (MessageDialog.Question("您是否可以直接访问12306?如果可以,那么将会设置成直接访问,速度最快,同时能享有服务器测速加速功能。\n\n一般家庭宽带用户均为『可以』,单位一般也『可以』,但是如果您的公司需要使用代理才能访问外网,请点击『否』。", true))
            {
                nc.ProxyType = 0;
            }
            else if (MessageDialog.Question("您是否有确定的代理服务器地址以访问12306,或您的代理服务器需要用户名和密码才可以访问?如果属于以上情况,请点击『是』。", true))
            {
                nc.ProxyType = 3;
                MessageDialog.Information("提示", "请继续在选项对话框中完成设置。");
                using (var od = new ConfigCenter())
                {
                    od.SelectedConfig = od.FindConfigUI <NetworkConfig>().First();
                    od.ShowDialog();
                }
            }
            else if (MessageDialog.Question("您的IE是否使用了PAC脚本?如果是的话,助手将无法为您的代理进行缓存,可能访问效果最慢。", true))
            {
                nc.ProxyType = 2;
            }
            else
            {
                nc.ProxyType = 1;
            }

            MessageDialog.Information("提示", "设置完毕,感谢您的耐心。亲,祝你回家顺利 :-)");
        }
Esempio n. 2
0
 /// <summary>
 /// 请求保存
 /// </summary>
 /// <returns></returns>
 public override bool Save()
 {
     if (chkEnableMail.Checked)
     {
         var msg = MailSender.Instance.CheckConfigurationError();
         if (!string.IsNullOrEmpty(msg))
         {
             MessageDialog.Information(msg);
             return(false);
         }
     }
     return(base.Save());
 }
        private async void metroButton2_Click(object sender, EventArgs e)
        {
            IsBusy = true;
            var response = await _productPurchaseService.SaveAsync(_purchaseProduct, _noOfItems, _totalAmount);

            if (response)
            {
                MessageDialog.Information("Saved SuccessFully.");
            }
            else
            {
                MessageDialog.Error("Something went wrong.");
            }
            IsBusy = false;
        }
        private async void metroButton1_Click(object sender, EventArgs e)
        {
            IsBusy = true;
            metroButton1.Enabled = false;
            var id      = metroComboBox1.SelectedValue as string;
            var results = await _permissionsManger.OnSaveAsync(id);

            if (results)
            {
                MessageDialog.Information("Saved SuccessFully");
            }
            else
            {
                MessageDialog.Error("Something went wrong.");
            }
            metroButton1.Enabled = true;
            IsBusy = false;
        }
        public void RunLoginProcedure(RequireSessionLoginWorker worker)
        {
            using (var wd = new YetAnotherWaitingDialog())
            {
                var vccount = 0;
                IVerifyCodeRecognizeResult vcResult = null;

                wd.WorkCallback      = worker.DoLogin;
                worker.StateChanged += (ss, se) =>
                {
                    wd.SetState(worker.State.ToExecutionState(), worker.Message);
                };
                worker.VerifyCodeError += (x, y) =>
                {
                    if (vcResult != null && VerifyCodeRecognizeServiceLoader.VerifyCodeRecognizeEngine != null)
                    {
                        VerifyCodeRecognizeServiceLoader.VerifyCodeRecognizeEngine.MarkResult(vcResult, false);
                        vcResult = null;
                    }
                };
                worker.RequireEnterVerifyCode += (ss, ee) =>
                {
                    wd.Invoke(() =>
                    {
                        if (vccount > 5 && ProgramConfiguration.Instance.AutoEnterLoginVcCode)
                        {
                            MessageDialog.Information("亲,验证码自动识别失败超过限制,自动识别已经关闭,请手动输入验证码。");
                        }
                        //var vcform = new UI.Dialogs.RequireVcCode
                        //{
                        //	Session = ee.Session,
                        //	EnableAutoVc = vccount < 6 && ProgramConfiguration.Instance.AutoEnterLoginVcCode,
                        //	AutoVcCount = vccount
                        //};
                        //if (vcform.ShowDialog(OwnerForm) == DialogResult.OK)
                        //{
                        //	vcResult = vcform.VcResult;
                        //	vccount = vcform.AutoVcCount;
                        //	ee.VerifyCode = vcform.Code;

                        //	if (vcResult != null)
                        //	{
                        //		//report
                        //		ApiEvents.OnAutoVc(null, new GeneralEventArgs<AutoVcLog>(new AutoVcLog()
                        //																{
                        //																	Account12306 = worker.UserName,
                        //																	TypeID = 0,
                        //																	TodayUsed = AutoVcBaseLimition.GetVcUsed()
                        //																}));

                        //	}
                        //}
                        var vc = new TouchClickVcSimpleForm(ee.Session)
                        {
                            RandCodeType = RandCodeType.SjRand,
                            EnableAutoVc = vccount < 6 && ProgramConfiguration.Instance.AutoEnterLoginVcCode
                        };
                        if (vc.ShowDialog(OwnerForm) == DialogResult.OK)
                        {
                            ee.VerifyCode = vc.Code;
                            vcResult      = vc.AutoVcResult;

                            if (vcResult != null)
                            {
                                vccount++;
                            }
                        }
                    });
                    vccount++;
                };

                wd.ShowDialog(OwnerForm);

                if (EnableFallback && worker.Session == null && (string.IsNullOrEmpty(worker.Message) || worker.Message.IndexOf("密码输入错误") != -1))
                {
                    //返回
                    using (var logindlg = new Login()
                    {
                        PreSelectUser = worker.UserName
                    })
                    {
                        logindlg.ShowDialog(OwnerForm);
                    }
                }
                else if (worker.State == OpearationState.Blocked && !worker.Message.IsNullOrEmpty())
                {
                    MessageDialog.Error(OwnerForm, "尝试登录的时候遇到了问题:\n\n" + worker.Message);
                }
                else if (wd.Exception != null)
                {
                    MessageDialog.Error(OwnerForm, "尝试登录的时候遇到了问题:\n\n" + wd.Exception.ToString());
                }
                if (worker.Session != null && worker.LoginConflict)
                {
                    MessageDialog.Information(OwnerForm, "此次登录检测到会话冲突,如果您此时还在其它的软件或浏览器上登录此账号,它们将会被12306无情地注销掉。\n\n世界就是这样的残酷,多坑点身份证注册几个账号吧……");
                }
            }
        }