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


C# DeploymentResult.AddError方法代码示例

本文整理汇总了C#中DeploymentResult.AddError方法的典型用法代码示例。如果您正苦于以下问题:C# DeploymentResult.AddError方法的具体用法?C# DeploymentResult.AddError怎么用?C# DeploymentResult.AddError使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在DeploymentResult的用法示例。


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

示例1: 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();
            }
        }
开发者ID:Allon-Guralnek,项目名称:dropkick,代码行数:29,代码来源:BaseSecurityCertificatePermissionsTask.cs

示例2: 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;
        }
开发者ID:GorelH,项目名称:dropkick,代码行数:27,代码来源:LogOnAsAServiceTask.cs

示例3: VerifyCanRun

        public override DeploymentResult VerifyCanRun()
        {
            var result = new DeploymentResult();

            if (Operation == Iis7Operation.Unspecified) result.AddError("IIS7 Operation has not been specified.");
            if (String.IsNullOrEmpty(ServerName)) result.AddError("IIS7 Server Name has not been specified.");
            if (String.IsNullOrEmpty(ApplicationPool)) result.AddError("IIS7 Application Pool has not been specified.");

            IisUtility.CheckForIis7(result);

            using (var iisManager = ServerManager.OpenRemote(ServerName))
            {
                CheckApplicationPoolExists(iisManager, result);    
            }
            
            return result;
        }
开发者ID:GorelH,项目名称:dropkick,代码行数:17,代码来源:Iis7OperationTask.cs

示例4: VerifyCanRun

      public override DeploymentResult VerifyCanRun() {
         var result = new DeploymentResult();
         result.AddNote(_reason);

         if(_filesShouldExist.Count > 0) {
            var tmpDR = new DeploymentResult();
            foreach(var filePath in _filesShouldExist) {
               string actualPath = _path.GetFullPath(filePath);
               if(!File.Exists(actualPath)) { tmpDR.AddError("  File '{0}' should exist!.".FormatWith(actualPath)); }
            }
            result.MergedWith(tmpDR);
            //errors show up anyway, give some feedback if everything OK.
            if(!tmpDR.ContainsError()) { result.AddNote("  All {0} files found!".FormatWith(_filesShouldExist.Count)); }
         } else {
            result.AddNote("  No Files that should exist.");
         }

         if(_directoriesShouldExist.Count > 0) {
            var tmpDR = new DeploymentResult();
            foreach(var dirPath in _directoriesShouldExist) {
               string actualPath = _path.GetFullPath(dirPath);
               if(!Directory.Exists(actualPath)) { tmpDR.AddError("  Directory '{0}' should exist".FormatWith(actualPath)); }
            }
            result.MergedWith(tmpDR);
            //errors show up anyway, give some feedback if everything OK.
            if(!tmpDR.ContainsError()) { result.AddNote("  All {0} directories found!".FormatWith(_directoriesShouldExist.Count)); }
         } else {
            result.AddNote("  No Directories that should exist.");
         }

         if(_filesShould_NOT_Exist.Count > 0) {
            var tmpDR = new DeploymentResult();
            foreach(var filePath in _filesShould_NOT_Exist) {
               string actualPath = _path.GetFullPath(filePath);
               if(File.Exists(actualPath)) { tmpDR.AddError("  File '{0}' should NOT exist!.".FormatWith(actualPath)); }
            }
            result.MergedWith(tmpDR);
            if(!tmpDR.ContainsError()) { result.AddNote("  None of the {0} files exist!".FormatWith(_filesShould_NOT_Exist.Count)); }
         } else {
            result.AddNote("  No Files that should NOT exist.");
         }

         if(_directoriesShould_NOT_Exist.Count > 0) {
            var tmpDR = new DeploymentResult();
            foreach(var dirPath in _directoriesShould_NOT_Exist) {
               string actualPath = _path.GetFullPath(dirPath);
               if(Directory.Exists(actualPath)) { tmpDR.AddError("  Directory '{0}' should NOT exist".FormatWith(actualPath)); }
            }
            result.MergedWith(tmpDR);
            if(!tmpDR.ContainsError()) { result.AddNote("  None of the {0} directories exist!".FormatWith(_directoriesShould_NOT_Exist.Count)); }
         } else {
            result.AddNote("  No Directories that should NOT exist.");
         }

         if(_shouldAbortOnError && result.ContainsError()) { result.AddAbort(_reason); }
         return result;
      }
开发者ID:GorelH,项目名称:dropkick,代码行数:57,代码来源:ExistsTasks.cs

示例5: Execute

        public override DeploymentResult Execute()
        {
            var result = new DeploymentResult();

            if (ServiceExists())
            {
                using (var c = new ServiceController(ServiceName, MachineName))
                {
                    Logging.Coarse("[svc] Starting service '{0}'", ServiceName);
                    try
                    {
                        c.Start();
                        LogCoarseGrain("[svc] Waiting up to {0} seconds because Windows can be silly", _timeout.TotalSeconds);
                        c.WaitForStatus(ServiceControllerStatus.Running, _timeout);
                    }
                    catch (InvalidOperationException ex)
                    {
                        result.AddError("The service '{0}' did not start, most likely due to a logon issue.".FormatWith(ServiceName), ex);
                        LogCoarseGrain("The service '{0}' did not start, most likely due to a logon issue.{1}{2}", ServiceName, Environment.NewLine, ex);
                        return result;
                    }
                    catch (TimeoutException)
                    {
                        if (ErrorOnFailure)
                            result.AddError(string.Format("Service '{0}' did not finish starting during the specified timeframe.", ServiceName));
                        else
                            result.AddAlert("Service '{0}' did not finish starting during the specified timeframe.  You will need to manually verify if the service started successfully.", ServiceName);
                        LogCoarseGrain("Service '{0}' did not finish starting during the specified timeframe.  You will need to manually verify if the service started successfully.", ServiceName);
                        return result;
                    }
                }
                result.AddGood("Started the service '{0}'", ServiceName);
            }
            else
            {
                if (ErrorOnFailure)
                    result.AddError(string.Format("Service '{0}' does not exist so it cannot be started", ServiceName));
                else
                    result.AddAlert("Service '{0}' does not exist so it cannot be started", ServiceName);
            }

            return result;
        }
开发者ID:Allon-Guralnek,项目名称:dropkick,代码行数:43,代码来源:WinServiceStartTask.cs

示例6: testArchive

		private void testArchive(DeploymentResult result)
		{
			if (!ZipFile.IsZipFile(_zipArchiveFilename))
				result.AddError(String.Format("The file '{0}' is not a valid zip archive.", _zipArchiveFilename));

			using (var zip = ZipFile.Read(_zipArchiveFilename))
			{
				result.AddGood("{0} items will be extracted from '{1}' to '{2}'", zip.Count, _zipArchiveFilename, _to);
			}
		}
开发者ID:GorelH,项目名称:dropkick,代码行数:10,代码来源:UnzipArchiveTask.cs

示例7: Execute

        public override DeploymentResult Execute()
        {
            var result = new DeploymentResult();

            ServiceReturnCode returnCode = WmiService.Delete(MachineName, ServiceName);

            if (ErrorOnFailure && returnCode != ServiceReturnCode.Success)
                result.AddError(string.Format("Failed to delete service '{0}': {1}", ServiceName, returnCode));

            return result;
        }
开发者ID:Allon-Guralnek,项目名称:dropkick,代码行数:11,代码来源:WinServiceDeleteTask.cs

示例8: Execute

        public DeploymentResult Execute()
        {
            var result = new DeploymentResult();

            var p = Path.Combine(ExecutableIsLocatedAt, Command);
            ProcessReturnCode returnCode  = WmiProcess.Run(Machine, Command, Args, ExecutableIsLocatedAt);

            //TODO: Get the output file. Parse it out to get ERRORS and other things and add them to the results

            if (returnCode != ProcessReturnCode.Success) result.AddError(_status[(int)returnCode] + " (" + p + ")");

            return result;
        }
开发者ID:GorelH,项目名称:dropkick,代码行数:13,代码来源:RemoteCommandLineTask.cs

示例9: Execute

        public DeploymentResult Execute()
        {
            var result = new DeploymentResult();

            try
            {
                bool value = SQLConfigDataSource((IntPtr) 0, (int) _action, _driver.Value, "SERVER={0}\0DSN={1}\0DESCRIPTION=NewDSN\0DATABASE={2}\0TRUSTED_CONNECTION=YES".FormatWith(_serverName, _dsnName, _databaseName));
                result.AddGood("Created DSN");
            }
            catch (Exception ex)
            {
                result.AddError("Failed to create DSN", ex);
            }

            return result;
        }
开发者ID:fchen,项目名称:dropkick,代码行数:16,代码来源:DsnTask.cs

示例10: VerifyCanRun

        public DeploymentResult VerifyCanRun()
        {
            var result = new DeploymentResult();

            try
            {
                File.GetAttributes(_target);
                result.AddGood(string.Format("'{0}' exists", _target));
            }
            catch (Exception ex)
            {
                result.AddError(string.Format("'{0}' doesn't exist: {1}", _target, ex.Message));
            }

            return result;
        }
开发者ID:Allon-Guralnek,项目名称:dropkick,代码行数:16,代码来源:RenameTask.cs

示例11: 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);

                        try
                        {
                            c.Stop();
                            c.WaitForStatus(ServiceControllerStatus.Stopped, _timeout);
                            LogCoarseGrain("[svc] Service stopped, waiting for process to exit...");
                            WaitForProcessToDie(result, pid);
                        }
                        catch (TimeoutException)
                        {
                            var error = string.Format("Service '{0}' did not finish stopping during the specified timeframe.", ServiceName);
                            result.AddError(error);
                            LogCoarseGrain(error);
                        }
                    }
                }

                if (!result.ContainsError())
                {
                    result.AddGood("Stopped Service '{0}'", ServiceName);
                    Logging.Coarse("[svc] Stopped service '{0}'", ServiceName);
                }
            }
            else
            {
                if (ErrorOnFailure)
                    result.AddError(string.Format("Service '{0}' does not exist and could not be stopped", 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;
        }
开发者ID:Allon-Guralnek,项目名称:dropkick,代码行数:47,代码来源:WinServiceStopTask.cs

示例12: VerifyCanRun

        public DeploymentResult VerifyCanRun()
        {
            var result = new DeploymentResult();

            ValidateFile(result, _target);

            if (File.Exists(_target))
            {
                result.AddGood(string.Format("'{0}' exists", _target));
            }
            else
            {
                result.AddError(string.Format("'{0}' doesn't exist", _target));
            }

            return result;
        }
开发者ID:oriacle,项目名称:dropkick,代码行数:17,代码来源:RenameTask.cs

示例13: ExecuteLocalTask

        public void ExecuteLocalTask(DeploymentResult result)
        {
            var cert = FindCertificateBy(_thumbprint, _storeName, _storeLocation, _server, result);

            if (cert == null)
            {
                result.AddError("Certificate with thumbprint '{0}' was not found in the '{1}' \\ '{2}' store.".FormatWith(_thumbprint, _storeLocation, _storeName));

                return;
            }

            foreach (string group in _groups)
            {
                AddAccessToPrivateKey(cert, group, FileSystemRights.Read, _storeLocation, _dotNetPath, _server, result);
                LogSecurity("[security][cert] Granted READ to X509 Certificate's private key to '{0}' for thumbprint '{1}'", group, _thumbprint);
            }

            result.AddGood(Name);
        }
开发者ID:Allon-Guralnek,项目名称:dropkick,代码行数:19,代码来源:GrantReadCertificatePrivateKeyTask.cs

示例14: Execute

        public DeploymentResult Execute()
        {
            var result = new DeploymentResult();
            var to = new DotNetPath().GetFullPath(_to);

            var toParent = GetRootShare(to);
            try 
            {
                using(var context = Authenticator.BeginFileShareAuthentication(toParent, _userName, _password))
                {
                    result.AddGood("'{0}' authenticated with {1}.".FormatWith(to, _userName));
                }
            }
            catch(Exception err)
            {
                result.AddError("Failed to access '{0}' as user '{1}'".FormatWith(toParent, _userName), err);
            }
            return result;
        }
开发者ID:gsbastian,项目名称:Sriracha.Deploy,代码行数:19,代码来源:OpenFolderShareAuthenticationTask.cs

示例15: VerifyCanRun

  public DeploymentResult VerifyCanRun()
  {
      var result = new DeploymentResult();
      var to = new DotNetPath().GetFullPath(_to);
      string toParent = GetRootShare(to);
      try 
      {
          using(var context = Authenticator.BeginFileShareAuthentication(toParent, _userName, _password))
          {
              result.AddGood(System.IO.Directory.Exists(to) ? "'{0}' already exists.".FormatWith(to) : Name);
          }
      }
      catch(Exception err)
      {
          result.AddError("Failed to access '{0}' as user '{1}'".FormatWith(toParent, _userName), err);
      }
      //TODO figure out a good verify step...
      return result;
 }
开发者ID:gsbastian,项目名称:Sriracha.Deploy,代码行数:19,代码来源:OpenFolderShareAuthenticationTask.cs


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