コード例 #1
0
        ////////////////////////////////////////////////////////////////////////////////////////////////////
        /// <summary>
        ///     This is a 4 step process 1. gather the file paths for each service into a collection of
        ///     service names to file paths 2. for each file parse the parameter names seen by a single
        ///     service into unique column names 3. for each file write the data obtained from a single
        ///     service call into a the target files as a new row under their appropriate column 4.
        ///     repeat steps 2 and 3 foreach service.
        /// </summary>
        ///
        /// <remarks>   Ahaynes, 12/12/2016. </remarks>
        ///
        /// ### <param name="args"> . </param>
        ////////////////////////////////////////////////////////////////////////////////////////////////////
        private static void StartProc()
        {
            ServiceLogger.WriteLine();
            FileImporter fileImporter = new FileImporter();

            //Write column headers for the call log only once
            CallLogBuilder.WriteColumnHeaders();
            //itterate through each service
            foreach (KeyValuePair <string, List <string> > kvp in serviceFilePaths)
            {
                //itterate through each file for this service
                foreach (string filePath in kvp.Value)
                {
                    //gather parameter names used in all calls of a service into the serviceColumns collection
                    fileImporter.ImportColumns(kvp.Key, filePath);
                }

                //print column headers to their appropriate files
                DataSheetBuilder.WriteColumnHeaders(kvp.Key);
                UsageStatisticsBuilder.WriteColumnHeaders(kvp.Key);

                //itterate through each file for this service again
                foreach (string filePath in kvp.Value)
                {
                    //Gather data per service call adding counts to the count collections (columnNullCount, columnEmptyCount, columnSeenCount)
                    //prints data per service call to the call log and data sheets
                    fileImporter.ImportValues(kvp.Key, filePath);
                }
                //print all of the statistics of a service to the usage statics sheet at once
                UsageStatisticsBuilder.AppendRowToFile(kvp.Key);
                // clear the collections for this service, they are no longer needed in memory
                ClearServiceCollections(kvp);
            }
        }
コード例 #2
0
ファイル: FilePathImporter.cs プロジェクト: MDCCXIII/AAI
 ////////////////////////////////////////////////////////////////////////////////////////////////////
 /// <summary>
 ///     For each path provided, determin if the path is a file or directory and processes that
 ///     path.
 /// </summary>
 ///
 /// <remarks>   Ahaynes, 12/13/2016. </remarks>
 ///
 /// <exception cref="Exception">    Thrown when an exception error condition occurs. </exception>
 ///
 /// <param name="args"> . </param>
 ////////////////////////////////////////////////////////////////////////////////////////////////////
 public static void ParseArgs(string[] args)
 {
     ServiceLogger.WriteLine();
     foreach (string path in args)
     {
         ServiceLogger.WriteLine("--- Picked up arg: " + path + " ---");
         if (FileUtils.FileExists(path))
         {
             // This path is a file
             if (!FileUtils.IsFileinUse(path))
             {
                 ProcessFile(path);
             }
         }
         else if (FileUtils.DirectoryExists(path))
         {
             // This path is a directory
             ProcessDirectory(path);
         }
         else
         {
             throw new Exception(path + " is not a valid file or directory.");
         }
     }
 }
コード例 #3
0
        ////////////////////////////////////////////////////////////////////////////////////////////////////
        /// <summary>   Clears the service collections. </summary>
        ///
        /// <remarks>   Ahaynes, 12/12/2016. </remarks>
        ///
        /// <param name="kvp">  The kvp. </param>
        ////////////////////////////////////////////////////////////////////////////////////////////////////

        private static void ClearServiceCollections(KeyValuePair <string, List <string> > kvp)
        {
            ServiceLogger.WriteLine();
            serviceColumns[kvp.Key].Clear();
            serviceColumns.Clear();
            columnEmptyCount.Clear();
            columnNullCount.Clear();
            columnSeenCount.Clear();
        }
コード例 #4
0
        static void Main(string[] args)
        {
            // Hide the console window
            NativeMethods.ShowWindow(NativeMethods.GetConsoleWindow(), NativeMethods.SW_HIDE);

            ServiceLogger.CreateLogFileDirectory();
            ServiceLogger.WriteLine();
            OutputDirectory = GetOutputDirectory();
            FileUtils.ValidFileExtensions.Add(".txt");
            try
            {
                //if no arguments where passed set the default source directory from the appconfig
                if (args.Length == 0)
                {
                    if (!ConfigurationManager.AppSettings.AllKeys.Contains("DefaultSourceDirectory"))
                    {
                        throw new Exception("App.config, Key: DefaultSourceDirectory, missing. Please pass source directory as argument.");
                    }
                    if (ConfigurationManager.AppSettings["DefaultSourceDirectory"].Equals(""))
                    {
                        throw new Exception("App.config, Key: DefaultSourceDirectory, value is empty. Please pass source directory as argument.");
                    }
                    args = new string[] { ConfigurationManager.AppSettings["DefaultSourceDirectory"] };
                }

                //Gather the filePaths into the serviceFilePath collection
                FilePathImporter.ParseArgs(args);

                if (FlexibleMessageBox.Show("The following files have been loaded for conversion:\n" + FileConfirmationMessage + "\n\nWould you like to start the conversion?", "AAI Log Converter - Continue?", MessageBoxButtons.YesNo).Equals(DialogResult.Yes))
                {
                    Thread t = new Thread(new ThreadStart(() => { MessageBox.Show("The Conversion will continue in the background.\nFeel free to continue working while you wait.", "AAI Log Converter - Info", MessageBoxButtons.OK); }));
                    t.Start();

                    //start the conversion process
                    StartProc();

                    if (MessageBox.Show("The log file conversion has Sucessfully Completed.\nWould you like to open the output directory now?", "AAI Log Converter - Success!", MessageBoxButtons.YesNo).Equals(DialogResult.Yes))
                    {
                        Process.Start(OutputDirectory);
                    }
                }
                else
                {
                    ServiceLogger.WriteLine("End user did not accept prompt to continue.");
                }
            }
            catch (Exception ex)
            {
                ServiceLogger.WriteLine("ERROR:: " + ex.Message, new StackTrace(ex).GetFrame(0).GetMethod().Name, ex.Source, new StackTrace(ex).GetFrame(0).GetFileLineNumber());
                MessageBox.Show(ex.Message, "AAI Log Converter - ERROR", MessageBoxButtons.OK);
            }
        }
コード例 #5
0
ファイル: FilePathImporter.cs プロジェクト: MDCCXIII/AAI
 ////////////////////////////////////////////////////////////////////////////////////////////////////
 /// <summary>
 ///     adds the file name as the service name and adds the file path to a collection of paths
 ///     for that service.
 /// </summary>
 ///
 /// <remarks>   Ahaynes, 12/13/2016. </remarks>
 ///
 /// <param name="serviceName">  The name of the service to be added to. </param>
 /// <param name="filePath">     The fully qualified file path. </param>
 ////////////////////////////////////////////////////////////////////////////////////////////////////
 private static void AddServiceFilePath(string serviceName, string filePath)
 {
     ServiceLogger.WriteLine();
     if (FileUtils.FileIsValid(filePath))
     {
         if (!Program.serviceFilePaths.ContainsKey(serviceName))
         {
             Program.serviceFilePaths.Add(serviceName, new List <string>());
         }
         Program.serviceFilePaths[serviceName].Add(filePath);
         ServiceLogger.WriteLine("--- Loaded File: " + filePath + " for conversion ---");
         Program.FileConfirmationMessage += filePath + "\n";
     }
 }
コード例 #6
0
        private static string GetOutputDirectory()
        {
            ServiceLogger.WriteLine();
            string result = Directory.GetCurrentDirectory() + "\\Converted AAI Logs\\";

            if (ConfigurationManager.AppSettings.AllKeys.Contains("OutputDirectory"))
            {
                if (!ConfigurationManager.AppSettings["OutputDirectory"].Equals(""))
                {
                    result = ConfigurationManager.AppSettings["OutputDirectory"];
                }
            }
            FileUtils.CreateDirectory(result);
            return(result);
        }
コード例 #7
0
ファイル: FilePathImporter.cs プロジェクト: MDCCXIII/AAI
        ////////////////////////////////////////////////////////////////////////////////////////////////////
        /// <summary>
        ///     pass through for AddServiceFilePath method. if the service name is set in the App.Config
        ///     only add files with a service name that matches the value from the app.config.
        /// </summary>
        ///
        /// <remarks>   Ahaynes, 12/13/2016. </remarks>
        ///
        /// <param name="filePath"> The fully qualified file path. </param>
        ////////////////////////////////////////////////////////////////////////////////////////////////////

        private static void ProcessFile(string filePath)
        {
            ServiceLogger.WriteLine();
            if (Program.ServiceName != null && !Program.ServiceName.Equals(""))
            {
                if (filePath.ToLower().Contains(Program.ServiceName.ToLower()))
                {
                    AddServiceFilePath(Program.ServiceName, filePath);
                }
            }
            else
            {
                AddServiceFilePath(FileUtils.GetFileName(filePath), filePath);
            }
        }
コード例 #8
0
ファイル: FilePathImporter.cs プロジェクト: MDCCXIII/AAI
 ////////////////////////////////////////////////////////////////////////////////////////////////////
 /// <summary>
 ///     Process all files in the directory passed in, recurse on any directories that are found,
 ///     and process the files they contain.
 /// </summary>
 ///
 /// <remarks>   Ahaynes, 12/13/2016. </remarks>
 ///
 /// <param name="targetDirectory">  The fully qualified directory path to the output directory. </param>
 ////////////////////////////////////////////////////////////////////////////////////////////////////
 public static void ProcessDirectory(string targetDirectory)
 {
     ServiceLogger.WriteLine();
     string[] fileEntries = FileUtils.GetAllFiles(targetDirectory);
     foreach (string fileName in fileEntries)
     {
         // Process the array of files found in the directory.
         ProcessFile(fileName);
     }
     string[] subdirectoryEntries = FileUtils.GetSubDirectories(targetDirectory);
     foreach (string subdirectory in subdirectoryEntries)
     {
         // Recurse into subdirectories of this directory.
         ProcessDirectory(subdirectory);
     }
 }
コード例 #9
0
        ////////////////////////////////////////////////////////////////////////////////////////////////////
        /// <summary>   File is valid. </summary>
        ///
        /// <remarks>   Ahaynes, 12/13/2016. </remarks>
        ///
        /// <exception cref="Exception">    Thrown when an exception error condition occurs. </exception>
        ///
        /// <param name="filePath"> Full pathname of the file. </param>
        ///
        /// <returns>   True if it succeeds, false if it fails. </returns>
        ////////////////////////////////////////////////////////////////////////////////////////////////////

        public static bool FileIsValid(string filePath)
        {
            if (ValidFileExtensions.Count > 0)
            {
                foreach (string extension in ValidFileExtensions)
                {
                    if (filePath.EndsWith(extension))
                    {
                        return(true);
                    }
                    else
                    {
                        ServiceLogger.WriteLine("SKIPPED FILE:: The file " + filePath + " does not have the file extension " + extension + ".");
                    }
                }
            }
            else
            {
                throw new Exception("No file extensions have been added to the ValidFileExtensions List.");
            }
            return(false);
        }