Example #1
0
        /// <summary>
        /// Collects the locations of full, diff, and log backup files.
        /// </summary>
        /// <returns></returns>
        public static MaintenancePlan GetPaths()
        {
            MaintenancePlan maintPlan = new MaintenancePlan();
            string answer = "";
            do
            {
                Console.Clear();
                if(maintPlan.FullBKPath == null)
                {
                    Console.WriteLine("Enter path to Full backups (c:\\FullBackups)");
                    Console.Write("Required: ");
                    maintPlan.FullBKPath = Console.ReadLine();
                    if (maintPlan.FullBKPath == null)
                    {
                        Console.Clear();
                        continue;
                    }
                    Console.WriteLine();
                }
                else
                {
                    Console.WriteLine("Enter path to Full backups (c:\\FullBackups)");
                    Console.WriteLine("Required: {0}\n", maintPlan.FullBKPath);
                }

                if (maintPlan.DiffBKPath == null)
                {
                    Console.WriteLine("Enter path to Differential backups (c:\\DiffBackups)");
                    Console.Write("Optional [N\\A]: ");
                    maintPlan.DiffBKPath = Console.ReadLine();
                    if (maintPlan.DiffBKPath == null)
                    {
                        Console.Clear();
                        continue;
                    }
                    Console.WriteLine();
                }
                else
                {
                    Console.WriteLine("Enter path to Differential backups (c:\\DiffBackups)");
                    Console.WriteLine("Optional [N\\A]: {0}\n", maintPlan.DiffBKPath);
                }

                if (maintPlan.LogBKPath == null)
                {
                    Console.WriteLine("Enter path to Log backups (c:\\LogBackups)");
                    Console.Write("Optional [N\\A]: ");
                    maintPlan.LogBKPath = Console.ReadLine();
                    if (maintPlan.LogBKPath == null)
                    {
                        Console.Clear();
                        continue;
                    }
                    Console.WriteLine();
                }
                else
                {
                    Console.WriteLine("Enter path to Log backups (c:\\LogBackups)");
                    Console.WriteLine("Optional [N\\A]: {0}\n", maintPlan.LogBKPath);
                }

                Console.WriteLine("{0}", maintPlan.ToString());
                Console.Write("\nIs this correct?[N] ");
                answer = Console.ReadLine();

                if(answer.ToLower() != "y")
                {
                    maintPlan = new MaintenancePlan();
                }

            }while (answer.ToLower() != "y");
            return maintPlan;
        }