Пример #1
0
		public bool modify(WsConfig wsconfig)
		{
			try
			{
				if (!Directory.Exists(wsconfig.RpcPhysicalPath)) Directory.CreateDirectory(wsconfig.RpcPhysicalPath);
				if (!Directory.Exists(wsconfig.RealtimeServerPath)) Directory.CreateDirectory(wsconfig.RealtimeServerPath);
				if (!Directory.Exists(wsconfig.SubscribeServerPath)) Directory.CreateDirectory(wsconfig.SubscribeServerPath);
				if (!Directory.Exists(wsconfig.CacheServerPath)) Directory.CreateDirectory(wsconfig.CacheServerPath);

				//检查站点配置文件是否存在
				if (!Program.CheckConfig(new string[] { 
					wsconfig.RpcPhysicalPath, 
					wsconfig.LogWebSitePath, 
					wsconfig.LogServerSitePath
					 }, "web.config"))
				{
					return false;
				}

				ExeConfigurationFileMap filemap = new ExeConfigurationFileMap();
				filemap.ExeConfigFilename = Path.Combine(wsconfig.RpcPhysicalPath, "web.config");//配置文件路径
				var rpcconfig = ConfigurationManager.OpenMappedExeConfiguration(filemap, ConfigurationUserLevel.None);
				rpcconfig.ConnectionStrings.ConnectionStrings["OracleConnection"].ConnectionString = wsconfig.OracleConnection;

				//修改appSettings
				rpcconfig.AppSettings.Settings["MSMQNAME"].Value = wsconfig.MsmqName;
				rpcconfig.AppSettings.Settings["MSMQSERVERIP"].Value = IISWorker.GetIp();

				rpcconfig.AppSettings.Settings["ENVTEXT"].Value = wsconfig.EnvText;
				rpcconfig.AppSettings.Settings["ENVTEXTCOLOR"].Value = wsconfig.EnvTextColor;
				rpcconfig.AppSettings.Settings["ENVBKCOLOR"].Value = wsconfig.EnvBKColor;

				rpcconfig.AppSettings.Settings["DISWEBSERVICE"].Value = string.Format("http://{0}:{1}/WSTosPacs.asmx", IISWorker.GetIp(),wsconfig.DISInterAPIServerSitePort);

				rpcconfig.Save(ConfigurationSaveMode.Modified);
				LocalLoggingService.Info("更新前台中间层站点[{0}]的web.config: 消息队列地址、数据库连接地址、环境标识", wsconfig.SiteName);

				
			
				Program.copyconfigfile(Path.Combine(wsconfig.RpcPhysicalPath, "Config"), "更新" + wsconfig.SiteName + "配置文件");

				//创建IIS站点
				Program.CreateWs(wsconfig.RpcPhysicalPath, wsconfig.SiteName, wsconfig.RpcDomainPort, wsconfig.IsCreateAppPool);

				//修改服务的配置文件
				if (!DeployServer(wsconfig))
				{
					return false;
				}

				//生成前台配置文件
				string dcip = IISWorker.GetIp();
				string rsip = dcip;
				string WsUrl = string.Format("http://{0}:{1}/Service.asmx", dcip, wsconfig.RpcDomainPort);
				string msg = string.Format(@"Windows Registry Editor Version 5.00

[HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Chnet\CTOS\PACS1.0]
""WebService""=""{0}""
""DebugLevel""=""3""
""PORT""=""{1}""
""AUTOUPDATE""=""N""
""Timeout""=""600""
""DCIP""=""{2}""
""DCPORT""=""{3}""
""REALTIMESERVER""=""{4}""
", WsUrl, wsconfig.SubscribePubport, dcip, wsconfig.SubscribeDcport, rsip);
				using (FileStream fs = File.Create("v4.reg"))
				{
					byte[] b = Encoding.UTF8.GetBytes(msg);
					fs.Write(b, 0, b.Length);
					fs.Flush();
				}

				LocalLoggingService.Info("生成前台注册表文件:v4.reg");
			}
			catch (Exception ex)
			{
				LocalLoggingService.Error(ex.Message);
				return false;
			}

			return true;
		}
Пример #2
0
		private bool DeployServer(WsConfig wsconfig)
		{

			//1,cacheserver
			ExeConfigurationFileMap filemap = new ExeConfigurationFileMap();
			filemap.ExeConfigFilename = Path.Combine(wsconfig.CacheServerPath, wsconfig.CacheServerExe + ".config");//配置文件路径

			if (!Program.CheckConfig(new string[] { 
					wsconfig.CacheServerPath
					 }, wsconfig.CacheServerExe + ".config"))
			{
				return false;
			}

			var config = ConfigurationManager.OpenMappedExeConfiguration(filemap, ConfigurationUserLevel.None);
			config.ConnectionStrings.ConnectionStrings["CTOSV4DbContext"].ConnectionString = wsconfig.CTOSV4DbContext;
			config.Save(ConfigurationSaveMode.Modified);

			LocalLoggingService.Info("修改缓存服务配置文件[exe.config]:数据库连接地址");

			Program.copyconfigfile(Path.Combine(wsconfig.CacheServerPath, "Config"), "更新缓存服务配置");

			if (!Program.CheckConfig(new string[] { 
					wsconfig.RealtimeServerPath,
					wsconfig.SubscribeServerPath
					 }, "config.ini"))
			{
				return false;
			}

			string wsIp, realtimeIp, subscribeIp, msmqIp;
			msmqIp = wsIp = realtimeIp = subscribeIp = IISWorker.GetIp();

			string WsUrl = string.Format("http://{0}:{1}/Service.asmx", wsIp, wsconfig.RpcDomainPort);

			//读取实时配置,修改msmq / 中间层地址。            
			string serverini = wsconfig.RealtimeServerPath + "\\config.ini";
			string queuename = string.Format(@"DIRECT=TCP:{0}\private$\{1}", msmqIp, wsconfig.MsmqName);
			
			IniUtility.IniWriteValue("MONITOR_SERVER", "SERVICENAME", wsconfig.MsmqName, serverini);
			IniUtility.IniWriteValue("MONITOR_SERVER", "PORT", wsconfig.RealtimeServerPort, serverini);
			IniUtility.IniWriteValue("MONITOR_SERVER", "LOCALADDRESS", realtimeIp, serverini);
			IniUtility.IniWriteValue("MSMQ_SERVER", "QUEUENAME", queuename, serverini);
			IniUtility.IniWriteValue("MSMQ_SERVER", "SENDMSMQ", queuename, serverini);
			IniUtility.IniWriteValue("WEBSERVICE", "URL", WsUrl, serverini);

			LocalLoggingService.Info("修改实时服务配置文件[config.ini]:前台中间层地址、消息队列地址");


			//读取订阅配置。修改。
			string cacheServerFullAddress = string.Format(@"{0}", CommonConfiguration.GetConfig().TOSDataServiceAddress);
			string logServerFullAddress = CommonConfiguration.GetConfig().MongodbServiceAddress;
			string subscribeini = wsconfig.SubscribeServerPath + "\\config.ini";
			IniUtility.IniWriteValue("DATASERVER", "WEBSERVICE", WsUrl, subscribeini);
			IniUtility.IniWriteValue("DATASERVER", "CACHESERVER", cacheServerFullAddress, subscribeini);
			IniUtility.IniWriteValue("DATASERVER", "DCPORT", wsconfig.SubscribeDcport.ToString(), subscribeini);
			IniUtility.IniWriteValue("DATASERVER", "PUBPORT", wsconfig.SubscribePubport.ToString(), subscribeini);
			IniUtility.IniWriteValue("REALTIME", "REALTIMESERVER", realtimeIp, subscribeini);
			IniUtility.IniWriteValue("REALTIME", "PORT", wsconfig.RealtimeServerPort, subscribeini);
			IniUtility.IniWriteValue("LOG", "LOGSERVER", logServerFullAddress, subscribeini);


			LocalLoggingService.Info("修改订阅服务配置文件[config.ini]:前台中间层地址、缓存服务地址、实时服务地址、日志服务地址");

			return true;
		}
Пример #3
0
		public bool modify(WsConfig wsconfig)
		{
			try
			{
				if (!Directory.Exists(wsconfig.DISServerSitePath)) Directory.CreateDirectory(wsconfig.DISServerSitePath);
				if (!Directory.Exists(wsconfig.DISAPIServerSitePath)) Directory.CreateDirectory(wsconfig.DISAPIServerSitePath);
				if (!Directory.Exists(wsconfig.DISInterAPIServerSitePath)) Directory.CreateDirectory(wsconfig.DISInterAPIServerSitePath);
				if (!Directory.Exists(wsconfig.EdiServerSitePath)) Directory.CreateDirectory(wsconfig.EdiServerSitePath);

				//检查站点配置文件是否存在
				if (!Program.CheckConfig(new string[] { 
					wsconfig.DISServerSitePath, 
					wsconfig.DISAPIServerSitePath, 
					wsconfig.DISInterAPIServerSitePath,
					wsconfig.EdiServerSitePath
					 }, "web.config"))
				{
					return false;
				}

			ExeConfigurationFileMap filemap = new ExeConfigurationFileMap();
			string diswebcofigpath = Path.Combine(wsconfig.DISServerSitePath, "web.config");//配置文件路径
			filemap.ExeConfigFilename = diswebcofigpath;
			var disconfig = ConfigurationManager.OpenMappedExeConfiguration(filemap, ConfigurationUserLevel.None);
			disconfig.ConnectionStrings.ConnectionStrings["OracleConnection"].ConnectionString = wsconfig.DisConnection;
			disconfig.AppSettings.Settings["MSMQNAME"].Value = wsconfig.MsmqName;
			disconfig.AppSettings.Settings["MSMQSERVERIP"].Value = IISWorker.GetIp();

			//disconfig.AppSettings.Settings["ENVTEXT"].Value = wsconfig.EnvText;
			//disconfig.AppSettings.Settings["ENVTEXTCOLOR"].Value = wsconfig.EnvTextColor;
			//disconfig.AppSettings.Settings["ENVBKCOLOR"].Value = wsconfig.EnvBKColor;

			SetDisUrl(wsconfig, disconfig);
			disconfig.Save(ConfigurationSaveMode.Modified);
			LocalLoggingService.Info("更新DIS中间层站点[{0}]的web.config: 消息队列地址、数据库连接地址、引用的服务地址", wsconfig.DISServerSite);

			Program.copyconfigfile(Path.Combine(wsconfig.DISServerSitePath, "Config"), "更新" + wsconfig.DISServerSite + "配置文件");

			//修改disapi站点web.config
			string disapiwebcofigpath = Path.Combine(wsconfig.DISAPIServerSitePath, "web.config");//配置文件路径
			filemap.ExeConfigFilename = disapiwebcofigpath;
			var disapiconfig = ConfigurationManager.OpenMappedExeConfiguration(filemap, ConfigurationUserLevel.None);
			disapiconfig.ConnectionStrings.ConnectionStrings["OracleConnection"].ConnectionString = wsconfig.DisConnection;
			disapiconfig.AppSettings.Settings["MSMQNAME"].Value = wsconfig.MsmqName;
			disapiconfig.AppSettings.Settings["MSMQSERVERIP"].Value = IISWorker.GetIp();
			SetDisUrl(wsconfig, disapiconfig);
			disapiconfig.Save(ConfigurationSaveMode.Modified);

			LocalLoggingService.Info("更新DIS中间层站点[{0}]的web.config: 消息队列地址、数据库连接地址、引用的服务地址", wsconfig.DISAPIServerSite);

			Program.copyconfigfile(Path.Combine(wsconfig.DISAPIServerSitePath, "Config"), "更新" + wsconfig.DISAPIServerSite + "配置文件");

			//修改disintapi站点web.config
			string disintapiwebcofigpath = Path.Combine(wsconfig.DISInterAPIServerSitePath, "web.config");//配置文件路径
			filemap.ExeConfigFilename = disintapiwebcofigpath;
			var disintapiconfig = ConfigurationManager.OpenMappedExeConfiguration(filemap, ConfigurationUserLevel.None);
			disintapiconfig.ConnectionStrings.ConnectionStrings["OracleConnection"].ConnectionString = wsconfig.DisConnection;
			disintapiconfig.AppSettings.Settings["MSMQNAME"].Value = wsconfig.MsmqName;
			disintapiconfig.AppSettings.Settings["MSMQSERVERIP"].Value = IISWorker.GetIp();
			SetDisUrl(wsconfig, disintapiconfig);
			disintapiconfig.Save(ConfigurationSaveMode.Modified);

			LocalLoggingService.Info("更新DIS中间层站点[{0}]的web.config: 消息队列地址、数据库连接地址、引用的服务地址", wsconfig.DISInterAPIServerSite);

			Program.copyconfigfile(Path.Combine(wsconfig.DISInterAPIServerSitePath, "Config"), "更新" + wsconfig.DISInterAPIServerSite + "配置文件");

			//修改EDI站点web.config
			filemap.ExeConfigFilename = Path.Combine(wsconfig.EdiServerSitePath, "web.config");//配置文件路径
			var ediconfig = ConfigurationManager.OpenMappedExeConfiguration(filemap, ConfigurationUserLevel.None);
			ediconfig.ConnectionStrings.ConnectionStrings["OracleConnection"].ConnectionString = wsconfig.EdiConnection;

			ApplicationSettingsGroup ediappSection = ediconfig.GetSectionGroup("applicationSettings") as ApplicationSettingsGroup;


			SetDisUrl(wsconfig, ediconfig);

			ediconfig.Save(ConfigurationSaveMode.Modified);			
			LocalLoggingService.Info("更新EDI中间层站点[{0}]的web.config: 数据库连接地址、后台内部api服务地址", wsconfig.EdiServerSite);

			//创建IIS站点
		
				Program.CreateWs(wsconfig.DISServerSitePath, wsconfig.DISServerSite, wsconfig.DISServerSitePort, wsconfig.IsCreateAppPool);
				Program.CreateWs(wsconfig.DISAPIServerSitePath, wsconfig.DISAPIServerSite, wsconfig.DISAPIServerSitePort, wsconfig.IsCreateAppPool);
				Program.CreateWs(wsconfig.DISInterAPIServerSitePath, wsconfig.DISInterAPIServerSite, wsconfig.DISInterAPIServerSitePort, wsconfig.IsCreateAppPool);

				Program.CreateWs(wsconfig.EdiServerSitePath, wsconfig.EdiServerSite, wsconfig.EdiServerSitePort, wsconfig.IsCreateAppPool);

				//生成客户端配置文件
				using (FileStream fs = File.Create("WebSeviceProxyUrl.xml"))
				{
					string dis = string.Format(disxml, IISWorker.GetIp(), wsconfig.DISServerSitePort);
					byte[] b = Encoding.Default.GetBytes(dis);
					fs.Write(b, 0, b.Length);
					fs.Flush();
				}


				using (FileStream fs = File.Create("NBWinUIPacs.xml"))
				{
					string dis = string.Format(comxml, IISWorker.GetIp(), wsconfig.DISServerSitePort, wsconfig.DISServerSite);
					byte[] b = Encoding.Default.GetBytes(dis);
					fs.Write(b, 0, b.Length);
					fs.Flush();
				}
			}
			catch (Exception ex)
			{
				LocalLoggingService.Error(ex.Message);
				return false;
			}

			return true;
		}
Пример #4
0
		public bool modify(WsConfig wsconfig)
		{
			try
			{
				//创建目录
				if (!Directory.Exists(wsconfig.LogWebSitePath)) Directory.CreateDirectory(wsconfig.LogWebSitePath);
				if (!Directory.Exists(wsconfig.LogServerSitePath)) Directory.CreateDirectory(wsconfig.LogServerSitePath);
				if (!Directory.Exists(wsconfig.SSOServerSitePath)) Directory.CreateDirectory(wsconfig.SSOServerSitePath);

				//检查sso系统环境。
				//sso-1,检查系统环境变量:
				string var_tns_admin = "TNS_ADMIN";
				var tnsadmin = Environment.GetEnvironmentVariable(var_tns_admin);
				if (string.IsNullOrEmpty(tnsadmin))
				{
					LocalLoggingService.Warning("未找到系统参数: TNS_ADMIN.");
					return false;
				}
				LocalLoggingService.Info("检查系统环境变量成功. " + tnsadmin);

				string queuepath = String.Format(".\\Private$\\{0}", wsconfig.MsmqName);
				CM.TOS.V4.Common.Utility.MsmqUtility.Createqueue(queuepath);
				LocalLoggingService.Info("创建实时消息队列: " + queuepath);

				//检查站点配置文件是否存在
				if (!Program.CheckConfig(new string[] { 
					wsconfig.SSOServerSitePath, 
					wsconfig.LogWebSitePath, 
					wsconfig.LogServerSitePath
					 }, "web.config"))
				{
					return false;
				}

				ExeConfigurationFileMap filemap = new ExeConfigurationFileMap();
				filemap.ExeConfigFilename = Path.Combine(wsconfig.SSOServerSitePath, "web.config");//配置文件路径
				var ssoconfig = ConfigurationManager.OpenMappedExeConfiguration(filemap, ConfigurationUserLevel.None);
				ssoconfig.ConnectionStrings.ConnectionStrings["OracleDbContext"].ConnectionString = wsconfig.SSOConnection;
				ssoconfig.Save(ConfigurationSaveMode.Modified);
				LocalLoggingService.Info("更新认证服务站点[{0}]的web.config:数据库连接地址", wsconfig.SSOServerSite);

				Program.copyconfigfile(Path.Combine(wsconfig.SSOServerSitePath, "Config"), "更新" + wsconfig.SSOServerSite + "配置文件");
				Program.copyconfigfile(Path.Combine(wsconfig.LogWebSitePath, "Config"), "更新" + wsconfig.LogWebSite + "配置文件");
				Program.copyconfigfile(Path.Combine(wsconfig.LogServerSitePath, "Config"), "更新" + wsconfig.LogServerSite + "配置文件");

				Program.CreateWs(wsconfig.SSOServerSitePath, wsconfig.SSOServerSite, wsconfig.SSOServerSitePort, wsconfig.IsCreateAppPool);
				Program.CreateWs(wsconfig.LogWebSitePath, wsconfig.LogWebSite, wsconfig.LogWebSitePort, wsconfig.IsCreateAppPool);
				Program.CreateWs(wsconfig.LogServerSitePath, wsconfig.LogServerSite, wsconfig.LogServerSitePort, wsconfig.IsCreateAppPool);


				LocalLoggingService.Info("开始验证部署网站:");


				//sso-2,调用sso服务。
				try
				{
					string passwordhash = CMPORT.Workspace.SSOHelper.GenPassword(wsconfig.User, wsconfig.Password);
					string languageno = "zh-CN";
					string cip = IISWorker.GetIp();
					long errcode = 0;
					string tid = WcfService.WcfServiceLocator.GetService<ILoginService>().LoginApp(wsconfig.User, passwordhash, languageno, cip, ref errcode);
					if (string.IsNullOrEmpty(tid) || errcode > 0)
					{
						LocalLoggingService.Warning("获取tid失败,错误码:" + errcode);
						return false;
					}
					LocalLoggingService.Warning("sso登录成功,获取tid:" + tid);
				}
				catch (Exception ex)
				{
					LocalLoggingService.Error("sso登录失败:" + ex.Message);
					return false; 
				}

			}
			catch (Exception ex)
			{
				LocalLoggingService.Error(ex.Message);

				return false;
			}

			return true;
		}
Пример #5
0
		//修改applicationSettings
		private void SetDisUrl(WsConfig wsconfig, Configuration config)
		{			
			ApplicationSettingsGroup appSection = config.GetSectionGroup("applicationSettings") as ApplicationSettingsGroup;			
			ClientSettingsSection css = appSection.Sections[0] as ClientSettingsSection;

			SettingElement se = css.Settings.Get("CM_EDI_Service_DocumentManagement_WSTosEdiInterface_WSTosEdiInterface");
			if (se != null)
			{
				css.Settings.Remove(se);
				se.Value.ValueXml.InnerXml = string.Format("http://{0}:{1}/Service.asmx", IISWorker.GetIp(), wsconfig.DISInterAPIServerSitePort);
				css.Settings.Add(se);
			}
			se = css.Settings.Get("CM_CTOS_BLL_BLLWebProxy_WSEdiTosInterface_WsEdiTosInterface");
			if (se != null)
			{
				css.Settings.Remove(se);
				se.Value.ValueXml.InnerXml = string.Format("http://{0}:{1}/Service.asmx", IISWorker.GetIp(), wsconfig.EdiServerSitePort);
				css.Settings.Add(se);
			}
			se = css.Settings.Get("TosPACSAddress");
			if (se != null)
			{
				css.Settings.Remove(se);
				se.Value.ValueXml.InnerXml = string.Format("http://{0}:{1}/Service.asmx", IISWorker.GetIp(), wsconfig.RpcDomainPort);
				css.Settings.Add(se);
			}
			se = css.Settings.Get("CM_CTOS_BLL_BLLWebProxy_WSBaseDataSearchForBilling_WSBaseDataSearch");
			if (se != null)
			{
				string url = string.IsNullOrEmpty(wsconfig.BillingDataServerSitePath) ? se.Value.ValueXml.InnerText = wsconfig.BillingDataServerSite :string.Format("http://{0}:{1}/{2}/Service.asmx", IISWorker.GetIp(), wsconfig.BillingDataServerSitePort, wsconfig.BillingDataServerSite);

				css.Settings.Remove(se);
				se.Value.ValueXml.InnerXml = url;
				css.Settings.Add(se);
			}
			se = css.Settings.Get("CM_CTOS_BLL_BLLWebProxy_WSBillingExternalInterface_WSBillingExternalInterface");
			if (se != null)
			{
				string url = string.IsNullOrEmpty(wsconfig.BillingInternelServerSitePath) ? se.Value.ValueXml.InnerText = wsconfig.BillingInternelServerSite :string.Format("http://{0}:{1}/{2}/Service.asmx", IISWorker.GetIp(), wsconfig.BillingInternelServerSitePort);

				css.Settings.Remove(se);
				se.Value.ValueXml.InnerXml = url;
				css.Settings.Add(se);
			}
		}