public List<DA_TRN_CASHFLOW> GetSCEDetailReport(SessionInfo sessioninfo, string strReportDate, string strCtpy, string strProduct, string strSource) { try { DateTime dteReport; DealBusiness _dealBusiness = new DealBusiness(); Guid guTemp; if (String.IsNullOrEmpty(strReportDate)) throw this.CreateException(new Exception(), "Please input report date."); else if (!DateTime.TryParseExact(strReportDate, "dd/MM/yyyy", null, DateTimeStyles.None, out dteReport)) throw this.CreateException(new Exception(), "Invalid report date."); else dteReport = DateTime.ParseExact(strReportDate, "dd/MM/yyyy", null); if (_dealBusiness.CountByProcessDate(dteReport) == 0) { throw this.CreateException(new Exception(), "No data for selected report date."); } var cashflows = _dealBusiness.GetFlowsByProcessDate(dteReport).AsQueryable(); if (!string.IsNullOrEmpty(strSource)) { cashflows = cashflows.Where(p => p.DA_TRN.SOURCE == strSource); } if (Guid.TryParse(strCtpy, out guTemp)) { cashflows = cashflows.Where(p => p.DA_TRN.CTPY_ID == Guid.Parse(strCtpy)); } if (Guid.TryParse(strProduct, out guTemp)) { cashflows = cashflows.Where(p => p.DA_TRN.PRODUCT_ID == Guid.Parse(strProduct)); } return cashflows.OrderBy(p => p.DA_TRN.INT_DEAL_NO).ThenByDescending(p => p.FLAG_FIRST).ThenBy(p => p.SEQ).ToList(); } catch (DataServicesException ex) { throw this.CreateException(ex, null); } }
public static object ImportExternalByProcessDate(SessionInfo sessioninfo) { OpicsBusiness _opicsBusiness = new OpicsBusiness(); DealBusiness _dealBusiness = new DealBusiness(); ReconcileBusiness _reconcileBusiness = new ReconcileBusiness(); List<DealTranModel> DealTrans = new List<DealTranModel>(); var results = new List<object>(); try { LoggingHelper.Debug("Get OPICS Deal on " + sessioninfo.Process.PreviousDate.ToString()); //Get data from OPICS List<DEALModel> opicsdeals = _opicsBusiness.GetOPICSDealExternal(sessioninfo.Process.PreviousDate); List<CASHFLOWModel> opicscashflows = _opicsBusiness.GetOPICSCashflow(sessioninfo.Process.PreviousDate); List<DA_TRN> importeddeals = _dealBusiness.GetImportedDealsByProcessDate(sessioninfo.Process.CurrentDate); //Ignore imported deals var query = from o in opicsdeals where !importeddeals.Any(d => d.EXT_DEAL_NO == o.EXT_DEAL_NO) select o; LoggingHelper.Debug("Import Passed OPICS Deal"); foreach (DEALModel opicdeal in query.ToList()) { if (ValidateOPICS(opicdeal)) ImportPassedOPICSDeal(sessioninfo, opicdeal, sessioninfo.Process.CurrentDate, ref DealTrans); } LoggingHelper.Debug("End Import Passed OPICS Deal as " + query.Count().ToString()); if (DealTrans.Count > 0) { //Insert to database LoggingHelper.Debug("Insert OPICS deals on " + sessioninfo.Process.PreviousDate.ToString()); _reconcileBusiness.UpdateDealReconcile(sessioninfo, DealTrans); } results.Add(new { Object = "OPICS Deals", Total = DealTrans.Count}); //Import Cashflows from OPICS List<DA_TRN_CASHFLOW> cashflows = null; if (opicscashflows != null && opicscashflows.Count > 0) { List<DA_TRN> allimporteddeals = importeddeals.Union(from t in DealTrans select t.Transaction).ToList(); List<DA_TRN_CASHFLOW> importedcashflows = _dealBusiness.GetFlowsByProcessDate(sessioninfo.Process.CurrentDate); cashflows = GenerateCashflowObject(sessioninfo, opicscashflows, importedcashflows, allimporteddeals); if (cashflows.Count > 0) { _reconcileBusiness.ImportCashflows(sessioninfo, cashflows); } } results.Add(new { Object = "OPICS Cashflows", Total = cashflows == null ? 0 : cashflows.Count }); //Return result to jTable return new { Result = "OK", //Records = count > 0 ? sortedRecords.Skip(startIndex).Take(count).ToList() : sortedRecords, Records = results, TotalRecordCount = results.Count }; } catch (Exception ex) { return new { Result = "ERROR", Message = ex.Message }; } }