Esempio n. 1
0
        public static void CleanDescriptionFiles(string directory, string exportDirectory, string errorExportDirectory)
        {
            FileCollection FileCollection = new FileCollection();

            FileCollection.AddFiles(directory, "*.csv");

            foreach (string file in FileCollection.Filenames)
            {
                string currentFileName = Importer.GetFileName(file);
                string exportFileName  = exportDirectory + currentFileName;
                string errorFileName   = errorExportDirectory + currentFileName;


                try
                {
                    CleanupDescriptionFile(file, exportFileName, errorFileName);
                }
                catch (Exception ex)
                {
                    Log.Warning(string.Format("{0}: Could not clean file", currentFileName));
                    Log.Warning(string.Format("{0}: {1}", currentFileName, ex.Message));
                    Log.Warning(string.Format("{0}: Stack Trace: {1}", currentFileName, ex.StackTrace));
                }
            }
        }
Esempio n. 2
0
        public static void AddAllDescriptionsToDatabase(string fileDirectory, [Optional] IntervalHierarchyNames columnIdentifiers)
        {
            FileCollection fileCollection = new FileCollection();


            fileCollection.AddFiles(fileDirectory, "*.csv");

            foreach (var file in fileCollection.Filenames)
            {
                Log.Information($"{file}: Trying to add descriptions the database");
                try
                {
                    var x = Task.Run(async() => await UploadDescriptionsFromFileToDatabaseAsync(file, columnIdentifiers).ConfigureAwait(true));
                    x.Wait();

                    Log.Information($"{file}: Successfully added descriptions the database");
                }
                catch (Exception ex)
                {
                    Log.Warning($"{file}: Could not add descriptions to database");
                    Log.Warning(ex.Message);
                    Log.Warning(ex.StackTrace);
                }

                Thread.Sleep(1000);
            }
        }
Esempio n. 3
0
        public ProgramWorkFlowHandler()
        {
            BatchProcessCompleted += NotifyConsoleOfBatchProcessed;
            string expedition = string.Empty;

            do
            {
                Console.WriteLine("Enter an expedition number to process its files or press E to exit");
                expedition = Console.ReadLine();
                expedition = "X" + expedition;

                FileCollection descriptionFileCollection = new FileCollection();

                descriptionFileCollection.AddFiles(@"C:\Users\percuoco\Desktop\AGU2019\AGU2019\" + expedition + @"\output\extracted_csv", "*.csv");
                descriptionFileCollection.ExportDirectory = ConfigurationManager.AppSettings["ExportDirectory"] + expedition + @"\Lithology\";
                descriptionFileCollection.Filenames.RemoveAll(x => !x.ToLower().Contains("sediment_macroscopic"));

                FileCollection measurementFileCollection = new FileCollection();

                //Measurement files with Laurel's related description data:
                // measurementFileCollection.AddFiles(@"C:\Users\percuoco\Desktop\AGU2019\AGU2019\" + expedition + @"\output\track_data", "*.csv");
                //Referencing the original measurement files:
                measurementFileCollection.AddFiles(@"C:\Users\percuoco\Desktop\AGU2019\AGU2019\" + expedition + @"\data\measurements", "*.csv");
                measurementFileCollection.ExportDirectory = ConfigurationManager.AppSettings["ExportDirectory"] + expedition + @"\Measurements\";

                ProcessData(descriptionFileCollection, measurementFileCollection);

                OnBatchProcessCompleted(this, new BatchProcessCompleteEventArgs(expedition));

                descriptionFileCollection = null;
                measurementFileCollection = null;
            }while (expedition != "E");
        }
Esempio n. 4
0
        public static async Task <ICollection <string> > AddAllMeasurementsToDatabase()
        {
            //var list = new CinnamonList("ExpeditionList").Parameters;
            //list.Reverse();
            //list.Remove("X376");
            //list.Remove("X372");
            //list.Remove("X371");
            //list.Remove("X368");
            //list.Remove("X367");
            //list.Remove("X366"); //Need to upload RGB
            //list.Remove("X362"); //Need to upload RGB
            //list.Remove("X361"); //Need to upload RGB
            //list.Remove("X360"); //Need to delete then add all measurements; Issue with disposing with DBcontext
            //list.Remove("X359");
            //list.Remove("X356");
            //list.Remove("X355");

            var list = new List <string>()
            {
                "X375", "X374", "X363", "X351", "X324"
            };


            ICollection <string> ErrorFiles = new HashSet <string>();


            foreach (var expedition in list)
            {
                FileCollection fileCollection = new FileCollection();
                string         fileDirectory  = $@"C:\Users\vperc\Desktop\All Hard Drive Files\DESC_DATAMINE\AGU2019\{expedition}\data";
                fileCollection.AddFiles(fileDirectory, "*.csv");

                foreach (var file in fileCollection.Filenames)
                {
                    Log.Information($"{file}: Trying to add measurements to database");
                    try
                    {
                        var uploadSuccessful = await Workflow.UploadMeasurementsFromFileToDatabaseAsync(file).ConfigureAwait(true);

                        if (uploadSuccessful)
                        {
                            Log.Information($"{file}: Successfully added measurements database");
                        }
                        else
                        {
                            Log.Information($"{file}: The file was not successfully uploaded. Either the all the measurments have been previously uploaded");
                        }
                    }
                    catch (Exception ex)
                    {
                        Log.Warning($"{file}: Could not add measurement file to database");
                        Log.Warning(ex.Message);
                        Log.Warning(ex.StackTrace);
                        ErrorFiles.Add(file);
                    }

                    Thread.Sleep(1000);
                }
            }

            return(ErrorFiles);
        }