当前位置: 首页>>代码示例>>C#>>正文


C# SetupVariables类代码示例

本文整理汇总了C#中SetupVariables的典型用法代码示例。如果您正苦于以下问题:C# SetupVariables类的具体用法?C# SetupVariables怎么用?C# SetupVariables使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


SetupVariables类属于命名空间,在下文中一共展示了SetupVariables类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1:

		void IPrepareDefaultsAction.Run(SetupVariables vars)
		{
			//
			if (String.IsNullOrEmpty(vars.WebSiteIP))
				vars.WebSiteIP = "127.0.0.1";
			//
			if (String.IsNullOrEmpty(vars.WebSitePort))
				vars.WebSitePort = "9002";
			//
			if (String.IsNullOrEmpty(vars.UserAccount))
				vars.UserAccount = "WPEnterpriseServer";
		}
开发者ID:jordan49,项目名称:websitepanel,代码行数:12,代码来源:EntServerActionManager.cs

示例2: CopySetupData

		private void CopySetupData(SetupVariables source, SetupVariables target)
		{
			var targetProperties = target.GetType().GetProperties();
			//
			foreach (var targetProperty in targetProperties)
			{
				if (targetProperty.CanWrite)
				{
					var sourceProperty = source.GetType().GetProperty(targetProperty.Name);
					//
					targetProperty.SetValue(target, sourceProperty.GetValue(source, null), null);
				}
			}
		}
开发者ID:jordan49,项目名称:websitepanel,代码行数:14,代码来源:StandaloneServerActionManager.cs

示例3: CreateUserAccount

		private void CreateUserAccount(SetupVariables vars)
		{
			//SetProgressText("Creating windows user account...");

			var domain = vars.UserDomain;
			var userName = vars.UserAccount;
			//
			var description = String.Format(UserAccountDescription, vars.ComponentName);
			var memberOf = vars.UserMembership;
			var password = vars.UserPassword;

			Log.WriteStart(LogStartMessage);

			Log.WriteInfo(String.Format(LogInfoMessage, userName));

			// create account
			SystemUserItem user = new SystemUserItem
			{
				Domain = domain,
				Name = userName,
				FullName = userName,
				Description = description,
				MemberOf = memberOf,
				Password = password,
				PasswordCantChange = true,
				PasswordNeverExpires = true,
				AccountDisabled = false,
				System = true
			};

			//
			SecurityUtils.CreateUser(user);

			// add rollback action
			//RollBack.RegisterUserAccountAction(domain, userName);

			// update log
			Log.WriteEnd(LogEndMessage);

			// update install log
			if (String.IsNullOrEmpty(domain))
				InstallLog.AppendLine(String.Format(InstallLogMessageLocal, userName));
			else
				InstallLog.AppendLine(String.Format(InstallLogMessageDomain, userName, domain));
		}
开发者ID:jordan49,项目名称:websitepanel,代码行数:45,代码来源:ServerActionManager.cs

示例4: XmlDocument

		void IInstallAction.Run(SetupVariables vars)
		{
			try
			{
				Begin(LogStartInstallMessage);
				//
				Log.WriteStart(LogStartInstallMessage);
				//
				var path = Path.Combine(vars.InstallationFolder, @"App_Data\SiteSettings.config");
				//
				if (!File.Exists(path))
				{
					Log.WriteInfo(String.Format("File {0} not found", path));
					//
					return;
				}
				//
				var doc = new XmlDocument();
				doc.Load(path);
				//
				var urlNode = doc.SelectSingleNode("SiteSettings/EnterpriseServer") as XmlElement;
				if (urlNode == null)
				{
					Log.WriteInfo("EnterpriseServer setting not found");
					return;
				}

				urlNode.InnerText = vars.EnterpriseServerURL;
				doc.Save(path);
				//
				Log.WriteEnd("Updated site settings");
				//
				InstallLog.AppendLine("- Updated site settings");
			}
			catch (Exception ex)
			{
				if (Utils.IsThreadAbortException(ex))
					return;
				//
				Log.WriteError("Site settigs error", ex);
				//
				throw;
			}
		}
开发者ID:lwhitelock,项目名称:Websitepanel,代码行数:44,代码来源:WebPortalActionManager.cs

示例5: DoMigration

 private void DoMigration(SetupVariables vars)
 {
     var fileName = Path.Combine(vars.InstallationFolder, "web.config");
     //
     var xdoc = XDocument.Load(fileName);
     // Modify <system.web /> node child elements
     var swnode = xdoc.Root.Element("system.web");
     {
         // Adjust httpRuntime maximum request length
         if (swnode.Element("httpRuntime") != null)
         {
             var htnode = swnode.Element("httpRuntime");
             //
             htnode.SetAttributeValue("maxRequestLength", "16384");
         }
     };
     // Save all changes
     xdoc.Save(fileName);
 }
开发者ID:jonwbstr,项目名称:Websitepanel,代码行数:19,代码来源:ServerActionManager.cs

示例6: StreamReader

		void IInstallAction.Run(SetupVariables vars)
		{
			try
			{
				OnInstallProgressChanged(LogStartInstallMessage, 0);
				Log.WriteStart(LogStartInstallMessage);

				var file = Path.Combine(vars.InstallationFolder, vars.ConfigurationFile);
				vars.CryptoKey = Utils.GetRandomString(20);

				// load file
				string content = string.Empty;
				using (StreamReader reader = new StreamReader(file))
				{
					content = reader.ReadToEnd();
				}

				// expand variables
				content = Utils.ReplaceScriptVariable(content, "installer.cryptokey", vars.CryptoKey);
				//
				Log.WriteInfo(String.Format("The following cryptographic key has been generated: '{0}'", vars.CryptoKey));

				// save file
				using (StreamWriter writer = new StreamWriter(file))
				{
					writer.Write(content);
				}
				//update log
				Log.WriteEnd(LogEndInstallMessage);
			}
			catch (Exception ex)
			{
				if (Utils.IsThreadAbortException(ex))
					return;
				//
				Log.WriteError("Update web.config error", ex);
				//
				throw;
			}
		}
开发者ID:jordan49,项目名称:websitepanel,代码行数:40,代码来源:EntServerActionManager.cs

示例7:

		void IPrepareDefaultsAction.Run(SetupVariables vars)
		{
			//
			if (String.IsNullOrEmpty(vars.WebSitePort))
				vars.WebSitePort = Global.WebPortal.DefaultPort;
			//
			if (String.IsNullOrEmpty(vars.UserAccount))
				vars.UserAccount = Global.WebPortal.ServiceAccount;

			// By default we use public ip for the component
			if (String.IsNullOrEmpty(vars.WebSiteIP))
			{
				var serverIPs = WebUtils.GetIPv4Addresses();
				//
				if (serverIPs != null && serverIPs.Length > 0)
				{
					vars.WebSiteIP = serverIPs[0];
				}
				else
				{
					vars.WebSiteIP = Global.LoopbackIPv4;
				}
			}
		}
开发者ID:lwhitelock,项目名称:Websitepanel,代码行数:24,代码来源:WebPortalActionManager.cs

示例8: XmlDocument

		void IInstallAction.Run(SetupVariables vars)
		{
			try
			{
				OnInstallProgressChanged(LogStartInstallMessage, 0);
				Log.WriteStart(LogStartInstallMessage);
                var file = Path.Combine(vars.InstallationFolder, vars.ConfigurationFile);
                vars.CryptoKey = Utils.GetRandomString(20);
                var Xml = new XmlDocument();
                Xml.Load(file);
                var CryptoNode = Xml.SelectSingleNode("configuration/appSettings/add[@key='WebsitePanel.CryptoKey']") as XmlElement;
                if (CryptoNode != null)
                    CryptoNode.SetAttribute("value", vars.CryptoKey);
                Xml.Save(file);
				Log.WriteEnd(LogEndInstallMessage);
			}
			catch (Exception ex)
			{
				if (Utils.IsThreadAbortException(ex))
					return;
				Log.WriteError("Update web.config error", ex);
				throw;
			}
		}
开发者ID:lwhitelock,项目名称:Websitepanel,代码行数:24,代码来源:EntServerActionManager.cs

示例9: CheckSql

 public static CheckStatuses CheckSql(SetupVariables setupVariables, out string Msg)
 {
     var Result = CheckStatuses.Error;
     try
     {
         var MsgBuilder = new StringBuilder();
         var MsgStr = string.Empty;
         var ConnStr = setupVariables.InstallConnectionString;
         if (CheckConnectionInfo(ConnStr, out MsgStr))
         {
             string V = SqlUtils.GetSqlServerVersion(ConnStr);
             var Valid = new string[] { "9.", "10.", "11.", "12." }.Any(x => V.StartsWith(x));
             if (Valid)
                 if (SqlUtils.GetSqlServerSecurityMode(ConnStr) == 0)
                 {
                     MsgBuilder.AppendLine("Good connection.");
                     Result = CheckStatuses.Success;
                 }
                 else
                     MsgBuilder.AppendLine("Please switch SQL Server authentication to mixed SQL Server and Windows Authentication mode.");
             else
                 MsgBuilder.AppendLine("This program can be installed on SQL Server 2005/2008/2012/2014 only.");
         }
         else
         {
             MsgBuilder.AppendLine("SQL Server does not exist or access denied");
             MsgBuilder.AppendLine(MsgStr);
         }
         Msg = MsgBuilder.ToString();
     }
     catch(Exception ex)
     {
         Msg = "Unable to configure the database server." + ex.Message;
     }
     return Result;
 }
开发者ID:lwhitelock,项目名称:Websitepanel,代码行数:36,代码来源:Adapter.cs

示例10: Exception

		void IInstallAction.Run(SetupVariables vars)
		{
			try
			{
				Begin(LogStartInstallMessage);
				//
				var connectionString = vars.DbInstallConnectionString;
				var database = vars.Database;

				Log.WriteStart(LogStartInstallMessage);
				Log.WriteInfo(String.Format("SQL Server Database Name: \"{0}\"", database));
				//
				if (SqlUtils.DatabaseExists(connectionString, database))
				{
					throw new Exception(String.Format("SQL Server database \"{0}\" already exists", database));
				}
				SqlUtils.CreateDatabase(connectionString, database);
				//
				Log.WriteEnd("Created SQL Server database");
				//
				InstallLog.AppendLine(String.Format("- Created a new SQL Server database \"{0}\"", database));
			}
			catch (Exception ex)
			{
				if (Utils.IsThreadAbortException(ex))
					return;
				//
				Log.WriteError("Create database error", ex);
				//
				throw;
			}
		}
开发者ID:jordan49,项目名称:websitepanel,代码行数:32,代码来源:EntServerActionManager.cs

示例11: CheckAspNet40Registered

		private bool CheckAspNet40Registered(SetupVariables setupVariables)
		{
			//
			var aspNet40Registered = false;
			// Run ASP.NET Registration Tool command
			var psOutput = Utils.ExecAspNetRegistrationToolCommand(setupVariables, "-lv");
			// Split process output per lines
			var strLines = psOutput.Split(new char[] { '\n' }, StringSplitOptions.RemoveEmptyEntries);
			// Lookup for an evidence of ASP.NET 4.0
			aspNet40Registered = strLines.Any((string s) => { return s.Contains("4.0.30319.0"); });
			//
			return aspNet40Registered;
		}
开发者ID:jordan49,项目名称:websitepanel,代码行数:13,代码来源:ServerActionManager.cs

示例12:

		void IUninstallAction.Run(SetupVariables vars)
		{
			try
			{
				var path = vars.InstallationFolder;
				//
				Log.WriteStart(LogStartUninstallMessage);
				Log.WriteInfo(String.Format("Deleting directory \"{0}\"", path));

				if (FileUtils.DirectoryExists(path))
				{
					FileUtils.DeleteDirectory(path);
				}
			}
			catch (Exception ex)
			{
				if (Utils.IsThreadAbortException(ex))
					return;

				Log.WriteError("Directory delete error", ex);

				throw;
			}
		}
开发者ID:jordan49,项目名称:websitepanel,代码行数:24,代码来源:ServerActionManager.cs

示例13: IsEncryptionEnabled

		void IInstallAction.Run(SetupVariables vars)
		{
			try
			{
				Log.WriteStart("Updating serveradmin password");
				//
				var path = Path.Combine(vars.InstallationFolder, vars.ConfigurationFile);
				var password = vars.ServerAdminPassword;

				if (!File.Exists(path))
				{
					Log.WriteInfo(String.Format("File {0} not found", path));
					return;
				}
				//
				bool encryptionEnabled = IsEncryptionEnabled(path);
				// Encrypt password
				if (encryptionEnabled)
				{
					password = Utils.Encrypt(vars.CryptoKey, password);
				}
				//
				SqlUtils.ExecuteQuery(vars.DbInstallConnectionString, String.Format(SqlStatement, vars.Database, password));
				//
				Log.WriteEnd("Updated serveradmin password");
				//
				InstallLog.AppendLine("- Updated password for the serveradmin account");
				//
			}
			catch (Exception ex)
			{
				if (Utils.IsThreadAbortException(ex))
					return;
				//
				Log.WriteError("Update error", ex);
				throw;
			}
		}
开发者ID:jordan49,项目名称:websitepanel,代码行数:38,代码来源:EntServerActionManager.cs

示例14: file

		void IInstallAction.Run(SetupVariables vars)
		{
			try
			{
				Begin(LogStartInstallMessage);
				//
				Log.WriteStart("Updating configuration file (server password)");
				Log.WriteInfo(String.Format("Server password is: '{0}'", vars.ServerPassword));
				Log.WriteInfo("Single quotes are added for clarity purposes");
				//
				string file = Path.Combine(vars.InstallationFolder, vars.ConfigurationFile);
				string hash = Utils.ComputeSHA1(vars.ServerPassword);
				// load file
				string content = string.Empty;
				using (StreamReader reader = new StreamReader(file))
				{
					content = reader.ReadToEnd();
				}

				// expand variables
				content = Utils.ReplaceScriptVariable(content, "installer.server.password", hash);

				// save file
				using (StreamWriter writer = new StreamWriter(file))
				{
					writer.Write(content);
				}
			}
			catch (Exception ex)
			{
				if (Utils.IsThreadAbortException(ex))
					return;

				Log.WriteError("Configuration file update error", ex);

				throw;
			}
		}
开发者ID:jordan49,项目名称:websitepanel,代码行数:38,代码来源:ServerActionManager.cs

示例15: SqlProcess

		void IInstallAction.Run(SetupVariables vars)
		{
			try
			{
				var component = vars.ComponentFullName;
				var componentId = vars.ComponentId;

				var path = Path.Combine(vars.InstallationFolder, SqlFilePath);

				if (!FileUtils.FileExists(path))
				{
					Log.WriteInfo(String.Format("File {0} not found", path));
					return;
				}
				//
				SqlProcess process = new SqlProcess(path, vars.DbInstallConnectionString, vars.Database);
				//
				process.ProgressChange += new EventHandler<ActionProgressEventArgs<int>>(process_ProgressChange);
				//
				process.Run();
				//
				InstallLog.AppendLine(string.Format("- Installed {0} database objects", component));
			}
			catch (Exception ex)
			{
				if (Utils.IsThreadAbortException(ex))
					return;
				//
				Log.WriteError("Run sql error", ex);
				//
				throw;
			}
		}
开发者ID:jordan49,项目名称:websitepanel,代码行数:33,代码来源:EntServerActionManager.cs


注:本文中的SetupVariables类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。