public bool StartSync()
 {
     //是否与服务器已经通步过
     if (!ClientConfiguration.HasSync)
     {
         lock (_syncLock)
         {
             if (!ClientConfiguration.HasSync)
             {
                 //心跳检测
                 if (ClientConfiguration.CheckHeartbeat())
                 {
                     //刷新HostToken
                     if (_hostService.RefreshToken())
                     {
                         //同步服务器白名单
                         if (_resourceService.SyncResources())
                         {
                             ClientConfiguration.HasSync = true;
                             return(true);
                         }
                     }
                 }
             }
         }
         return(false);
     }
     return(true);
 }
 public bool HasSync(HttpContext context)
 {
     //是否与服务器已经通步过
     if (!ClientConfiguration.HasSync)
     {
         lock (_syncLock)
         {
             if (!ClientConfiguration.HasSync)
             {
                 //心跳检测
                 if (ClientConfiguration.CheckHeartbeat())
                 {
                     //刷新HostToken
                     if (!_hostService.RefreshToken())
                     {
                         context.Response.StatusCode = 500;
                         ReturnMessage(context, 5001, "刷新Token失败,请核对主机与服务端信息!");
                     }
                     else
                     {
                         //同步服务器白名单
                         if (!_resourceService.SyncResources())
                         {
                             context.Response.StatusCode = 500;
                             ReturnMessage(context, 5002, "获取白名单资源失败,请核对主机与服务端信息!");
                         }
                         else
                         {
                             ClientConfiguration.HasSync = true;
                             return(true);
                         }
                     }
                 }
                 else
                 {
                     context.Response.StatusCode = 500;
                     //心跳检测不通过
                     ReturnMessage(context, 5000, "与服务器联通失败,请检查网络和服务端!");
                 }
             }
         }
         return(false);
     }
     return(true);
 }
 /// <summary>
 /// 心跳检测实现
 /// </summary>
 /// <returns></returns>
 public static bool Heartbeat()
 {
     return(ClientConfiguration.CheckHeartbeat());
 }