private void Logout() { Console.WriteLine(); try { rt = mid.Logout(SessionID); // call logout if (rt.HasError) { Logger logger = LogManager.GetCurrentClassLogger(); logger.Error(DateTime.Now.ToString() + "\t" + rt.ErrorInfo.ErrorReference + "\t" + rt.ErrorInfo.ErrorText); } else { SessionID = null; // termination accepted - no point to keep old value Console.WriteLine(String.Format("Logout successful.")); } } catch (Exception ex) //catch unexpected stuff that is not able to set "rt" (like network failure) { Logger logger = LogManager.GetCurrentClassLogger(); logger.Error(DateTime.Now.ToString() + "\t" + ex.Message); } finally { //always close once done. // if (mid != null) // mid.Close(); } }
private string Login(string UserName, string Password, string Participant) { string sessionID = String.Empty; Console.WriteLine(); try { /* Call actual login. password is sent in MD5 */ rt = mid.DependLogin(UserName, Utils.MD5(Password), Assembly.GetExecutingAssembly().GetName().Name + " Ver: " + Assembly.GetExecutingAssembly().GetName().Version.ToString(), Participant, out sessionID); if (rt.HasError) { Logger logger = LogManager.GetCurrentClassLogger(); logger.Error(DateTime.Now.ToString() + "\t" + String.Format("Login error: {0}\r\n{1}", rt.ErrorInfo.ErrorReference, rt.ErrorInfo.ErrorText)); } else { Logger logger = LogManager.GetCurrentClassLogger(); logger.Error(DateTime.Now.ToString() + "\t" + String.Format("Login successful.\r\nSessionID:{0}", sessionID)); } } catch (Exception ex) //catch unexpected stuff that is not able to set "rt" (like network failure) { // Console.WriteLine(String.Format("Login exception:\r\n{0}", ex.Message)); Logger logger = LogManager.GetCurrentClassLogger(); logger.Error(DateTime.Now.ToString() + "\t" + "Login exception: \t" + ex.Message); } finally { //always close once done. //if (mid != null) //mid.Close(); } return(sessionID); }
public DataTable GetDataTable(string SessionID, string OperationName, string TableName, int RowCount, string Holderfilter, out string schema, out byte[] bs) { DataTable Table = new DataTable(); schema = null; bs = null; try { rt = mid.DataSetListZIP(SessionID, OperationName, RowCount, Holderfilter, out schema, out bs); if (rt.HasError) { Logger logger = LogManager.GetCurrentClassLogger(); logger.Error(DateTime.Now.ToString() + "\t" + rt.ErrorInfo.ErrorReference + "\t" + rt.ErrorInfo.ErrorText); } else { DataSet opListDS = Utils.unZipDS(bs, schema); //opListDS.WriteXml(@"C:\data\DEPOOPMEMBER.xml"); Table = opListDS.Tables[TableName]; } } catch (Exception ex) { Logger logger = LogManager.GetCurrentClassLogger(); logger.Error(DateTime.Now.ToString() + "\t" + ex.Message); } return(Table); }
private List <Commitments> GetCommitments(string SessionID, string OpName, int RowCount, string Commitmentfilter, out string schema, out byte[] bs, DateTime StartDate, DateTime EndDate) { int Postiveperiod = Properties.Settings.Default.SettlementPeriod; int Negperiod = Postiveperiod * (-1); //EndDate = EndDate.AddDays(Properties.Settings.Default.SettlementPeriod); EndDate = Utils.AddBusinessDays(EndDate, Postiveperiod); List <Commitments> CommitmentList = new List <Commitments>(); rt = mid.DataSetListZIP(SessionID, OpName, RowCount, Commitmentfilter, out schema, out bs); if (rt.HasError) // lets see what server thinks about that { Logger logger = LogManager.GetCurrentClassLogger(); logger.Error(DateTime.Now.ToString() + "\t" + rt.ErrorInfo.ErrorReference + "\t" + rt.ErrorInfo.ErrorText); } else { DataSet opListDS = Utils.unZipDS(bs, schema); DataTable CommitmentDT = opListDS.Tables["LIST_COMMIT"]; try { var commitmentlist = from commitment in CommitmentDT.AsEnumerable() .Where(t => t.Field <DateTime>("COMMIT_DATE") >= StartDate && t.Field <DateTime>("COMMIT_DATE") <= EndDate) select new { CommitmentID = commitment.Field <int>("COMMIT_PARENT"), CommitmentDate = commitment.Field <DateTime?>("COMMIT_DATE"), CommitmentDesc = commitment.Field <string>("COMTYP_DESCRIPTION"), //ComTypeDesc = commitment.Field<string>("COMTYP_DESCRIPTION"), CommitmentQty = commitment.Field <decimal?>("COMMIT_QTY"), IsinID = commitment.Field <int?>("ISIN_ID"), IsinCode = commitment.Field <string>("ISIN_CODE"), IsinShortName = commitment.Field <string>("ISIN_SHORT_NAME"), IsinFullName = commitment.Field <string>("ISIN_FULL_NAME"), Account_Reference = commitment.Field <string>("ACCOUNT_REFERENCE") }; foreach (var c in commitmentlist.ToList()) { Commitments commitments = new Commitments(); int CommittmentDate = Convert.ToInt32(Utils.AddBusinessDays(Convert.ToDateTime(c.CommitmentDate), Negperiod).ToString("yyyyMMdd")); commitments.Account_Reference = c.Account_Reference.ToString(); commitments.CommitmentDate = CommittmentDate; commitments.CommitmentDesc = c.CommitmentDesc; commitments.CommitmentID = c.CommitmentID.ToString(); commitments.CommitmentQty = (decimal)c.CommitmentQty; commitments.IsinCode = c.IsinCode; commitments.IsinFullName = c.IsinFullName; commitments.IsinID = (Int32)c.IsinID; commitments.IsinShortName = c.IsinShortName; CommitmentList.Add(commitments); } } catch (Exception ex) { Logger logger = LogManager.GetCurrentClassLogger(); logger.Error(DateTime.Now.ToString() + "\t" + ex.Message); } } return(CommitmentList); }
private IEnumerable <Transaction> GetTransactions(string AccountNumber, string StartDate, string EndDate) { byte[] bs; string schema; string StartdateTemplate = Properties.Settings.Default.StartDate_Template.ToString(); string EnddateTemplate = Properties.Settings.Default.EndDate_Template.ToString(); string TimeZone = Properties.Settings.Default.TimeInfo.ToString(); string strtDate = StartDate + TimeZone; string edDate = EndDate + TimeZone; string TransQuery = Properties.Settings.Default.LIST_TRANSACTION_QUERY.ToString(); string ISINQuery = Properties.Settings.Default.LIST_ISIN_QUERY.ToString(); string TransactionOperationName = Properties.Settings.Default.LIST_TRANSACTION_OPNAME.ToString(); string TransactionTableName = Properties.Settings.Default.LIST_TRANSACTION_TABLE.ToString(); int RowCount = 10; RowCount = Properties.Settings.Default.DEFAULT_ROW_COUNT; StartDate = StartDate.Insert(6, "-"); StartDate = StartDate.Insert(4, "-"); StartDate = string.Format(StartdateTemplate, StartDate); EndDate = EndDate.Insert(6, "-"); EndDate = EndDate.Insert(4, "-"); EndDate = string.Format(EnddateTemplate, EndDate); DateTime Start = DateTime.Parse(StartDate); DateTime End = DateTime.Parse(EndDate); string TemplateFileName = HttpContext.Current.Server.MapPath("~/" + TransQuery); string Transfilter = FileToString(TemplateFileName); Transfilter = Transfilter.Replace("@ACCOUNT_REFERENCE", AccountNumber); TemplateFileName = HttpContext.Current.Server.MapPath("~/" + ISINQuery); string ISINfilter = FileToString(TemplateFileName); List <ISINClass> ISINList = null; List <Transaction> TransactionList = new List <Transaction>(); List <Commitments> CommitmentList = new List <Commitments>(); try { rt = mid.DataSetListZIP(SessionID, TransactionOperationName, RowCount, Transfilter, out schema, out bs); if (rt.HasError) // lets see what server thinks about that { Logger logger = LogManager.GetCurrentClassLogger(); logger.Error(DateTime.Now.ToString() + "\t" + rt.ErrorInfo.ErrorReference + "\t" + rt.ErrorInfo.ErrorText); } else { DataSet opListDS = Utils.unZipDS(bs, schema); DataTable Transactions = opListDS.Tables[TransactionTableName]; string expression = null; //Get Symbols schema = null; bs = null; rt = null; rt = mid.DataSetListZIP(SessionID, "LIST_ISIN.1", RowCount, ISINfilter, out schema, out bs); if (rt.HasError) { Logger logger = LogManager.GetCurrentClassLogger(); logger.Error(DateTime.Now.ToString() + "\t" + rt.ErrorInfo.ErrorReference + "\t" + rt.ErrorInfo.ErrorText); } else { opListDS = Utils.unZipDS(bs, schema); DataTable ISINS = opListDS.Tables["LIST_ISIN"]; try { ISINList = DependAPIOperation.GetInstruments(ISINS); } catch (Exception ex) { ISINList = null; Logger logger = LogManager.GetCurrentClassLogger(); logger.Error(DateTime.Now.ToString() + "\t" + ex.Message); } } string Commitmentfilter = null; try { Commitmentfilter = FileToString(HttpContext.Current.Server.MapPath("~/" + Properties.Settings.Default.LIST_COMMIT_QUERY.ToString())); string AccountID = AccountNumber.Substring(0, AccountNumber.Length - 1); Commitmentfilter = Commitmentfilter.Replace("@ACCOUNT_ID", AccountID); } catch (Exception exp) { Commitmentfilter = ""; } string CommittmentOpName = Properties.Settings.Default.LIST_COMMIT_OPNAME.ToString(); //List<Commitments> commitmentslist CommitmentList = GetCommitments(SessionID, CommittmentOpName, RowCount, Commitmentfilter, out schema, out bs, Start, End); var TransList = from Trans in Transactions.AsEnumerable() .Where(t => t.Field <DateTime>("BALCHANGE_DATE") >= Start && t.Field <DateTime>("BALCHANGE_DATE") <= End) select new { TransactionID = Trans.Field <int>("TRANS_ID"), TransactionQty = Trans.Field <decimal>("BALCHANGE_QTY"), TransactionISIN = Trans.Field <int?>("BALCHANGE_ISIN"), TransactionAccount = Trans.Field <int?>("BALCHANGE_ACCOUNT"), TransactionDate = Trans.Field <DateTime?>("BALCHANGE_DATE"), TransactionType = Trans.Field <string>("TRANS_TYPE"), TransactionTypeDesc = Trans.Field <string>("TRANTYPE_DESCRIPTION"), ISINCode = Trans.Field <string>("ISIN_CODE"), ISINSHORTName = Trans.Field <string>("ISIN_SHORT_NAME"), TransactionPrice = Trans.Field <decimal?>("TRANS_PRICE"), TransactionValue = Trans.Field <decimal?>("TRANS_VALUE"), BalTimeBal = Trans.Field <decimal?>("BALTIME_BALANCE"), BrokerCode = Trans.Field <string>("TRANS_BROKER"), TransactionMatch = Trans.Field <int?>("TRANS_MATCH") }; foreach (var Trans in TransList.ToList()) { Transaction transaction = new Transaction(); transaction.AccountReference = AccountNumber.Trim(); transaction.TransactionID = Trans.TransactionID; transaction.TransactionPrice = Trans.TransactionPrice == null ? null : Trans.TransactionPrice; transaction.TransactionValue = Trans.TransactionValue == null ? null : Trans.TransactionValue; transaction.TransactionVolume = Trans.TransactionQty; transaction.BrokerCode = Trans.BrokerCode; transaction.TransactionTypeID = Trans.TransactionType; transaction.InstrumentCode = Trans.ISINSHORTName; transaction.InstrumentISINCode = Trans.ISINCode; transaction.Available = Trans.BalTimeBal; transaction.Owned = Trans.BalTimeBal; transaction.TradeDate = Convert.ToInt32(Convert.ToDateTime(Trans.TransactionDate).ToString("yyyyMMdd")); /* Should be Removed. */ transaction.BrokerID = ""; transaction.BrokerCode = ""; transaction.BrokerName = ""; if (ISINList == null || ISINList.Count == 0) { transaction.InstrumentName = ""; } else { try { string IsINName = ISINList.First(a => a.ISIN_CODE == transaction.InstrumentISINCode).ISIN_FULL_NAME; transaction.InstrumentName = IsINName; } catch (Exception ex) { Logger logger = LogManager.GetCurrentClassLogger(); logger.Error(DateTime.Now.ToString() + "\t" + ex.Message); transaction.InstrumentName = ""; } } transaction.TransactionDate = Convert.ToInt32(Convert.ToDateTime(Trans.TransactionDate).ToString("yyyyMMdd")); transaction.TransactionDescription = Trans.TransactionTypeDesc.ToString(); TransactionList.Add(transaction); } } } catch (Exception ex) { Logger logger = LogManager.GetCurrentClassLogger(); logger.Error(DateTime.Now.ToString() + "\t" + ex.Message); } finally { mid.Close(); } //Merging List return(MergeTransactionAndCommitment(TransactionList, CommitmentList)); // return TransactionList; }
private ClientPortfolio GetTransactions(string AccountNumber, string StartDate, string EndDate) { byte[] bs; string schema; string TimeZone = Properties.Settings.Default.TimeInfo.ToString(); string strtDate = StartDate + TimeZone; string edDate = EndDate + TimeZone; string fileName = Properties.Settings.Default.LIST_TRANSACTION_QUERY.ToString(); int RowCount = 10; RowCount = Properties.Settings.Default.DEFAULT_ROW_COUNT; string TemplateFileName = HttpContext.Current.Server.MapPath("~/" + fileName); string filter = FileToString(TemplateFileName); filter = filter.Replace("@ACCOUNT_REFERENCE", AccountNumber); filter = filter.Replace("@StartDate", strtDate); filter = filter.Replace("@EndDate", edDate); ClientPortfolio clientPortfolio = new ClientPortfolio(); List <InstrumentInfo> instrumentInfoList = new List <InstrumentInfo>(); BrokerInfo brokerInfo = new BrokerInfo(); AccountDetails accountDetails = new AccountDetails(); try { rt = mid.DataSetListZIP(SessionID, "LIST_TRANSACTION.1", RowCount, filter, out schema, out bs); if (rt.HasError) // lets see what server thinks about that { Logger logger = LogManager.GetCurrentClassLogger(); logger.Error(DateTime.Now.ToString() + "\t" + rt.ErrorInfo.ErrorReference + "\t" + rt.ErrorInfo.ErrorText); } else { /* unzip output from server */ DataSet opListDS = Utils.unZipDS(bs, schema); DataTable Transacitons = opListDS.Tables["LIST_TRANSACTION"]; var TransactionList = from Trans in Transacitons.AsEnumerable() select new { TransactionID = Trans.Field <int>("TRANS_ID"), TransactionQty = Trans.Field <decimal>("BALCHANGE_QTY"), TransactionISIN = Trans.Field <int?>("BALCHANGE_ISIN"), TransactionAccount = Trans.Field <int?>("BALCHANGE_ACCOUNT"), TransactionDate = Trans.Field <DateTime?>("BALCHANGE_DATE"), TransactionTypeDesc = Trans.Field <string>("TRANTYPE_DESCRIPTION"), ISINCode = Trans.Field <string>("ISIN_CODE"), TransactionPrice = Trans.Field <decimal?>("TRANS_PRICE"), TransactionValue = Trans.Field <decimal?>("TRANS_VALUE"), // Name = Trans.Field<string>("NAME_BLOCK_1"), BrokerName = Trans.Field <string>("TRANS_BROKER"), BrokerCode = Trans.Field <string>("TRANS_BROKER"), TransactionMatch = Trans.Field <int?>("TRANS_MATCH") }; } } catch (Exception ex) { Logger logger = LogManager.GetCurrentClassLogger(); logger.Error(DateTime.Now.ToString() + "\t" + ex.Message); } finally { mid.Close(); } return(clientPortfolio); }
private ClientPortfolio GetListOperations(string AccountNumber, string StartDate, string EndDate) { byte[] bs; string schema; string TimeZone = Properties.Settings.Default.TimeInfo.ToString(); string strtDate = StartDate + TimeZone; string edDate = EndDate + TimeZone; string fileName = Properties.Settings.Default.REP_REGADVICE_QUERY.ToString(); string OperationName = Properties.Settings.Default.REP_REGADVICE_OPNAME.ToString(); int RowCount = 10; RowCount = Properties.Settings.Default.DEFAULT_ROW_COUNT; string TemplateFileName = HttpContext.Current.Server.MapPath("~/" + fileName); string filter = FileToString(TemplateFileName); filter = filter.Replace("@AccountReference", AccountNumber); filter = filter.Replace("@StartDate", strtDate); filter = filter.Replace("@EndDate", edDate); ClientPortfolio clientPortfolio = new ClientPortfolio(); List <InstrumentInfo> instrumentInfoList = new List <InstrumentInfo>(); BrokerInfo brokerInfo = new BrokerInfo(); AccountDetails accountDetails = new AccountDetails(); try { rt = mid.DataSetListZIP(SessionID, OperationName, RowCount, filter, out schema, out bs); if (rt.HasError) // lets see what server thinks about that { Logger logger = LogManager.GetCurrentClassLogger(); logger.Error(DateTime.Now.ToString() + "\t" + rt.ErrorInfo.ErrorReference + "\t" + rt.ErrorInfo.ErrorText); } else { /* unzip output from server */ DataSet opListDS = Utils.unZipDS(bs, schema); DataTable Balances = opListDS.Tables["BALANCE"]; DataTable Balchange = opListDS.Tables["BALCHANGE"]; DataTable ISIN = opListDS.Tables["ISIN"]; DataTable TranTypes = opListDS.Tables["CONFIG_TRANSACTION_TYPE"]; decimal NetActivity = 0.0M; var balanceList = from Balance in Balances.AsEnumerable() select new { BalanceAccount = Balance.Field <int>("BALANCE_ACCOUNT"), AccountReference = Balance.Field <string>("ACCOUNT_REFERENCE"), StartPledge = Balance.Field <decimal?>("BALTIME_PLEDGED_OPEN") == null ? 0 : Balance.Field <decimal?>("BALTIME_PLEDGED_OPEN"), EndingPledge = Balance.Field <decimal?>("BALTIME_PLEDGED_CLOSE") == null ? 0 : Balance.Field <decimal?>("BALTIME_PLEDGED_CLOSE"), Price = Balance.Field <decimal?>("PHIST_CLOSE") == null ? 0 : Balance.Field <decimal?>("PHIST_CLOSE"), // Value = Balance.Field<decimal?>("PHIST_CLOSE") == null ? 0 : Balance.Field<decimal?>("PHIST_CLOSE") * Balance.Field<decimal?>("BALTIME_BALANCE_CLOSE") ,//== null ? 0 : Balance.Field<decimal?>("BALTIME_BALANCE_CLOSE"), Value = Balance.Field <decimal?>("PHIST_CLOSE") * Balance.Field <decimal?>("BALTIME_BALANCE_CLOSE"), //== null ? 0 : Balance.Field<decimal?>("BALTIME_BALANCE_CLOSE"), ISINCCY = Balance.Field <string>("PHIST_CCY"), Name = Balance.Field <string>("NAME_BLOCK_1"), BrokerName = Balance.Field <string>("DEPOPART_NAME"), BrokerCode = Balance.Field <string>("DEPOPART_CODE"), BalCarriedForward = Balance.Field <decimal?>("BALTIME_BALANCE_CLOSE"), BalBroughtForward = Balance.Field <decimal?>("BALTIME_BALANCE_OPEN"), ISIN = Balance.Field <int?>("BALANCE_ISIN"), ISIN_CCY = Balance.Field <string>("PHIST_CCY") }; List <InstrumentInfo> InstrumentInfoList = new List <InstrumentInfo>(); NetActivity = 0; foreach (var b in balanceList.ToList()) { brokerInfo.BrokerCode = b.BrokerCode; brokerInfo.BrokerName = b.BrokerName; accountDetails.Name = b.Name; accountDetails.Account = b.AccountReference.ToString(); InstrumentInfo InstrInfo = new InstrumentInfo(); InstrInfo.InstrumentISINCode = b.ISIN.ToString(); //Get Balance Data var BalChange = from Balch in Balchange.AsEnumerable() where Balch.Field <int>("BALCHANGE_ACCOUNT") == b.BalanceAccount && Balch.Field <int>("BALCHANGE_ISIN") == b.ISIN && Balch.Field <string>("TRANS_CCY") == b.ISINCCY /* No records will be returned if there is a transaction without currency */ select new { TransactionID = Balch.Field <int>("Trans_ID"), TransactionType = Balch.Field <string>("Trans_Type"), TransactionDate = Balch.Field <DateTime>("BALCHANGE_DATE"), TransactonQty = Balch.Field <decimal?>("BALCHANGE_QTY"), TransactonCurr = Balch.Field <string>("TRANS_CCY") }; //GetInstruments Header var Instrument = from isin in ISIN.AsEnumerable() where isin.Field <int>("ISIN_ID") == b.ISIN select new { ISINID = isin.Field <int>("ISIN_ID"), ISIN_Code = isin.Field <string>("ISIN_CODE"), ISIN_CCY = isin.Field <string>("ISIN_CCY"), ISIN_FULL_NAME = isin.Field <string>("ISIN_FULL_NAME"), ISIN_SHORT_NAME = isin.Field <string>("ISIN_SHORT_NAME") }; InstrInfo.InstrumentISINCode = b.ISIN.ToString(); foreach (var inst in Instrument.ToList()) { InstrInfo.InstrumentISINCode = inst.ISIN_Code; InstrInfo.InstrumentCode = inst.ISIN_SHORT_NAME.ToString(); InstrInfo.InstrumentName = inst.ISIN_FULL_NAME.ToString(); InstrInfo.ISINCurrency = inst.ISIN_CCY.ToString(); } //Get Transaction Details ----------------------------------------------------Balchange -------------------------------------------------------------- NetActivity = 0; List <TransactionActivity> TransActivityList = new List <TransactionActivity>(); foreach (var bal in BalChange.ToList()) { TransactionActivity TransActivity = new TransactionActivity(); TransActivity.TransactionDate = bal.TransactionDate.ToString("yyyy-MM-dd"); TransActivity.TransactionID = bal.TransactionID.ToString(); TransActivity.TransCurrency = bal.TransactonCurr; TransActivity.Quantity = bal.TransactonQty.ToString(); NetActivity = NetActivity + Convert.ToDecimal(TransActivity.Quantity); var TransType = from TranType in TranTypes.AsEnumerable() where TranType.Field <string>("TRANTYPE") == bal.TransactionType select new { TranType = TranType.Field <string>("TRANTYPE"), TranDesc = TranType.Field <string>("TRANTYPE_DESCRIPTION") }; foreach (var Tran in TransType.ToList()) { TransActivity.TransType = Tran.TranDesc; } TransActivityList.Add(TransActivity); } // InstrInfo.TransactionActivity = TransActivityList; // TransActivityList.GroupBy(x => x.TransactionID).Select(g => g.First()); //InstrInfo.TransactionActivity = TransActivityList.Distinct().ToList(); //InstrInfo.TransactionActivity = InstrInfo.TransactionActivity = TransActivityList.GroupBy(p => p.TransactionID).Select(g => g.First()).ToList(); InstrInfo.BroughtForwardDate = StartDate.ToString(); InstrInfo.CarryForwardDate = EndDate.ToString(); //; InstrInfo.PledgeEndingBalance = b.EndingPledge.ToString(); InstrInfo.PlegeStartingBalance = b.StartPledge.ToString(); InstrInfo.Value = b.Value.ToString().Trim() == "" ? "0" : b.Value.ToString().Trim(); InstrInfo.Price = b.Price.ToString(); InstrInfo.NetActivityAmount = NetActivity.ToString(); InstrInfo.CarryForwardAmount = b.BalCarriedForward.ToString(); InstrInfo.BroughtForwardAmount = b.BalBroughtForward.ToString(); InstrInfo.ISINCurrency = b.ISINCCY; InstrumentInfoList.Add(InstrInfo); } //GrandTotal List <GrandTotal> GrandTotalList = new List <Models.GrandTotal>(); try { var GrandTotal = from t in InstrumentInfoList group t by t.ISINCurrency into g select new { ISINCurrency = g.Key, totalAmount = g.Sum(a => (decimal.Parse(a.Value))) // blanks will be treated as 0 }; foreach (var g in GrandTotal.ToList()) { GrandTotal grandTotal = new GrandTotal(); grandTotal.GrandTotalCurrency = g.ISINCurrency; grandTotal.GrandTotalAmount = g.totalAmount.ToString(); GrandTotalList.Add(grandTotal); } } catch (Exception ex) { Logger logger = LogManager.GetCurrentClassLogger(); logger.Error(DateTime.Now.ToString() + "\t" + ex.Message); } clientPortfolio.GrandTotal = GrandTotalList; clientPortfolio.AccountDetails = accountDetails; clientPortfolio.Broker = brokerInfo; clientPortfolio.InstrumentInfo = InstrumentInfoList; } } catch (Exception ex) { Logger logger = LogManager.GetCurrentClassLogger(); logger.Error(DateTime.Now.ToString() + "\t" + ex.Message); //Console.WriteLine(String.Format("Operations list exception:\r\n{0}", ex.Message)); } finally { //always close once done. //if (mid != null) // mid.Close(); } return(clientPortfolio); }