Ejemplo n.º 1
0
        }         // constructor

        public void Generate()
        {
            Report = new ExcelPackage();

            m_oSp.ForEachRowSafe(ProcessRow);

            CustomerData oRandomCustomer = null;

            foreach (KeyValuePair <int, CustomerData> pair in m_oData)
            {
                pair.Value.SaveTo(Report);
                oRandomCustomer = pair.Value;
            }             // for each

            if (oRandomCustomer != null)
            {
                oRandomCustomer.AddApprovalPhaseTotal(Report);
            }

            SaveAlibabaIDs();

            Report.AutoFitColumns();
        }         // Generate
Ejemplo n.º 2
0
        private void ProcessRow(SafeReader sr)
        {
            string sRowType = sr[CustomerData.RowType];

            RptAlibabaDataSharing.RowTypes nRowType;

            if (!Enum.TryParse(sRowType, out nRowType))
            {
                m_oLog.Alert("Failed to parse DataSharing row type '{0}'.", sRowType);
                return;
            }             // if

            switch (nRowType)
            {
            case RptAlibabaDataSharing.RowTypes.MetaData:
                var cd = new CustomerData(sr);

                if (cd.CustomerID < 1)
                {
                    m_oLog.Alert("Invalid customer id detected.");
                    break;
                }                 // if

                m_oData[cd.CustomerID] = cd;

                break;

            case RptAlibabaDataSharing.RowTypes.Loan: {
                int nCustomerID = sr[CustomerData.LoanDataCustomerIDField];

                if (!m_oData.ContainsKey(nCustomerID))
                {
                    m_oLog.Alert("Ignoring loan data for customer {0} because customer not found.", nCustomerID);
                    break;
                }                 // if

                m_oData[nCustomerID].AddLoanData(sr);
            } break;

            case RptAlibabaDataSharing.RowTypes.Repayment: {
                int nCustomerID = sr[CustomerData.LoanDataCustomerIDField];

                if (!m_oData.ContainsKey(nCustomerID))
                {
                    m_oLog.Alert("Ignoring loan data for customer {0} because customer not found.", nCustomerID);
                    break;
                }                 // if

                m_oData[nCustomerID].AddRepayment(sr, m_oLateLoans);
            } break;

            case RptAlibabaDataSharing.RowTypes.Marketplace: {
                int nCustomerID = sr[CustomerData.LoanDataCustomerIDField];

                if (!m_oData.ContainsKey(nCustomerID))
                {
                    m_oLog.Alert("Ignoring marketplace for customer {0} because customer not found.", nCustomerID);
                    break;
                }                 // if

                m_oData[nCustomerID].AddMarketplace(sr);
            } break;

            case RptAlibabaDataSharing.RowTypes.IsLate:
                m_oLateLoans.Add(sr["LoanID"]);
                break;

            case RptAlibabaDataSharing.RowTypes.AlibabaID:
                ExtractAlibabaID(sr["Source"]);
                break;

            default:
                throw new ArgumentOutOfRangeException();
            }     // switch
        }         // ProcessRow