Exemple #1
0
        public void UpdateTradesForTradeids(string fileName)
        {
            _logger.LogInformation("UpdateTradesForTradeids method called");
            string tradeIds = "";

            _logger.LogInformation("converting received file to datatable");
            try
            {
                _logger.LogInformation("File name to convert into datatable is " + fileName);

                DataTable reportFile = ExcelToDataSet.CreateDataTable(fileName).Tables[0];
                _logger.LogInformation("converted successfully");
                _logger.LogInformation("no of rows in a file are : " + reportFile.Rows.Count);
                foreach (DataRow row in reportFile.Rows)
                {
                    _logger.LogInformation("Entered into foreach block and Checking for matched as confirmation status for every row in a file.");
                    string confirmationstatus = row.Field <string>("ConfirmationStatus");
                    _logger.LogInformation("Checking for matched as confirmation status , confirmation status of row in a file is : " + confirmationstatus);

                    if (confirmationstatus.Equals("Matched") || confirmationstatus.Equals("Confirmed"))
                    {
                        _logger.LogInformation("Confirmation status of row in a file matched , fetching its id");
                        string id = row.Field <string>("ClientTradeId");
                        _logger.LogInformation("And id is >>" + id);
                        id        = id.Substring(0, 6);
                        tradeIds += id + ",";
                        _logger.LogInformation("Ids in tradeid are >> " + tradeIds);
                    }
                }
                tradeIds = tradeIds.TrimEnd(',');
                _logger.LogInformation("Matched Ids in file: " + fileName + "tradeids are >> " + tradeIds);
            }
            catch (Exception e)
            {
                _logger.LogError("found an exception while converting into datatable" + e);
            }

            try
            {
                try
                {
                    _logger.LogInformation("Calling database update function for trade.trades and trade.additionaltradedatareport.");
                    string date = DateTime.Now.ToString();
                    DBRepository.UpdateVerificationStatus(EODModel.ConnectionString, tradeIds, date);
                    _logger.LogInformation("Database updated successfully");
                }
                catch (Exception e)
                {
                    _logger.LogError("Got exception while updating database for respective tradeids " + e);
                }
            }
            catch (Exception e)
            {
                _logger.LogError("Got exception while checking rows in a loop " + e);
            }
        }