Ejemplo n.º 1
0
        private bool HasServer()
        {
            string        cityid = RemotingHelper.CityName;
            SysDataServer ds     = null;

            try
            {
                ds = ServicesSys.BaseService.GetOneByKey <SysDataServer>(cityid);
                if (combCity.EditValue == null)
                {
                    MsgBox.Show("请您选择正确的城市!");
                }
            }
            catch (Exception)
            {
                MessageBox.Show("无法连接到服务器!请确保服务器参数正确并确认服务器已启动");
            }
            return(IsServerStart);
        }
Ejemplo n.º 2
0
        //删除
        private void barDel_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
        {
            if (gridView1.RowCount < 1)
            {
                return;
            }
            if (gridView1.FocusedRowHandle < 1)
            {
                return;
            }
            SysDataServer ds = gridView1.GetRow(gridView1.FocusedRowHandle) as SysDataServer;

            if (MessageBox.Show("确定要删除城市" + ds.CityName + "?", "询问", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
            {
                //删除数据库代码{}


                ServicesSys.BaseService.Delete <SysDataServer>(ds);
                InitData();
            }
        }
Ejemplo n.º 3
0
        //新建城市
        private void barAdd_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
        {
            SysDataServer ds = new SysDataServer();

            ds.Sort          = gridView1.RowCount + 1;
            ds.ServerAddress = ServicesSys.GetServerAddress;
            ds.ServerUser    = ServicesSys.GetUid;
            ds.ServerPwd     = ServicesSys.GetPwd;



            FrmSysDataAdd frm = new FrmSysDataAdd();

            frm.sds  = ds;
            frm.Text = "新增城市";
            if (frm.ShowDialog() == DialogResult.OK)
            {
                ds = frm.sds;
                ServicesSys.BaseService.Create <SysDataServer>(ds);
                InitData();
            }
        }
Ejemplo n.º 4
0
        //编辑
        private void barEdit_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
        {
            if (gridView1.RowCount < 1)
            {
                return;
            }
            if (gridView1.FocusedRowHandle < 0)
            {
                return;
            }
            SysDataServer ds  = gridView1.GetRow(gridView1.FocusedRowHandle) as SysDataServer;
            FrmSysDataAdd frm = new FrmSysDataAdd();

            frm.sds  = ds;
            frm.Text = "编辑城市";
            if (frm.ShowDialog() == DialogResult.OK)
            {
                ds = frm.sds;
                ServicesSys.BaseService.Update <SysDataServer>(ds);
                InitData();
            }
        }
Ejemplo n.º 5
0
        /// <summary>
        /// 启动本机服务
        /// </summary>
        private void StartServer()
        {
            CloseServer();
            string        cityid = RemotingHelper.CityName;
            SysDataServer ds     = null;

            try
            {
                ds = ServicesSys.BaseService.GetOneByKey <SysDataServer>(cityid);
                if (combCity.EditValue == null)
                {
                    IsServerStart = false;
                    return;
                }
            }
            catch (Exception)
            {
                IsServerStart = false;
                return;
            }
            if (ds == null)
            {
                return;
            }

            MIS.DataServer = ds;
            MIS.CityName   = ds.CityName;
            CreateDir(ds.CityName);
            MIS.JD       = ds.CityJD;
            MIS.WD       = ds.CityWD;
            MIS.PYJD     = ds.CityPYJD;
            MIS.PYWD     = ds.CityPYWD;
            MIS.CityArea = ds.CityPYWD;

            Itop.Client.Option.Settings.SetJWDvalue(ds.CityJD, ds.CityWD);
            Itop.Client.Option.Settings.SetCityName(ds.CityName);
            Itop.Client.Option.Settings.SetPYJWDvalue(ds.CityPYJD, ds.CityPYWD);
            Itop.Client.Option.Settings.SetCityPYArea(ds.CityPYArea);
            int port = int.Parse(RemotingHelper.ServerPortSys);

            port++;
            ServerSettings.RemotingProtocol = RemotingHelper.ServerProtocolSys;
            ServerSettings.RemotingPort     = port.ToString();
            ServerSettings.Pwd         = ds.ServerPwd;
            ServerSettings.Uid         = ds.ServerUser;
            ServerSettings.Database    = ds.ServerName;
            ServerSettings.DataServer  = ds.ServerAddress;
            ServerSettings.IsOneServer = "two";
            ServerSettings.Save();
            RemotingHelper.ServerAddress  = "localhost";
            RemotingHelper.ServerPort     = ServerSettings.RemotingPort;
            RemotingHelper.ServerProtocol = ServerSettings.RemotingProtocol;


            try
            {
                ProcessStartInfo sysserver = new ProcessStartInfo(Application.StartupPath + "\\Server\\Itop.Server.exe");
                sysserver.WorkingDirectory = Application.StartupPath + "\\Server";
                MIS.curpro    = System.Diagnostics.Process.Start(sysserver);
                IsServerStart = true;
            }
            catch (Exception)
            {
                IsServerStart = false;
                throw;
            }
        }