コード例 #1
0
        private int AddFileInformation(string fileTypeName, UploadViewFile uploadedFile)
        {
            // if it's a new file type add it

            var currentFileTypeNames = new List<string>();
            foreach (string s in (db.IngestionFileTypes.Select(x => x.IngestionFileTypeName)))
                currentFileTypeNames.Add(s);

            int fileTypeID;

            if (currentFileTypeNames.Contains(fileTypeName))
            {
                fileTypeID =
                    (db.IngestionFileTypes.Where(x => x.IngestionFileTypeName == fileTypeName).Select(x => x.Id)).First();
            }
            else
            {
                IngestionFileType ingestionFileType = AddFileTypeToDb(fileTypeName, uploadedFile);
                fileTypeID = ingestionFileType.Id;

            }

            // for now I am not doing any file info stuff
            // just file type stuff

            //string fileName = uploadedFile.FileName;

            //IngestionFileInfo ingestionFileInfo = AddFileInfoToDb(fileTypeID, fileName);

            //int newFileInfoId = ingestionFileInfo.Id;

            return fileTypeID;
        }
コード例 #2
0
        private UploadViewFile HomeIngest(string fileName)
        {
            FileInfo existingFile = new FileInfo(fileName);
            ExcelPackage package = new ExcelPackage(existingFile);

            UploadViewFile uploadedFile = new UploadViewFile
            {
                FileName = existingFile.Name,
                TabList = MakeTabTypeList(package)
            };

            return uploadedFile;
        }
コード例 #3
0
        private int WhatFileTypeIsThis(UploadViewFile uploadedFile)
        {
            // need to get a list of all of the tab types used in this file

            List<int> listOfTabTypesUsedInThisFile = WhatTabTypesAreThese(uploadedFile.TabList);

            if (listOfTabTypesUsedInThisFile.Contains(0)) return 0;

            // now let's make a list of file type that use just those sorts of tabs
            // from the WTIW db

            List<int> listOfpossibleFileTypes = MakeListOfFileTypesThatUseJustTheseTabs(listOfTabTypesUsedInThisFile);

            if (listOfpossibleFileTypes.Count > 1)
            {
                // if there are more than one tabs on that list
                // then figure out what type it is off of that list
                // this should never happen

                throw new Exception();
            }

            return listOfpossibleFileTypes.First();
        }
コード例 #4
0
        private IngestionFileType AddFileTypeToDb(string fileTypeName, UploadViewFile uploadedFile)
        {
            IngestionFileType uploadedFileType = new IngestionFileType
            {
                IngestionFileTypeName = fileTypeName,
                NumberOfTabs = uploadedFile.TabList.Count
            };

            db.IngestionFileTypes.Add(uploadedFileType);
            db.SaveChanges();

            // now that we have added the new file type to the db let's figure out which of its
            // children are new types

            AddTabInformation(uploadedFileType.Id,uploadedFile.TabList);

            return uploadedFileType;
        }