private void loadEndPoints()
        {
            List<string> endPoints = XMLUtils.DeSerilize<List<string>>(m_EndPointsFilePath);
            IRestartService restartService = null;
            AgentInstance agentInstance = null;
            Stopwatch sw = new Stopwatch();
            sw.Start();
            string fullEndPoint = string.Empty;
            LogManager.Instance.WriteInfo("CreateChannel operation on endpoints started");
            foreach (string endpoint in endPoints)
            {
                try
                {
                    fullEndPoint = "http://" + endpoint + ":5050/RestartService";
                    restartService = WCFUtils.ServiceFactory<IRestartService>.GetService(fullEndPoint);
                    agentInstance = new AgentInstance(restartService);
                    agentInstance.UpdateInstanceInfo();
                    m_Agents.Add(agentInstance.IP, agentInstance);
                    LogManager.Instance.WriteInfo("[Endpoint]: " + fullEndPoint + " Added");

                }
                catch (Exception ex)
                {
                    SystemLogManager.Instance.Log(eLogType.Error, "TryingCreateChannel", fullEndPoint, string.Empty, ex.Message, string.Empty);
                    LogManager.Instance.WriteError("Error while trying to CreateChannel , [Endpoint]: " + fullEndPoint + " [Exception]: " + ex.Message);
                }
            }
            sw.Stop();
            LogManager.Instance.WriteInfo("CreateChannel operation on endpoints ended, elapsed: " + sw.Elapsed);
        }
示例#2
0
        public async Task DisconnectAllPlayersAsync(string warnMsg, bool isRestart = false)
        {
            int             count   = this.Players.Count;
            IRestartService restart = this.ServiceManager.GetService <IRestartService>("Restart");

            foreach ((ulong _, IEnergizePlayer ply) in this.Players)
            {
                if (ply.VoiceChannel == null)
                {
                    continue;
                }

                await this.DisconnectAsync(ply.VoiceChannel);

                if (ply.TextChannel != null)
                {
                    if (isRestart)
                    {
                        await restart.WarnChannelAsync(ply.TextChannel, warnMsg);
                    }
                    else
                    {
                        await this.MessageSender.SendWarningAsync(ply.TextChannel, "music player", warnMsg);
                    }
                }
            }

            this.Logger.Nice("MusicPlayer", ConsoleColor.Yellow, $"Disconnected {count} players");
        }
示例#3
0
        public async Task Execute(IJobExecutionContext context)
        {
            JobDataMap           dataMap        = context.JobDetail.JobDataMap;
            IServiceManager      serviceManager = (IServiceManager)dataMap["ServiceManager"];
            DiscordShardedClient discordClient  = (DiscordShardedClient)dataMap["DiscordClient"];

            IMusicPlayerService music   = serviceManager.GetService <IMusicPlayerService>("Music");
            IRestartService     restart = serviceManager.GetService <IRestartService>("Restart");

            await music.DisconnectAllPlayersAsync("Weekly update on-going, disconnecting", true);

            SocketChannel updateChan = discordClient.GetChannel(Config.Instance.Discord.UpdateChannelID);

            if (updateChan != null)
            {
                await restart.WarnChannelAsync(updateChan, "Updating to the latest changes...");
            }

            await restart.RestartAsync();
        }
示例#4
0
 public Startup()
 {
     ServiceName     = "BackupScheduler";
     _restartService = new RestartService();
 }
 public AgentInstance(IRestartService i_IRestartService)
 {
     RestartServiceContract = i_IRestartService;
 }
示例#6
0
 public AgentInstance(IRestartService i_IRestartService)
 {
     RestartServiceContract = i_IRestartService;
 }