示例#1
0
        private void btnOK_Click(object sender, EventArgs e)
        {
            if (textBoxX1.Text.Length == 0 || textBoxX2.Text.Length == 0)
            {
                btnOK.Enabled = false;
                return;
            }


            CGisDataSettings.gCurrentProject.projectUrl       = CGisDataSettings.gProjectList[comboBoxEx1.SelectedIndex].projectUrl;//ipAddressInput1.Value;
            CGisDataSettings.gCurrentProject.userName         = textBoxX1.Text.Trim();
            CGisDataSettings.gCurrentProject.userPSD          = textBoxX2.Text.Trim();
            CGisDataSettings.gCurrentProject.projectLocalPath = CGisDataSettings.gProjectList[comboBoxEx1.SelectedIndex].projectLocalPath;

            CServerWrapper.ConnectToServer(CGisDataSettings.gCurrentProject.projectUrl);

            //string url = "http://" + GlobalSettings.gProjectUrl + "/webservice/usrlogin.asmx";

            string resultStr = null;

            if (CServerWrapper.isConnected)
            {
                resultStr = CServerWrapper.webLogin(CGisDataSettings.gCurrentProject.userName, CGisDataSettings.gCurrentProject.userPSD);
            }

            //try
            //{
            //    WebServiceAgent ag = new WebServiceAgent(url);
            //    resultStr = (string)ag.Invoke("CheckUsrLogin", GlobalSettings.gUserName, GlobalSettings.gUserPWD);
            //}
            //catch (System.Exception ex)
            //{
            //    MessageBox.Show(ex.ToString().Split('\n')[0]);
            //}
            //finally
            //{
            if (resultStr == "µÇ¼³É¹¦")
            {
                CGisDataSettings.UpdateConfigInfo();
                this.DialogResult = DialogResult.OK;     // Setting the DialogResult, will close the dialog, and the ShowDialog call will return.
            }
            else if (resultStr != null)
            {
                MessageBox.Show("Wrong User Name or Password");
                Environment.Exit(-1);
                //this.DialogResult
            }
            else
            {
                MessageBox.Show("No response from remote server, using local database instead");
                this.DialogResult = DialogResult.OK;
            }
            this.btnOK.Enabled = true;
            //}
            //GlobalVar.useLocalDB = true;
            //this.DialogResult = DialogResult.OK;
        }
示例#2
0
        private void btnOK_Click(object sender, EventArgs e)
        {
            CGisDataSettings.gCurrentProject.projectUrl       = CGisDataSettings.gProjectList[comboBoxEx1.SelectedIndex].projectUrl;//ipAddressInput1.Value;
            CGisDataSettings.gCurrentProject.userName         = textBoxX1.Text.Trim();
            CGisDataSettings.gCurrentProject.userPSD          = textBoxX2.Text.Trim();
            CGisDataSettings.gCurrentProject.projectLocalPath = CGisDataSettings.gProjectList[comboBoxEx1.SelectedIndex].projectLocalPath;
            CServerWrapper.isConnected = !(checkBoxX1.CheckState == CheckState.Checked);
            if (CServerWrapper.isConnected)
            {
                CServerWrapper.isConnected = CServerWrapper.ConnectToServer(CGisDataSettings.gCurrentProject.projectUrl);
            }

            //string url = "http://" + GlobalSettings.gProjectUrl + "/webservice/usrlogin.asmx";

            string resultStr = null;

            if (CServerWrapper.isConnected)
            {
                resultStr = CServerWrapper.webLogin(CGisDataSettings.gCurrentProject.userName, CGisDataSettings.gCurrentProject.userPSD);
                if (resultStr == "登录成功")
                {
                    CGisDataSettings.UpdateConfigInfo();
                    this.DialogResult = DialogResult.OK; // Setting the DialogResult, will close the dialog, and the ShowDialog call will return.
                }
                else if (resultStr != null)
                {
                    MessageBox.Show("用户名或密码错误");
                    //Environment.Exit(-1);
                    //this.DialogResult
                }
            }
            else
            {
                MessageBox.Show("脱机状态使用本系统");
                CGisDataSettings.UpdateConfigInfo();
                this.DialogResult = DialogResult.OK;
            }
            //this.btnOK.Enabled = true;
            //}
            //GlobalVar.useLocalDB = true;
            //this.DialogResult = DialogResult.OK;
        }