/// <summary>
 /// 初始化
 /// </summary>
 //先检查服务器状态;然后连接数据库;最后初始化套接字。如果出错则给出错误信息。
 public void Init()
 {
     if (runningData.IsInit == ServerState.初始化完成)
     {
         Terminal.ServerPrint(InfoType.信息, "服务器已经运行");
         return;
     }
     else if (runningData.IsInit == ServerState.初始化中)
     {
         Terminal.ServerPrint(InfoType.信息, "服务器初始化中...");
         return;
     }
     try
     {
         runningData.IsInit = ServerState.初始化中;
         Terminal.SetServerTitle(runningData.Ip, runningData.Port);
         Terminal.ServerPrint(InfoType.信息, "服务器初始化中...");
         Terminal.ServerPrint(InfoType.信息, "连接数据库");
         IResult result = ServerCallDatabase.ConnectDatabase();
         if (result.BaseResult == baseResult.Faild)
         {
             Terminal.ServerPrint(InfoType.异常, "初始化失败 原因:" + result.Info);
             runningData.IsInit = ServerState.未初始化;
             return;
         }
         Terminal.ServerPrint(InfoType.信息, "数据库连接成功");
         Terminal.ServerPrint(InfoType.信息, "初始化套接字");
         result = ServerSocket.Access(runningData.Ip, runningData.Port, 10, Accept);
         if (result.BaseResult == baseResult.Faild)
         {
             Terminal.ServerPrint(InfoType.异常, "初始化失败 原因:" + result.Info);
             runningData.IsInit = ServerState.未初始化;
             return;
         }
         runningData.IsInit = ServerState.初始化完成;
     }
     catch (Exception e)
     {
         Terminal.ServerPrint(InfoType.异常, "初始化失败 原因:" + e.Message);
         runningData.IsInit = ServerState.未初始化;
         throw e;
     }
     Terminal.ServerPrint(InfoType.信息, "初始化完成");
 }