public static object SendFIReport(SessionInfo sessioninfo, string IDs) { try { string[] TrnsID = IDs.Split(','); DealBusiness _dealBusiness = new DealBusiness(); LookupBusiness _lookupBusiness = new LookupBusiness(); MA_TBMA_CONFIG config = _lookupBusiness.GetTBMAConfig(sessioninfo); Guid productID = _lookupBusiness.GetProductAll().FirstOrDefault(p => p.LABEL == ProductCode.BOND.ToString()).ID; List<DA_TRN> trns = _dealBusiness.GetDealInternalByProcessDate(sessioninfo.Process.CurrentDate) .Where(a => a.PRODUCT_ID.Value == productID && TrnsID.Contains(a.ID.ToString()) && a.DA_TMBA_EXTENSION.SEND_DATE == null).ToList(); var validateTBMA_NAME = (from o1 in trns where string.IsNullOrEmpty(o1.MA_COUTERPARTY.TBMA_NAME) select o1.MA_COUTERPARTY.SNAME).Distinct().ToArray(); //verify required info if (validateTBMA_NAME.Length > 0) { throw CreateException(new Exception(), "TBMA_NAME can't be empty. Please input TBMA_NAME on counterparty " + string.Join(",", validateTBMA_NAME)); } if (config == null) throw CreateException(new Exception(), "Cannot get configurations. Please contact administrator"); foreach (DA_TRN trn in trns) { _dealBusiness.CreatingTBMAReportFile(sessioninfo, trn, config); } Guid[] TrnsIDSend = trns.Select(t => t.ID).ToArray(); _dealBusiness.UpdateFISendReport(sessioninfo, TrnsIDSend); return new { Result = "OK", Message = String.Format("Sending report completed") }; } catch (Exception ex) { return new { Result = "ERROR", Message = ex.Message }; } }
public static List<FIDealModel> GetDealInternalByProcessDate(SessionInfo sessioninfo) { DealBusiness _dealBusiness = new DealBusiness(); UserBusiness _userBusiness = new UserBusiness(); LookupBusiness _lookupBusiness = new LookupBusiness(); List<MA_CURRENCY> ccys = _lookupBusiness.GetCurrencyAll(); List<MA_USER> users = _userBusiness.GetAll(); Guid productID = _lookupBusiness.GetProductAll().FirstOrDefault(p => p.LABEL == ProductCode.BOND.ToString()).ID; List<DA_TRN> trns = _dealBusiness.GetDealInternalByProcessDate(sessioninfo.Process.CurrentDate); return (from t in trns.Where(a => a.PRODUCT_ID.Value == productID && a.DA_TMBA_EXTENSION != null) join user in users on t.LOG.INSERTBYUSERID equals user.ID into ljuser from inputuser in ljuser.DefaultIfEmpty() join tempccy1 in ccys on t.FIRST.CCY_ID equals tempccy1.ID into ljccy1 from ccy1 in ljccy1.DefaultIfEmpty() join tbmauser in users on t.DA_TMBA_EXTENSION.SENDER_ID equals tbmauser.ID into ljtbmauser from tbmainputuser in ljtbmauser.DefaultIfEmpty() orderby t.LOG.INSERTDATE descending select new FIDealModel { ID = t.ID, DMK_NO = t.INT_DEAL_NO, OPICS_NO = t.EXT_DEAL_NO, InsertState = t.MA_STATUS.LABEL == StatusCode.CANCELLED.ToString() ? "Cancelled" : t.DA_TMBA_EXTENSION.SEND_DATE != null ? "Sent" : 1800 - DateTime.Now.Subtract(t.LOG.INSERTDATE).TotalSeconds <=0 ? "Late" : (1800 - Math.Round( DateTime.Now.Subtract(t.LOG.INSERTDATE).TotalSeconds)).ToString() , TradeDate = t.TRADE_DATE.Value, MaturityDate = t.MATURITY_DATE, Instrument = t.MA_INSRUMENT.LABEL, BuySell = t.FLAG_BUYSELL, Portfolio = t.MA_PORTFOLIO.LABEL, Counterparty = t.MA_COUTERPARTY.SNAME, Yield = t.FIRST.RATE.Value, GrossValue = t.FIRST.NOTIONAL.Value, CCY = ccy1 != null ? ccy1.LABEL : null, Trader = inputuser != null ? inputuser.USERCODE : null, Status = t.MA_STATUS.LABEL, PCE = t.KK_CONTRIBUTE.HasValue ? t.KK_CONTRIBUTE.Value : 0, Sender = tbmainputuser != null ? tbmainputuser.USERCODE : null, Unit = t.DA_TMBA_EXTENSION != null ? t.DA_TMBA_EXTENSION.UNIT : 0, CleanPrice = t.DA_TMBA_EXTENSION != null ? t.DA_TMBA_EXTENSION.CLEAN_PRICE : 0, GrossPrice = t.DA_TMBA_EXTENSION != null ? t.DA_TMBA_EXTENSION.GROSS_PRICE : 0, YieldType = t.DA_TMBA_EXTENSION != null ? t.DA_TMBA_EXTENSION.YIELD_TYPE : string.Empty, ReporyBy = t.DA_TMBA_EXTENSION != null ? t.DA_TMBA_EXTENSION.IS_REPORT_CLEAN ? "Clean Price" : "Gross Price" : string.Empty, Purpose = t.DA_TMBA_EXTENSION != null ? t.DA_TMBA_EXTENSION.PURPOSE : string.Empty, Term = t.DA_TMBA_EXTENSION != null && t.DA_TMBA_EXTENSION.TERM.HasValue ? t.DA_TMBA_EXTENSION.TERM.Value : 0, Rate = t.DA_TMBA_EXTENSION != null && t.DA_TMBA_EXTENSION.RATE.HasValue ? t.DA_TMBA_EXTENSION.RATE.Value : 0, TBMA_Remark = t.DA_TMBA_EXTENSION != null ? t.DA_TMBA_EXTENSION.REMARK : string.Empty, SendTime = t.DA_TMBA_EXTENSION != null ? t.DA_TMBA_EXTENSION.SEND_DATE.HasValue ? t.DA_TMBA_EXTENSION.SEND_DATE.Value.ToString("dd MMM yyy HH:mm") : string.Empty : string.Empty, PrimaryMarket = t.FLAG_PCE.Value ? "Yes" : "No", NonDVP = t.FLAG_SETTLE.Value ? "Yes" : "No" }).ToList(); }