Ejemplo n.º 1
0
        /// <summary>
        /// Сохранить файл
        /// </summary>
        /// <param name="file">Загружаемый файл</param>
        /// <param name="userIdentityid"></param>
        /// <param name="loadType"></param>
        /// <returns>Идентификатор файла в БД</returns>
        public async Task <ImportedFile> SaveImportedFile(HttpPostedFileBase file, int userIdentityid,
                                                          EImportType loadType)
        {
            if (file == null)
            {
                throw new Exception("Входной файл не определен");
            }

            var exchangeFileId = await SaveFile(file.InputStream, file.FileName, userIdentityid);

            using (var context = new ApplicationDbContext())
            {
                //создаем сущность импортированного файла
                var importedFile = new ImportedFile
                {
                    LoadType     = loadType,
                    LoadStatus   = ELoadStatus.InProcess,
                    ExchangeFile = await context.ExchangeFiles.FindAsync(exchangeFileId),
                    Organization =
                        context.Employee.Where(x => x.ApplicationUser.Id == userIdentityid)
                        .Select(x => x.Organization)
                        .FirstOrDefault() ??
                        context.Abonent.Where(x => x.ApplicationUser.Id == userIdentityid)
                        .Select(x => x.Organization)
                        .FirstOrDefault()
                };
                context.ImportedFiles.Add(importedFile);
                await context.SaveChangesAsync();

                return(importedFile);
            }
        }
Ejemplo n.º 2
0
 public ChoixClass(EImportType typ) => Type = typ;
Ejemplo n.º 3
0
        public IEnumerable<ImportItem> GetExportItems(EImportType type)
        {
            return this.ExportList.Where(o =>
            {
                if ((type & EImportType.Order) != 0 && o is IExport2OrderTable)
                    return true;
                else if ((type & EImportType.Trade) != 0 && o is IExport2TradeTable)
                    return true;
                else if ((type & EImportType.Market) != 0 && o is IExport2MarketTable)
                    return true;

                return false;
            });
        }