private void AddColumnInformation(UploadViewFileTab tab, int thisTabType) { foreach (var column in tab.ColumnList) { IngestionColumnType ingestionColumnType = new IngestionColumnType(); int thisColumnType = WhatColumnTypeIsThis(column); if (thisColumnType == 0) { ingestionColumnType = AddColumnTypeToDb(column); thisColumnType = ingestionColumnType.Id; } var thisPairIsAlreadyInWCIWDb = (from x in db.WhichColumnsInWhichTabs where ((x.ColumnID == thisColumnType) && (x.TabID == thisTabType)) select x).Any(); if (!thisPairIsAlreadyInWCIWDb) AddWciwInfoToDb(thisColumnType, thisTabType); // for now we are not adding column info to the db //AddColumnInfoToDb(thisColumnType, column); } }
private List<int> MakeListOfColumnsUsedInThisTab(UploadViewFileTab uploadedTab) { List<int> columnTypeList = WhatColumnTypesAreThese(uploadedTab.ColumnList); if (columnTypeList.Contains(0)) { columnTypeList = new List<int> {0}; } return columnTypeList; }
private int WhatTabTypeIsThis(UploadViewFileTab uploadedTab) { // need to get a list of all the columns by type used in this tab List<int> listOfColumnTypesUsedInThisTab = MakeListOfColumnsUsedInThisTab(uploadedTab); // if none of those are a new column type (columntypeID == 0) if (listOfColumnTypesUsedInThisTab.Contains(0)) return 0; // then get a list of all the tab types from the WCIW db that use just those columns List<int> listOfPossibleTabTypes = MakeListOfTabTypesThatUseJustTheseColumns(listOfColumnTypesUsedInThisTab); if (listOfPossibleTabTypes.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 listOfPossibleTabTypes.First(); }
private IngestionTabType AddTabTypeToDb(UploadViewFileTab tab) { string uniqueTabTypeName = MakeUniqueTabTypeName(tab.TabName); IngestionTabType ingestionTabType = new IngestionTabType { IngestionTabTypeName = uniqueTabTypeName, HeaderRow = tab.HeaderRow, NumberOfDataColumns = tab.ColumnList.Count }; db.IngestionTabTypes.Add(ingestionTabType); db.SaveChanges(); return ingestionTabType; }
private void AddTabInfoToDb(int newTabType, UploadViewFileTab tab) { string tabName = tab.TabName; IngestionTabInfo uploadedTabInfo = new IngestionTabInfo { IngestionTabType = newTabType, IngestionTabName = tabName }; db.IngestionTabInfoes.Add(uploadedTabInfo); db.SaveChanges(); }