Exemplo n.º 1
0
        private void Frm_Load(object sender, EventArgs e)
        {
            try
            {
                TH.Smart.BaseClass.ClsBaseDataInfo.sWebPath = Path.GetDirectoryName(Assembly.GetExecutingAssembly().ManifestModule.FullyQualifiedName) + @"\WebURL.txt";
                if (!File.Exists(TH.Smart.BaseClass.ClsBaseDataInfo.sWebPath))
                {
                    MessageBox.Show("请先设置连接");
                    FrmWebURL f = new FrmWebURL();
                    f.ShowDialog();
                }

                StreamReader sr   = new StreamReader(TH.Smart.BaseClass.ClsBaseDataInfo.sWebPath);
                string       sUrl = sr.ReadToEnd().Trim();
                if (sUrl.Trim() != "")
                {
                    TH.Smart.BaseClass.ClsBaseDataInfo.sConnString = @"http://" + sUrl.Trim() + @"/webDMC/DBScanForCheck.asmx";
                }
                sr.Close();

                if (TH.Smart.BaseClass.ClsBaseDataInfo.sConnString == "")
                {
                    MessageBox.Show("请先设置连接");
                    FrmWebURL f = new FrmWebURL();
                    f.ShowDialog();
                }

                TH.Smart.WebService.ClsUseWebService clsWeb = new TH.Smart.WebService.ClsUseWebService();
                if (clsWeb.HelloWork() != "Hello World")
                {
                    throw new Exception("网络地址配置不正确,或网络不通");
                }

                DateTime d = Convert.ToDateTime(clsWeb.sServerTime());
                if (d > Convert.ToDateTime("1900-01-01"))
                {
                    dtmLogin.Value = d;
                }

                txtUid.Focus();
            }
            catch (Exception ee)
            {
                MessageBox.Show(ee.Message);
            }
        }
Exemplo n.º 2
0
        private void btnSave_Click(object sender, EventArgs e)
        {
            try
            {
                if (txtURL.Text.Trim() == "")
                {
                    txtURL.Focus();
                    throw new Exception("连接不能为空");
                }
                TH.Smart.BaseClass.ClsBaseDataInfo.sConnString = @"http://" + txtURL.Text.Trim() + @"/webDMC/DBScanForCheck.asmx";

                TH.Smart.WebService.ClsUseWebService clsWeb = new TH.Smart.WebService.ClsUseWebService();
                if (clsWeb.HelloWork() == "Hello World")
                {
                    FileStream   fs1 = new FileStream(TH.Smart.BaseClass.ClsBaseDataInfo.sWebPath, FileMode.Open, FileAccess.Write);
                    StreamWriter sw  = new StreamWriter(fs1);
                    try
                    {
                        sw.WriteLine(this.txtURL.Text.Trim());

                        this.DialogResult = DialogResult.OK;
                    }
                    catch (Exception ee)
                    {
                        MessageBox.Show("保存网络服务地址失败");
                    }
                    finally
                    {
                        sw.Close();
                        fs1.Close();
                    }
                }
                else
                {
                    throw new Exception("网络地址配置不正确,或网络不通");
                }
            }
            catch (Exception ee)
            {
                MessageBox.Show(ee.Message);
            }
        }