ReadInputFile() public static method

public static ReadInputFile ( string inputFileSpec, bool hasHeader ) : string[]
inputFileSpec string
hasHeader bool
return string[]
Beispiel #1
0
        public static void DoWork()
        {
            string timeStamp = DateTime.Now.ToString("yyyyMMdd_hhmmss");

            csvOutputFileSpec      = Environment.CurrentDirectory + "\\ManageMaintenanceBanners-" + timeStamp + Constants.CSVExtension;
            csvOutputFileHasHeader = System.IO.File.Exists(csvOutputFileSpec);

            Logger.OpenLog("ManageMaintenanceBanners", timeStamp);
            Logger.LogInfoMessage(String.Format("Scan starting {0}", DateTime.Now.ToString()), true);

            BannerOperation operationToPerform = BannerOperation.None;

            if (!ReadInputOptions(ref operationToPerform))
            {
                System.Console.ForegroundColor = System.ConsoleColor.Yellow;
                Logger.LogInfoMessage("Operation aborted by user.", true);
                Logger.LogInfoMessage(String.Format("Scan aborted {0}", DateTime.Now.ToString()), true);
                Logger.CloseLog();
                System.Console.ResetColor();
                return;
            }

            string cdnAbsoluteUrl = String.Empty;

            if (operationToPerform == BannerOperation.Add)
            {
                if (!ReadCdnUrl(ref cdnAbsoluteUrl))
                {
                    System.Console.ForegroundColor = System.ConsoleColor.Red;
                    Logger.LogErrorMessage("CDN Library Folder Url was not specified.");
                    Logger.LogInfoMessage(String.Format("Scan aborted {0}", DateTime.Now.ToString()), true);
                    Logger.CloseLog();
                    System.Console.ResetColor();
                    return;
                }
            }

            string inputFileSpec = Environment.CurrentDirectory + "\\" + Constants.UsageReport_SitesInputFileName;

            if (!System.IO.File.Exists(inputFileSpec))
            {
                System.Console.ForegroundColor = System.ConsoleColor.Red;
                Logger.LogErrorMessage(String.Format("Input file {0} is not available", inputFileSpec), true);
                Logger.LogInfoMessage(String.Format("Scan aborted {0}", DateTime.Now.ToString()), true);
                Logger.CloseLog();
                System.Console.ResetColor();
                return;
            }

            string[] siteUrls = Helper.ReadInputFile(inputFileSpec, false);
            Logger.LogInfoMessage(String.Format("Preparing to process a total of {0} sites ...", siteUrls.Length), true);

            foreach (string siteUrl in siteUrls)
            {
                ProcessSite(siteUrl, operationToPerform, cdnAbsoluteUrl);
            }

            Logger.LogInfoMessage(String.Format("Scan completed {0}", DateTime.Now.ToString()), true);
            Logger.CloseLog();
        }
        public static void DoWork()
        {
            string timeStamp = DateTime.Now.ToString("yyyyMMdd_hhmmss");

            csvOutputFileSpec      = Environment.CurrentDirectory + "\\GenerateSecurityGroupReport-" + timeStamp + Constants.CSVExtension;
            csvOutputFileHasHeader = System.IO.File.Exists(csvOutputFileSpec);

            Logger.OpenLog("GenerateSecurityGroupReport", timeStamp);
            Logger.LogInfoMessage(String.Format("Scan starting {0}", DateTime.Now.ToString()), true);

            string[] securityGroups = new string[0];
            string   securityGroupsInputFileSpec = Environment.CurrentDirectory + "\\" + Constants.SecurityGroupsInputFileName;

            if (!System.IO.File.Exists(securityGroupsInputFileSpec))
            {
                System.Console.ForegroundColor = System.ConsoleColor.Red;
                Logger.LogErrorMessage(String.Format("Input file {0} is not available", securityGroupsInputFileSpec), true);
                Logger.LogInfoMessage(String.Format("Scan aborted {0}", DateTime.Now.ToString()), true);
                Logger.CloseLog();
                System.Console.ResetColor();
                return;
            }
            securityGroups = Helper.ReadInputFile(securityGroupsInputFileSpec, false);
            if (securityGroups.Length == 0)
            {
                System.Console.ForegroundColor = System.ConsoleColor.Red;
                Logger.LogErrorMessage(String.Format("Input file {0} is empty", securityGroupsInputFileSpec), true);
                Logger.LogInfoMessage(String.Format("Scan aborted {0}", DateTime.Now.ToString()), true);
                Logger.CloseLog();
                System.Console.ResetColor();
                return;
            }
            Logger.LogInfoMessage(String.Format("Loaded a total of {0} security groups ...", securityGroups.Length), true);

            string inputFileSpec = Environment.CurrentDirectory + "\\" + Constants.UsageReport_SitesInputFileName;

            if (!System.IO.File.Exists(inputFileSpec))
            {
                System.Console.ForegroundColor = System.ConsoleColor.Red;
                Logger.LogErrorMessage(String.Format("Input file {0} is not available", inputFileSpec), true);
                Logger.LogInfoMessage(String.Format("Scan aborted {0}", DateTime.Now.ToString()), true);
                Logger.CloseLog();
                System.Console.ResetColor();
                return;
            }

            string[] siteUrls = Helper.ReadInputFile(inputFileSpec, false);
            Logger.LogInfoMessage(String.Format("Preparing to scan a total of {0} sites ...", siteUrls.Length), true);

            foreach (string siteUrl in siteUrls)
            {
                ProcessSite(siteUrl, securityGroups);
            }
            Logger.LogInfoMessage(String.Format("Scan completed {0}", DateTime.Now.ToString()), true);
            Logger.CloseLog();
        }
Beispiel #3
0
        /// <summary>
        /// This method reports on the usage of custom master pages.
        ///
        /// General Approach:
        /// - disable site feature: V4VisualUpgrade
        /// -  note: the feature deactivator processes MPs of all child webs
        /// - process webs
        /// -  delete custom hidden list: Lists/RedirectURL
        /// -  disable web feature: Redirect Url List
        /// -  disable web features: custom Master Pages (6)
        /// -  delete custom master page files
        /// </summary>
        public static void DoWork()
        {
            Logger.OpenLog("GenerateNonDefaultMasterPageUsageReport");
            Logger.LogInfoMessage(String.Format("Scan starting {0}", DateTime.Now.ToString()), true);

            string inputFileSpec = Environment.CurrentDirectory + "\\" + Constants.UsageReport_SitesInputFileName;

            string[] siteUrls = Helper.ReadInputFile(inputFileSpec, false);
            Logger.LogInfoMessage(String.Format("Preparing to scan a total of {0} sites ...", siteUrls.Length), true);

            foreach (string siteUrl in siteUrls)
            {
                ProcessSite(siteUrl);
            }

            Logger.LogInfoMessage(String.Format("Scan completed {0}", DateTime.Now.ToString()), true);
            Logger.CloseLog();
        }
Beispiel #4
0
        public static void DoWork()
        {
            Logger.OpenLog("GenerateColumnAndTypeUsageReport");
            Logger.LogInfoMessage(String.Format("Scan starting {0}", DateTime.Now.ToString()), true);

            string contentTypesInputFileSpec = Environment.CurrentDirectory + "\\" + Constants.UsageReport_ContentTypesInputFileName;

            string[] contentTypeRows = Helper.ReadInputFile(contentTypesInputFileSpec, true);
            Logger.LogInfoMessage(String.Format("Loaded {0} content type definitions ...", contentTypeRows.Length), true);
            List <ContentTypeSpec> contentTypes = new List <ContentTypeSpec>();

            foreach (string s in contentTypeRows)
            {
                string[] arr = s.Split(',');
                contentTypes.Add(new ContentTypeSpec(arr[0], arr[1]));
            }

            string siteColumnsInputFileSpec = Environment.CurrentDirectory + "\\" + Constants.UsageReport_SiteColumnsInputFileName;

            string[] siteColumnRows = Helper.ReadInputFile(siteColumnsInputFileSpec, true);
            Logger.LogInfoMessage(String.Format("Loaded {0} site column definitions ...", siteColumnRows.Length), true);
            List <SiteColumnSpec> siteColumns = new List <SiteColumnSpec>();

            foreach (string s in siteColumnRows)
            {
                string[] arr = s.Split(',');
                siteColumns.Add(new SiteColumnSpec(arr[0], arr[1]));
            }

            string inputFileSpec = Environment.CurrentDirectory + "\\" + Constants.UsageReport_SitesInputFileName;

            string[] siteUrls = Helper.ReadInputFile(inputFileSpec, false);
            Logger.LogInfoMessage(String.Format("Preparing to scan a total of {0} sites ...", siteUrls.Length), true);

            foreach (string siteUrl in siteUrls)
            {
                ProcessSite(siteUrl, contentTypes, siteColumns);
            }

            Logger.LogInfoMessage(String.Format("Scan completed {0}", DateTime.Now.ToString()), true);
            Logger.CloseLog();
        }
        public static void DoWork()
        {
            string timeStamp            = DateTime.Now.ToString("yyyyMMdd_hhmmss");
            string NonDefMasterFileName = outputPath + @"\" + Constants.NonDefaultMasterPageFileName + timeStamp + Constants.CSVExtension;

            Logger.OpenLog("GenerateNonDefaultMasterPageUsageReport", timeStamp);
            if (!ShowInformation())
            {
                return;
            }
            Logger.LogInfoMessage(String.Format("Scan starting {0}", DateTime.Now.ToString()), true);

            if (!System.IO.File.Exists(NonDefMasterFileName))
            {
                headermasterPage = false;
            }
            else
            {
                headermasterPage = true;
            }

            string inputFileSpec = Environment.CurrentDirectory + "\\" + Constants.UsageReport_SitesInputFileName;

            if (System.IO.File.Exists(inputFileSpec))
            {
                string[] siteUrls = Helper.ReadInputFile(inputFileSpec, false);
                Logger.LogInfoMessage(String.Format("Preparing to scan a total of {0} sites ...", siteUrls.Length), true);

                foreach (string siteUrl in siteUrls)
                {
                    ProcessSite(siteUrl, NonDefMasterFileName);
                }
                Logger.LogSuccessMessage(String.Format("[GenerateNonDefaultMasterPageUsageReport] Usage report is exported to the file {0}", NonDefMasterFileName), true);
            }
            else
            {
                Logger.LogErrorMessage(String.Format("[GenerateNonDefaultMasterPageUsageReport] Input file {0} is not available", inputFileSpec), true);
            }

            Logger.LogInfoMessage(String.Format("Scan completed {0}", DateTime.Now.ToString()), true);
            Logger.CloseLog();
        }
        public static void DoWork()
        {
            string timeStamp    = DateTime.Now.ToString("yyyyMMdd_hhmmss");
            string CTCFFileName = outputPath + @"\" + Constants.ContentTypeAndCustomFieldFileName + timeStamp + Constants.CSVExtension;

            Logger.OpenLog("GenerateColumnORFieldAndTypeUsageReport", timeStamp);
            if (!ShowInformation())
            {
                return;
            }
            Logger.LogInfoMessage(String.Format("Scan starting {0}", DateTime.Now.ToString()), true);

            string contentTypesInputFileSpec    = Environment.CurrentDirectory + "\\" + Constants.ContentTypeInput;
            List <ContentTypeSpec> contentTypes = new List <ContentTypeSpec>();

            if (System.IO.File.Exists(contentTypesInputFileSpec))
            {
                IEnumerable <InputContentTypeBase> objInputContentType = ImportCSV.ReadMatchingColumns <InputContentTypeBase>(contentTypesInputFileSpec, Constants.CsvDelimeter);
                Logger.LogInfoMessage(String.Format("Loaded {0} content type definitions ...", objInputContentType.Count()), true);
                foreach (InputContentTypeBase s in objInputContentType)
                {
                    contentTypes.Add(new ContentTypeSpec(s.ContentTypeID, s.ContentTypeName));
                }
            }
            else
            {
                Logger.LogErrorMessage(String.Format("[GenerateColumnORFieldAndTypeUsageReport] Input file {0} is not available", contentTypesInputFileSpec), true);
            }

            string customFieldsInputFileSpec = Environment.CurrentDirectory + "\\" + Constants.CustomFieldsInput;

            List <SiteColumnSpec> customFields = new List <SiteColumnSpec>();

            if (System.IO.File.Exists(customFieldsInputFileSpec))
            {
                IEnumerable <InputCustomFieldBase> objInputCustomField = ImportCSV.ReadMatchingColumns <InputCustomFieldBase>(customFieldsInputFileSpec, Constants.CsvDelimeter);
                Logger.LogInfoMessage(String.Format("Loaded {0} site column/custom field definitions ...", objInputCustomField.Count()), true);
                foreach (InputCustomFieldBase s in objInputCustomField)
                {
                    customFields.Add(new SiteColumnSpec(s.ID, s.Name));
                }
            }
            else
            {
                Logger.LogErrorMessage(String.Format("[GenerateColumnORFieldAndTypeUsageReport] Input file {0} is not available", customFieldsInputFileSpec), true);
            }

            if (!System.IO.File.Exists(CTCFFileName))
            {
                headerContentType = false;
            }
            else
            {
                headerContentType = true;
            }

            string inputFileSpec = Environment.CurrentDirectory + "\\" + Constants.UsageReport_SitesInputFileName;

            if (System.IO.File.Exists(inputFileSpec))
            {
                string[] siteUrls = Helper.ReadInputFile(inputFileSpec, false);
                Logger.LogInfoMessage(String.Format("Preparing to scan a total of {0} sites ...", siteUrls.Length), true);

                foreach (string siteUrl in siteUrls)
                {
                    ProcessSite(siteUrl, contentTypes, customFields, CTCFFileName);
                }
                Logger.LogSuccessMessage(String.Format("[GenerateColumnORFieldAndTypeUsageReport] Usage report is exported to the file {0} ", CTCFFileName), true);
            }
            else
            {
                Logger.LogErrorMessage(String.Format("[GenerateColumnORFieldAndTypeUsageReport] Input file {0} is not available", inputFileSpec), true);
            }

            Logger.LogInfoMessage(String.Format("Scan completed {0}", DateTime.Now.ToString()), true);
            Logger.CloseLog();
        }