/// <summary>
        /// Executes status update process
        /// </summary>
        private static void Execute()
        {
            // Get connected SSIDs
            var wifiNames = NetworkCheck.GetWifiConnectionSSIDs();

            // Find out the corresponding status to be set
            var statusToSet = StatusProfileService.GetStatus(wifiNames);

            // Null check and compare status to previous status. Update if changed.
            if (statusToSet != null && !statusToSet.Equals(_previousStatus))
            {
                var success = SlackStatusService.SetSlackStatus(statusToSet);
                if (success)
                {
                    _previousStatus = statusToSet;
                }
            }
        }
示例#2
0
        public static void SaveCurrentProfile()
        {
            // Get current Wifis
            var currentWifis = NetworkCheck.GetWifiConnectionSSIDs();

            // Get current status
            var currentStatus = SlackStatusService.GetSlackStatus();

            // Get current settings
            var settings = SettingsManager.GetSettings();

            // Null checks etc.
            if (currentWifis == null || currentWifis.Count < 1 || currentStatus == null || settings == null)
            {
                return;
            }

            // Save current wifi and status to settings as a profile
            foreach (var wifi in currentWifis)
            {
                var matchingProfile = settings.StatusProfiles.Find(s => s.WifiName == wifi);

                if (matchingProfile != null)
                {
                    matchingProfile.Status = currentStatus;
                }
                else
                {
                    settings.StatusProfiles.Add(
                        new StatusProfile()
                    {
                        WifiName = wifi,
                        Status   = currentStatus
                    }
                        );
                }
            }

            SettingsManager.ApplySettings(settings);
        }