コード例 #1
0
 public StateResponse GetStateRequest(ClientAuthStruct auth, string guidStateGuid, DateTime time)
 {
     StateResponse response = new StateResponse();
     using (ClientRequestHandler handler = new ClientRequestHandler())
     {
         try
         {
             if (handler.Authorize(auth, null))
             {
                 response.State = handler.GetState(guidStateGuid, auth.MachineGuid);
                 if (response.State == null)
                 {
                     response.ErrorCode = (int)ResponseCode.RequestedObjectNotFound;
                     LoggerHelper.Log(LogCategories.ClientRequest, LogEventID.BusinessError, System.Diagnostics.TraceEventType.Warning, string.Format("GetStateRequest - State nie istnieje ({0})", guidStateGuid));
                 }
                 else
                 {
                     if (!response.State.Active)
                     {
                         response.State = null;
                         response.ErrorCode = (int)ResponseCode.RequestedObjectIsDisabled;
                         LoggerHelper.Log(LogCategories.ClientRequest, LogEventID.BusinessError, System.Diagnostics.TraceEventType.Warning, string.Format("GetStateRequest - State nieaktywny ({0})", guidStateGuid));
                     }
                     response.ErrorCode = (int)BusinessLayer.ResponseCode.OK;
                     LoggerHelper.Log(LogCategories.ClientRequest, LogEventID.OK, System.Diagnostics.TraceEventType.Information, "GetStateRequest - OK");
                 }
             }
             else
             {
                 LoggerHelper.Log(LogCategories.ClientRequest, LogEventID.AuthorizationFailed, System.Diagnostics.TraceEventType.Warning, string.Format("Autoryzacja nieudana! Użytkownik {0} hasło {1}", auth.UserName, auth.Password));
                 response.ErrorCode = (int)BusinessLayer.ResponseCode.AuthorizationFailed;
             }
         }
         catch (Exception exc)
         {
             response.ErrorCode = (int)ResponseCode.ProxyServerError;
             response.ErrorDescription = exc.ToString();
             LoggerHelper.Log(LogCategories.ClientRequest, LogEventID.InternalError, System.Diagnostics.TraceEventType.Error, exc.ToString());
         }
     }
     return response;
 }
コード例 #2
0
ファイル: ClientProxy.cs プロジェクト: macper/MWRWebRemoter
 public StateResponse GetStateRequest(ProxyServer.BusinessLayer.ClientAuthStruct auth, string guidStateGuid, DateTime time)
 {
     StateResponse response = new StateResponse();
     ClientInterface.StateResponse proxyResp = client.GetStateRequest(GetAuthData(auth), guidStateGuid, time);
     response.ErrorCode = proxyResp.ErrorCode;
     response.ErrorDescription = proxyResp.ErrorDescription;
     if (response.ErrorCode != 0)
     {
         return response;
     }
     response.State = new StateStruct();
     response.State.Active = proxyResp.State.Active;
     response.State.Guid = proxyResp.State.Guid;
     response.State.ID = proxyResp.State.ID;
     response.State.Machine = proxyResp.State.Machine;
     response.State.Name = proxyResp.State.Name;
     response.State.RegisteredDate = proxyResp.State.RegisteredDate;
     response.State.XmlInfo = proxyResp.State.XmlInfo;
     return response;
 }