public void AddAndAdaptPlaces() { ConsoleWriter.LogInfo("Enter quantitiesSheet name. Should be 1 word, no spaces"); string quantitiesSheetName = ""; string interchangeablesSheet = ""; string[] sheetsToAddQuantities = { }; try { quantitiesSheetName = ConsoleReader.Read(); ConsoleWriter.LogInfo("Enter interchangeables Sheet name. Should be 1 word, no spaces"); interchangeablesSheet = ConsoleReader.Read(); ConsoleWriter.LogInfo("Enter sheet names for which you want to adapt product places."); sheetsToAddQuantities = ConsoleReader.Read().Split(' '); } catch (Exception) { ConsoleWriter.LogError("input not entered correctly"); } foreach (var sheetName in sheetsToAddQuantities) { try { ExcelManager.AdaptProductsPlace(quantitiesSheetName, sheetName, interchangeablesSheet); } catch (Exception e) { FileLogger.LogError($"-------------------------- Adding Product Places: {sheetName} --------------------------", errorsfilePathToWrite); FileLogger.LogError(e.Message, errorsfilePathToWrite); } } }
public void ReplaceDescription() { string baseSheetName = ""; string[] targetSheets = { }; try { ConsoleWriter.LogInfo("Enter baseSheet name. Should be 1 word, no spaces"); baseSheetName = ConsoleReader.Read(); ConsoleWriter.LogInfo("Enter sheets you want to replace description column with baseSheet's one; names separated by spaces. No empty spaces in sheet names!"); targetSheets = ConsoleReader.Read().Split(' '); } catch (Exception) { ConsoleWriter.LogError("Input not entered correctly"); } foreach (var targetSheetName in targetSheets) { try { ExcelManager.ReplaceGivenColumnWithSourceOne(baseSheetName, targetSheetName, "Description"); } catch (Exception e) { FileLogger.LogError($"-------------------------- DESCRIPTION REPLACEMENT: {targetSheetName} --------------------------", errorsfilePathToWrite); FileLogger.LogError(e.Message, errorsfilePathToWrite); } } }
public void AddOESCode() { ConsoleWriter.LogInfo("Enter baseSheet(source) name. Should be 1 word, no spaces"); string baseSheetName = ""; string[] targetSheets = { }; try { baseSheetName = ConsoleReader.Read(); ConsoleWriter.LogInfo("Enter sheets you want to add OESCode column with baseSheet's one; names separated by spaces. No empty spaces in sheet names!"); targetSheets = ConsoleReader.Read().Split(' '); } catch (Exception) { ConsoleWriter.LogError("input not entered correctly"); } foreach (var targetSheetName in targetSheets) { try { ExcelManager.ReplaceGivenColumnWithSourceOne(baseSheetName, targetSheetName, "OESCode"); } catch (Exception e) { FileLogger.LogError($"-------------------------- OESCode add: {targetSheetName} --------------------------", errorsfilePathToWrite); FileLogger.LogError(e.Message, errorsfilePathToWrite); } } }
public void AdaptDescription() { string[] sheetsToAdaptDescriptionColumn = new string[] { }; try { ConsoleWriter.LogInfo("Enter sheet names you want to adapt the descripton column, separated by spaces. No empty spaces in sheet names!"); sheetsToAdaptDescriptionColumn = ConsoleReader.Read().Split(' '); } catch (Exception) { ConsoleWriter.LogError("sheet names not entered correctly"); } foreach (var sheetName in sheetsToAdaptDescriptionColumn) { try { ExcelManager.AdaptDescription(sheetName); } catch (Exception e) { FileLogger.LogError($"-------------------------- DESCRIPTION ADAPTATION: {sheetName} --------------------------", errorsfilePathToWrite); FileLogger.LogError(e.Message, errorsfilePathToWrite); } } }
static void Main() { string projectDirectory = Directory.GetParent(Directory.GetCurrentDirectory()).Parent.Parent.FullName; string errorsfilePathToWrite = $@"{projectDirectory}\ExcelManagerErrors_{DateTime.Now.ToString("ddMMyy_HHmm")}.txt"; string infofilePathToWrite = $@"{projectDirectory}\ExcelManagerInfo_{DateTime.Now.ToString("ddMMyy_HHmm")}.txt"; ConsoleWriter consoleWriter = new ConsoleWriter(); FileLogger fileLogger = new FileLogger(); ConsoleReader consoleReader = new ConsoleReader(); consoleWriter.LogInfo("enter fileName:"); string filePathName = consoleReader.Read(); //string filePathName = @"D:\my documents\professional\GGG_OnlineShop\ggg\glasses.xlsx"; ExcelManager excelManager = new ExcelManager(fileLogger, infofilePathToWrite, filePathName); Engine engine = new Engine(consoleWriter, fileLogger, consoleReader, filePathName, excelManager, errorsfilePathToWrite, infofilePathToWrite); engine.Startup(); }
public void ReplaceGivenColumnWithSourceOneByGivenColumnMatch() { string baseSheetName = ""; string matchColumn = ""; string columnToReplace = ""; string[] targetSheets = { }; try { ConsoleWriter.LogInfo("Enter baseSheet(source) name. Should be 1 word, no spaces"); baseSheetName = ConsoleReader.Read(); ConsoleWriter.LogInfo("Enter matchColumn(column on which will look for match) name. Should be 1 word, no spaces"); matchColumn = ConsoleReader.Read(); ConsoleWriter.LogInfo("Enter columnToReplace name. Should be 1 word, no spaces"); columnToReplace = ConsoleReader.Read(); ConsoleWriter.LogInfo($"Enter sheets you want to replace {columnToReplace} column with baseSheet's one; names separated by spaces. No empty spaces in sheet names!"); targetSheets = ConsoleReader.Read().Split(' '); } catch (Exception) { ConsoleWriter.LogError("input not entered correctly"); } foreach (var targetSheetName in targetSheets) { try { ExcelManager.ReplaceGivenColumnWithSourceOne(baseSheetName, targetSheetName, columnToReplace, matchColumn, true); } catch (Exception e) { FileLogger.LogError($"-------------------------- {columnToReplace} replace: {targetSheetName} --------------------------", errorsfilePathToWrite); FileLogger.LogError(e.Message, errorsfilePathToWrite); } } }
public void Startup() { ConsoleWriter.LogInfo($"used file: {this.filePathName}"); Help(); ConsoleWriter.LogInfo("Enter command number:"); int command = -1; while (command != 0) { if (int.TryParse(ConsoleReader.Read(), out command)) { switch (command) { case 0: return; case 1: AdaptDescription(); break; case 2: ReplaceDescription(); break; case 3: AddQuantities(); break; case 4: AddInterchangeables(); break; case 5: AddOESCode(); break; case 6: AddAndAdaptPlaces(); break; case 7: ReplaceGivenColumnWithSourceOneByGivenColumnMatch(); break; default: Help(); break; } ConsoleWriter.LogInfo("Enter command number:"); } } }