예제 #1
0
        static public void SaveLog(List <DeleteEvent> deletes)
        {
            Console.WriteLine("Logging to database, please wait...");
            Database database = new Database();
            string   s        = string.Empty;

            if (database.SaveLog(deletes))
            {
                Console.WriteLine("Log has been written to database successfully");
                XmlLogger log = new XmlLogger();
                log.FileAwayLog();
                do
                {
                    Console.WriteLine("Close application?  Enter 'Y' for yes or enter 'N' to restart program.");
                    s = Console.ReadLine();
                    if (s.ToUpper() == "Y")
                    {
                        Environment.Exit(0);
                    }
                    if (s.ToUpper() == "N")
                    {
                        Restart(true);
                    }
                } while (s != "Y");
            }
            else
            {
                Console.WriteLine("Error in parsing log to database, contact admin for help.\r\nPress enter key to close program.");
                Console.ReadLine();
                Environment.Exit(0);
            }
        }
예제 #2
0
        static void Main(string[] args)
        {
            int      input;
            Database database;

            do
            {
                Console.WriteLine("Please select which task you would like to perform.\r\n\r\n1.  Parse today's file deletions.\r\n\r\n2.  View deleted files from previous days.\r\n\r\n3.  Lookup file deletions by filename.\r\n\r\n4.  Lookup file deletions by folder name.");
                try
                {
                    input = int.Parse(Console.ReadLine());
                }
                catch
                {
                    input = -1;
                }
                Console.Clear();
            } while (input != 1 && input != 2 && input != 3 && input != 4);
            switch (input)
            {
            case 1:
                XmlLogger log    = new XmlLogger();
                var       events = log.ParseXML();
                if (events == null)
                {
                    Console.WriteLine("\r\n\r\nPlease ensure you have the file in the correct location with the correct file name.\r\nOnce confirmed, press enter to reload program...");
                    Console.ReadLine();
                    System.Diagnostics.Process.Start(Environment.GetCommandLineArgs()[0]);
                    Environment.Exit(0);
                }
                else
                {
                    WriteLog(events);
                    SaveLog(events);
                }
                break;

            case 2:
                var start = GetStartDate();
                var end   = GetEndDate(start);
                database = new Database();
                var records = database.GetEvents(start, end);
                WriteLog(records, true);
                break;

            case 3:
                database = new Database();
                var recs = database.GetDeletesByName(searchString());
                WriteLog(recs, true);
                break;

            case 4:
                database = new Database();
                var rqs = database.GetDeletesByPath(searchString());
                WriteLog(rqs, true);
                break;
            }
        }