Esempio n. 1
0
        /// <summary>
        /// 初始化窗体
        /// </summary>
        private void InitForm()
        {
            //获取设置
            this.lbErrMessage.Visible = false;
            EditServiceSetting        = ConfigService.GetServiceSetting(EditServerConfig);
            this.txtServerName.Text   = EditServiceSetting.ServiceName;
            this.txtDisplayName.Text  = EditServiceSetting.DisplayName;
            this.txtDescription.Text  = EditServiceSetting.Description;

            //设置参数
            IsSaved           = false;
            EditServiceConfig = ConfigService.GetServiceConfig(EditServerConfig);
            if (EditServiceConfig == null)
            {
                return;
            }
            this.txtServerIP.Text              = EditServiceConfig.serverIP;
            this.txtServerPort.Text            = EditServiceConfig.serverPort;
            this.txtServerAET.Text             = EditServiceConfig.serverAET;
            this.txtClientAET.Text             = EditServiceConfig.clientAET;
            this.txtClientPort.Text            = EditServiceConfig.clientPort;
            this.txtCacheDays.Text             = EditServiceConfig.cacheDays;
            this.txtDeviceType.Text            = EditServiceConfig.deviceType;
            this.txtLoopSeconds.Text           = EditServiceConfig.loopSeconds;
            this.chkIsRealTime.Checked         = EditServiceConfig.isRealTime;
            this.chkIsOnlyArrived.Checked      = EditServiceConfig.isOnlyArrived;
            this.txtSetAETitle.Text            = EditServiceConfig.setAETitle;
            this.chkIsConvertPatientId.Checked = !EditServiceConfig.isNotConvertPatientId;
        }
Esempio n. 2
0
        /// <summary>
        /// 保存参数
        /// </summary>
        /// <param name="serverConfig"></param>
        /// <param name="serviceConfig"></param>
        public static void SaveConfig(Model.ServerConfig serverConfig, Model.ServiceConfig serviceConfig)
        {
            string      xmlFileName = StartupPath + "\\" + serverConfig.FileFloderName + serviceConfigPath;
            XmlDocument xmlDoc      = new XmlDocument();
            //创建xml的根节点
            XmlElement nodeRoot = xmlDoc.CreateElement("configuration");

            //将根节点加入到xml文件中(AppendChild)
            xmlDoc.AppendChild(nodeRoot);

            //创建startup节点
            XmlElement nodeStartUp = xmlDoc.CreateElement("startup");
            //创建startup节点
            XmlElement nodesupportedRuntime = xmlDoc.CreateElement("supportedRuntime");

            nodesupportedRuntime.SetAttribute("version", "v4.0");
            nodesupportedRuntime.SetAttribute("sku", ".NETFramework,Version=v4.5.2");
            //添加新建的节点
            nodeStartUp.AppendChild(nodesupportedRuntime);
            //添加到根节点
            nodeRoot.AppendChild(nodeStartUp);//添加到根节点

            //创建appSettings节点
            XmlElement nodeAppSettingsp = xmlDoc.CreateElement("appSettings");

            //创建add节点
            System.Reflection.PropertyInfo[] propertyInfo = typeof(Model.ServiceConfig).GetProperties(System.Reflection.BindingFlags.Public | System.Reflection.BindingFlags.Instance);
            foreach (System.Reflection.PropertyInfo pinfo in propertyInfo)
            {
                XmlElement nodeAdd = xmlDoc.CreateElement("add");
                nodeAdd.SetAttribute("key", pinfo.Name);
                string value = string.Empty;
                if (pinfo.GetValue(serviceConfig, null) != null)
                {
                    if (pinfo.GetValue(serviceConfig, null) is bool)
                    {
                        if (pinfo.GetValue(serviceConfig, null).ToString().ToUpper() == "TRUE" || pinfo.GetValue(serviceConfig, null).ToString().ToUpper() == "YES")
                        {
                            value = "1";
                        }
                        else
                        {
                            value = "0";
                        }
                    }
                    else
                    {
                        value = pinfo.GetValue(serviceConfig, null) as string;
                    }
                }
                nodeAdd.SetAttribute("value", value);
                //添加新建的节点
                nodeAppSettingsp.AppendChild(nodeAdd);
            }
            //添加到根节点
            nodeRoot.AppendChild(nodeAppSettingsp);//添加到根节点

            //保存xml
            xmlDoc.Save(xmlFileName);
        }
Esempio n. 3
0
        /// <summary>
        /// 获取服务配置
        /// </summary>
        /// <returns></returns>
        public static Model.ServiceConfig GetServiceConfig(Model.ServerConfig serverConfig)
        {
            if (serverConfig.ServerName == null)
            {
                return(null);
            }
            Model.ServiceConfig serviceConfig = new Model.ServiceConfig();
            string path      = StartupPath + "\\" + serverConfig.FileFloderName + serviceConfigPath.Replace(".config", "");
            var    appConfig = System.Configuration.ConfigurationManager.OpenExeConfiguration(path);

            System.Reflection.PropertyInfo[] propertyInfo = typeof(Model.ServiceConfig).GetProperties(System.Reflection.BindingFlags.Public | System.Reflection.BindingFlags.Instance);
            foreach (System.Reflection.PropertyInfo pinfo in propertyInfo)
            {
                if (appConfig.AppSettings.Settings.AllKeys.Contains(pinfo.Name))
                {
                    if (pinfo.GetValue(serviceConfig, null) is bool)
                    {
                        bool value = false;
                        if ((appConfig.AppSettings.Settings[pinfo.Name].Value == "1"))
                        {
                            value = true;
                        }
                        pinfo.SetValue(serviceConfig, value, null);
                    }
                    else
                    {
                        pinfo.SetValue(serviceConfig, appConfig.AppSettings.Settings[pinfo.Name].Value, null);
                    }
                }
            }

            return(serviceConfig);
        }
Esempio n. 4
0
        /// <summary>
        /// 保存新服务
        /// </summary>
        /// <param name="serverConfig"></param>
        /// <param name="serviceConfig"></param>
        /// <param name="serviceSetting"></param>
        public static bool SaveNewService(Model.ServerConfig serverConfig, Model.ServiceConfig serviceConfig, Model.ServiceSetting serviceSetting)
        {
            Err = string.Empty;
            try
            {
                CopyService(serverConfig);
                SaveSetting(serverConfig, serviceSetting);
                SaveConfig(serverConfig, serviceConfig);

                SaveConfigList(serverConfig);
            }
            catch (Exception ex)
            {
                Err = ex.Message;
                return(false);
            }
            return(true);
        }
Esempio n. 5
0
        /// <summary>
        /// 保存设置
        /// </summary>
        private bool SaveConfig()
        {
            if (string.IsNullOrEmpty(EditServerConfig.ServerID))
            {
                EditServerConfig.ServerID = Guid.NewGuid().ToString();
            }
            EditServerConfig.ServerName = this.txtServerName.Text;
            if (string.IsNullOrEmpty(EditServerConfig.FileFloderName))
            {
                EditServerConfig.FileFloderName = EditServerConfig.ServerID;
            }

            EditServiceSetting             = new Model.ServiceSetting();
            EditServiceSetting.ServiceName = this.txtServerName.Text;
            EditServiceSetting.DisplayName = this.txtDisplayName.Text;
            EditServiceSetting.Description = this.txtDescription.Text;

            EditServiceConfig                       = new Model.ServiceConfig();
            EditServiceConfig.serverIP              = this.txtServerIP.Text;
            EditServiceConfig.serverPort            = this.txtServerPort.Text;
            EditServiceConfig.serverAET             = this.txtServerAET.Text;
            EditServiceConfig.clientAET             = this.txtClientAET.Text;
            EditServiceConfig.clientPort            = this.txtClientPort.Text;
            EditServiceConfig.cacheDays             = this.txtCacheDays.Text;
            EditServiceConfig.deviceType            = this.txtDeviceType.Text;
            EditServiceConfig.loopSeconds           = this.txtLoopSeconds.Text;
            EditServiceConfig.isRealTime            = this.chkIsRealTime.Checked;
            EditServiceConfig.isOnlyArrived         = this.chkIsOnlyArrived.Checked;
            EditServiceConfig.setAETitle            = this.txtSetAETitle.Text;
            EditServiceConfig.isNotConvertPatientId = !this.chkIsConvertPatientId.Checked;

            bool isSaved = ConfigService.SaveNewService(EditServerConfig, EditServiceConfig, EditServiceSetting);

            if (!isSaved)
            {
                Err = ConfigService.Err;
            }

            return(isSaved);
        }