public void prepareData(List<BuildStatusConfig> configs)
        {
            List<string> listOfStatuses = new List<string>();
            for (int row = 0; row < groupStatuses.GetLength(0); row++)
            {
                String currentStatus = groupStatuses[row, ViewConnector.jobStatus].Split('_')[0];
                listOfStatuses.Add(currentStatus);

                if(ViewConnector.redPattern.Contains(currentStatus))
                {
                    if (!String.IsNullOrEmpty(failedBuilds))
                    {
                        failedBuilds += ", ";
                    }
                    failedBuilds += groupStatuses[row, ViewConnector.jobName];
                }
            }
            status = getEpicStatus(listOfStatuses);

            foreach(BuildStatusConfig statusConfig in configs)
            {
                if (statusConfig.type.Contains(status))
                {
                    config = statusConfig;
                }
            }
        }
예제 #2
0
 public void prepareData(List<BuildStatusConfig> configs)
 {
     foreach (BuildStatusConfig statusConfig in configs)
     {
         if (statusConfig.type == build.getStatus())
         {
             this.config = statusConfig;
             this.validation = true;
         }
     }
 }
예제 #3
0
        public static List<JobConfiguration> prepareJobs(String path)
        {
            XmlDocument configXml = readConfigFile(path);

            List<JobConfiguration> jobsConfig = new List<JobConfiguration>();

            Trace.Write("++ done, loaded: ");
            foreach (XmlNode jobNode in configXml.SelectNodes("//job"))
            {
                JobConfiguration config = new JobConfiguration();
                config.enabled = true;
                config.activeMessaging = true;

                config.name = getValue(jobNode, "ciUri", "name");
                config.url = getValue(jobNode, "ciUri", "url");
                config.timeout = Convert.ToInt64(getValue(jobNode, "ciUri", "timeout"));
                config.onTime = getValue(jobNode, "ciUri", "onTime");
                config.onDate = getValue(jobNode, "ciUri", "onDate");

                config.messengerChatId = getValue(jobNode, "messenger", "chatId");

                XmlNode jobMonitoring = jobNode.SelectSingleNode("notifications");

                XmlNode buildStatusNode = jobMonitoring.SelectSingleNode("buildStatusChanged");
                config.bldStatusChanged = Convert.ToBoolean(getValue(buildStatusNode, "enabled"));
                config.buildStatusTopicChange = Convert.ToBoolean(getValue(buildStatusNode, "topicChange"));
                if (config.bldStatusChanged)
                {
                    XmlNodeList jobStatusNodes = buildStatusNode.SelectNodes("status");
                    List<BuildStatusConfig> buildStatuses = new List<BuildStatusConfig>(jobStatusNodes.Count);

                    String defaultMessageSend = getValue(buildStatusNode, "messageSend");
                    String defaultMessageText = getValue(buildStatusNode, "defaultMessage");
                    String defaultTopicChange = getValue(buildStatusNode, "topicChange");
                    String defaultTopicText = getValue(buildStatusNode, "defaultTopic");
                    String defaultParameterName = getValue(buildStatusNode, "defaultParameterName");
                    String defaultParameterMsg = getValue(buildStatusNode, "defaultParameterMsg");
                    String defaultTextFromLogKey = getValue(buildStatusNode, "defaultTextFromLogKey");
                    String defaultTextFromLogMsg = getValue(buildStatusNode, "defaultTextFromLogMsg");

                    foreach (XmlNode jobStatusNode in jobStatusNodes)
                    {
                        BuildStatusConfig buildStatus = new BuildStatusConfig();

                        buildStatus.type = getValue(jobStatusNode, "type");

                        buildStatus.messageSend = Convert.ToBoolean(tryGetValue(jobStatusNode, "messageSend", defaultMessageSend));
                        buildStatus.messageText = tryGetValue(jobStatusNode, "message", defaultMessageText);

                        buildStatus.topicChange = Convert.ToBoolean(tryGetValue(jobStatusNode, "topicChange", defaultTopicChange));
                        buildStatus.topicText = tryGetValue(jobStatusNode, "topic", defaultTopicText);

                        buildStatus.participantMsg = getValue(jobStatusNode, "participantMsg");

                        buildStatus.parameterName = tryGetValue(jobStatusNode, "parameterName", defaultParameterName);
                        buildStatus.parameterMsg = tryGetValue(jobStatusNode, "parameterMsg", defaultParameterMsg);

                        buildStatus.textFromLogKey = tryGetValue(jobStatusNode, "textFromLogKey", defaultTextFromLogKey);
                        buildStatus.textFromLogMsg = tryGetValue(jobStatusNode, "textFromLogMsg", defaultTextFromLogMsg);

                        buildStatuses.Add(buildStatus);
                    }
                    config.bldStatusChangedConfigs = buildStatuses;
                }

                XmlNode eachBuildStatusNode = jobMonitoring.SelectSingleNode("statusOfEachBuild");
                config.eachBuildStatus = Convert.ToBoolean(getValue(eachBuildStatusNode, "enabled"));
                if (config.eachBuildStatus)
                {
                    XmlNodeList singleBuildStatusNodes = eachBuildStatusNode.SelectNodes("status");
                    List<BuildStatusConfig> eachBuildStatuses = new List<BuildStatusConfig>(singleBuildStatusNodes.Count);

                    String defaultMessageSend = getValue(eachBuildStatusNode, "messageSend");
                    String defaultMessageText = getValue(eachBuildStatusNode, "defaultMessage");
                    String defaultParameterName = getValue(eachBuildStatusNode, "defaultParameterName");
                    String defaultParameterMsg = getValue(eachBuildStatusNode, "defaultParameterMsg");
                    String defaultTextFromLogKey = getValue(eachBuildStatusNode, "defaultTextFromLogKey");
                    String defaultTextFromLogMsg = getValue(eachBuildStatusNode, "defaultTextFromLogMsg");

                    foreach (XmlNode singleBuildStatusNode in singleBuildStatusNodes)
                    {
                        BuildStatusConfig buildStatus = new BuildStatusConfig();

                        buildStatus.type = getValue(singleBuildStatusNode, "type");

                        buildStatus.messageSend = Convert.ToBoolean(tryGetValue(singleBuildStatusNode, "messageSend", defaultMessageSend));
                        buildStatus.messageText = tryGetValue(singleBuildStatusNode, "message", defaultMessageText);

                        buildStatus.participantMsg = getValue(singleBuildStatusNode, "participantMsg");

                        buildStatus.parameterName = tryGetValue(singleBuildStatusNode, "parameterName", defaultParameterName);
                        buildStatus.parameterMsg = tryGetValue(singleBuildStatusNode, "parameterMsg", defaultParameterMsg);

                        buildStatus.textFromLogKey = tryGetValue(singleBuildStatusNode, "textFromLogKey", defaultTextFromLogKey);
                        buildStatus.textFromLogMsg = tryGetValue(singleBuildStatusNode, "textFromLogMsg", defaultTextFromLogMsg);

                        eachBuildStatuses.Add(buildStatus);
                    }
                    config.eachBuildStatusConfigs = eachBuildStatuses;
                }

                XmlNode buildStillRedNode = jobMonitoring.SelectSingleNode("buildStillRed");
                config.bldStillRed = Convert.ToBoolean(getValue(buildStillRedNode, "enabled"));
                if (config.bldStillRed)
                {
                    BuildStillRedConfig buildStillRedConfig = new BuildStillRedConfig();
                    buildStillRedConfig.statuses = getValue(buildStillRedNode, "type");
                    buildStillRedConfig.message = getValue(buildStillRedNode, "message");
                    buildStillRedConfig.participantMsg = getValue(buildStillRedNode, "participantMsg");
                    config.bldStillRedConfig = buildStillRedConfig;
                }

                XmlNode buildFrozen = jobMonitoring.SelectSingleNode("buildFrozen");
                config.bldFroze = Convert.ToBoolean(getValue(buildFrozen, "enabled"));
                if (config.bldFroze)
                {
                    config.bldFrozenTimeout = Convert.ToInt32(getValue(buildFrozen, "timeout"));
                    config.bldFrozenMessage = getValue(buildFrozen, "message");
                }

                XmlNode dailyReport = jobMonitoring.SelectSingleNode("dailyReport");
                config.dailyReport = Convert.ToBoolean(getValue(dailyReport, "enabled"));
                if (config.dailyReport)
                {
                    DailyReportConfig dailyReportConfig = new DailyReportConfig();
                    dailyReportConfig.dailyTimeFrom = getValue(dailyReport, "timeFrom");
                    dailyReportConfig.dailyTimeTo = getValue(dailyReport, "timeTo");

                    XmlNodeList messageNodes = dailyReport.SelectNodes("achieve");
                    List<DailyMessagesConfig> messages = new List<DailyMessagesConfig>(messageNodes.Count);
                    foreach (XmlNode messageNode in messageNodes)
                    {
                        DailyMessagesConfig messageConfig = new DailyMessagesConfig();

                        messageConfig.type = getValue(messageNode, "type");
                        messageConfig.condition = getValue(messageNode, "condition");
                        String minToGet = getValue(messageNode, "minToGet");
                        if (!String.IsNullOrEmpty(minToGet))
                            messageConfig.minToGet = Convert.ToInt16(getValue(messageNode, "minToGet"));
                        String maxToGet = getValue(messageNode, "maxToGet");
                        if (!String.IsNullOrEmpty(maxToGet))
                            messageConfig.maxToGet = Convert.ToInt16(getValue(messageNode, "maxToGet"));
                        messageConfig.message = getValue(messageNode, "message");

                        messages.Add(messageConfig);
                    }
                    dailyReportConfig.messageConfig = messages;

                    config.dailyReportConfig = dailyReportConfig;
                }

                XmlNode groupStatusNode = jobMonitoring.SelectSingleNode("groupStatusMonitoring");
                config.grpStatusMonitoring = Convert.ToBoolean(getValue(groupStatusNode, "enabled"));
                if (config.grpStatusMonitoring)
                {
                    XmlNodeList jobStatusNodes = groupStatusNode.SelectNodes("status");
                    List<BuildStatusConfig> buildStatuses = new List<BuildStatusConfig>(jobStatusNodes.Count);

                    String defaultTopicChange = getValue(groupStatusNode, "topicChange");
                    String defaultTopicText = getValue(groupStatusNode, "defaultTopic");

                    foreach (XmlNode jobStatusNode in jobStatusNodes)
                    {
                        BuildStatusConfig buildStatus = new BuildStatusConfig();

                        buildStatus.type = getValue(jobStatusNode, "type");

                        buildStatus.topicChange = Convert.ToBoolean(tryGetValue(jobStatusNode, "topicChange", defaultTopicChange));
                        buildStatus.topicText = tryGetValue(jobStatusNode, "topic", defaultTopicText);

                        buildStatuses.Add(buildStatus);
                    }
                    config.grpStatusMonitoringConfigs = buildStatuses;
                }

                //other
                config.lastBuildStatus = "success";

                Trace.Write("'" + config.name + "', ");
                jobsConfig.Add(config);
            }
            Trace.WriteLine(" jobs");
            return jobsConfig;
        }