Ejemplo n.º 1
0
        /// <summary> 完成注册
        /// </summary>
        private void btnReg_Click(object sender, EventArgs e)
        {
            #region 在线注册
            #region 通讯鉴权  注册需要验证鉴权信息,非注册不处理
            if (!string.IsNullOrEmpty(txtauthentication.Caption))
            {
                Validator.SetError(errProvider, txtauthentication, "请录入通讯鉴权码");
                return;
            }
            if (string.IsNullOrEmpty(txts_user.Caption))
            {
                Validator.SetError(errProvider, txts_user, "请录入通讯账号");
                return;
            }
            if (string.IsNullOrEmpty(txts_pwd.Caption))
            {
                Validator.SetError(errProvider, txts_pwd, "请录入通讯密码");
                return;
            }
            string errMsg = ValidateSocket();
            if (!string.IsNullOrEmpty(errMsg))
            {
                MessageBoxEx.Show("鉴权失败:" + errMsg, "系统提示");
                txtauthentication.Focus();
                return;
            }

            #endregion

            #region 提交支撑注册结果
            Hashtable ht      = new Hashtable();
            string    jsonStr = GetModelFromFrm();
            ht.Add("machineCodeSequence", Secret.StringToBase64String(txtmachine_code_sequence.Caption.Trim()));
            string resultStr = HttpRequest.DoGet(GlobalStaticObj_Server.Instance.SoftRegUrl + "remoteSendAuthResult.do", ht);
            if (!string.IsNullOrEmpty(resultStr))
            {
                jsonStr = Secret.Base64StringToString(resultStr);
                ResultInfoBase resultInfo = Newtonsoft.Json.JsonConvert.DeserializeObject <ResultInfoBase>(jsonStr);
                if (resultInfo.isSuccess != 1)
                {
                    MessageBoxEx.Show("软件注册失败:" + resultInfo.errMsg, "系统提示");
                    return;
                }
            }
            #endregion

            #endregion

            bool flag = SaveCorpInfo();
            if (!flag)
            {
                MessageBoxEx.Show("注册失败", "系统提示");
                return;
            }
            MessageBoxEx.Show("注册成功", "系统提示");
            this.DialogResult = DialogResult.OK;
        }
Ejemplo n.º 2
0
        /// <summary> 完成注册
        /// </summary>
        public void FinishReg()
        {
            #region 在线注册
            #region 通讯鉴权  注册需要验证鉴权信息,非注册不处理
            string errMsg = ValidateSocket();
            if (!string.IsNullOrEmpty(errMsg))
            {
                this.Invoke(new Action(() =>
                {
                    Validator.SetError(errProvider, txts_pwd, "鉴权失败:" + errMsg);
                }));
                return;
            }
            #endregion

            #region 提交支撑注册结果
            Hashtable ht      = new Hashtable();
            string    jsonStr = GetModelFromFrm();
            ht.Add("machineCodeSequence", Secret.StringToBase64String(txtmachine_code_sequence.Caption.Trim()));
            string resultStr = HttpRequest.DoGet(GlobalStaticObj_Server.Instance.SoftRegUrl + "remoteSendAuthResult.do", ht);
            if (!string.IsNullOrEmpty(resultStr))
            {
                jsonStr = Secret.Base64StringToString(resultStr);
                ResultInfoBase resultInfo = Newtonsoft.Json.JsonConvert.DeserializeObject <ResultInfoBase>(jsonStr);
                if (resultInfo.isSuccess != 1)
                {
                    this.Invoke(new Action(() =>
                    {
                        MessageBoxEx.ShowWarning("软件注册失败");
                    }));
                    return;
                }
            }
            #endregion
            #endregion

            bool flag = SaveCorpInfo();
            if (!flag)
            {
                throw new Exception("注册失败");
            }
        }
Ejemplo n.º 3
0
        /// <summary> 验证软件是否过期
        /// </summary>
        /// <returns></returns>
        public static long GetSoftValidate()
        {
            Hashtable ht = new Hashtable();

            ht.Add("signId", Secret.StringToBase64String(GlobalStaticObj_Server.Instance.StationID));
            //GlobalStaticObj_Server.Instance.SoftRegUrl = "http://192.168.35.108:8080/sspapp/operation/auth/";
            string resultStr = HttpRequest.DoGet(GlobalStaticObj_Server.Instance.SoftRegUrl + "getValidate.do", ht);

            if (!string.IsNullOrEmpty(resultStr))
            {
                string     jsonStr    = Secret.Base64StringToString(resultStr);
                ResultInfo resultInfo = Newtonsoft.Json.JsonConvert.DeserializeObject <ResultInfo>(jsonStr);
                if (resultInfo.isSuccess != 1)
                {
                    GlobalStaticObj_Server.GlobalLogService.WriteLog("软件有效期", resultInfo.errMsg);
                    return(0);
                }
                Dictionary <string, string> dic = new Dictionary <string, string>();
                dic.Add("protocol_expires_time", resultInfo.validate);
                DBHelper.Submit_AddOrEdit("更新软件有效期", GlobalStaticObj_Server.DbPrefix + GlobalStaticObj_Server.CommAccCode, "tb_signing_info", "sign_id", GlobalStaticObj_Server.Instance.StationID, dic);
                return(Convert.ToInt64(resultInfo.validate));
            }
            return(0);
        }
Ejemplo n.º 4
0
        /// <summary> 每步处理
        /// </summary>
        public bool HandleStep()
        {
            if (currStep == 1)
            {
                #region 软件注册
                if (string.IsNullOrEmpty(txtcom_name.Caption))
                {
                    Validator.SetError(errProvider, txtcom_name, "请录入公司名称");
                    return(false);
                }
                if (string.IsNullOrEmpty(txtcom_address.Caption))
                {
                    Validator.SetError(errProvider, txtcom_address, "请录入联系地址");
                    return(false);
                }
                if (!string.IsNullOrEmpty(txtzip_code.Caption))
                {
                    if (Common.ValidateStr(txtzip_code.Caption.Trim(), @"[1-9]\d{5}(?!\d)") != 1)
                    {
                        Validator.SetError(errProvider, txtzip_code, "请录入正确的邮政编码");
                        return(false);
                    }
                }
                if (string.IsNullOrEmpty(txtcom_contact.Caption))
                {
                    Validator.SetError(errProvider, txtcom_contact, "请录入联系人");
                    return(false);
                }
                if (string.IsNullOrEmpty(txtcom_tel.Caption))
                {
                    Validator.SetError(errProvider, txtcom_tel, "请录入联系人电话号码或手机号");
                    return(false);
                }
                else
                {
                    if (Common.ValidateStr(txtcom_tel.Caption.Trim(), @"[\d-]+") != 1)
                    {
                        Validator.SetError(errProvider, txtcom_tel, "请录入正确的电话号码或手机号");
                        return(false);
                    }
                }

                if (!string.IsNullOrEmpty(txtcom_email.Caption))
                {
                    if (Common.ValidateStr(txtcom_email.Caption.Trim(), @"\w+([-+.]\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*") != 1)
                    {
                        Validator.SetError(errProvider, txtcom_email, "请录入正确的电子邮箱");
                        return(false);
                    }
                }
                if (!string.IsNullOrEmpty(txthotline.Caption))
                {
                    if (Common.ValidateStr(txthotline.Caption.Trim(), @"[\d-]+") != 1)
                    {
                        Validator.SetError(errProvider, txthotline, "请录入正确的电话号码或手机号");
                        return(false);
                    }
                }

                if (isAdd)
                {
                    #region 如果填写sap代码,就验证是否能够同步服务站信息
                    if (!string.IsNullOrEmpty(txtservice_station_sap.Caption))
                    {
                        if (string.IsNullOrEmpty(txtaccess_code.Caption.Trim()))
                        {
                            Validator.SetError(errProvider, txtaccess_code, "请录入宇通接入码");
                            return(false);
                        }
                        string errMsg = yuTongWebService.WebServ_YT_BasicData.LoadServiceStation(txtaccess_code.Caption.Trim(), txtservice_station_sap.Caption.Trim(), false);
                        if (!string.IsNullOrEmpty(errMsg))
                        {
                            Validator.SetError(errProvider, txtaccess_code, "验证失败," + errMsg);
                            return(false);
                        }
                    }
                    #endregion

                    #region 在线注册
                    Hashtable ht      = new Hashtable();
                    string    jsonStr = GetModelFromFrm();
                    ht.Add("jsonStr", Secret.StringToBase64String(jsonStr));
                    //GlobalStaticObj_Server.Instance.SoftRegUrl = "http://192.168.35.111:8080/SspApp/operation/auth/";
                    string resultStr = HttpRequest.DoGet(GlobalStaticObj_Server.Instance.SoftRegUrl + "remoteRegisterAuth.do", ht);
                    if (!string.IsNullOrEmpty(resultStr))
                    {
                        jsonStr = Secret.Base64StringToString(resultStr);
                        ResultInfo resultInfo = Newtonsoft.Json.JsonConvert.DeserializeObject <ResultInfo>(jsonStr);
                        if (resultInfo.isSuccess == 1)
                        {
                            txtsign_id.Caption  = resultInfo.sign_id;
                            txtsign_id.ReadOnly = true;
                            if (!string.IsNullOrEmpty(resultInfo.grantAuthorization))
                            {
                                txtgrant_authorization.Caption  = resultInfo.grantAuthorization;
                                txtgrant_authorization.ReadOnly = true;
                            }
                            else
                            {
                                txtgrant_authorization.ReadOnly = false;
                            }
                            txtgrant_authorization.Tag = resultInfo.validate;
                            txtauthentication.Caption  = resultInfo.authentication;
                            txtauthentication.ReadOnly = true;
                            txts_user.Caption          = resultInfo.sUser;
                            txts_user.ReadOnly         = true;
                            txts_pwd.Caption           = resultInfo.sPwd;
                            txts_pwd.ReadOnly          = true;
                            isOnline = true;
                        }
                        else
                        {
                            txtsign_id.ReadOnly = false;
                        }
                    }
                    #endregion

                    txtcom_name2.Caption = txtcom_name.Caption;
                }

                if (!isAdd)
                {
                    bool flag = SaveCorpInfo();
                    if (!flag)
                    {
                        MessageBoxEx.Show("保存失败", "系统提示");
                        return(false);
                    }
                }
                #endregion
            }
            else if (currStep == 2)
            {
                #region 软件授权  注册需要验证授权信息,非注册不处理
                if (isAdd)
                {
                    if (string.IsNullOrEmpty(txtsign_id.Caption))
                    {
                        Validator.SetError(errProvider, txtsign_id, "请录入服务站ID");
                        return(false);
                    }
                    if (string.IsNullOrEmpty(txtgrant_authorization.Caption))
                    {
                        Validator.SetError(errProvider, txtgrant_authorization, "请录入授权码");
                        return(false);
                    }
                    if (!ValidateGrantAuthorizationInfo())
                    {
                        MessageBoxEx.Show("授权验证失败,请录入正确的授权码", "系统提示");
                        txtgrant_authorization.Focus();
                        return(false);
                    }
                    if (txtgrant_authorization.Tag == null)
                    {
                        //如是离线注册默认一年期限
                        txtgrant_authorization.Tag = Common.LocalDateTimeToUtcLong(GlobalStaticObj_Server.Instance.CurrentDateTime.AddYears(1));
                    }
                }
                #endregion
            }
            return(true);
        }
Ejemplo n.º 5
0
        /// <summary> 第一步
        /// </summary>
        /// <returns></returns>
        public bool FirstStep()
        {
            #region 软件注册
            if (isNeedReg)
            {
                #region 如果sap代码可以编辑且填写sap代码,就验证是否能够同步服务站信息
                if (!string.IsNullOrEmpty(txtservice_station_sap.Caption))
                {
                    string errMsg = yuTongWebService.WebServ_YT_BasicData.LoadServiceStation(txtaccess_code.Caption.Trim(), txtservice_station_sap.Caption.Trim(), false);
                    if (!string.IsNullOrEmpty(errMsg))
                    {
                        this.Invoke(new Action(() =>
                        {
                            MessageBoxEx.ShowWarning("宇通sap代码及接入码验证失败," + errMsg);
                        }));
                        return(false);
                    }
                }
                #endregion

                #region 在线注册
                Hashtable ht      = new Hashtable();
                string    jsonStr = GetModelFromFrm();
                ht.Add("jsonStr", Secret.StringToBase64String(jsonStr));
                //GlobalStaticObj_Server.Instance.SoftRegUrl = "http://192.168.35.111:8080/SspApp/operation/auth/";
                string resultStr = HttpRequest.DoGet(GlobalStaticObj_Server.Instance.SoftRegUrl + "remoteRegisterAuth.do", ht);
                if (!string.IsNullOrEmpty(resultStr))
                {
                    jsonStr = Secret.Base64StringToString(resultStr);
                    ResultInfo resultInfo = Newtonsoft.Json.JsonConvert.DeserializeObject <ResultInfo>(jsonStr);
                    if (resultInfo.isSuccess == 1)
                    {
                        txtsign_id.Caption  = resultInfo.sign_id;
                        txtsign_id.ReadOnly = true;
                        if (!string.IsNullOrEmpty(resultInfo.grantAuthorization))
                        {
                            txtgrant_authorization.Caption  = resultInfo.grantAuthorization;
                            txtgrant_authorization.ReadOnly = true;
                        }
                        else
                        {
                            txtgrant_authorization.ReadOnly = false;
                        }
                        txtgrant_authorization.Tag = resultInfo.validate;
                        txtauthentication.Caption  = resultInfo.authentication;
                        txtauthentication.ReadOnly = true;
                        txts_user.Caption          = resultInfo.sUser;
                        txts_user.ReadOnly         = true;
                        txts_pwd.Caption           = resultInfo.sPwd;
                        txts_pwd.ReadOnly          = true;
                    }
                    else
                    {
                        txtsign_id.ReadOnly = false;
                    }
                }
                #endregion

                txtcom_name2.Caption = txtcom_name.Caption;
            }


            bool flag = SaveCorpInfo();
            if (!flag)
            {
                this.Invoke(new Action(() =>
                {
                    MessageBoxEx.ShowWarning("保存失败");
                }));
                return(false);
            }
            #endregion
            return(true);
        }