public JsonResult Accounts(PayPointAccountModel model)
        {
            string errorMsg;

            if (!PayPointConnector.Validate(model.mid, model.vpnPassword, model.remotePassword, out errorMsg))
            {
                var errorObject = new { error = errorMsg };
                Log.ErrorFormat("PayPoint validation failed: {0}", errorObject);
                return(Json(errorObject));
            }
            try
            {
                var mpId = SavePaypoint(model);
                m_oServiceClient.Instance.UpdateMarketplace(_context.Customer.Id, mpId, true, _context.Customer.Id);
                return(Json(model));
            }
            catch (MarketPlaceAddedByThisCustomerException e)
            {
                Log.Error(e);
                return(Json(new { error = DbStrings.AccountAddedByYou }));
            }
            catch (MarketPlaceIsAlreadyAddedException e)
            {
                Log.Error(e);
                return(Json(new { error = DbStrings.StoreAlreadyExistsInDb }));
            }
            catch (Exception e)
            {
                Log.Error(e);
                return(Json(new { error = e.Message }));
            }
        }
Example #2
0
        }         // DeleteOldData

        private PayPointDataSet.TransactionDataTable Fetch(string sCondition, Conf.Account account)
        {
            Debug(
                "PayPointBalance.Fetch started using condition '{0}' from PayPoint account {1}...",
                sCondition,
                account.Mid
                );

            PayPointDataSet.TransactionDataTable tbl = null;

            for (int r = 1; r <= account.RetryCount; r++)
            {
                Debug("Attempt {0}: fetching data from PayPoint account {1}...", r, account.Mid);

                try {
                    tbl = PayPointConnector.GetOrdersDragonStyle(
                        sCondition,
                        account.Mid,
                        account.VpnPassword,
                        account.RemotePassword
                        );

                    Info(
                        "Attempt {1}: {0} fetched from PayPoint account {2}.",
                        Grammar.Number(tbl.Rows.Count, "row"),
                        r,
                        account.Mid
                        );

                    break;
                }
                catch (Exception e) {
                    string sMsg = (r == account.RetryCount)
                                                ? string.Empty
                                                : string.Format("\n\nRetrying in {0} seconds...", account.SleepInterval);

                    Error(
                        e,
                        "Attempt {0}: failed to fetch data from PayPoint account {1} with exception {2}",
                        r,
                        account.Mid,
                        sMsg
                        );

                    System.Threading.Thread.Sleep(account.SleepInterval * 1000);
                }         // try
            }             // for

            Say(
                tbl == null ? Severity.Error : Severity.Debug,
                "PayPointBalance.Fetch {0} from PayPoint account {1}.",
                tbl == null ? "failed" : "complete",
                account.Mid
                );

            return(tbl);
        }         // Fetch