예제 #1
0
 public WebResponse DeleteTaskRequest(ClientAuthStruct auth, int TaskID)
 {
     WebResponse response = new WebResponse();
     using (ClientRequestHandler handler = new ClientRequestHandler())
     {
         try
         {
             if (handler.Authorize(auth, null))
             {
                 if (handler.DeleteTask(TaskID))
                 {
                     response.ErrorCode = (int)ResponseCode.OK;
                     LoggerHelper.Log(LogCategories.ClientRequest, LogEventID.OK, System.Diagnostics.TraceEventType.Information, "DeleteTask - OK");
                 }
                 else
                 {
                     response.ErrorCode = (int)ResponseCode.RequestedObjectNotFound;
                     LoggerHelper.Log(LogCategories.ClientRequest, LogEventID.BusinessError, System.Diagnostics.TraceEventType.Error, "Nie udało się usunąć Taska o ID " + TaskID.ToString());
                 }
             }
             else
             {
                 response.ErrorCode = (int)ResponseCode.AuthorizationFailed;
                 LoggerHelper.Log(LogCategories.ClientRequest, LogEventID.AuthorizationFailed, System.Diagnostics.TraceEventType.Warning, "Autoryzacja nieudana - użytkownik " + auth.UserName);
             }
         }
         catch (Exception exc)
         {
             response.ErrorCode = (int)ResponseCode.ProxyServerError;
             response.ErrorDescription = exc.ToString();
         }
     }
     return response;
 }
예제 #2
0
 public TaskResponse CreateTaskRequest(ClientAuthStruct auth, MWRCommonTypes.TaskStruct task)
 {
     TaskResponse response = new TaskResponse();
     using (ClientRequestHandler handler = new ClientRequestHandler())
     {
         try
         {
             if (handler.Authorize(auth, null))
             {
                 int taskID = -1;
                 if (handler.CreateTask(task, ref taskID))
                 {
                     response.Task = task;
                     response.TaskID = taskID;
                     LoggerHelper.Log(LogCategories.ClientRequest, LogEventID.OK, System.Diagnostics.TraceEventType.Information, "CreateTaskRequest - OK");
                     response.ErrorCode = (int)ResponseCode.OK;
                 }
                 else
                 {
                     response.ErrorCode = (int)ResponseCode.IncorrectDataError;
                     LoggerHelper.Log(LogCategories.ClientRequest, LogEventID.BusinessError, System.Diagnostics.TraceEventType.Error, string.Format("Nie udało się dodać Taska ({0})", task.Guid));
                 }
             }
             else
             {
                 response.ErrorCode = (int)ResponseCode.AuthorizationFailed;
                 LoggerHelper.Log(LogCategories.ClientRequest, LogEventID.AuthorizationFailed, System.Diagnostics.TraceEventType.Warning, "Autoryzacja nieudana - użytkownik " + auth.UserName);
             }
         }
         catch (Exception exc)
         {
             response.ErrorCode = (int)ResponseCode.ProxyServerError;
             response.ErrorDescription = exc.ToString();
         }
     }
     return response;
 }
예제 #3
0
 protected WebResponse CommonFunction(WebResponse emptyStructure, ClientAuthStruct auth, WebMethodInvoker method, object [] arguments)
 {
     WebResponse response = emptyStructure;
     using (ClientRequestHandler handler = new ClientRequestHandler())
     {
         try
         {
             if (handler.Authorize(auth, null))
             {
                 response = method(handler, arguments);
                 if (response.ErrorCode == (int)ResponseCode.OK)
                 {
                     LoggerHelper.Log(LogCategories.ClientRequest, LogEventID.OK, System.Diagnostics.TraceEventType.Information, method.Method.Name);
                 }
                 else
                 {
                     LoggerHelper.Log(LogCategories.ClientRequest, LogEventID.BusinessError, System.Diagnostics.TraceEventType.Error, method.Method.Name);
                 }
             }
             else
             {
                 response.ErrorCode = (int)ResponseCode.AuthorizationFailed;
                 LoggerHelper.Log(LogCategories.ClientRequest, LogEventID.AuthorizationFailed, System.Diagnostics.TraceEventType.Error, method.Method.Name);
             }
         }
         catch (Exception exc)
         {
             response.ErrorCode = (int)ResponseCode.ProxyServerError;
             LoggerHelper.Log(LogCategories.ClientRequest, LogEventID.InternalError, System.Diagnostics.TraceEventType.Error, method.Method.Name + " błąd - " + exc.ToString());
         }
     }
     return response;
 }
예제 #4
0
 public TaskResponse GetTaskRequest(ClientAuthStruct auth, int TaskID)
 {
     TaskResponse response = new TaskResponse();
     using (ClientRequestHandler handler = new ClientRequestHandler())
     {
         try
         {
             if (handler.Authorize(auth, null))
             {
                 response.Task = handler.GetTask(TaskID);
                 if (response.Task == null)
                 {
                     response.ErrorCode = (int)ResponseCode.RequestedObjectNotFound;
                     LoggerHelper.Log(LogCategories.ClientRequest, LogEventID.BusinessError, System.Diagnostics.TraceEventType.Warning, string.Format("GetTaskRequest - Task nie istnieje ({0})", TaskID));
                 }
                 else
                 {
                     if (!response.Task.Active)
                     {
                         response.Task = null;
                         response.ErrorCode = (int)ResponseCode.RequestedObjectIsDisabled;
                         LoggerHelper.Log(LogCategories.ClientRequest, LogEventID.BusinessError, System.Diagnostics.TraceEventType.Warning, string.Format("GetTaskRequest - Task nie istnieje ({0})", TaskID));
                     }
                     else
                     {
                         response.ErrorCode = (int)BusinessLayer.ResponseCode.OK;
                         LoggerHelper.Log(LogCategories.ClientRequest, LogEventID.OK, System.Diagnostics.TraceEventType.Information, "GetTaskRequest - 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;
 }