Beispiel #1
0
        public async Task ExecuteCommitsAsync(IEnumerable <DateTime> dates, int year, string repositoryPath)
        {
            string filePath = string.Format(FILE_PATH_BASE, repositoryPath, year);

            fileService.Create(filePath);

            using var powerShell = PowerShell.Create();
            int progressCount = 1;

            foreach (var date in dates)
            {
                await fileService.AppendAsync(filePath, date.ToString());

                await powerShell
                .AddCommands(
                    gitCommand.CommitterDate(date),
                    gitCommand.ChangeDir(repositoryPath),
                    gitCommand.Checkout("master"),
                    gitCommand.Add(),
                    gitCommand.Commit(date))
                .ThenInvokeAndClearCommandsAsync();

                Console.WriteLine($"Processed { progressCount++ } / { dates.Count() } commits");
            }

            await powerShell
            .AddCommands(gitCommand.Push())
            .ThenInvokeAndClearCommandsAsync();
        }
Beispiel #2
0
        /// <summary>
        /// Saves the changes in CSV file in a mode which was selected by user
        /// (Rewrite, append w/o header string, append w header string)
        /// </summary>
        private async void SaveFile(object sender, EventArgs e)
        {
            string filePath = filePathTextBox.Text;

            try
            {
                Close();

                Process.SetInitialStatus("Открываем файл");
                CSVService.UpdateFilePath(filePathTextBox.Text);
                IFileService <TunnelExit> csvService = CSVService.CSVServiceObject;

                Process.UpdateStatus("Записываем в файл");
                if (rewriteFileRadioBtn.IsChecked == true)
                {
                    await csvService.RewriteAsync(TunnelExits);
                }
                else
                {
                    await csvService.AppendAsync(TunnelExits, false);
                }

                Process.SetFinalStatus("Файл перезаписан", true);
            }
            catch (UnauthorizedAccessException ex)
            {
                HandleSaveFileException(ex);
            }
            catch (IOException ex)
            {
                HandleSaveFileException(ex);
            }
            catch (Exception ex)
            {
                HandleSaveFileException(ex);
            }
        }