public List <string> Calc(ConstructionDataContext context, CalculationTemplate template)
        {
            _template            = template;
            context.Database.Log = Print.PrintLog;
            var fileList = new List <string>();

            foreach (var construction in template.Constructions)
            {
                var list               = context.Constructions.Where(w => w.FileId == construction.Id).ToList();
                var fileName           = Path.Combine(BaseDirectory, $"{Guid.NewGuid()}.xlsx");
                var calculatedFileName = Path.Combine(BaseDirectory, $"{Guid.NewGuid()}.xlsx");
                list.Export(fileName, $"{construction.Name} Calculated");
                using (var excel = new ExcelPackage(new FileInfo(fileName)))
                {
                    ProcessInExcel(excel, context, construction.Id);
                    excel.SaveAs(new FileInfo(calculatedFileName));
                    fileList.Add(calculatedFileName);
                }
            }

            return(fileList);
        }
        public static object GetDataByFileType(ConstructionDataContext context, FileType type)
        {
            switch (type)
            {
            case FileType.BusinessValue:
                return(context.BusinessValues);

            case FileType.BusinessFeature:
                return(context.BusinessFeatures);

            case FileType.CellMapping:
                return(context.CellMappings);

            case FileType.Construction:
                return(context.Constructions);

            case FileType.ConstructionValue:
                return(context.ConstructionValues);

            case FileType.RiskLevel:
                return(context.RiskLevels);
            }
            return(null);
        }
        private File FindFile(ConstructionDataContext context, int fileId)
        {
            var file = context.Files.FirstOrDefault(f => f.Id == fileId);

            return(file);
        }
 public RiskLevel GetRiskLevel(ConstructionDataContext context, double value)
 {
     return(context.RiskLevels.FirstOrDefault(w =>
                                              w.MinValue < value && w.MaxValue >= value && w.FileId == _template.RiskLevel.Id));
 }
 public static bool Exists(ConstructionDataContext context, string fileName, string type)
 {
     return(File.Select(context, fileName, ConvertFileType(type)) != null);
 }
Esempio n. 6
0
 public ConstructionValueEdit(int fileId, ConstructionDataContext context) : base(fileId, context)
 {
 }
Esempio n. 7
0
 public BusinessFeatureEdit(int fileId, ConstructionDataContext context) : base(fileId, context)
 {
 }
 public ExcelDataImportBase(string fileName, string database = "Construction")
 {
     Excel   = new ExcelPackage(new FileInfo(fileName));
     Context = new ConstructionDataContext(database);
 }
 public ExcelDataImportBase(Stream stream, string database = "Construction")
 {
     Excel   = new ExcelPackage(stream);
     Context = new ConstructionDataContext(database);
 }
Esempio n. 10
0
 public FileMgr(ConstructionDataContext context) : base(context)
 {
 }
 public DataEditBase(int fileId, ConstructionDataContext context)
 {
     FileId  = fileId;
     Context = context;
 }
 public CellMappingEdit(int fileId, ConstructionDataContext context) : base(fileId, context)
 {
 }
 public BusinessValueMgr(ConstructionDataContext context) : base(context)
 {
 }
Esempio n. 14
0
 public RiskLevelEdit(int fileId, ConstructionDataContext context) : base(fileId, context)
 {
 }