本文整理汇总了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";
}
示例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);
}
}
}
示例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));
}
示例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;
}
}
示例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);
}
示例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;
}
}
示例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;
}
}
}
示例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;
}
}
示例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;
}
示例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;
}
}
示例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;
}
示例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;
}
}
示例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;
}
}
示例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;
}
}
示例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;
}
}