本文整理汇总了C#中DeploymentResult类的典型用法代码示例。如果您正苦于以下问题:C# DeploymentResult类的具体用法?C# DeploymentResult怎么用?C# DeploymentResult使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
DeploymentResult类属于命名空间,在下文中一共展示了DeploymentResult类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: CopyFile
protected void CopyFile(DeploymentResult result, string newFileName, string from, string to)
{
if (ExtensionsToString.IsNotEmpty(newFileName))
CopyFileToFile(result, new FileInfo(from), new FileInfo(_path.Combine(to,newFileName)));
else
CopyFileToDirectory(result, new FileInfo(from), new DirectoryInfo(to));
}
示例2: Execute
public DeploymentResult Execute()
{
var deploymentResult = new DeploymentResult();
bool abort = false;
Ex(d =>
{
if(!abort) {
var o = d.Verify();
deploymentResult.MergedWith(o);
if(deploymentResult.ShouldAbort) { abort = true; }
if(o.ContainsError()) {
//display errors!
DisplayResults(o);
//stop. report verify error.
return;
}
var result = d.Execute();
DisplayResults(result);
deploymentResult.MergedWith(result);
if(deploymentResult.ShouldAbort) { abort = true; }
} else {
Logging.Coarse(LogLevel.Error, "[Skip ] {0}", d.Name);
}
});
return deploymentResult;
}
示例3: Execute
public DeploymentResult Execute()
{
Thread.Sleep(_waitTime);
var result = new DeploymentResult();
result.AddGood("Waited for '{0}' seconds", _waitTime.TotalSeconds.ToString());
return result;
}
示例4: PerformReplacements
private void PerformReplacements(DeploymentResult result)
{
var contents = File.ReadAllText(_filePath, _encoding);
foreach (var replacement in _replacements)
contents = replacement.Replace(contents, result);
File.WriteAllText(_filePath, contents, _encoding);
}
示例5: VerifyCanRun
public override DeploymentResult VerifyCanRun()
{
var result = new DeploymentResult();
ValidateIsFile(result, _filePath);
result.AddGood(Name);
return result;
}
示例6: VerifyCanRun
public DeploymentResult VerifyCanRun()
{
var result = new DeploymentResult();
VerifyInAdministratorRole(result);
if (Environment.MachineName.Equals(_serverName))
{
//if(MessageQueue.Exists(path))
//{
// result.AddGood("'{0}' does exist");
//}
//else
//{
// result.AddAlert(string.Format("'{0}' doesn't exist and will be created", _queueName));
//}
result.AddAlert("I can't check queue exstance yet");
}
else
{
result.AddAlert(string.Format("Cannot check for queue '{0}' on server '{1}' while on server '{2}'",
_queueName, _serverName, Environment.MachineName));
}
return result;
}
示例7: Execute
public override DeploymentResult Execute()
{
//http://weblogs.asp.net/avnerk/archive/2007/05/10/granting-user-rights-in-c.aspx
var result = new DeploymentResult();
try
{
var serverName = _server.Name;
if (!_server.IsLocal) serverName = "\\\\{0}".FormatWith(_server.Name);
LsaUtility.SetRight(serverName, _userAccount, "SeServiceLogonRight");
//using (var lsa = new LsaWrapper())
//{
// lsa.AddPrivileges(_userAccount, "SeServiceLogonRight");
//}
LogSecurity("[security][lpo] Grant '{0}' LogOnAsService on '{1}'", _userAccount, _server.Name);
}
catch (Win32Exception ex)
{
var sb = new StringBuilder();
sb.AppendFormat("Error while attempting to grant '{0}' the right '{1}'", _userAccount, "SeServiceLogonRight");
result.AddError(sb.ToString(), ex);
}
return result;
}
示例8: CopyDirectory
protected void CopyDirectory(DeploymentResult result, DirectoryInfo source, DirectoryInfo destination, IEnumerable<Regex> ignoredPatterns)
{
if (!destination.Exists)
{
destination.Create();
}
else
{
RemoveReadOnlyAttributes(destination, result);
}
// Copy all files.
FileInfo[] files = source.GetFiles();
foreach (FileInfo file in files.Where(f => !IsIgnored(ignoredPatterns, f)))
{
string fileDestination = _path.Combine(destination.FullName, file.Name);
CopyFileToFile(result, file, new FileInfo(fileDestination));
}
// Process subdirectories.
DirectoryInfo[] dirs = source.GetDirectories();
foreach (var dir in dirs)
{
// Get destination directory.
string destinationDir = _path.Combine(destination.FullName, dir.Name);
// Call CopyDirectory() recursively.
CopyDirectory(result, dir, new DirectoryInfo(destinationDir), ignoredPatterns);
}
}
示例9: Execute
public override DeploymentResult Execute()
{
var result = new DeploymentResult();
if (ServiceExists())
{
using (var c = new ServiceController(ServiceName, MachineName))
{
Logging.Coarse("[svc] Stopping service '{0}'", ServiceName);
if (c.CanStop)
{
int pid = GetProcessId(ServiceName);
c.Stop();
c.WaitForStatus(ServiceControllerStatus.Stopped, 30.Seconds());
//WaitForProcessToDie(pid);
}
}
result.AddGood("Stopped Service '{0}'", ServiceName);
Logging.Coarse("[svc] Stopped service '{0}'", ServiceName);
}
else
{
result.AddAlert("Service '{0}' does not exist and could not be stopped", ServiceName);
Logging.Coarse("[svc] Service '{0}' does not exist.", ServiceName);
}
return result;
}
示例10: CheckForSiteAndVDirExistance
public void CheckForSiteAndVDirExistance(Func<bool> website, Func<bool> vdir, DeploymentResult result)
{
if (website())
{
result.AddGood("Found Website '{0}'", WebsiteName);
if (vdir())
{
result.AddGood("Found VDir '{0}'", VdirPath);
}
else
{
result.AddAlert("Couldn't find VDir '{0}'", VdirPath);
if (ShouldCreate)
result.AddAlert("The VDir '{0}' will be created", VdirPath);
}
}
else
{
result.AddAlert("Couldn't find Website '{0}'", WebsiteName);
if (ShouldCreate)
result.AddAlert("Website '{0}' and VDir '{1}' will be created", WebsiteName, VdirPath);
}
}
示例11: FindCertificateBy
public static X509Certificate2 FindCertificateBy(string thumbprint, StoreName storeName, StoreLocation storeLocation, PhysicalServer server, DeploymentResult result)
{
if (string.IsNullOrEmpty(thumbprint)) return null;
var certstore = new X509Store(storeName, storeLocation);
try
{
certstore.Open(OpenFlags.ReadOnly);
thumbprint = thumbprint.Trim();
thumbprint = thumbprint.Replace(" ", "");
foreach (var cert in certstore.Certificates)
{
if (string.Equals(cert.Thumbprint, thumbprint, StringComparison.OrdinalIgnoreCase) || string.Equals(cert.Thumbprint, thumbprint, StringComparison.InvariantCultureIgnoreCase))
{
return cert;
}
}
result.AddError("Could not find a certificate with thumbprint '{0}' on '{1}'".FormatWith(thumbprint, server.Name));
return null;
}
finally
{
certstore.Close();
}
}
示例12: Execute
public DeploymentResult Execute()
{
var results = new DeploymentResult();
var log = new DeploymentLogger(results);
var scriptsPath = Path.GetFullPath(_scriptsLocation);
var useSimpleRecovery = _recoveryMode == DatabaseRecoveryMode.Simple ? true : false;
try
{
switch (_roundhouseMode)
{
case RoundhousEMode.Drop:
RoundhousEClientApi.Run(log, _connectionString, scriptsPath, _environmentName, true, useSimpleRecovery,_repositoryPath,_versionFile,_versionXPath);
break;
case RoundhousEMode.Restore:
RoundhousEClientApi.Run(log, _connectionString, scriptsPath, _environmentName, false, useSimpleRecovery, _repositoryPath, _versionFile, _versionXPath, true, _restorePath);
break;
case RoundhousEMode.DropCreate:
RoundhousEClientApi.Run(log, _connectionString, @".\", _environmentName, true, useSimpleRecovery, _repositoryPath, _versionFile, _versionXPath);
goto case RoundhousEMode.Normal;
case RoundhousEMode.Normal:
RoundhousEClientApi.Run(log, _connectionString, scriptsPath, _environmentName, false, useSimpleRecovery, _repositoryPath, _versionFile, _versionXPath);
break;
default:
goto case RoundhousEMode.Normal;
}
}
catch (Exception ex)
{
results.AddError("An error occured during RoundhousE execution.", ex);
}
return results;
}
示例13: Execute
public override DeploymentResult Execute()
{
var result = new DeploymentResult();
var iisManager = ServerManager.OpenRemote(ServerName);
BuildApplicationPool(iisManager, result);
if (!DoesSiteExist(result)) CreateWebSite(iisManager, WebsiteName, result);
Site site = GetSite(iisManager, WebsiteName);
BuildVirtualDirectory(site, iisManager, result);
try
{
iisManager.CommitChanges();
result.AddGood("'{0}' was created/updated successfully.", VirtualDirectoryPath);
}
catch (COMException ex)
{
if (ProcessModelIdentityType == ProcessModelIdentityType.SpecificUser) throw new DeploymentException("An exception occurred trying to apply deployment changes. If you are attempting to set the IIS " +
"Process Model's identity to a specific user then ensure that you are running DropKick with elevated privileges, or UAC is disabled.", ex);
throw;
}
LogCoarseGrain("[iis7] {0}", Name);
return result;
}
示例14: VerifyCanRun
public override DeploymentResult VerifyCanRun()
{
var result = new DeploymentResult();
//can I connect to the server?
IDbConnection conn = null;
try
{
conn = GetConnection();
conn.Open();
result.AddGood("I can talk to the database");
}
catch (Exception)
{
result.AddAlert("I cannot open the connection");
throw;
}
finally
{
if (conn != null)
{
conn.Close();
conn.Dispose();
}
}
//can I connect to the database?
if (OutputSql != null)
result.AddAlert(string.Format("I will run the sql '{0}'", OutputSql));
return result;
}
示例15: CopyDirectory
protected void CopyDirectory(DeploymentResult result, DirectoryInfo source, DirectoryInfo destination)
{
if (!destination.Exists)
{
destination.Create();
}
// Copy all files.
FileInfo[] files = source.GetFiles();
foreach (var file in files)
{
string fileDestination = _path.Combine(destination.FullName,
file.Name);
CopyFileToFile(result, file, new FileInfo(fileDestination));
}
// Process subdirectories.
DirectoryInfo[] dirs = source.GetDirectories();
foreach (var dir in dirs)
{
// Get destination directory.
string destinationDir = _path.Combine(destination.FullName, dir.Name);
// Call CopyDirectory() recursively.
CopyDirectory(result, dir, new DirectoryInfo(destinationDir));
}
}