Esempio n. 1
0
        static void Main(string[] args)
        {
            if (args.Length == 0)
            {
                WriteHelpToConsole();
                return;
            }

            if (!CheckArgumentsExist(CommandLineArgument.StorageName, CommandLineArgument.StorageKey, CommandLineArgument.Container, CommandLineArgument.MinDaysOld))
            {
                return;
            }

            string storageAccountName = GetArgumentValue(CommandLineArgument.StorageName);  // storage account
            string storageAccessKey   = GetArgumentValue(CommandLineArgument.StorageKey);   // storage key
            string containerName      = GetArgumentValue(CommandLineArgument.Container);    // storage container

            bool success    = false;
            int  minDaysOld = -1;

            success = int.TryParse(GetArgumentValue(CommandLineArgument.MinDaysOld), out minDaysOld);

            if (!success || (minDaysOld < 0))
            {
                Console.WriteLine(string.Format("Please supply a valid \"{0}\" argument", CommandLineArgument.MinDaysOld));
                return;
            }

            bool recursive = args.Contains(CommandLineArgument.Recursive);

            StorageCleaner storageCleaner = new StorageCleaner(storageAccountName, storageAccessKey, containerName, minDaysOld, recursive);

            storageCleaner.Cleanup();
        }
        static void Main(string[] args)
        {
            if (args.Length == 0)
            {
                WriteHelpToConsole();
                return;
            }

            if (!CheckArgumentsExist(CommandLineArgument.StorageName, CommandLineArgument.StorageKey, CommandLineArgument.Container, CommandLineArgument.MinDaysOld))
                return;

            string storageAccountName = GetArgumentValue(CommandLineArgument.StorageName);  // storage account
            string storageAccessKey = GetArgumentValue(CommandLineArgument.StorageKey);     // storage key
            string containerName = GetArgumentValue(CommandLineArgument.Container);         // storage container

            bool success = false;
            int minDaysOld = -1;
            success = int.TryParse(GetArgumentValue(CommandLineArgument.MinDaysOld), out minDaysOld);

            if (!success || (minDaysOld < 0))
            {
                Console.WriteLine(string.Format("Please supply a valid \"{0}\" argument", CommandLineArgument.MinDaysOld));
                return;
            }

            bool recursive = args.Contains(CommandLineArgument.Recursive);

            StorageCleaner storageCleaner = new StorageCleaner(storageAccountName, storageAccessKey, containerName, minDaysOld, recursive);
            storageCleaner.Cleanup();
            storageCleaner.SetMimeTypes();
        }
Esempio n. 3
0
        static void Main(string[] args)
        {
            if (args.Length == 0)
            {
                WriteHelpToConsole();
                return;
            }

            if (!CheckArgumentsExist(CommandLineArgument.StorageName, CommandLineArgument.StorageKey, CommandLineArgument.Container, CommandLineArgument.MinDaysOld))
            {
                return;
            }

            string storageAccountName = GetArgumentValue(CommandLineArgument.StorageName);  // storage account
            string storageAccessKey   = GetArgumentValue(CommandLineArgument.StorageKey);   // storage key
            string containerName      = GetArgumentValue(CommandLineArgument.Container);    // storage container

            bool success    = false;
            int  minDaysOld = -1;

            success = int.TryParse(GetArgumentValue(CommandLineArgument.MinDaysOld), out minDaysOld);

            if (!success || (minDaysOld < 0))
            {
                Console.WriteLine(string.Format("Please supply a valid \"{0}\" argument", CommandLineArgument.MinDaysOld));
                return;
            }

            string searchPattern = GetArgumentValue(CommandLineArgument.SearchPattern);

            if (searchPattern == null)
            {
                searchPattern = DEFAULT_SEARCH_PATTERN;
            }

            try
            {
                var regex = new Regex(searchPattern);
            }
            catch (Exception ex)
            {
                Console.WriteLine(string.Format("searchpattern regex compilation failed: {0}", ex.Message));
                return;
            }

            bool recursive = args.Contains(CommandLineArgument.Recursive);
            bool whatif    = args.Contains(CommandLineArgument.WhatIf);

            StorageCleaner storageCleaner = new StorageCleaner(storageAccountName, storageAccessKey, containerName, minDaysOld, searchPattern, recursive, whatif);

            storageCleaner.Cleanup();
        }