Exemplo n.º 1
0
        public DeploymentResult ExecuteAndGetResults(RemoteCommandLineTask task)
        {
            string noteStatus  = "[{0,-5}]".FormatWith(DeploymentItemStatus.Note);
            string goodStatus  = "[{0,-5}]".FormatWith(DeploymentItemStatus.Good);
            string alertStatus = "[{0,-5}]".FormatWith(DeploymentItemStatus.Alert);
            string errorStatus = "[{0,-5}]".FormatWith(DeploymentItemStatus.Error);

            var vResult = task.Execute();

            string remoteLogPath = Path.Combine(_remotePhysicalPath, "dropkick.deployment.log");

            if (File.Exists(remoteLogPath))
            {
                var remoteLogLocalPath = Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), "dropkick.remote.deployment.log");
                CopyFileWithNoLocking(remoteLogPath, remoteLogLocalPath);

                var remoteLog  = File.ReadAllText(remoteLogLocalPath);
                var serverName = _server.Name;
                var lines      = Regex.Split(remoteLog, "\r\n");

                foreach (string line in lines)
                {
                    if (line.Trim() == string.Empty)
                    {
                        continue;
                    }

                    //review: kind of nasty right now, but it does the job - v2 should use a TCP sink to communicate between logs
                    if (line.Contains(noteStatus))
                    {
                        vResult.AddNote("[remote:{0}] {1}".FormatWith(serverName, line.Replace(noteStatus, string.Empty)));
                    }
                    else if (line.Contains(goodStatus))
                    {
                        vResult.AddGood("[remote:{0}] {1}".FormatWith(serverName, line.Replace(goodStatus, string.Empty)));
                    }
                    else if (line.Contains(alertStatus))
                    {
                        vResult.AddAlert("[remote:{0}] {1}".FormatWith(serverName, line.Replace(alertStatus, string.Empty)));
                    }
                    else if (line.Contains(errorStatus))
                    {
                        vResult.AddError("[remote:{0}] {1}".FormatWith(serverName, line.Replace(errorStatus, string.Empty)));
                    }
                    else
                    {
                        Logging.Fine("[remote:{0}] {1}".FormatWith(serverName, line.Replace(noteStatus, string.Empty)));
                    }
                }
            }

            return(vResult);
        }
Exemplo n.º 2
0
        public void Remote()
        {
            var task = new RemoteCommandLineTask("ping")
                           {
                               Args = "www.fhlbtopeka.com -n 5",
                               Machine = "SrvTestWeb01"
                           };

            var output = task.Execute();
            foreach (var item in output.Results)
            {
                Console.WriteLine(item.Message);
            }
        }
        public DeploymentResult ExecuteAndGetResults(RemoteCommandLineTask task)
        {
            string noteStatus = "[{0,-5}]".FormatWith(DeploymentItemStatus.Note);
            string goodStatus = "[{0,-5}]".FormatWith(DeploymentItemStatus.Good);
            string alertStatus = "[{0,-5}]".FormatWith(DeploymentItemStatus.Alert);
            string errorStatus = "[{0,-5}]".FormatWith(DeploymentItemStatus.Error);

            var vResult = task.Execute();

            string remoteLogPath = Path.Combine(_remotePhysicalPath, "dropkick.deployment.log");
            if (File.Exists(remoteLogPath))
            {
                var remoteLogLocalPath = Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), "dropkick.remote.deployment.log");
                CopyFileWithNoLocking(remoteLogPath, remoteLogLocalPath);

                var remoteLog = File.ReadAllText(remoteLogLocalPath);
                var serverName = _server.Name;
                var lines = Regex.Split(remoteLog, "\r\n");

                foreach (string line in lines)
                {
                    if (line.Trim() == string.Empty) continue;

                    //review: kind of nasty right now, but it does the job - v2 should use a TCP sink to communicate between logs
                    if (line.Contains(noteStatus))
                    {
                        vResult.AddNote("[remote:{0}] {1}".FormatWith(serverName,line.Replace(noteStatus, string.Empty)));
                    }
                    else if (line.Contains(goodStatus))
                    {
                        vResult.AddGood("[remote:{0}] {1}".FormatWith(serverName, line.Replace(goodStatus, string.Empty)));
                    }
                    else if (line.Contains(alertStatus))
                    {
                        vResult.AddAlert("[remote:{0}] {1}".FormatWith(serverName, line.Replace(alertStatus, string.Empty)));
                    }
                    else if (line.Contains(errorStatus))
                    {
                        vResult.AddError("[remote:{0}] {1}".FormatWith(serverName, line.Replace(errorStatus, string.Empty)));
                    }
                    else
                    {
                        Logging.Fine("[remote:{0}] {1}".FormatWith(serverName, line.Replace(noteStatus, string.Empty)));
                    }
                }
            }

            return vResult;
        }