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


C# DeploymentResult.AddAlert方法代码示例

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


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

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

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

示例3: VerifyCanRun

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

            if (UserName.ShouldPrompt())
                result.AddAlert("We are going to prompt for a username.");

			if (shouldPromptForPassword())
                result.AddAlert("We are going to prompt for a password.");

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

示例4: VerifyCanRun

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

            ValidatePath(result, _to);
            ValidatePath(result, _from);

            _from = _path.GetFullPath(_from);
            _to = _path.GetFullPath(_to);

            //check can write from _to
            if (_path.DirectoryDoesntExist(_to)) result.AddAlert(string.Format("'{0}' doesn't exist and will be created", _to));

            if (_clearOptions == DestinationCleanOptions.Delete) result.AddAlert("The files and directories in '{0}' will be deleted before deploying, except for items being ignored.", _to);
            if (_clearOptions == DestinationCleanOptions.Clear) result.AddAlert("The files in '{0}' will be cleared before deploying, except for items being ignored.", _to);

            DirectoryInfo fromDirectory = new DirectoryInfo(_from);
            if (fromDirectory.Exists)
            {
                result.AddGood(string.Format("'{0}' exists", fromDirectory.FullName));

                //check can read from _from
                FileInfo[] readFiles = fromDirectory.GetFiles();
                foreach (var file in readFiles.Where(f => !IsIgnored(_copyIgnorePatterns, f)))
                {
                    Stream fs = new MemoryStream();
                    try
                    {
                        fs = File.Open(file.FullName, FileMode.Open, FileAccess.Read, FileShare.ReadWrite);
                        _log.DebugFormat("Going to copy '{0}' to '{1}'", file.FullName, _to);
                    }
                    catch (Exception)
                    {
                        result.AddAlert("CopyDirectoryTask: Can't read file '{0}'");
                    }
                    finally
                    {
                        fs.Dispose();
                    }
                }
            }
            else
            {
                result.AddAlert(string.Format("'{0}' doesn't exist", _from));
            }

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

示例5: 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;
        }
开发者ID:fchen,项目名称:dropkick,代码行数:26,代码来源:MsmqTask.cs

示例6: 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;
        }
开发者ID:oriacle,项目名称:dropkick,代码行数:30,代码来源:WinServiceStopTask.cs

示例7: ValidateIsDirectory

        protected void ValidateIsDirectory(DeploymentResult result, string path)
        {
            if (!(new DirectoryInfo(_path.GetFullPath(path)).Exists))
                result.AddAlert("'{0}' does not exist and will be created.".FormatWith(path));

            if (!_path.IsDirectory(path))
                result.AddError("'{0}' is not a directory.".FormatWith(path));
        }
开发者ID:drusellers,项目名称:dropkick,代码行数:8,代码来源:BaseIoTask.cs

示例8: verifyKeyExists

		private void verifyKeyExists(DeploymentResult result)
		{
			using (var regHive = OpenHive())
				using (var regKey = regHive.OpenSubKey(Key))
				{
					if (regKey == null)
						result.AddAlert(@"Registry Key '{0}' does not exist and will need to be created.", GetRegistryKeyDisplayString(Hive, Key));
				}
		}
开发者ID:GorelH,项目名称:dropkick,代码行数:9,代码来源:CreateRegistryValueTask.cs

示例9: 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

示例10: VerifyCanRun

        public DeploymentResult VerifyCanRun()
        {
            //verify admin
            var result = new DeploymentResult();

            if (!Directory.Exists(PointingTo)) result.AddAlert("'{0}' doesn't exist", PointingTo);
            else result.AddGood("'{0}' exists", PointingTo);

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

示例11: Replace

		public string Replace(string contents, DeploymentResult result)
		{
			var newContents = Regex.Replace(contents, _pattern, _replacement, _regexOptions);

			if (newContents == contents)
				result.AddAlert("[filepoke] No replacement made for pattern '{0}'.", _pattern);
			else
				_log.InfoFormat("[filepoke] Pattern '{0}' replaced with '{1}' using options {2}.", _pattern, _replacement, _regexOptions);

			return newContents;
		}
开发者ID:GorelH,项目名称:dropkick,代码行数:11,代码来源:FilePokeReplacement.cs

示例12: VerifyCanRun

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

            if (_address.IsLocal)
                VerifyInAdministratorRole(result);
            else
                result.AddAlert("Cannot set permissions for the private remote queue '{0}' while on server '{1}'".FormatWith(_address.ActualUri, Environment.MachineName));

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

示例13: VerifyInAdministratorRole

 protected void VerifyInAdministratorRole(DeploymentResult result)
 {
     if (Thread.CurrentPrincipal.IsInRole("Administrator"))
     {
         result.AddAlert("You are not in the 'Administrator' role. You will not be able to start/stop services");
     }
     else
     {
         result.AddGood("You are in the 'Administrator' role");
     }
 }
开发者ID:GorelH,项目名称:dropkick,代码行数:11,代码来源:BaseTask.cs

示例14: VerifyCanRun

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

            _target = _path.GetFullPath(_target);

            if (!_path.DirectoryExists(_target) && !_path.FileExists(_target))
                result.AddAlert("'{0}' does not exist. It may be created.".FormatWith(_target));

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

示例15: VerifyInAdministratorRole

 void VerifyInAdministratorRole(DeploymentResult result)
 {
     if (Thread.CurrentPrincipal.IsInRole("Administrator"))
     {
         result.AddAlert("You are not in the Administrator role");
     }
     else
     {
         result.AddGood("You are in the Administrator role");
     }
 }
开发者ID:fchen,项目名称:dropkick,代码行数:11,代码来源:DsnTask.cs


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