Пример #1
0
        private void btnSetTest_Click(object sender, System.EventArgs e)
        {
            try
            {
                if (this.chkOrdial.Checked == true)
                {
                    XmlDocument xDoc = new XmlDocument();
                    xDoc.Load("Info.xml");
                    xDoc.DocumentElement.SelectSingleNode("./tcpServer").Attributes.GetNamedItem("name").Value = "";
                    xDoc.Save("Info.xml");
                    MessageBox.Show("设置完成!");
                    return;
                }
                if (this.chkServer.Checked == true)
                {
                    //服务器
                    this.cmbTcpServ.Text = System.Net.Dns.GetHostName();

                    if (this.txtPort.Text.Trim() == "")
                    {
                        MessageBox.Show("请填写端口号!");
                        return;
                    }

                    if (this.cmbTcpServ.Text.Trim() == "")
                    {
                        MessageBox.Show("请填写服务器名称!");
                        return;
                    }

                    GprsSoft.serverMonitor.CServerMonitor cSerMon = new GprsSoft.serverMonitor.CServerMonitor();

                    //打开监听
                    if (cSerMon.openWebRemoting(this.txtPort.Text.Trim()) == true)
                    {
                        //cSerMon.closeWebRemote();
                        XmlDocument xDoc = new XmlDocument();
                        xDoc.Load("Info.xml");
                        xDoc.DocumentElement.SelectSingleNode("./socketPort").InnerText = this.txtPort.Text;
                        xDoc.DocumentElement.SelectSingleNode("./tcpServer").InnerText  = this.cmbTcpServ.Text;
                        xDoc.DocumentElement.SelectSingleNode("./tcpServer").Attributes.GetNamedItem("name").Value = "server";
                        xDoc.Save("Info.xml");
                    }
                    else
                    {
                        MessageBox.Show("服务设置失败!");
                        return;
                    }
                    MessageBox.Show("服务设置成功!");
                }
                else
                {
                    if (this.chkClient.Checked == true)
                    {
                        //客户端
                        XmlDocument xDoc = new XmlDocument();
                        xDoc.Load("Info.xml");

                        if (this.txtPort.Text.Trim() == "")
                        {
                            MessageBox.Show("请填写端口号!");
                            return;
                        }

                        string strSocketPort = "";
                        strSocketPort = this.txtPort.Text.Trim();
                        int iPort = Convert.ToInt32(strSocketPort);

                        if (this.cmbTcpServ.Text.Trim() == "")
                        {
                            MessageBox.Show("请填写服务器名称!");
                            return;
                        }
                        string strServer = "";
                        strServer = this.cmbTcpServ.Text.Trim();

                        string strUrl = String.Format("tcp://{1}:{0}/serverMonitor", iPort.ToString(), strServer);
                        GprsSoft.serverMonitor.CServer cServerObj = (GprsSoft.serverMonitor.CServer)Activator.GetObject(typeof(GprsSoft.serverMonitor.CServer), strUrl);
                        //CDBConnection.m_cServerMonObj=cServerObj;
                        if (cServerObj == null)
                        {
                            cServerObj = null;
                            MessageBox.Show("连接失败,请检查服务器监听是否打开!");
                            return;
                        }
                        try
                        {
                            cServerObj.getRefreshTime();
                            MessageBox.Show("连接成功!");
                        }
                        catch (Exception ex)
                        {
                            cServerObj = null;
                            MessageBox.Show("连接失败,请检查服务器监听是否打开!");
                            return;
                        }

                        xDoc.DocumentElement.SelectSingleNode("./socketPort").InnerText = this.txtPort.Text;
                        xDoc.DocumentElement.SelectSingleNode("./tcpServer").InnerText  = this.cmbTcpServ.Text;
                        xDoc.DocumentElement.SelectSingleNode("./tcpServer").Attributes.GetNamedItem("name").Value = "client";
                        xDoc.Save("Info.xml");
                    }
                    else
                    {
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString());
            }
        }
Пример #2
0
        private void frmWaterSys_Load(object sender, System.EventArgs e)
        {
            try
            {
                string strSql=string.Format("select softName,userName,version,image from tbAdInfo where userid='{0}'",BengZhan.CDBConnection.m_strUserID);
                DataTable dtAdInfo=new DataTable();

                BengZhan.CDBConnection.getDataTable(ref dtAdInfo,strSql,"dt");

                XmlDocument xDocInfo=new XmlDocument();
                xDocInfo.Load(@"ini/sysIni.xml");

                xDocInfo.DocumentElement.SelectSingleNode("./abort/softName").Attributes.GetNamedItem("val").Value=dtAdInfo.Rows[0]["softName"].ToString().Trim();
                xDocInfo.DocumentElement.SelectSingleNode("./abort/version").Attributes.GetNamedItem("val").Value=dtAdInfo.Rows[0]["version"].ToString().Trim();
                xDocInfo.DocumentElement.SelectSingleNode("./abort/user").Attributes.GetNamedItem("val").Value=dtAdInfo.Rows[0]["userName"].ToString().Trim();

                xDocInfo.Save(@"ini/sysIni.xml");

                System.Resources.ResourceManager resources = new System.Resources.ResourceManager(typeof(frmWaterSys));

            //				if(dtAdInfo.Rows[0]["image"].ToString().Trim()=="frm1")
            //				{
            //
            //					BengZhan.frm1 frm=new frm1();
            //					System.Drawing.Image im=frm.BackgroundImage;
            //					this.BackgroundImage=im;
            //
            //				}
            //
            //				if(dtAdInfo.Rows[0]["image"].ToString().Trim()=="frmWaterSys1")
            //				{
            //					BengZhan.frm2 frm=new frm2();
            //					System.Drawing.Image im=frm.BackgroundImage;
            //					this.BackgroundImage=im;
            //				}
            //
            //				if(dtAdInfo.Rows[0]["image"].ToString().Trim()=="th")
            //				{
            //					this.BackgroundImage = ((System.Drawing.Image)(resources.GetObject("$this.BackgroundImage")));
            //				}

                //System.Drawing.Image im=frm.BackgroundImage;

                //	string strSql=string.Format("delete from tbcmd insert into tbCmd values('start')");
                //	BengZhan.CDBConnection.ExecuteSql(strSql);
                //				this.pictureBox1.Location=new Point((this.toolBar1.Location.Y+this.toolBar1.Height),this.toolBar1.Location.X);
                //				this.pictureBox1.Height=this.Height-this.pictureBox1.Location.Y;
                //				this.pictureBox1.Width=this.Width;
                //this.pictureBox1.Image=((System.Drawing.Image)(resources.GetObject("$this.BackgroundImage")));

                //this.errorProvider2.SetError(this.toolBar1.b,"warn");

                //��ʼһ����ͼ
                iniWellAmount();

                CInsertMenu cInsertM=new CInsertMenu();
                cInsertM.EnableMenu(this.mainMenu1);
                cInsertM.enableToolbar(this.toolBar1,this.mainMenu1);
                //this.enableToolBar();
                this.iniFrm();

                //*******************************ϵͳ��ʼ��**********************************************
                //New.laidianDisplay.GDBConnection GDBC=new New.laidianDisplay.GDBConnection();
                //GDBC.initialCDB();

                BengZhan.CDBConnection cdb=new CDBConnection();
                cdb.initialCon();
                //��ʼ��remotingϵͳ��
                GprsSoft.serverMonitor.CServer csObj=new GprsSoft.serverMonitor.CServer();
                csObj.InitialCServer();
                CDBConnection.refreshHis();
                //***************************************************************************************

                if(BengZhan.CDBConnection.m_bClient==true)
                {
                    this.Text=this.Text+"[�ͻ���]";
                }
                if(BengZhan.CDBConnection.m_bServer==true)
                {
                    this.Text=this.Text+"[������]";
                }

                if(m_softName!=null)
                {
                    if(m_softName.Trim()!="")
                    {

                        this.Text=m_softName;
                        //this.Text=m_softName+string.Format("    [��ǰ�û���{0}]",CDBConnection.m_strUserName);
                    }
                }

                //this.BackgroundImage=null;
                //�Զ��������ݿ�

                //this.startFrm();

                autoBackup();

                this.startTimer();

                this.regCom();

                this.disToolBar();

                this.BackColor=Color.White;
                this.Text=this.Text+"[�°�]";

                this.Text="��������ϵͳ";

                XmlDocument xDoc=new XmlDocument();

                xDoc.Load("Server.xml");

                string strTitle=xDoc.DocumentElement.SelectSingleNode("./abort/softName").Attributes.GetNamedItem("val").Value.Trim();

                this.Text=strTitle;

            }
            catch(Exception ex)
            {
                MessageBox.Show(ex.ToString());
            }
        }