public frmMain() { InitializeComponent(); this.WindowState = FormWindowState.Minimized; busylight = new Busylight.SDK(); cmbSensivity.Items.Clear(); cmbSensivity.Items.Add(new KeyValuePair <string, byte>("1", 0)); cmbSensivity.Items.Add(new KeyValuePair <string, byte>("2", 2)); cmbSensivity.Items.Add(new KeyValuePair <string, byte>("3", 4)); cmbSensivity.Items.Add(new KeyValuePair <string, byte>("4", 8)); cmbSensivity.Items.Add(new KeyValuePair <string, byte>("5", 16)); cmbSensivity.SelectedItem = cmbSensivity.Items[2]; cmbTimeout.Items.Clear(); for (byte i = 3; i <= 20; i++) { cmbTimeout.Items.Add(new KeyValuePair <string, byte>(i.ToString(), i)); } cmbTimeout.SelectedItem = cmbTimeout.Items[1]; cmbTriggertime.Items.Clear(); cmbTriggertime.Items.Add(new KeyValuePair <string, byte>("1", 85)); cmbTriggertime.Items.Add(new KeyValuePair <string, byte>("2", 126)); cmbTriggertime.Items.Add(new KeyValuePair <string, byte>("3", 167)); cmbTriggertime.Items.Add(new KeyValuePair <string, byte>("4", 208)); cmbTriggertime.Items.Add(new KeyValuePair <string, byte>("5", 250)); cmbTriggertime.SelectedItem = cmbTriggertime.Items[0]; // this.Text = "Testje" + busylight.Version; }
private void BusyLightUpdate(UserStatus status) { //create it just in cast it isn't already, should be though at this point if (busylight == null) { busylight = new Busylight.SDK(true); } _timer.Stop(); //try to get the color by status message or type from the file that is loaded / populated at load var type = _colorConfig.StatusTypes.Where(x => x.Name.ToUpper() == status.StatusMessageDetails.GroupTag.ToUpper()).Select(x => x).FirstOrDefault(); var message = _colorConfig.StatusMessages.Where(x => x.Name.ToUpper() == status.StatusMessageDetails.MessageText.ToUpper()).Select(x => x).FirstOrDefault(); //var messageColor = _colorConfig.StatusMessages.Where(x => x.Name.ToUpper() == status.StatusMessageDetails.MessageText.ToUpper()).Select(x => x.Color).FirstOrDefault(); //var IDmessage = status.StatusMessageDetails.MessageText; //var statusColor = _colorConfig.StatusTypes.Where(x => x.Name.ToUpper() == status.StatusMessageDetails.GroupTag.ToUpper()).Select(x => x.Color).FirstOrDefault(); //var IDgroup = status.StatusMessageDetails.GroupTag; //_notification.Notify(message.Name + " " + message.Type + " " + message.BlinkDelay.ToString() + " " + message.Color + " " + IDgroup, "message", NotificationType.Info,TimeSpan.FromSeconds(10)); //_notification.Notify(type.Name + " " + type.BlinkDelay.ToString() + " " + type.Color + " " + IDgroup , "group", NotificationType.Info,TimeSpan.FromSeconds(10)); //if there is a individual message color, use that if (!string.IsNullOrEmpty(message.Name)) { ColorCase(message.Color); //lets start a timer if the message has a value if (message.BlinkDelay > 0) { _timer.Interval = message.BlinkDelay * 1000; _timer.Start(); _rate = message.BlinkRate; } else if (type.BlinkDelay > 0) //or if the default one does { _timer.Interval = type.BlinkDelay * 1000; _timer.Start(); _rate = type.BlinkRate; } } else //or use the type color { ColorCase(type.Color); if (type.BlinkDelay > 0) { _timer.Interval = type.BlinkDelay * 1000; _timer.Start(); _rate = type.BlinkRate; } } }
public void Load(IServiceProvider serviceProvider) { _notification = (INotificationService)serviceProvider.GetService(typeof(INotificationService)); _timer.Stop(); _timer.Elapsed += TimerElasped; busylight = new Busylight.SDK(true); //Check to see if they have one attached, else why load? var list = busylight.GetAttachedBusylightDeviceList(); if (list.Length == 0) { //_notification.Notify("No Busy Light Detected. Stopping Status Light App Load", "Not Detected", NotificationType.Info,TimeSpan.FromSeconds(10)); return; } //Lets look for a config file ConfigLoad(); //got this far try to get a session and then a People manager instance so that we can watch a user's status try { _session = (Session)serviceProvider.GetService(typeof(Session)); if (_session != null) { try { _people = PeopleManager.GetInstance(_session); if (_people != null) { StartWatch(); } } catch (Exception) { throw; } } } catch (Exception) { throw; } }
public void Unload() { //Clean up our stuff busylight = null; StopWatch(); if (_session != null) { if (_session.ConnectionState == ConnectionState.Up) { _session.Disconnect(); } _session.Dispose(); _session = null; } }
private void annoyUser(BusylightColor myColor) { //Play sound if (this.sound_file != "") { player = new SoundPlayer(sound_file); player.Play(); } //Flash Busylight and play sound var controller = new Busylight.SDK(); controller.Jingle(myColor, sound, volume); Thread.Sleep(5000); controller.Terminate(); }
public void StopWatch() { try { /* Used this for testing to make sure it would kill it on the way out. * * _notification.Notify("Stoping User Status Watch", "Stop Watch", NotificationType.Info, TimeSpan.FromSeconds(10)); * */ _SessionUserStatusList.StopWatchingAsync(null, null); _SessionUserStatusList.WatchedObjectsChanged -= SessionUserStatusChanged; busylight = null; } catch (Exception) { throw; } }
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); } } } }