Exemplo n.º 1
0
        /// <summary>
        /// 获取token值
        /// </summary>
        private bool GetNewToken(out string errorMsg)
        {
            errorMsg = string.Empty;
            var  loop      = 0;
            bool isSuccess = false;

            //while ((loop < 5 && !string.IsNullOrEmpty(CryptTool.ErrorMsg) && CryptTool.ErrorMsg.Contains(PRO_ReceiptsInvMgr.Resources.Message.JXCertError)) || loop == 0)
            while (loop < 5)
            {
                isSuccess = CryptTool.Login(GlobalInfo.JxPwd);
                loop++;
                if (isSuccess)
                {
                    break;
                }
            }

            if (!isSuccess)
            {
                errorMsg = CryptTool.ErrorMsg;
            }
            else
            {
                GlobalInfo.token = CryptTool.Token;
            }
            return(isSuccess);
        }
Exemplo n.º 2
0
        private void btnLogin_Click(object sender, RoutedEventArgs e)
        {
            if (string.IsNullOrEmpty(pwd.Password))
            {
                MessageBoxEx.Show(this, PRO_ReceiptsInvMgr.Resources.Message.PwdNotEmpty, PRO_ReceiptsInvMgr.Resources.Message.Tips, MessageBoxExButtons.OK, MessageBoxExIcon.Error);
                return;
            }
            var deviceId = BoxInfoHelper.GetDeviceNo();

            if (string.IsNullOrEmpty(deviceId))
            {
                MessageBoxEx.Show(this, PRO_ReceiptsInvMgr.Resources.Message.GetDeviceNoError, PRO_ReceiptsInvMgr.Resources.Message.Tips, MessageBoxExButtons.OK, MessageBoxExIcon.Error);
                return;
            }
            var    isSuccess    = false;
            string getDqdmError = string.Empty;

            this.Dispatcher.Invoke(new Action(() =>
            {
                WaitingBox.Show(() =>
                {
                    string netLocation = service.GetNetLocation(GlobalInfo.Dqdm);

                    if (!string.IsNullOrEmpty(netLocation))
                    {
                        CryptTool.LoginUrl = netLocation + ConfigHelper.GetAppSettingValue("JXLoginUri");
                        CryptTool.QueryUrl = netLocation + ConfigHelper.GetAppSettingValue("JXQueryUri");
                    }

                    if (!string.IsNullOrEmpty(getDqdmError))
                    {
                        return;
                    }

                    var loop = 0;
                    while ((loop < 5 && !string.IsNullOrEmpty(CryptTool.ErrorMsg) && CryptTool.ErrorMsg.Contains(PRO_ReceiptsInvMgr.Resources.Message.JXCertError)) || loop == 0)
                    {
                        isSuccess        = CryptTool.Login(pwd.Password);
                        GlobalInfo.NSRMC = CryptTool.Nsrmc;

                        loop++;
                        if (isSuccess)
                        {
                            break;
                        }
                    }
                }, PRO_ReceiptsInvMgr.Resources.Message.loginWait);
            }));

            if (!string.IsNullOrEmpty(getDqdmError))
            {
                MessageBoxEx.Show(this, getDqdmError, PRO_ReceiptsInvMgr.Resources.Message.Tips, MessageBoxExButtons.OK, MessageBoxExIcon.Error);
                return;
            }
            else
            {
                Logging.Log4NetHelper.Info(this, "地区代码:" + GlobalInfo.Dqdm);
            }

            if (!isSuccess)
            {
                MessageBoxEx.Show(this, CryptTool.ErrorMsg, PRO_ReceiptsInvMgr.Resources.Message.Tips, MessageBoxExButtons.OK, MessageBoxExIcon.Error);
            }
            else
            {
                GlobalInfo.JxPwd = pwd.Password;
                GlobalInfo.token = CryptTool.Token;

                JXManager win = new JXManager();
                win.Show();

                isBack = false;
                this.Close();
            }
        }