public void Start() { InvoiceModel currentRequest; ResponseModel currentResponse; for (int i = 0; i < dtRequests.Rows.Count; i++) { Console.WriteLine(DateTime.Now.ToLongTimeString() + " " + (dtRequests.Rows.Count - i) + " requests are in step 3"); Thread.Sleep(500); String type = dtRequests.Rows[i][2].ToString(); currentRequest = new InvoiceModel(Int64.Parse(dtRequests.Rows[i][0].ToString()), RequestType.PDF, dtRequests.Rows[i][10].ToString()); currentResponse = CXsdValidator.XsdValidatorProcess.ValidateInvoice(currentRequest); if (currentResponse.success) { Request.Update_Estado(currentRequest.Id, (int)InvoiceState.xsdValidated); if (SendInvoiceThread.ThreadState != ThreadState.Running && SendInvoiceThread.ThreadState != ThreadState.WaitSleepJoin) { SendInvoiceThread = new Thread(SendInvoiceDelegate); SendInvoiceThread.Start(); } } else { Request.Update_Estado(currentRequest.Id, (int)InvoiceState.xsdValidationError); } } Console.WriteLine(DateTime.Now.ToLongTimeString() + " There are no requests in step 3"); dtRequests = Request.SelectStatus((int)InvoiceState.signed); if (dtRequests.Rows.Count > 0) { Start(); } }
public void Start() { InvoiceModel currentRequest; ResponseModel currentResponse; for (int i = 0; i < dtRequests.Rows.Count; i++) { Console.WriteLine(DateTime.Now.ToLongTimeString() + ": " + (dtRequests.Rows.Count - i) + " requests are in step 5"); Thread.Sleep(500); String type = dtRequests.Rows[i][2].ToString(); currentRequest = new InvoiceModel(Int64.Parse(dtRequests.Rows[i][0].ToString()), RequestType.PDF, dtRequests.Rows[i][10].ToString()); currentResponse = EConfirmState.ConfirmStateProcess.ConfirmState(currentRequest); if (currentResponse.success) { Request.Update_Estado(currentRequest.Id, (int)InvoiceState.received); } else { if (currentResponse.error == Error.decline) { Request.Update_Estado(currentRequest.Id, (int)InvoiceState.notAccepted); } else { Request.Update_Estado(currentRequest.Id, (int)InvoiceState.connectionConfirmError); } } } Console.WriteLine(DateTime.Now.ToLongTimeString() + ": There are no requests in step 5"); dtRequests = Request.SelectStatus((int)InvoiceState.sended, (int)InvoiceState.connectionConfirmError); if (dtRequests.Rows.Count > 0) { Start(); } }
public void Start() { InvoiceModel currentRequest; ResponseModel currentResponse; for (int i = 0; i < dtRequests.Rows.Count; i++) { Console.WriteLine(DateTime.Now.ToLongTimeString() + " " + (dtRequests.Rows.Count - i) + " requests are in step 1, in the validator 1"); Thread.Sleep(500); String type = dtRequests.Rows[i][2].ToString(); if (type == "PDF") { currentRequest = new InvoiceModel(Int64.Parse(dtRequests.Rows[i][0].ToString()), RequestType.PDF, dtRequests.Rows[i][7].ToString()); currentResponse = Software1Validator.Process.AttachPDF(currentRequest); } else { currentRequest = new InvoiceModel(Int64.Parse(dtRequests.Rows[i][0].ToString()), RequestType.XML, dtRequests.Rows[i][8].ToString()); currentResponse = Software1Validator.Process.ProcesInvoice(currentRequest); } if (currentResponse.success) { Request.Update_Estado(currentRequest.Id, (int)InvoiceState.saved); CompleteProcess(); } else { if (currentResponse.error == Error.validate) { Request.Update_Estado(currentRequest.Id, (int)InvoiceState.validationError); } else { Request.Update_Estado(currentRequest.Id, (int)InvoiceState.saveError); } } } Console.WriteLine(DateTime.Now.ToLongTimeString() + " The validator 1 has no requests"); dtRequests = Request.SelectValidator(1); if (dtRequests.Rows.Count > 0) { Start(); } }