Esempio n. 1
0
        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 };
                }
        }