/// <summary> /// Helper method to add a dictionary object to the output report for /// improved styling. /// </summary> /// <param name="JobOutput"></param> /// <param name="report"></param> private void AddJobOutputToReport(Dictionary<string, string> JobOutput, ref ProgressReport report) { foreach(string processColumn in JobOutput.Keys) { report.AddEntry(JobOutput[processColumn]); } }
/// <summary> /// Wrapper function to cover several activities (looping around all site collections) /// 1. Getting content types for the SC /// 2. removing field links to the fields /// 3. removing the fields /// 4. Hide and rename of content types /// 5. removal of content types /// 6. Reset the 'refresh CT publishing' flag /// </summary> /// <param name="ResetValues"></param> /// <param name="outputReport"></param> private void ProcessSiteCollections(SyndicationResetValues ResetValues, ref string outputReport) { Dictionary<string, string> jobOutput = new Dictionary<string, string>(); foreach (string siteCollectionURL in _resetValues.SiteCollections) { ProgressReport scReport = new ProgressReport(siteCollectionURL); using (_ctx = GetClientContext(siteCollectionURL)) { RetreiveContentTypes(); scReport.AddEntry("Content types read from target site collection"); if (_resetValues.ProcessFields) { scReport.AddEntry("*** Removing field links"); jobOutput = RemoveFieldLinks(); AddJobOutputToReport(jobOutput, ref scReport); scReport.AddEntry(String.Format("*** Removing Site Columns: {0} columns to process", _cthCols.Keys.Count)); jobOutput = RemoveSiteColumns(); AddJobOutputToReport(jobOutput, ref scReport); } if (_resetValues.ProcessCTHide) { scReport.AddEntry(String.Format("*** Rename and hiding {0} content types", ResetValues.ContentTypesToRenameAndHide.Count)); jobOutput = RenameAndHideContentTypes(ResetValues.ContentTypesToRenameAndHide); AddJobOutputToReport(jobOutput, ref scReport); } if (_resetValues.ProcessCTRemove) { scReport.AddEntry(String.Format("*** Removing {0} content types", ResetValues.ContentTypesToRemove.Count)); jobOutput = RemoveContentTypes(ResetValues.ContentTypesToRemove); AddJobOutputToReport(jobOutput, ref scReport); } if (_resetValues.ProcessRemoveFieldsFromLists) { scReport.AddEntry(String.Format("*** Removing {0} content types", ResetValues.ContentTypesToRemove.Count)); jobOutput = RemoveFieldsFromLists(); AddJobOutputToReport(jobOutput, ref scReport); } if (_resetValues.ProcessRefreshCTFlag) { scReport.AddEntry("*** Setting the 'Refresh Content Types' Flag"); SetRefreshContentTypesFlag(); } } outputReport += scReport.Output() + Environment.NewLine; outputReport += "-----------------------------------------------------------" + Environment.NewLine + Environment.NewLine; } }