Esempio n. 1
0
        }         // Fetch

        private void Save(AConnection oDB, PayPointDataSet.TransactionDataTable tbl, List <string> aryColumns)
        {
            Debug("PayPointBalance.Save started...");

            int nCurRowIdx = 0;

            foreach (PayPointDataSet.TransactionRow row in tbl.Rows)
            {
                QueryParameter[] args = aryColumns.Select(sName => {
                    PropertyInfo pi = row.GetType().GetProperty(sName);
                    var obj         = pi.GetGetMethod().Invoke(row, null);

                    if (sName == "date")
                    {
                        DateTime result;
                        obj = DateTime.TryParse(obj.ToString(), out result) ? result : (DateTime?)null;
                    }                     // if

                    return(new QueryParameter("@" + sName, obj));
                }).ToArray();

                oDB.ExecuteNonQuery(InsertDataStoredProc.Name, CommandSpecies.StoredProcedure, args);

                Debug("Row {0} processing complete.", nCurRowIdx);
                nCurRowIdx++;
            }             // foreach

            Debug("PayPointBalance.Save complete.");
        }         // Save
Esempio n. 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