Ejemplo n.º 1
0
 void bot_StateChanged(CenterBot sender, CenterBot.StatusType e)
 {
     if (!ManagerOnline)
     {
         if (e == CenterBot.StatusType.bot_Process_Terminated)
         {
             sender.Stop();
             RemoveBot(sender);
         }
         return;
     }
     Log.LogType logtyp = Log.LogType.Stander;
     Log.LogLevel loglvl = Log.LogLevel.Stander;
     switch (e)
     {
         case CenterBot.StatusType.Connecting_please_wait:
              logtyp = Log.LogType.Info;
              loglvl = Log.LogLevel.Debug;
              break;
         case CenterBot.StatusType.Ready_to_login:
              logtyp = Log.LogType.Info;
              loglvl = Log.LogLevel.Debug;
              break;
         case CenterBot.StatusType.Sending_login_informations:
              logtyp = Log.LogType.Info;
              loglvl = Log.LogLevel.Debug;
              break;
         case CenterBot.StatusType.Sending_secondary_passcode:
              logtyp = Log.LogType.Info;
              loglvl = Log.LogLevel.Debug;
              break;
         case CenterBot.StatusType.Character_listing:
              logtyp = Log.LogType.Info;
              loglvl = Log.LogLevel.Debug;
              break;
         case CenterBot.StatusType.Login_Successful:
              logtyp = Log.LogType.Info;
              loglvl = Log.LogLevel.Stander;
              break;
         case CenterBot.StatusType.Disconnected_from_server:
              logtyp = Log.LogType.Error;
              loglvl = Log.LogLevel.Stander;
              sender.StartLoginTimer();
              break;
         case CenterBot.StatusType.bot_Process_Terminated:
             logtyp = Log.LogType.Error;
             loglvl = Log.LogLevel.Debug;
             sender.Stop();
             if (sender.BotAccount == null || !sender.BotAccount.Start)
                 RemoveBot(sender);
             else if (sender.BotAccount.DCRestart)
                 sender.Start();
             break;
         case CenterBot.StatusType.Error_Stuck_On_Login:
             logtyp = Log.LogType.Error;
             loglvl = Log.LogLevel.Debug;
             try
             {
                 sender.Stop();
                 if (!sender.BotAccount.Start)
                     RemoveBot(sender);
                 else
                     sender.Start();
             }
             catch { }
             break;
         case CenterBot.StatusType.Error_Script_Steps:
         case CenterBot.StatusType.Error_C9PingTimeOut:
             logtyp = Log.LogType.Error;
             loglvl = Log.LogLevel.Debug;
             //try
             //{
             //    if (sender.BotAccount == null)
             //        break;
             //    sender.Stop();
             //    if (!sender.BotAccount.Start)
             //        RemoveBot(sender);
             //    else
             //        sender.Start();
             //}
             //catch { }
             break;
         case CenterBot.StatusType.Error_HS_Is_Down:
               logtyp = Log.LogType.Error;
               loglvl = Log.LogLevel.Stander;
             if (sender.BotAccount == null)
                 break;
             sender.Stop();
             RemoveBot(sender);
             System.Threading.ThreadPool.QueueUserWorkItem((o) =>
                 {
                     sender.BotAccount.bot = null;
                     Random sleepTime = new Random();
                     System.Threading.Thread.Sleep(sleepTime.Next(120000, 130000));
                     if (ManagerOnline)
                         AddBot(sender.BotAccount);
                 });
             break;
         case CenterBot.StatusType.Unknown:
             logtyp = Log.LogType.Error;
             loglvl = Log.LogLevel.Stander;
             break;
     }
     if (sender.BotAccount == null)
         Program.Logger.AddLog(logtyp, loglvl, string.Format("[{0}][{1}]-{2}", sender.CharName, sender.ServerName, e.ToString()));
     else
         Program.Logger.AddLog(logtyp, loglvl, string.Format("[{0}][{1}]-{2}", sender.BotAccount.CharName, DataManager.ServerList[sender.BotAccount.silkroadServer], e.ToString()));
 }
Ejemplo n.º 2
0
        private void AddBot(CenterBot bot)
        {
            Bots.Add(bot);
            bot.StateChanged += bot_StateChanged;
            bot.PropertyChanged += bot_PropertyChanged;

            Program.Logger.AddLog(Log.LogType.Info, Log.LogLevel.Stander, string.Format("[{0}][{1}]- Ready", bot.CharName, bot.ServerName));
            if (BotListChanged != null)
                BotListChanged(bot, ChangesType.Added);
            bot.Start();
        }
Ejemplo n.º 3
0
 public void RemoveBot(CenterBot bot)
 {
     if (BotListChanged != null)
         BotListChanged(bot, ChangesType.Deleted);
     bot.StateChanged -= bot_StateChanged; bot.PropertyChanged -= bot_PropertyChanged;
     bot.BotAccount.bot = null;
     Program.Logger.AddLog(Log.LogType.Info, Log.LogLevel.Stander, string.Format("[{0}][{1}]- Closed", bot.BotAccount.CharName, DataManager.ServerList[bot.BotAccount.silkroadServer]));
     lock (Bots)
         Bots.Remove(bot);
     bot.Dispose();
 }
Ejemplo n.º 4
0
 public static CenterBot Createbot(Process botProcess = null)
 {
     CenterBot bot = new CenterBot();
     bot._process = botProcess;
     return bot;
 }