/// <summary>
 /// PushNotification method implementation
 /// </summary>
 internal void PushNotification(NotificationsKind kind, string message, string appname)
 {
     using (MailSlotClient mailslot = new MailSlotClient(appname))
     {
         if (string.IsNullOrEmpty(message))
         {
             mailslot.Text = Environment.MachineName;
         }
         else
         {
             mailslot.Text = message;
         }
         mailslot.SendNotification(kind);
     }
 }
示例#2
0
        /// <summary>
        /// BroadcastNotification method implementation
        /// </summary>
        public static void BroadcastNotification(MFAConfig config, NotificationsKind kind, string message, bool local = true, bool dispatch = true)
        {
            WebAdminClient manager = new WebAdminClient();

            try
            {
                manager.Initialize();
                IWebAdminServices client = manager.Open();
                try
                {
                    client.BroadcastNotification(GetServers(config), CFGReaderUtilities.GetCryptedConfig(config), kind, message, local, dispatch);
                }
                finally
                {
                    manager.Close(client);
                }
            }
            finally
            {
                manager.UnInitialize();
            }
        }
 /// <summary>
 /// BroadcastNotification method implmentation
 /// </summary>
 internal static void BroadcastNotification(MFAConfig config, NotificationsKind kind, string message, bool local = true, bool dispatch = true)
 {
     CFGUtilities.BroadcastNotification(config, kind, message, local, dispatch);
 }
示例#4
0
 /// <summary>
 /// BroadcastNotification method implementation
 /// </summary>
 public void BroadcastNotification(Dictionary <string, bool> servers, byte[] config, NotificationsKind kind, string message, bool local = true, bool dispatch = true, bool mustwrite = false)
 {
     try
     {
         _manager.BroadcastNotification(servers, config, kind, message, local, dispatch, mustwrite);
     }
     catch (Exception e)
     {
         _log.WriteEntry(string.Format("Error on WebAdminService Service BroadcastNotification method : {0}.", e.Message), EventLogEntryType.Error, 2010);
         throw e;
     }
 }
        /// <summary>
        /// BroadcastNotification method implementation
        /// </summary>
        public void BroadcastNotification(Dictionary <string, bool> servers, byte[] config, NotificationsKind kind, string message, bool local = true, bool dispatch = true, bool mustwrite = false)
        {
            try
            {
                if (local)
                {
                    switch (kind)
                    {
                    case NotificationsKind.ConfigurationReload:
                        if (!File.Exists(CFGUtilities.ConfigCacheFile))
                        {
                            mustwrite = true;
                        }
                        if (!File.Exists(SystemUtilities.SystemCacheFile))
                        {
                            mustwrite = true;
                        }
                        if (mustwrite)
                        {
                            WriteConfigurationToCache(config);
                        }
                        PushNotification(NotificationsKind.ConfigurationReload, message, null);
                        break;

                    case NotificationsKind.ConfigurationCreated:
                        WriteConfigurationToCache(config);
                        PushNotification(NotificationsKind.ConfigurationCreated, message, null);
                        break;

                    case NotificationsKind.ConfigurationDeleted:
                        DeleteConfigurationFromCache();
                        PushNotification(NotificationsKind.ConfigurationDeleted, message, null);
                        break;

                    case NotificationsKind.ServiceStatusInError:
                        PushNotification(NotificationsKind.ServiceStatusInError, message, "MGT");
                        break;

                    case NotificationsKind.ServiceStatusPending:
                        PushNotification(NotificationsKind.ServiceStatusPending, message, "MGT");
                        break;

                    case NotificationsKind.ServiceStatusRunning:
                        PushNotification(NotificationsKind.ServiceStatusRunning, message, "MGT");
                        break;

                    case NotificationsKind.ServiceStatusStopped:
                        PushNotification(NotificationsKind.ServiceStatusStopped, message, "MGT");
                        break;
                    }
                }
                if (dispatch)
                {
                    string        fqdn        = Dns.GetHostEntry("localhost").HostName;
                    List <string> servernames = (from server in servers
                                                 where (server.Key.ToLower() != fqdn.ToLower())
                                                 select server.Key.ToLower()).ToList <string>();

                    foreach (string srv in servernames)
                    {
                        WebAdminClient manager = new WebAdminClient();
                        manager.Initialize(srv);
                        try
                        {
                            IWebAdminServices client = manager.Open();
                            try
                            {
                                client.BroadcastNotification(servers, config, kind, message, true, false, true);
                            }
                            finally
                            {
                                manager.Close(client);
                            }
                        }
                        catch (Exception e)
                        {
                            _log.WriteEntry(string.Format("Error on WebAdminService Service BroadcastNotification method : {0} / {1}.", srv, e.Message), EventLogEntryType.Error, 2010);
                        }
                        finally
                        {
                            manager.UnInitialize();
                        }
                    }
                }
            }
            catch (Exception e)
            {
                _log.WriteEntry(string.Format("Error on WebAdminService Service BroadcastNotification method : {0}.", e.Message), EventLogEntryType.Error, 2010);
                throw e;
            }
        }