示例#1
0
        public static void DoWork()
        {
            Logger.OpenLog("DeleteMissingEventReceivers");
            Logger.LogInfoMessage(String.Format("Scan starting {0}", DateTime.Now.ToString()), true);

            string inputFileSpec = Environment.CurrentDirectory + "\\" + Constants.MissingEventReceiversInputFileName;
            //Read Input file
            IEnumerable <MissingEventReceiversInput> objInputMissingEventReceivers = ImportCSV.ReadMatchingColumns <MissingEventReceiversInput>(inputFileSpec, Constants.CsvDelimeter);

            if (objInputMissingEventReceivers != null)
            {
                try
                {
                    Logger.LogInfoMessage(String.Format("Preparing to delete a total of {0} event receivers ...", objInputMissingEventReceivers.Cast <Object>().Count()), true);

                    foreach (MissingEventReceiversInput MissingEventReceiver in objInputMissingEventReceivers)
                    {
                        DeleteMissingEventReceiver(MissingEventReceiver);
                    }
                }
                catch (Exception ex)
                {
                    Logger.LogErrorMessage(String.Format("DeleteMissingEventReceivers() failed: Error={0}", ex.Message), true);
                }

                Logger.LogInfoMessage(String.Format("Scan completed {0}", DateTime.Now.ToString()), true);
            }
            else
            {
                Logger.LogInfoMessage("There is nothing to delete from the '" + inputFileSpec + "' File ", true);
            }
            Logger.CloseLog();
        }
示例#2
0
        private static void ReadWebPartUsageCSV(string sourceWebPartType, string usageFilePath, out IEnumerable <WebpartInput> objWPDInput)
        {
            objWPDInput = null;
            objWPDInput = ImportCSV.ReadMatchingColumns <WebpartInput>(usageFilePath, Constants.CsvDelimeter);

            try
            {
                if (objWPDInput.Any())
                {
                    objWPDInput = from p in objWPDInput
                                  where p.WebPartType.Equals(sourceWebPartType, StringComparison.OrdinalIgnoreCase)
                                  select p;

                    if (objWPDInput.Any())
                    {
                        Logger.LogInfoMessage("Number of Webparts found with WebpartType '" + sourceWebPartType + "' are " + objWPDInput.Count());
                    }
                    else
                    {
                        Logger.LogInfoMessage("No Webparts found with WebpartType '" + sourceWebPartType + "'");
                    }
                }
            }
            catch (Exception ex)
            {
                Logger.LogErrorMessage("[DeleteMissingWebparts: ReadWebPartUsageCSV]. Exception Message: " + ex.Message
                                       + ", Exception Comments: Exception occured while rading input file ", true);
                ExceptionCsv.WriteException(Constants.NotApplicable, Constants.NotApplicable, Constants.NotApplicable, "Webpart", ex.Message,
                                            ex.ToString(), "ReadWebPartUsageCSV", ex.GetType().ToString(), "Exception occured while rading input file");
            }
        }
        public static void DoWork()
        {
            string timeStamp      = DateTime.Now.ToString("yyyyMMdd_hhmmss");
            string setupInputFile = string.Empty;

            Logger.OpenLog("DeleteSetupFiles", timeStamp);

            //if (!ShowInformation())
            //    return;

            if (!ReadInputFile(ref setupInputFile))
            {
                System.Console.ForegroundColor = System.ConsoleColor.Red;
                Logger.LogErrorMessage("Setup Files input file is not valid or available. So, Operation aborted!");
                Logger.LogErrorMessage("Please enter path like: E.g. C:\\<Working Directory>\\<InputFile>.csv");
                System.Console.ResetColor();
                return;
            }

            string inputFileSpec = setupInputFile;

            if (System.IO.File.Exists(inputFileSpec))
            {
                Logger.LogInfoMessage(String.Format("Scan starting {0}", DateTime.Now.ToString()), true);
                IEnumerable <MissingSetupFilesInput> objInputMissingSetupFiles = ImportCSV.ReadMatchingColumns <MissingSetupFilesInput>(inputFileSpec, Constants.CsvDelimeter);
                if (objInputMissingSetupFiles != null && objInputMissingSetupFiles.Any())
                {
                    try
                    {
                        string csvFile = Environment.CurrentDirectory + @"\" + Constants.DeleteSetupFileStatus + timeStamp + Constants.CSVExtension;
                        if (System.IO.File.Exists(csvFile))
                        {
                            System.IO.File.Delete(csvFile);
                        }
                        Logger.LogInfoMessage(String.Format("Preparing to delete a total of {0} files ...", objInputMissingSetupFiles.Cast <Object>().Count()), true);

                        foreach (MissingSetupFilesInput missingFile in objInputMissingSetupFiles)
                        {
                            DeleteMissingFile(missingFile, csvFile);
                        }
                    }
                    catch (Exception ex)
                    {
                        Logger.LogErrorMessage(String.Format("[DeleteSetupFiles: DoWork] failed: Error={0}", ex.Message), true);
                        ExceptionCsv.WriteException(Constants.NotApplicable, Constants.NotApplicable, Constants.NotApplicable, "SetupFile", ex.Message,
                                                    ex.ToString(), "DoWork", ex.GetType().ToString(), "Exception occured while reading input file");
                    }
                }
                else
                {
                    Logger.LogInfoMessage("There is nothing to delete from the '" + inputFileSpec + "' File ", true);
                }
                Logger.LogInfoMessage(String.Format("Scan Completed {0}", DateTime.Now.ToString()), true);
            }
            else
            {
                Logger.LogErrorMessage(String.Format("[DeleteSetupFiles: DoWork]: Input file {0} is not available", inputFileSpec), true);
            }
            Logger.CloseLog();
        }
示例#4
0
        private static void ReadWebPartUsageCSV(string sourceWebPartType, string usageFilePath, string outPutFolder, out IEnumerable <WebPartDiscoveryInput> objWPDInput)
        {
            string exceptionCommentsInfo1 = string.Empty;

            Logger.LogInfoMessage("[ReadWebPartUsageCSV] [START] Calling function ImportCsv.ReadMatchingColumns<WebPartDiscoveryInput>");

            objWPDInput = null;
            objWPDInput = ImportCSV.ReadMatchingColumns <WebPartDiscoveryInput>(usageFilePath, Constants.CsvDelimeter);

            Logger.LogInfoMessage("[ReadWebPartUsageCSV] [END] Read all the WebParts Usage Details from Discovery Usage File and saved in List - out IEnumerable<WebPartDiscoveryInput> objWPDInput, for processing.");

            try
            {
                if (objWPDInput.Any())
                {
                    Logger.LogInfoMessage("[START] ReadWebPartUsageCSV - After Loading InputCSV ");

                    objWPDInput = from p in objWPDInput
                                  where p.WebPartType.ToLower() == sourceWebPartType.ToLower()
                                  select p;
                    exceptionCommentsInfo1 = objWPDInput.ToString();

                    Logger.LogInfoMessage("[END] ReadWebPartUsageCSV - After Loading InputCSV");
                }
            }
            catch (Exception ex)
            {
                System.Console.ForegroundColor = System.ConsoleColor.Red;
                Logger.LogErrorMessage("[ReadWebPartUsageCSV] Exception Message: " + ex.Message + ", Exception Comments:" + exceptionCommentsInfo1);
                System.Console.ResetColor();
                ExceptionCsv.WriteException(Constants.NotApplicable, Constants.NotApplicable, Constants.NotApplicable, "ReplaceWebPart", ex.Message, ex.ToString(), "ReadWebPartUsageCSV()", ex.GetType().ToString(), exceptionCommentsInfo1);
            }
        }
        public static void DoWork(string inputFileSpec)
        {
            Logger.OpenLog("CommentUDCXFileNodes");
            Logger.LogInfoMessage(String.Format("Scan starting {0}", DateTime.Now.ToString()), true);
            Logger.LogInfoMessage(inputFileSpec, true);

            List <UdcxReportOutput> _WriteUDCList = null;

            Logger.LogInfoMessage(String.Format("AppSettings:"), true);
            Logger.LogInfoMessage(String.Format("- AppSettings[UseAppModel] = {0}", Program.UseAppModel), true);
            if (Program.UseAppModel == true)
            {
                Logger.LogInfoMessage(String.Format("- AppId = {0}", ConfigurationManager.AppSettings["ClientId"].ToString()), true);
            }
            else
            {
                string adminUsername = String.Format("{0}{1}", (String.IsNullOrEmpty(Program.AdminDomain) ? "" : String.Format("{0}\\", Program.AdminDomain)), Program.AdminUsername);
                Logger.LogInfoMessage(String.Format("- Admin Username = {0}", adminUsername), true);
            }

            IEnumerable <UdcxReportInput> udcxCSVRows = ImportCSV.ReadMatchingColumns <UdcxReportInput>(inputFileSpec, Constants.CsvDelimeter);

            if (udcxCSVRows != null)
            {
                try
                {
                    var authRows = udcxCSVRows.Where(x => x.Authentication != null && x.Authentication != Constants.ErrorStatus && x.Authentication.Length > 0);
                    if (authRows != null && authRows.Count() > 0)
                    {
                        _WriteUDCList = new List <UdcxReportOutput>();
                        Logger.LogInfoMessage(String.Format("Preparing to process a total of {0} Udcx Files ...", authRows.Count()), true);

                        foreach (UdcxReportInput udcxFileInput in authRows)
                        {
                            CommentUDCXFileNode(udcxFileInput, _WriteUDCList);
                        }

                        GenerateStatusReport(_WriteUDCList);
                    }
                    else
                    {
                        Logger.LogInfoMessage("No UDCX File records with authentication nodes found in '" + inputFileSpec + "' File ", true);
                    }
                }
                catch (Exception ex)
                {
                    Logger.LogErrorMessage(String.Format("CommentUDCXFileNode() failed: Error={0}", ex.Message), true);
                }

                Logger.LogInfoMessage(String.Format("Scan completed {0}", DateTime.Now.ToString()), true);
            }
            else
            {
                Logger.LogInfoMessage("No UDCX File records found in '" + inputFileSpec + "' File ", true);
            }

            Logger.CloseLog();
        }
        public static void DoWork()
        {
            string timeStamp = DateTime.Now.ToString("yyyyMMdd_hhmmss");

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

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

            string inputFileSpec = String.Empty;

            if (!ReadInputFile(ref inputFileSpec))
            {
                System.Console.ForegroundColor = System.ConsoleColor.Red;
                Logger.LogErrorMessage(String.Format("Input file [{0}] does not exist.", inputFileSpec), true);
                Logger.LogInfoMessage(String.Format("Scan aborted {0}", DateTime.Now.ToString()), true);
                Logger.CloseLog();
                System.Console.ResetColor();
                return;
            }

            // The Locked Master Pages input file is essentially a filtered instance of the Missing Setup Files input file.
            IEnumerable <LockedMasterPageFilesInput> objInputLockedMasterPageFiles = ImportCSV.ReadMatchingColumns <LockedMasterPageFilesInput>(inputFileSpec, Constants.CsvDelimeter);

            if (objInputLockedMasterPageFiles == null || objInputLockedMasterPageFiles.Count() == 0)
            {
                System.Console.ForegroundColor = System.ConsoleColor.Red;
                Logger.LogErrorMessage(String.Format("Input file [{0}] is empty.", inputFileSpec), true);
                Logger.LogInfoMessage(String.Format("Scan aborted {0}", DateTime.Now.ToString()), true);
                Logger.CloseLog();
                System.Console.ResetColor();
                return;
            }

            Logger.LogInfoMessage(String.Format("Preparing to process a total of {0} master page files ...", objInputLockedMasterPageFiles.Count()), true);
            try
            {
                foreach (LockedMasterPageFilesInput masterPageFile in objInputLockedMasterPageFiles)
                {
                    ResetMappingFile(masterPageFile);
                }
            }
            catch (Exception ex)
            {
                Logger.LogErrorMessage(String.Format("ResetDeviceChannelMappingFiles() failed: Error={0}", ex.Message), true);
                ExceptionCsv.WriteException(
                    Constants.NotApplicable, Constants.NotApplicable, Constants.NotApplicable,
                    "MappingFile",
                    ex.Message, ex.ToString(), "DoWork", ex.GetType().ToString(),
                    "Exception occured while processing input file."
                    );
            }

            Logger.LogInfoMessage(String.Format("Scan completed {0}", DateTime.Now.ToString()), true);
            Logger.CloseLog();
        }
示例#7
0
        public static void DoWork(string inputFileSpec)
        {
            Logger.OpenLog("PeoplePickerRemediation");
            Logger.LogInfoMessage(String.Format("Scan starting {0}", DateTime.Now.ToString()), true);
            Logger.LogInfoMessage(inputFileSpec, true);
            List <PeoplePickerListOutput> _WriteUDCList = null;

            IEnumerable <PeoplePickerListsInput> pprCSVRows = ImportCSV.ReadMatchingColumns <PeoplePickerListsInput>(inputFileSpec, Constants.CsvDelimeter);

            if (pprCSVRows != null)
            {
                try
                {
                    var lists = pprCSVRows.Where(x => x.ListName != null && x.WebUrl != null);
                    if (lists != null && lists.Count() > 0)
                    {
                        _WriteUDCList = new List <PeoplePickerListOutput>();
                        Logger.LogInfoMessage(String.Format("Preparing to process a total of {0} PeoplePicker InfoPath Forms ...", lists.Count()), true);
                        PeoplePickerListOutput ps = new PeoplePickerListOutput();
                        foreach (PeoplePickerListsInput pprFileInput in lists)
                        {
                            ReadFormLibUsingAppOnlyAndCredentials(pprFileInput, ref _WriteUDCList);
                        }

                        if (_WriteUDCList != null && _WriteUDCList.Any())
                        {
                            GenerateStatusReport(_WriteUDCList);
                            _WriteUDCList = null;
                        }
                    }
                    else
                    {
                        Logger.LogInfoMessage("No valid authentication records found in '" + inputFileSpec + "' File ", true);
                    }
                }
                catch (Exception ex)
                {
                    Logger.LogErrorMessage(String.Format("PeoplePickerRemediation:DoWork() failed: Error={0}", ex.Message), true);
                }

                Logger.LogInfoMessage(String.Format("Scan completed {0}", DateTime.Now.ToString()), true);
            }
            else
            {
                Logger.LogInfoMessage("No records found in '" + inputFileSpec + "' File ", true);
            }

            Logger.CloseLog();
        }
示例#8
0
        public static void DoWork(string inputFileSpec)
        {
            Logger.OpenLog("CommentUDCXFileNodes");
            Logger.LogInfoMessage(String.Format("Scan starting {0}", DateTime.Now.ToString()), true);
            Logger.LogInfoMessage(inputFileSpec, true);

            List <UdcxReportOutput> _WriteUDCList = null;

            IEnumerable <UdcxReportInput> udcxCSVRows = ImportCSV.ReadMatchingColumns <UdcxReportInput>(inputFileSpec, Constants.CsvDelimeter);

            if (udcxCSVRows != null)
            {
                try
                {
                    var authRows = udcxCSVRows.Where(x => x.Authentication != null && x.Authentication != Constants.ErrorStatus && x.Authentication.Length > 0);
                    if (authRows != null && authRows.Count() > 0)
                    {
                        _WriteUDCList = new List <UdcxReportOutput>();
                        Logger.LogInfoMessage(String.Format("Preparing to comment a total of {0} Udcx Files Nodes ...", authRows.Count()), true);

                        foreach (UdcxReportInput udcxFileInput in authRows)
                        {
                            CommentUDCXFileNode(udcxFileInput, _WriteUDCList);
                        }

                        GenerateStatusReport(_WriteUDCList);
                    }
                    else
                    {
                        Logger.LogInfoMessage("No valid authentication records found in '" + inputFileSpec + "' File ", true);
                    }
                }
                catch (Exception ex)
                {
                    Logger.LogErrorMessage(String.Format("CommentUDCXFileNode() failed: Error={0}", ex.Message), true);
                }

                Logger.LogInfoMessage(String.Format("Scan completed {0}", DateTime.Now.ToString()), true);
            }
            else
            {
                Logger.LogInfoMessage("No records found in '" + inputFileSpec + "' File ", 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();
        }
示例#10
0
        public static void DoWork()
        {
            outputPath = Environment.CurrentDirectory;
            string webPartsInputFile = string.Empty;
            string webpartType       = string.Empty;
            IEnumerable <WebpartInput> objWPDInput;
            string timeStamp = DateTime.Now.ToString("yyyyMMdd_hhmmss");

            //Trace Log TXT File Creation Command
            Logger.OpenLog("DeleteWebparts", timeStamp);

            if (!ReadInputFile(ref webPartsInputFile))
            {
                System.Console.ForegroundColor = System.ConsoleColor.Red;
                Logger.LogErrorMessage("Webparts input file is not valid or available. So, Operation aborted!");
                Logger.LogErrorMessage("Please enter path like: E.g. C:\\<Working Directory>\\<InputFile>.csv");
                System.Console.ResetColor();
                return;
            }

            System.Console.ForegroundColor = System.ConsoleColor.Cyan;
            Logger.LogMessage("Please enter Webpart Type (enter 'all' to delete all webparts):");
            System.Console.ResetColor();
            webpartType = System.Console.ReadLine().ToLower();

            try
            {
                string csvFile = outputPath + @"/" + Constants.DeleteWebpartStatus + timeStamp + Constants.CSVExtension;
                if (System.IO.File.Exists(csvFile))
                {
                    System.IO.File.Delete(csvFile);
                }

                if (System.IO.File.Exists(webPartsInputFile))
                {
                    if (String.Equals(Constants.WebpartType_All, webpartType, StringComparison.CurrentCultureIgnoreCase))
                    {
                        //Reading Input File
                        objWPDInput = ImportCSV.ReadMatchingColumns <WebpartInput>(webPartsInputFile, Constants.CsvDelimeter);

                        if (objWPDInput.Any())
                        {
                            IEnumerable <string> webPartTypes = objWPDInput.Select(x => x.WebPartType);

                            webPartTypes = webPartTypes.Distinct();
                            Logger.LogInfoMessage(String.Format("Preparing to delete a total of {0} webparts ...", webPartTypes.Count()), true);

                            foreach (string webPartType in webPartTypes)
                            {
                                try
                                {
                                    DeleteWebPart_UsingCSV(webPartType, webPartsInputFile, csvFile);
                                }
                                catch (Exception ex)
                                {
                                    Logger.LogErrorMessage("[DeleteMissingWebparts: DoWork]. Exception Message: " + ex.Message, true);
                                    ExceptionCsv.WriteException(Constants.NotApplicable, Constants.NotApplicable, Constants.NotApplicable, "Webpart", ex.Message,
                                                                ex.ToString(), "DoWork", ex.GetType().ToString(), Constants.NotApplicable);
                                }
                            }
                            webPartTypes = null;
                        }
                        else
                        {
                            Logger.LogInfoMessage("There is nothing to delete from the '" + webPartsInputFile + "' File ", true);
                        }
                    }
                    else
                    {
                        DeleteWebPart_UsingCSV(webpartType, webPartsInputFile, csvFile);
                    }
                    Logger.LogInfoMessage("Processing input file has been comepleted...");
                }
                else
                {
                    Logger.LogErrorMessage("[DeleteMissingWebparts: DoWork]The input file " + webPartsInputFile + " is not present", true);
                }
            }
            catch (Exception ex)
            {
                Logger.LogErrorMessage("[DeleteMissingWebparts: DoWork]. Exception Message: " + ex.Message, true);
                ExceptionCsv.WriteException(Constants.NotApplicable, Constants.NotApplicable, Constants.NotApplicable, "Webpart", ex.Message,
                                            ex.ToString(), "DoWork", ex.GetType().ToString(), Constants.NotApplicable);
            }
            finally
            {
                objWPDInput = null;
            }

            Logger.CloseLog();
        }
        public static void DoWork(string inputFileSpec)
        {
            Logger.OpenLog("PeoplePickerRemediation");
            Logger.LogInfoMessage(String.Format("Scan starting {0}", DateTime.Now.ToString()), true);
            Logger.LogInfoMessage(inputFileSpec, true);
            List <PeoplePickerListOutput> _WriteUDCList = null;

            Logger.LogInfoMessage(String.Format("AppSettings:"), true);
            Logger.LogInfoMessage(String.Format("- AppSettings[UseAppModel] = {0}", Program.UseAppModel), true);
            if (Program.UseAppModel == true)
            {
                Logger.LogInfoMessage(String.Format("- AppId = {0}", ConfigurationManager.AppSettings["ClientId"].ToString()), true);
            }
            else
            {
                string adminUsername = String.Format("{0}{1}", (String.IsNullOrEmpty(Program.AdminDomain) ? "" : String.Format("{0}\\", Program.AdminDomain)), Program.AdminUsername);
                Logger.LogInfoMessage(String.Format("- Admin Username = {0}", adminUsername), true);
            }
            Logger.LogInfoMessage(String.Format("- AppSettings[LocalAdLdapQuery] = {0}", ConfigurationManager.AppSettings["LocalAdLdapQuery"].ToString()), true);
            Logger.LogInfoMessage(String.Format("- AppSettings[UpnPrefix] = {0}", ConfigurationManager.AppSettings["UpnPrefix"].ToString()), true);
            Logger.LogInfoMessage(String.Format("- AppSettings[UpdateUserInfoEvenIfEventReceiversEnabled] = {0}", ConfigurationManager.AppSettings["UpdateUserInfoEvenIfEventReceiversEnabled"].ToString()), true);
            Logger.LogInfoMessage(String.Format("- AppSettings[UpdateUserInfoEvenIfWorkflowsEnabled] = {0}", ConfigurationManager.AppSettings["UpdateUserInfoEvenIfWorkflowsEnabled"].ToString()), true);
            Logger.LogInfoMessage(String.Format("- AppSettings[CamlQueryRowLimit] = {0}", ConfigurationManager.AppSettings["CamlQueryRowLimit"].ToString()), true);

            IEnumerable <PeoplePickerListsInput> pprCSVRows = ImportCSV.ReadMatchingColumns <PeoplePickerListsInput>(inputFileSpec, Constants.CsvDelimeter);

            if (pprCSVRows != null)
            {
                try
                {
                    var lists = pprCSVRows.Where(x => x.ListName != null && x.WebUrl != null);
                    if (lists != null && lists.Count() > 0)
                    {
                        _WriteUDCList = new List <PeoplePickerListOutput>();
                        Logger.LogInfoMessage(String.Format("Preparing to process a total of {0} PeoplePicker InfoPath Form Libraries ...", lists.Count()), true);
                        PeoplePickerListOutput ps = new PeoplePickerListOutput();
                        foreach (PeoplePickerListsInput pprFileInput in lists)
                        {
                            ReadFormLibUsingAppOnlyAndCredentials(pprFileInput, ref _WriteUDCList);
                        }

                        if (_WriteUDCList != null && _WriteUDCList.Any())
                        {
                            GenerateStatusReport(_WriteUDCList);
                            _WriteUDCList = null;
                        }
                    }
                    else
                    {
                        Logger.LogInfoMessage("No valid PeoplePicker InfoPath Form Library records found in '" + inputFileSpec + "' File ", true);
                    }
                }
                catch (Exception ex)
                {
                    Logger.LogErrorMessage(String.Format("PeoplePickerRemediation:DoWork() failed: Error={0}", ex.Message), true);
                }

                Logger.LogInfoMessage(String.Format("Scan completed {0}", DateTime.Now.ToString()), true);
            }
            else
            {
                Logger.LogInfoMessage("No PeoplePicker InfoPath Form Library records found in '" + inputFileSpec + "' File ", true);
            }

            Logger.CloseLog();
        }
示例#12
0
        public static void DoWork()
        {
            try
            {
                Logger.OpenLog("DeleteMissingWorkflowAssociations");
                System.Console.WriteLine("Enter the path of input file PreMT_MissingWorkflowAssociations.csv");
                string filePath = System.Console.ReadLine();
                if (string.IsNullOrEmpty(filePath) || !System.IO.Directory.Exists(filePath))
                {
                    Logger.LogWarningMessage("Input FilePath '" + filePath + "' is not valid", true);
                    filePath = Environment.CurrentDirectory;
                    Logger.LogInfoMessage("Correct Input FilePath is not provided so it changed to current environment '" + filePath + "'", true);
                }

                Logger.LogInfoMessage(String.Format("Scan starting {0}", DateTime.Now.ToString()), true);
                string inputFileSpec = filePath + "\\" + Constants.MissingWorkflowAssociationsInputFileName;
                if (System.IO.File.Exists(inputFileSpec))
                {
                    IEnumerable <MissingWorkflowAssociationsInput> objInputMissingWorkflowAssociations = ImportCSV.ReadMatchingColumns <MissingWorkflowAssociationsInput>(inputFileSpec, Constants.CsvDelimeter);
                    if (objInputMissingWorkflowAssociations != null)
                    {
                        try
                        {
                            Logger.LogInfoMessage(String.Format("\nPreparing to delete a total of {0} files ...", objInputMissingWorkflowAssociations.Cast <Object>().Count()), true);

                            foreach (MissingWorkflowAssociationsInput missingFile in objInputMissingWorkflowAssociations)
                            {
                                DeleteMissingFile(missingFile);
                            }
                        }
                        catch (Exception ex)
                        {
                            Logger.LogErrorMessage(String.Format("DeleteMissingWorkflowAssociationFiles() failed: Error={0}", ex.Message), true);
                        }
                        Logger.LogInfoMessage(String.Format("Scan completed {0}", DateTime.Now.ToString()), true);
                    }
                    else
                    {
                        Logger.LogInfoMessage("There is nothing to delete from the '" + inputFileSpec + "' File ", true);
                    }
                }
                else
                {
                    Logger.LogErrorMessage("The input file " + inputFileSpec + " is not present", true);
                }
            }
            catch (Exception ex)
            {
                Logger.LogErrorMessage(String.Format("DeleteMissingWorkflowAssociationFiles() failed: Error={0}", ex.Message), true);
            }
            Logger.CloseLog();
        }