예제 #1
0
 public static bool ReLoadServerList()
 {
     try
     {
         using (ServiceBussiness db = new ServiceBussiness())
         {
             lock (_syncStop)
             {
                 ServerInfo[] list = db.GetServerList();
                 foreach (ServerInfo s in list)
                 {
                     if (_list.ContainsKey(s.ID))
                     {
                         _list[s.ID].IP = s.IP;
                         _list[s.ID].Name = s.Name;
                         _list[s.ID].Port = s.Port;
                         _list[s.ID].Room = s.Room;
                         _list[s.ID].Total = s.Total;
                         _list[s.ID].MustLevel = s.MustLevel;
                         _list[s.ID].LowestLevel = s.LowestLevel;
                         _list[s.ID].Online = s.Online;
                         _list[s.ID].State = s.State;
                     }
                     else
                     {
                         s.State = 1;
                         s.Online = 0;
                         _list.Add(s.ID, s);
                     }
                 }
             }
         }
         log.Info("ReLoad server list from db.");
         return true;
     }
     catch (Exception ex)
     {
         log.ErrorFormat("ReLoad server list from db failed:{0}", ex);
         return false;
     }
 }
예제 #2
0
 public static bool Start()
 {
     try
     {
         using (ServiceBussiness db = new ServiceBussiness())
         {
             ServerInfo[] list = db.GetServerList();
             foreach (ServerInfo s in list)
             {
                 s.State = 1;
                 s.Online = 0;
                 _list.Add(s.ID, s);
             }
         }
         log.Info("Load server list from db.");
         return true;
     }
     catch (Exception ex)
     {
         log.ErrorFormat("Load server list from db failed:{0}", ex);
         return false;
     }
 }