Example #1
0
        public JsonDataContext()
        {
            this.directoryHelper = new DirectoryHelper();
            location             = @"C:\Users\pgathany\Desktop\Personal\Json";
            if (!directoryHelper.Exists(location))
            {
                directoryHelper.CreateDirectory(location);
            }
            this.dbLocation = location + @"\" + typeof(T).Name + ".json";
            if (!File.Exists(dbLocation))
            {
                File.Create(dbLocation).Close();
            }

            using (StreamReader r = new StreamReader(dbLocation))
            {
                string json = r.ReadToEnd();
                items = JsonConvert.DeserializeObject <List <T> >(json);
            }
            if (items == null)
            {
                items = new List <T>();
            }
            if (items.Any())
            {
                NextID = items.Select(b => (b as Entity).ID).Max() + 1;
            }
        }
Example #2
0
        private void BrowseFileExecute(object parameter)
        {
            _directoryHelper.CreateDirectory(OutputFolder);

            var result = _saveFileQuery.GetFileName(OutputFolder, OutputFilename, OutputFormat);

            if (result.Success)
            {
                SetOutputFilenameAndFolder(result.Data.Filepath);
                _latestDialogFilePath = result.Data.Filepath;
                OutputFormat          = result.Data.OutputFormat;
            }
        }
Example #3
0
        private async Task BrowseFileExecute(object parameter)
        {
            _directoryHelper.CreateDirectory(OutputFolder);

            var result = await GetFileOrRetry();

            if (result.Success)
            {
                SetOutputFilenameAndFolder(result.Data.Filepath);
                _latestDialogFilePath = result.Data.Filepath;
                OutputFormat          = result.Data.OutputFormat;
            }
        }
Example #4
0
        /// <summary>
        /// Saves coverage report to file system
        /// </summary>
        /// <param name="report">Coverage report</param>
        /// <param name="reportFileName">Coverage report file name</param>
        /// <returns>Coverage report file path</returns>
        private string SaveCoverageReport(string report, string reportFileName)
        {
            try
            {
                _directoryHelper.CreateDirectory(_reportDirectory);
                string filePath = Path.Combine(_reportDirectory, reportFileName);
                _fileHelper.WriteAllText(filePath, report);
                _eqtTrace.Info("{0}: Saved coverage report to path: '{1}'", CoverletConstants.DataCollectorName, filePath);

                return(filePath);
            }
            catch (Exception ex)
            {
                string errorMessage = string.Format(Resources.FailedToSaveCoverageReport, CoverletConstants.DataCollectorName, reportFileName, _reportDirectory);
                throw new CoverletDataCollectorException(errorMessage, ex);
            }
        }
        private async Task <MacroCommandIsDoneEventArgs> BrowseFileWithNotificationForTooLongInput(object arg)
        {
            var job           = _getJob();
            var inputFilePath = job.OutputFileTemplate;

            var inputDirectory = PathSafe.GetDirectoryName(inputFilePath);
            var inputFilename  = PathSafe.GetFileName(inputFilePath);

            _directoryHelper.CreateDirectory(inputDirectory);

            var result = await GetFileOrRetry(inputDirectory, inputFilename, job.Profile.OutputFormat);

            if (result.Success)
            {
                job.OutputFileTemplate   = result.Data.Filepath;
                job.Profile.OutputFormat = result.Data.OutputFormat;
                _updateUi();
                _setLastConfirmedPath(result.Data.Filepath);
                return(new MacroCommandIsDoneEventArgs(ResponseStatus.Success));
            }

            _setLastConfirmedPath("");
            return(new MacroCommandIsDoneEventArgs(ResponseStatus.Cancel));
        }
 private bool CreateTargetDirectory(string saveDirectory)
 {
     return(_directoryHelper.CreateDirectory(saveDirectory));
 }