Exemplo n.º 1
0
        public HttpResponseMessage Acknowledge(string userName, string password, string integrationModule, IEnumerable<string> orderReferences)
        {
            var acknowledmentResponse = new TransactionsAcknowledgementResponse();

             try
             {

                 _log.InfoFormat("Login attempt for {0} - {1}", userName, integrationModule);
                 CostCentreLoginResponse response = _costCentreApplicationService.CostCentreLogin(userName, password,
                                                                                                  "HQAdmin");
                 AuditCCHit(response.CostCentreId, "Login", "Login attempt for " + integrationModule, response.ErrorInfo);

                 if (response.CostCentreId == Guid.Empty)
                 {
                     acknowledmentResponse.ErrorInfo = "Invalid user credentials";
                     acknowledmentResponse.Result = "Error";
                 }
                 else
                 {
                     acknowledmentResponse = _integrationService.MarkAsExported(integrationModule, orderReferences);
                 }
             }catch(Exception ex)
             {
                 acknowledmentResponse.Result = "Error";
                 acknowledmentResponse.ErrorInfo = "Error: An error occurred executing the task.Result details=>" + ex.Message + "Inner Exception:" + (ex.InnerException != null ? ex.InnerException.Message : "");
                 _log.Error(string.Format("Error: An error occurred when acknowledging transactions for {0}\n", integrationModule), ex);
             }
             return Request.CreateResponse(HttpStatusCode.OK, acknowledmentResponse);
        }
 public TransactionsAcknowledgementResponse MarkAsExported(string integrationModule, IEnumerable<string> orderReferences)
 {
     TransactionsAcknowledgementResponse response;
     IntegrationModule module = (IntegrationModule)Enum.Parse(typeof(IntegrationModule), integrationModule);
     bool done = false;
     switch (module)
     {
         case IntegrationModule.Sage:
             done=_sageTransactionsExportService.MarkAsExported(orderReferences);
             break;
             case IntegrationModule.SAP:
             done = _sapTransactionsDownloadService.MarkAsExported(orderReferences);
             break;
             case IntegrationModule.QuickBooks:
             done = _quickBooksTransactionsDownloadService.MarkAsExported(orderReferences);
             break;
     }
     if(done)
     {
         response=new TransactionsAcknowledgementResponse
                      {
                          Result = "Success",
                          ResultInfo = "All orders acknowledged successfully"
                      };
     }
     else
     {
         response = new TransactionsAcknowledgementResponse
         {
             Result = "Error",
             ResultInfo = "Unknown Server Error Occured while acknowledging"
         };
     }
     return response;
 }