private void ColorCase(string message)
        {
            //BusylightColor color = new BusylightColor();

            switch (message)
            {
            case "GREEN":
                busylight.Light(0, 0, 255);
                _currentcolor = "GREEN";
                //_notification.Notify("Green Color Case", "color case", NotificationType.Info, TimeSpan.FromSeconds(10));
                break;

            case "YELLOW":
                busylight.Light(255, 0, 255);
                _currentcolor = "YELLOW";
                break;

            case "BLUE":
                busylight.Light(0, 255, 0);
                _currentcolor = "BLUE";
                break;

            case "RED":
                busylight.Light(255, 0, 0);
                _currentcolor = "RED";
                break;

            case "PURPLE":
                busylight.Light(128, 128, 0);
                _currentcolor = "PURPLE";
                break;

            case "ORANGE":
                busylight.Light(255, 0, 40);
                _currentcolor = "ORANGE";
                break;

            case "WHITE":
                busylight.Light(255, 255, 255);
                _currentcolor = "WHITE";
                break;

            default:
                busylight.Light(0, 0, 255);
                _currentcolor = "GREEN";
                break;
            }
        }
 private void btnGreen_Click(object sender, EventArgs e)
 {
     busylight.Light(Busylight.BusylightColor.Green);
 }
Esempio n. 3
0
        private void alertInventory()
        {
            //Scans the inventory and alerts
            if (failHosts.Count + failServices.Count > Properties.Settings.Default.spam_thres)
            {
                //The shit just hit the fan, gross!
                showTip(rm.GetString("balloon_chaos_title"),
                        rm.GetString("balloon_chaos_msg").Replace("X", failHosts.Count.ToString())
                        .Replace("Y", failServices.Count.ToString()),
                        ToolTipIcon.Warning);
            }
            else
            {
                //Hosts
                try
                {
                    foreach (string host in failHosts.Keys)
                    {
                        if (Properties.Settings.Default.balloon_enable == true)
                        {
                            //Show tooltip if enabled
                            showTip(string.Format("Host {0}", dictStatesHost[failHosts[host]].ToUpper()), string.Format("Host '{0}' {1}", host, dictStatesHost[failHosts[host]]), ToolTipIcon.Error);
                        }

                        SimpleLoggerHelper.Log(Properties.Settings.Default.log_mode,
                                               string.Format("Alarm: Host '{0}' is '{1}'", host, dictStatesHost[failHosts[host]]),
                                               Properties.Settings.Default.log_level, 2);

                        annoyUser(dictColorHost[failHosts[host]]);
                    }

                    //Services
                    foreach (string host in failServices.Keys)
                    {
                        //Only report if host not generally down
                        if (failHosts.ContainsKey(host) == false)
                        {
                            SimpleLoggerHelper.Log(Properties.Settings.Default.log_mode,
                                                   string.Format("Host '{0}' not blacklisted!", host),
                                                   Properties.Settings.Default.log_level, 2);

                            //Report service
                            foreach (string service in failServices[host])
                            {
                                try
                                {
                                    //Extract state and service
                                    int    thisState   = Convert.ToInt32(service.Substring(service.IndexOf(';') + 1));
                                    string thisService = service.Substring(service.IndexOf('!') + 1);
                                    thisService = thisService.Substring(0, thisService.IndexOf(';'));

                                    SimpleLoggerHelper.Log(Properties.Settings.Default.log_mode,
                                                           string.Format("Alarm: '{0}' on '{1}' is '{2}'", thisService, host, dictStates[thisState]),
                                                           Properties.Settings.Default.log_level, 2);

                                    //Show tooltip if enabled
                                    if (Properties.Settings.Default.balloon_enable == true)
                                    {
                                        showTip(string.Format("Service {0}", dictStates[thisState].ToUpper()),
                                                string.Format("Service '{0}' {1} '{2}' {3}", thisService, rm.GetString("state_on"), host, dictStates[thisState]), dictIcons[thisState]);
                                    }

                                    annoyUser(dictColor[thisState]);
                                }
                                catch (FormatException e)
                                {
                                    //Format error
                                    SimpleLoggerHelper.Log(Properties.Settings.Default.log_mode, string.Format("Format error: '{0}'", e.Message), Properties.Settings.Default.log_level, 2);
                                }
                            }
                        }
                        else
                        {
                            //Ignoring host
                            SimpleLoggerHelper.Log(Properties.Settings.Default.log_mode, string.Format("Ignoring host '{0}' as it's down", host), Properties.Settings.Default.log_level, 2);
                        }
                    }
                }
                catch (InvalidOperationException e)
                {
                    SimpleLoggerHelper.Log(Properties.Settings.Default.log_mode, string.Format("Invalid operation: '{0}'", e.Message), Properties.Settings.Default.log_level, 2);
                }

                //Reset Lync/SfB state if enabled
                if (Properties.Settings.Default.lync_enable == true)
                {
                    SimpleLoggerHelper.Log(Properties.Settings.Default.log_mode, "Resetting Lync/SfB state...", Properties.Settings.Default.log_level, 2);
                    try
                    {
                        lyncClient = LyncClient.GetClient();
                        if (lyncClient.State == ClientState.SignedIn)
                        {
                            //Read state
                            ContactAvailability myAvailability = (ContactAvailability)lyncClient.Self.Contact.GetContactInformation(ContactInformationType.Availability);
                            SimpleLoggerHelper.Log(Properties.Settings.Default.log_mode, string.Format("Lync/SfB state is '{0}'", myAvailability.ToString()), Properties.Settings.Default.log_level, 2);
                            //Set color
                            var controller = new Busylight.SDK();
                            controller.Light(dictSkypeColor[myAvailability]);
                        }
                    }
                    catch (System.Runtime.InteropServices.MarshalDirectiveException e)
                    {
                        SimpleLoggerHelper.Log(Properties.Settings.Default.log_mode, string.Format("Unable to read Lync/SfB state: '{0}'", e.Message), Properties.Settings.Default.log_level, 0);
                    }
                    catch (Exception e)
                    {
                        SimpleLoggerHelper.Log(Properties.Settings.Default.log_mode, string.Format("Unable to read Lync/SfB state: '{0}'", e.Message), Properties.Settings.Default.log_level, 0);
                    }
                }
            }
        }