Пример #1
0
 public static string UpdateCalibrationEadBehaviouralTerm(CalibrationResultBehaviouralTerm input)
 {
     return($"Update [CalibrationResult_EAD_Behavioural_Terms] " +
            $" set Assumption_Expired = {input.Expired}, " +
            $" Assumption_NonExpired = {input.NonExpired} " +
            $" where CalibrationId = (select top 1 id from CalibrationRunEadBehaviouralTerms where OrganizationUnitId = {input.AffiliateId} and [Status] = 7);");
 }
        public List <CalibrationResultBehaviouralTerm> ReadFromExcel()
        {
            var dataList = new List <CalibrationResultBehaviouralTerm>();
            var filePath = $"{Path.Combine(_dataAccess.GetFilePath(), "AssumptionTemplate.xlsx")}";

            ExcelPackage.LicenseContext = LicenseContext.NonCommercial;
            using (var package = new ExcelPackage(new FileInfo(filePath)))
            {
                ExcelWorksheet worksheet = package.Workbook.Worksheets[1];
                int            rows      = worksheet.Dimension.Rows;

                for (int i = 2; i <= rows; i++)
                {
                    var AffiliateId = worksheet.Cells[i, 1].Value;
                    var Expired     = worksheet.Cells[i, 2].Value;
                    var NonExpired  = worksheet.Cells[i, 3].Value;

                    if (AffiliateId == null)
                    {
                        //Console.WriteLine("Row is empty: " + i.ToString());
                    }
                    else if (string.IsNullOrWhiteSpace(AffiliateId.ToString()))
                    {
                        //Console.WriteLine("Row is empty: " + i.ToString());
                    }
                    else
                    {
                        var data = new CalibrationResultBehaviouralTerm();
                        try { data.AffiliateId = Convert.ToInt64(AffiliateId); } catch { data.AffiliateId = -1; }
                        try { data.Expired = Convert.ToDouble(Expired); } catch { data.Expired = 0.0; }
                        try { data.NonExpired = Convert.ToDouble(NonExpired); } catch { data.NonExpired = 0.0; }

                        dataList.Add(data);
                    }
                }
            }

            return(dataList);
        }