コード例 #1
0
        public void SaveAndLoadConfigData()
        {
            try {
                var config = new BuildStatusConfig();
                config.Settings.Add("PollFrequency", "15");

                var setting = new Settings();
                setting.Add("Host", "nzakledci01:8080");
                setting.Add("ProjectID", "project8");

                var monitor1 = config.Monitors.Add("Monitor1", "Assembly1", "Class1", setting);
                var monitor2 = config.Monitors.Add("Monitor2", "Assembly2", "Class2", setting);

                var visualiser1 = config.Visualisers.Add("Visualiser1", "Assembly1", "Class1",setting);
                var visualiser2 = config.Visualisers.Add("Visualiser2", "Assembly2", "Class2",setting);

                config.Schedules.Add(new Schedule("6:00AM", "8:00PM", "ON", "Week"));
                config.Schedules.DefaultState = "OFF";

                config.Save("C:\\Test.xml");

                BuildStatusConfig newConfig = BuildStatusConfig.Load("C:\\Test.xml");

                Assert.AreEqual(config.Settings["PollFrequency"], newConfig.Settings["PollFrequency"]);
            }
            catch (Exception ex) {
                Console.WriteLine(ex.Message);
            }
        }
コード例 #2
0
        public void SaveAndLoadConfigData()
        {
            try {
                var config = new BuildStatusConfig();
                config.Settings.Add("PollFrequency", "15");

                var monitor1 = config.Monitors.Add("Monitor1", "Assembly1", "Class1");
                monitor1.Settings.Add("Setting1", "Value1");
                var monitor2 = config.Monitors.Add("Monitor2", "Assembly2", "Class2");
                monitor2.Settings.Add("Setting2", "Value2");
                monitor2.Settings.Add("Setting3", "Value3");

                var visualiser1 = config.Visualisers.Add("Visualiser1", "Assembly1", "Class1");
                visualiser1.Settings.Add("Setting1", "Value1");
                var visualiser2 = config.Visualisers.Add("Visualiser2", "Assembly2", "Class2");
                visualiser2.Settings.Add("Setting2", "Value2");
                visualiser2.Settings.Add("Setting3", "Value3");

                config.Save("C:\\Test.xml");

                BuildStatusConfig newConfig = BuildStatusConfig.Load("C:\\Test.xml");

                Assert.AreEqual(config.Settings["PollFrequency"], newConfig.Settings["PollFrequency"]);
            }
            catch (Exception ex) {
                Console.WriteLine(ex.Message);
            }
        }
コード例 #3
0
        /// <summary>
        /// Starts this Master Controller. 
        /// </summary>
        public void Initialise()
        {
            _controllers = new List<InstanceController>();
            try {
                _config = BuildStatusConfig.Load();
            } catch (Exception ex) {
                throw new LogApplicationException("Could not load the Configuration File.",ex);
            }

            // Using the Data, Load and Instantiate each of the Visualisers and Monitors.
            // ---------------------------------------------------------------------------
            if (_config != null) {
                FileLogger.Logger.LogVerbose("Loading Controllers.");

                foreach (var controller in _config.Controllers) {

                    FileLogger.Logger.LogInformation("Controller: {0} with Monitor={1} and Visualiser={2}", controller.Name, controller.Monitor, controller.Visualiser);

                    if (_visualiser.Contains(controller.Visualiser)) throw new ApplicationException("A visualiser cannot be used more than once.");
                    if (_config.Visualisers[controller.Visualiser] == null) throw new ApplicationException("Invalid Visualiser Specified: " +controller.Visualiser);
                    if (_config.Monitors[controller.Monitor] == null) throw new ApplicationException("Invalid Monitor Specified: " +controller.Monitor);
                    if (_config.Transitions[controller.Transition] == null) throw new ApplicationException("Invalid Transition Specified: " +controller.Transition);

                    var monitorInfo     = _config.Monitors[controller.Monitor];
                    var visualiserInfo  = _config.Visualisers[controller.Visualiser];

                    if (monitorInfo != null && visualiserInfo != null) {
                        var monitor     = ComponentFactory<IMonitor>.CreateComponent(monitorInfo);
                        var visualiser  = ComponentFactory<IVisualiser>.CreateComponent(visualiserInfo);

                        if (monitor != null && visualiser != null) {
                            visualiser.Transitions = _config.Transitions[controller.Transition];
                            _controllers.Add(new InstanceController(controller.Name, monitor, visualiser));
                        }
                    }
                    else {
                        FileLogger.Logger.LogError("Invalid Monitor and/or Visualiser Data in Config file.");
                        throw new ApplicationException("Invalid Monitor and/or Visualiser Data in Config File");
                    }
                }
                _schedules = _config.Schedules;
            }
        }
コード例 #4
0
        /// <summary>
        /// Creates the default configuration File
        /// </summary>
        public static void CreateDefaultConfigFile()
        {
            var config = new BuildStatusConfig();

            #region Add Default Core Data (Schedule and Controllers)
            config.Settings.Add(new Setting("PollFrequency", "5"));
            config.Schedules.DefaultState = "OFF";
            config.Schedules.Add(new Schedule("6:00AM", "8:00PM", "ON", "Week"));
            config.Schedules.Add(new Schedule("12:00AM", "11:59PM", "OFF", "Weekend"));
            config.Controllers.Add(new Controller("Controller1", "Monitor1", "Visualiser1", "Transition1"));
            config.Controllers.Add(new Controller("Controller2", "Monitor1", "Visualiser2", "Transition2"));
            #endregion

            #region Add the Sample Monitors
            var settings1 = new Settings();
            settings1.Add(new Setting("Host", "yourhost:8080"));
            settings1.Add(new Setting("User", "guest"));
            settings1.Add(new Setting("Password", "guest"));
            settings1.Add(new Setting("UseGuest", "true"));
            settings1.Add(new Setting("ProjectID", "project2"));
            settings1.Add(new Setting("ProjectID", "project6"));
            settings1.Add(new Setting("ProjectID", "project4"));
            config.Monitors.Add(new Monitor("Monitor1", "BuildStatusMonitor", "BuildStatusMonitor.Monitors.TeamCityMonitor", settings1));

            var settings2 = new Settings();
            settings2.Add(new Setting("Host", "yourhost:8080"));
            settings2.Add(new Setting("User", "guest"));
            settings2.Add(new Setting("Password", "guest"));
            settings2.Add(new Setting("UseGuest", "true"));
            settings2.Add(new Setting("ProjectID", "projectID"));
            settings2.Add(new Setting("BuildID", "buildID"));
            settings2.Add(new Setting("ProjectName", "projectName"));
            config.Monitors.Add(new Monitor("Monitor2", "BuildStatusMonitor", "BuildStatusMonitor.Monitors.TeamCityMonitor", settings2));
            #endregion

            #region Add Sample Visualisers
            var settings3 = new Settings();
            settings3.Add(new Setting("DeviceID", @"\\?\hid#vid_0fc5&amp;pid_b080#7&amp;141d6465&amp;0&amp;0000#{4d1e55b2-f16f-11cf-88cb-001111000030}"));
            config.Visualisers.Add(new Visualiser("DelcomLight#1", "BuildStatusMonitor", "BuildStatusMonitor.Visualisers.DelcomVisualiser", settings3));

            var settings4 = new Settings();
            settings4.Add(new Setting("DeviceID", @"\\?\hid#vid_0fc5&amp;pid_b080#7&amp;26d7150a&amp;0&amp;0000#{4d1e55b2-f16f-11cf-88cb-001111000030}"));
            config.Visualisers.Add(new Visualiser("DelcomLight#2", "BuildStatusMonitor", "BuildStatusMonitor.Visualisers.DelcomVisualiser", settings4));

            var settings5 = new Settings();
            settings5.Add(new Setting("File", @"C:\Status.Log"));
            config.Visualisers.Add(new Visualiser("FileTrace", "BuildStatusMonitor", "BuildStatusMonitor.Visualisers.FileTraceVisualiser", settings5));
            #endregion

            #region Add Transitions

            var transition1 = config.Transitions.Add(new Transition("Transition1"));
            var t1s1        = transition1.Add(new State("Unknown", "YELLOW:ON", null));
            var t1s2        = transition1.Add(new State("Success", "GREEN:ON"));
            t1s2.SubState.Add(new SubState("Success1", "TIME:0-15", "GREEN:FLASH"));
            var t1s3 = transition1.Add(new State("SuccessInProgress", "GREEN:ON;YELLOW:FLASH", null));
            var t1s4 = transition1.Add(new State("Failed", "RED:ON"));
            t1s4.SubState.Add(new SubState("Failed1", "TIME:0-15", "RED:FLASH-SLOW"));
            t1s4.SubState.Add(new SubState("Failed2", "TIME:15-30", "RED:FLASH"));
            t1s4.SubState.Add(new SubState("Failed3", "TIME:30-60", "RED:FLASH-FAST"));
            var t1s5 = transition1.Add(new State("FailedInProgress", "RED:ON;YELLOW:FLASH", null));
            var t1s6 = transition1.Add(new State("InProgress", "YELLOW:FLASH", null));
            var t1s7 = transition1.Add(new State("Error", "RED:FLASH", null));

            var transition2 = config.Transitions.Add(new Transition("Transition2"));
            var t2s1        = transition2.Add(new State("Unknown", "Build State is UNKNOWN", null));
            var t2s2        = transition2.Add(new State("Success", "Build was Sucessfull"));
            t2s2.SubState.Add(new SubState("Success1", "TIME:0-15", "Build Sucessfull - Ready For QA"));
            var t2s3 = transition2.Add(new State("SuccessInProgress", "Last build was Sucessfull. New Build in Progress", null));
            var t2s4 = transition2.Add(new State("Failed", "Build Failed."));
            t2s4.SubState.Add(new SubState("Failed1", "TIME:0-15", "Build Failed: First Warning"));
            t2s4.SubState.Add(new SubState("Failed2", "TIME:15-30", "Build Failed: Second Warning"));
            t2s4.SubState.Add(new SubState("Failed3", "TIME:30-60", "Build Failed: Third Warning"));
            var t2s5 = transition2.Add(new State("FailedInProgress", "Build Failed - New Build in Progress", null));
            var t2s6 = transition2.Add(new State("InProgress", "Build in Progress - Previus State is Unknown", null));
            var t2s7 = transition2.Add(new State("Error", "WARNING: Unknown Error Has Occurred", null));
            #endregion

            config.Save("BuildStatusMonitor.settings.sample.xml");
        }
コード例 #5
0
        /// <summary>
        /// Creates the default configuration File
        /// </summary>
        public static void CreateDefaultConfigFile()
        {
            var config = new BuildStatusConfig();

            #region Add Default Core Data (Schedule and Controllers)
            config.Settings.Add(new Setting("PollFrequency","5"));
            config.Schedules.DefaultState = "OFF";
            config.Schedules.Add(new Schedule("6:00AM", "8:00PM", "ON", "Week"));
            config.Schedules.Add(new Schedule("12:00AM","11:59PM", "OFF", "Weekend"));
            config.Controllers.Add(new Controller("Controller1", "Monitor1","Visualiser1","Transition1"));
            config.Controllers.Add(new Controller("Controller2", "Monitor1","Visualiser2","Transition2"));
            #endregion

            #region Add the Sample Monitors
            var settings1 = new Settings();
            settings1.Add(new Setting("Host","yourhost:8080"));
            settings1.Add(new Setting("User", "guest"));
            settings1.Add(new Setting("Password", "guest"));
            settings1.Add(new Setting("UseGuest", "true"));
            settings1.Add(new Setting("ProjectID", "project2"));
            settings1.Add(new Setting("ProjectID", "project6"));
            settings1.Add(new Setting("ProjectID","project4"));
            config.Monitors.Add(new Monitor("Monitor1", "BuildStatusMonitor", "BuildStatusMonitor.Monitors.TeamCityMonitor",settings1));

            var settings2 = new Settings();
            settings2.Add(new Setting("Host","yourhost:8080"));
            settings2.Add(new Setting("User", "guest"));
            settings2.Add(new Setting("Password", "guest"));
            settings2.Add(new Setting("UseGuest", "true"));
            settings2.Add(new Setting("ProjectID", "projectID"));
            settings2.Add(new Setting("BuildID", "buildID"));
            settings2.Add(new Setting("ProjectName","projectName"));
            config.Monitors.Add(new Monitor("Monitor2", "BuildStatusMonitor", "BuildStatusMonitor.Monitors.TeamCityMonitor",settings2));
            #endregion

            #region Add Sample Visualisers
            var settings3 = new Settings();
            settings3.Add(new Setting("DeviceID",@"\\?\hid#vid_0fc5&amp;pid_b080#7&amp;141d6465&amp;0&amp;0000#{4d1e55b2-f16f-11cf-88cb-001111000030}"));
            config.Visualisers.Add(new Visualiser("DelcomLight#1","BuildStatusMonitor","BuildStatusMonitor.Visualisers.DelcomVisualiser",settings3));

            var settings4 = new Settings();
            settings4.Add(new Setting("DeviceID",@"\\?\hid#vid_0fc5&amp;pid_b080#7&amp;26d7150a&amp;0&amp;0000#{4d1e55b2-f16f-11cf-88cb-001111000030}"));
            config.Visualisers.Add(new Visualiser("DelcomLight#2","BuildStatusMonitor","BuildStatusMonitor.Visualisers.DelcomVisualiser",settings4));

            var settings5 = new Settings();
            settings5.Add(new Setting("File",@"C:\Status.Log"));
            config.Visualisers.Add(new Visualiser("FileTrace","BuildStatusMonitor","BuildStatusMonitor.Visualisers.FileTraceVisualiser",settings5));
            #endregion

            #region Add Transitions

            var transition1 = config.Transitions.Add(new Transition("Transition1"));
            var t1s1 = transition1.Add(new State("Unknown","YELLOW:ON",null));
            var t1s2 = transition1.Add(new State("Success","GREEN:ON"));
            t1s2.SubState.Add(new SubState("Success1","TIME:0-15","GREEN:FLASH"));
            var t1s3 = transition1.Add(new State("SuccessInProgress","GREEN:ON;YELLOW:FLASH",null));
            var t1s4 = transition1.Add(new State("Failed","RED:ON"));
            t1s4.SubState.Add(new SubState("Failed1","TIME:0-15","RED:FLASH-SLOW"));
            t1s4.SubState.Add(new SubState("Failed2","TIME:15-30","RED:FLASH"));
            t1s4.SubState.Add(new SubState("Failed3","TIME:30-60","RED:FLASH-FAST"));
            var t1s5 = transition1.Add(new State("FailedInProgress","RED:ON;YELLOW:FLASH",null));
            var t1s6 = transition1.Add(new State("InProgress","YELLOW:FLASH",null));
            var t1s7 = transition1.Add(new State("Error","RED:FLASH",null));

            var transition2 = config.Transitions.Add(new Transition("Transition2"));
            var t2s1 = transition2.Add(new State("Unknown","Build State is UNKNOWN",null));
            var t2s2 = transition2.Add(new State("Success","Build was Sucessfull"));
            t2s2.SubState.Add(new SubState("Success1","TIME:0-15","Build Sucessfull - Ready For QA"));
            var t2s3 = transition2.Add(new State("SuccessInProgress","Last build was Sucessfull. New Build in Progress",null));
            var t2s4 = transition2.Add(new State("Failed","Build Failed."));
            t2s4.SubState.Add(new SubState("Failed1","TIME:0-15","Build Failed: First Warning"));
            t2s4.SubState.Add(new SubState("Failed2","TIME:15-30","Build Failed: Second Warning"));
            t2s4.SubState.Add(new SubState("Failed3","TIME:30-60","Build Failed: Third Warning"));
            var t2s5 = transition2.Add(new State("FailedInProgress","Build Failed - New Build in Progress",null));
            var t2s6 = transition2.Add(new State("InProgress","Build in Progress - Previus State is Unknown",null));
            var t2s7 = transition2.Add(new State("Error","WARNING: Unknown Error Has Occurred",null));
            #endregion

            config.Save("BuildStatusMonitor.settings.sample.xml");
        }