public static List<DealViewModel> GetPCEDetailData(SessionInfo sessioninfo, string strReportDate, string strCtpy, string strProduct, string strSource) { try { ReportBusiness _reportBusiness = new ReportBusiness(); LookupBusiness _lookupBusiness = new LookupBusiness(); CountryBusiness _countryBusiness = new CountryBusiness(); CounterpartyBusiness _ctpyBusiness = new CounterpartyBusiness(); List<DA_TRN> trns = _reportBusiness.GetPCEDetailReport(sessioninfo, strReportDate, strCtpy, strProduct, strSource); List<MA_CURRENCY> ccys = _lookupBusiness.GetCurrencyAll(); List<MA_CSA_PRODUCT> csaproducts = _ctpyBusiness.GetCSAProductAll(sessioninfo); List<MA_COUNTRY> country = _countryBusiness.GetCountryAll(); var report = (from trn in trns join ct in country on trn.MA_COUTERPARTY.COUNTRY_ID equals ct.ID join ccy1 in ccys on trn.FIRST.CCY_ID equals ccy1.ID into ljccy1 from subccy1 in ljccy1.DefaultIfEmpty() join ccy2 in ccys on trn.SECOND.CCY_ID equals ccy2.ID into ljccy2 from subccy2 in ljccy2.DefaultIfEmpty() join csaproduct in csaproducts on new { CTPY_ID = trn.CTPY_ID, PRODUCT_ID = trn.PRODUCT_ID.Value } equals new { CTPY_ID = csaproduct.CSA_AGREEMENT_ID, PRODUCT_ID = csaproduct.PRODUCT_ID } into ljcsa from subcsa in ljcsa.DefaultIfEmpty() select new DealViewModel { EngineDate = trn.ENGINE_DATE, DMK_NO = trn.INT_DEAL_NO, OPICS_NO = trn.EXT_DEAL_NO, Source = trn.SOURCE == "INT" ? "DMK" : "OPICS", Product = trn.MA_PRODUCT.LABEL, Portfolio = trn.MA_PORTFOLIO.LABEL, TradeDate = trn.TRADE_DATE.Value, EffectiveDate = trn.START_DATE, MaturityDate = trn.MATURITY_DATE, Instrument = trn.MA_INSRUMENT.LABEL, Counterparty = trn.MA_COUTERPARTY.SNAME, Notional1 = trn.FIRST.NOTIONAL, Notional2 = trn.SECOND.NOTIONAL, FixedFloat1 = !trn.FIRST.FLAG_FIXED.HasValue ? "-" : trn.FIRST.FLAG_FIXED.Value ? trn.FIRST.FLAG_PAYREC + "-FIXED" : trn.FIRST.FLAG_PAYREC + "-FLOAT", FixedFloat2 = !trn.SECOND.FLAG_FIXED.HasValue ? "-" : trn.SECOND.FLAG_FIXED.Value ? trn.SECOND.FLAG_PAYREC + "-FIXED" : trn.SECOND.FLAG_PAYREC + "-FLOAT", KKPCCF = trn.KK_PCCF, KKContribute = trn.KK_CONTRIBUTE, CCY1 = subccy1 != null ? subccy1.LABEL : "-", CCY2 = subccy2 != null ? subccy2.LABEL : "-", CSA = subcsa != null ? "Yes" : "No", Country = ct.LABEL }).OrderBy(p => p.DMK_NO).ToList(); return report; } catch (Exception ex) { throw ex; } }
public static object GetCountryOptions(SessionInfo sessioninfo) { try { CountryBusiness _countryBusiness = new CountryBusiness(); //Get data from database var countries = _countryBusiness.GetCountryAll() .OrderBy(p => p.LABEL) .Select(c => new { DisplayText = c.LABEL, Value = c.ID }); //Return result to jTable return new { Result = "OK", Options = countries }; } catch (Exception ex) { return new { Result = "ERROR", Message = ex.Message }; } }
public List<LimitAuditReportModel> GetLimitAuditReport(SessionInfo sessionInfo, string strLogDatefrom, string strLogDateto, string strCtpy, string strCountry, string strEvent) { try { DateTime dteReportfrom; DateTime dteReportto; Guid guCtpyID = Guid.Empty; Guid guCountryID = Guid.Empty; LogBusiness _logBusiness = new LogBusiness(); CounterpartyBusiness _counterpartyBusiness = new CounterpartyBusiness(); CountryBusiness _countryBusiness = new CountryBusiness(); UserBusiness _userBusiness = new UserBusiness(); var log = _logBusiness.GetLogAll().Where(l => l.EVENT == LimitLogEvent.LIMIT_AUDIT.ToString() || l.EVENT == LimitLogEvent.TEMP_LIMIT_AUDIT.ToString() || l.EVENT == LimitLogEvent.COUNTRY_LIMIY_AUDIT.ToString() || l.EVENT == LimitLogEvent.TEMP_COUNTRY_LIMIT_AUDIT.ToString()).AsQueryable(); var ctpyLimit = _counterpartyBusiness.GetCounterpartyLimitAll().AsQueryable(); var ctpys = _counterpartyBusiness.GetCounterpartyAll().AsQueryable(); var countrys = _countryBusiness.GetCountryAll().AsQueryable(); var users = _userBusiness.GetAll().AsQueryable(); if (String.IsNullOrEmpty(strLogDatefrom)) throw this.CreateException(new Exception(), "Please input start log date."); else if (!DateTime.TryParseExact(strLogDatefrom, "dd/MM/yyyy", null, DateTimeStyles.None, out dteReportfrom)) throw this.CreateException(new Exception(), "Invalid start log date."); else dteReportfrom = DateTime.ParseExact(strLogDatefrom, "dd/MM/yyyy", null); if (String.IsNullOrEmpty(strLogDateto)) throw this.CreateException(new Exception(), "Please input end log date."); else if (!DateTime.TryParseExact(strLogDateto, "dd/MM/yyyy", null, DateTimeStyles.None, out dteReportto)) throw this.CreateException(new Exception(), "Invalid end log date."); else dteReportto = DateTime.ParseExact(strLogDateto, "dd/MM/yyyy", null); if (dteReportto < dteReportfrom) throw this.CreateException(new Exception(), "Start log date must before end log date."); var limits = from limit in ctpyLimit join ctpy in ctpys on limit.CTPY_ID equals ctpy.ID select new { LIMIT_ID = limit.ID, CTPY_ID = ctpy.ID, SNAME = ctpy.SNAME, LIMIT = limit.MA_LIMIT.LABEL }; log = log.Where(l => l.LOG_DATE.Date >= dteReportfrom.Date && l.LOG_DATE.Date <= dteReportto.Date); if (strEvent != "-1") log = log.Where(p => p.EVENT == strEvent); var limitAudits = from l in log join user in users on l.LOG.INSERTBYUSERID equals user.ID join c in limits on l.RECORD_ID equals c.LIMIT_ID into templimit from sublimit in templimit.DefaultIfEmpty() join country in countrys on l.RECORD_ID equals country.ID into tempcountry from subcountry in tempcountry.DefaultIfEmpty() orderby l.LOG_DATE select new LimitAuditReportModel { ENTITY = sublimit != null ? sublimit.SNAME : subcountry != null ? subcountry.LABEL : "", ENTITY_ID = sublimit != null ? sublimit.CTPY_ID : (subcountry != null ? subcountry.ID : Guid.Empty), LIMIT = (l.EVENT.Contains("TEMP") ? "TEMP-" : "") + (sublimit != null ? sublimit.LIMIT : "COUNTRY-LIMIT"), //sublimit != null ? sublimit.LIMIT : "Country Limit", USER = user.USERCODE, LOG_DATE = l.LOG_DATE, LOG_DATE_STR = l.LOG_DATE.ToString("dd-MMM-yyyy HH:mm"), DETAIL = l.LOG_DETAIL }; if (Guid.TryParse(strCtpy, out guCtpyID)) { guCtpyID = Guid.Parse(strCtpy); limitAudits = limitAudits.Where(p => p.ENTITY_ID == guCtpyID); } if (Guid.TryParse(strCountry, out guCountryID)) { guCountryID = Guid.Parse(strCountry); limitAudits = limitAudits.Where(t => t.ENTITY_ID == guCountryID); } return limitAudits.ToList(); } catch (DataServicesException ex) { throw this.CreateException(ex, null); } }