public void PickupReceivedTransactions()
        {
            TaskManager.Write("Start looking for transactions submitted");
            //
            List <HandlerResponse> transactions = ServiceHandlerController.GetServiceHandlersResponsesByReseller(SecurityContext.User.UserId);

            //
            if (transactions.Count > 0)
            {
                XmlDocument xmldoc      = new XmlDocument();
                XmlElement  root        = xmldoc.CreateElement("Result");
                XmlElement  succeedNode = xmldoc.CreateElement("Succeed");
                XmlElement  failedNode  = xmldoc.CreateElement("Failed");
                root.AppendChild(succeedNode);
                root.AppendChild(failedNode);
                //
                List <HandlerResponse> succeedItems = new List <HandlerResponse>();
                List <HandlerResponse> failedItems  = new List <HandlerResponse>();
                //
                TaskManager.Write("Found {0} transactions pending", transactions.Count.ToString());
                foreach (HandlerResponse transaction in transactions)
                {
                    XmlElement responseNode = xmldoc.CreateElement("Response");
                    responseNode.SetAttribute("ID", Convert.ToString(transaction.ResponseId));
                    //
                    try
                    {
                        CheckoutDetails details = new CheckoutDetails();
                        //
                        string[] dataPairs = transaction.TextResponse.Split('&');
                        foreach (string dataPair in dataPairs)
                        {
                            string[] data = dataPair.Split('=');
                            if (data.Length >= 2)
                            {
                                details[data[0]] = data[1];
                            }
                        }
                        //
                        CheckoutResult result = PaymentGatewayController.CheckOut(transaction.ContractId, transaction.InvoiceId,
                                                                                  transaction.MethodName, details);
                        //
                        if (result.Succeed)
                        {
                            succeedNode.AppendChild(responseNode);
                            succeedItems.Add(transaction);
                        }
                        else
                        {
                            responseNode.SetAttribute("Error", result.StatusCode);
                            failedNode.AppendChild(responseNode);
                            //
                            transaction.ErrorMessage = result.StatusCode;
                            failedItems.Add(transaction);
                        }
                    }
                    catch (Exception ex)
                    {
                        //
                        if (!failedItems.Contains(transaction))
                        {
                            responseNode.SetAttribute("Error", ex.StackTrace);
                            failedNode.AppendChild(responseNode);
                            //
                            transaction.ErrorMessage = ex.StackTrace;
                            failedItems.Add(transaction);
                        }
                        //
                        TaskManager.WriteError(ex);
                    }
                }
                // peform transactions update
                ServiceHandlerController.UpdateServiceHandlersResponses(SecurityContext.User.UserId, root.InnerXml);
            }
            else
            {
                TaskManager.Write("No transactions found");
            }
            TaskManager.Write("End looking for transactions submitted");
        }
 public void AddServiceHandlerTextResponse(string serviceId, string contractId, int invoiceId, string dataReceived)
 {
     ServiceHandlerController.AddServiceHandlerTextResponse(serviceId, contractId, invoiceId, dataReceived);
 }