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;
 }
Example #2
0
 public ProxyServer.BusinessLayer.WebResponse UpdateTaskRequest(ProxyServer.BusinessLayer.ServerAuthStruct auth, int taskID, int newState, string xmlResponse, string errorDetails)
 {
     WebResponse response = new WebResponse();
     ServerInterface.WebResponse localRes = soapClient.UpdateTaskRequest(GetAuth(auth), taskID, newState, xmlResponse, errorDetails);
     response.ErrorCode = localRes.ErrorCode;
     response.ErrorDescription = localRes.ErrorDescription;
     return response;
 }
Example #3
0
 public ProxyServer.BusinessLayer.WebResponse UpdateStateRequest(ProxyServer.BusinessLayer.ServerAuthStruct auth, string stateGuid, string informationXml)
 {
     WebResponse response = new WebResponse();
     ServerInterface.WebResponse localRes = soapClient.UpdateStateRequest(GetAuth(auth), stateGuid, informationXml);
     response.ErrorCode = localRes.ErrorCode;
     response.ErrorDescription = localRes.ErrorDescription;
     return response;
 }
Example #4
0
 public WebResponse DeleteTaskRequest(ProxyServer.BusinessLayer.ClientAuthStruct auth, int TaskID)
 {
     WebResponse response = new WebResponse();
     ClientInterface.WebResponse proxyResp = client.DeleteTaskRequest(GetAuthData(auth), TaskID);
     response.ErrorCode = proxyResp.ErrorCode;
     response.ErrorDescription = proxyResp.ErrorDescription;
     return response;
 }
 protected WebResponse UpdateDictionary(ClientRequestHandler handler, object[] arguments)
 {
     WebResponse response = new WebResponse();
     if (handler.UpdateDictionary((string)arguments[0], (int)arguments[1], (string)arguments[2]))
     {
         response.ErrorCode = 0;
     }
     else
     {
         response.ErrorCode = (int)ProxyServer.BusinessLayer.ResponseCode.ProxyServerError;
         response.ErrorDescription = "Nie udało się zapisać";
     }
     return response;
 }
 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;
 }
Example #7
0
 public WebResponse UpdateDictionary(ClientAuthStruct auth, string Guid, int newState, string Config)
 {
     WebResponse response = new WebResponse();
     ClientInterface.WebResponse proxyResponse = client.UpdateDictionary(GetAuthData(auth), Guid, newState, Config);
     response.ErrorCode = proxyResponse.ErrorCode;
     response.ErrorDescription = proxyResponse.ErrorDescription;
     return response;
 }
        public WebResponse UpdateStateRequest(ServerAuthStruct auth, string stateGuid, string informationXml)
        {
            WebResponse response = new WebResponse();
            ServerRequestHandler handler = new ServerRequestHandler();

            try
            {
                if (!handler.Authorize(auth))
                {
                    response.ErrorCode = (int)ResponseCode.AuthorizationFailed;
                    LoggerHelper.Log(LogCategories.ServerRequest, LogEventID.AuthorizationFailed, System.Diagnostics.TraceEventType.Error, string.Format("Błąd autoryzacji - maszyna {0}", auth.MachineGuid));
                    return response;
                }

                bool active = false;
                if (!handler.MWRStateExists(stateGuid, ref active))
                {
                    response.ErrorCode = (int)ResponseCode.RequestedObjectNotFound;
                    LoggerHelper.Log(LogCategories.ServerRequest, LogEventID.BusinessError, System.Diagnostics.TraceEventType.Error, string.Format("Stan {0} nie istnieje ! ", stateGuid));
                    return response;
                }

                if (!active)
                {
                    response.ErrorCode = (int)ResponseCode.RequestedObjectIsDisabled;
                    LoggerHelper.Log(LogCategories.ServerRequest, LogEventID.BusinessError, System.Diagnostics.TraceEventType.Warning, string.Format("Stan {0} jest wyłączony ", stateGuid));
                    return response;
                }

                if (!handler.UpdateState(stateGuid, informationXml, auth.MachineGuid))
                {
                    response.ErrorCode = (int)ResponseCode.ProxyServerError;
                    LoggerHelper.Log(LogCategories.ServerRequest, LogEventID.InternalError, System.Diagnostics.TraceEventType.Error, string.Format("Nie udało się dodać stanu - {0}", stateGuid));
                }
                else
                {
                    response.ErrorCode = (int)ResponseCode.OK;
                    LoggerHelper.Log(LogCategories.ServerRequest, LogEventID.OK, System.Diagnostics.TraceEventType.Information, string.Format("Stan {0} - OK", stateGuid));
                }
                return response;
            }
            catch (Exception exc)
            {
                response.ErrorCode = (int)ResponseCode.ProxyServerError;
                response.ErrorDescription = exc.ToString();
                return response;
            }
            finally
            {
                handler.Dispose();
            }
        }
        public WebResponse UpdateTaskRequest(ServerAuthStruct auth, int taskID, int newState, string xmlResponse, string errorInfo)
        {
            WebResponse response = new WebResponse();
            ServerRequestHandler handler = new ServerRequestHandler();

            try
            {

                if (!handler.Authorize(auth))
                {
                    response.ErrorCode = (int)ResponseCode.AuthorizationFailed;
                    LoggerHelper.Log(LogCategories.ServerRequest, LogEventID.AuthorizationFailed, System.Diagnostics.TraceEventType.Error, string.Format("Błąd autoryzacji - maszyna {0}", auth.MachineGuid));
                    return response;
                }

                TaskStruct task = handler.GetTask(taskID);

                if (task == null)
                {
                    response.ErrorCode = (int)ResponseCode.RequestedObjectNotFound;
                    LoggerHelper.Log(LogCategories.ServerRequest, LogEventID.BusinessError, System.Diagnostics.TraceEventType.Error, string.Format("UpdateTask - task o ID {0} nie istnieje", taskID.ToString()));
                    return response;
                }

                if (!task.Active)
                {
                    response.ErrorCode = (int)ResponseCode.RequestedObjectIsDisabled;
                    LoggerHelper.Log(LogCategories.ServerRequest, LogEventID.BusinessError, System.Diagnostics.TraceEventType.Error, string.Format("UpdateTask - task o guid {0} jest wyłączony", task.Guid));
                    return response;
                }

                task.State = newState;
                task.XmlResponse = xmlResponse;
                task.ID = taskID;
                task.DateCompleted = DateTime.Now;
                     task.ErrorDetails = errorInfo;

                if (!handler.UpdateTask(task))
                {
                    response.ErrorCode = (int)ResponseCode.ProxyServerError;
                    LoggerHelper.Log(LogCategories.ServerRequest, LogEventID.InternalError, System.Diagnostics.TraceEventType.Error, string.Format("UpdateTask - nie udało się dodać, Task Guid : {0}", task.Guid));
                }
                else
                {
                    response.ErrorCode = (int)ResponseCode.OK;
                    LoggerHelper.Log(LogCategories.ServerRequest, LogEventID.OK, System.Diagnostics.TraceEventType.Information, string.Format("UpdateTask - {0} - OK", task.Guid));
                }
                return response;

            }
            catch (Exception exc)
            {
                response.ErrorCode = (int)ResponseCode.ProxyServerError;
                response.ErrorDescription = exc.ToString();
                return response;
            }
            finally
            {
                handler.Dispose();
            }
        }