Example #1
0
        private bool CheckAndWarnForFileDeletion()
        {
            IUploadService service        = UploadServiceFactory.CreateUploadService(AppParameters);
            var            deletableFiles = service.GetFilesOlderThan(GetEndOfLifeDate()).ToArray();

            if (deletableFiles.Count() > ApplicationConfiguration.WarningTrigger)
            {
                var result =
                    MessageBox.Show(
                        $"{deletableFiles.Length} files of recordings will be deleted when this cycle is finished. Are you sure you want to do this?",
                        "Warning", MessageBoxButtons.YesNo);

                if (CancelIfUnsatisfied(
                        result.Equals(DialogResult.No),
                        "Check the 'keep for' field, you may have entered an incorrect value."))
                {
                    return(true);
                }
            }
            return(false);
        }
Example #2
0
        private void UploadConvertedFile(AudioLog audioLog)
        {
            var uploadService = UploadServiceFactory.CreateUploadService(AppParameters);

            // Retry cycle
            var retryCount = 3;

            for (var i = 0; i < retryCount; i++)
            {
                if (uploadService.TryUploadFile(audioLog))
                {
                    break;
                }
                Logger.Error($"Upload attempt {i + 1} failed");
                if (i >= retryCount)
                {
                    Logger.Error("Failed to upload file");
                }
                Thread.Sleep(2000);
            }

            FileManager.TryDeleteOldFiles(uploadService, GetEndOfLifeDate());
        }