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();
        }
Exemple #2
0
        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);
                }
            }
        }
Exemple #3
0
        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:");
                }
            }
        }