public static bool ProcessStpFile(string filePath, string solFileName, ref ListTemplateFTCAnalysisOutputBase objListCustOutput) { bool isCustomizationPresent = false; bool isCustomContentType = false; bool isCustomEventReceiver = false; bool isCustomSiteColumn = false; StringBuilder cTHavingCustomER = new StringBuilder(); string fileName = objListCustOutput.ListTemplateName; string downloadFolder = filePath + @"\" + Constants.DownloadPathListTemplates; Logger.LogInfoMessage("[DownloadAndModifyListTemplate: ProcessStpFile] Processing the List Template: " + objListCustOutput.ListTemplateName, true); try { string cabDir = string.Empty; string newFilePath = solFileName.ToLower().Replace(".stp", ".cab"); if (System.IO.File.Exists(newFilePath)) System.IO.File.Delete(newFilePath); System.IO.File.Move(solFileName, newFilePath); var destDir = newFilePath.Substring(0, newFilePath.LastIndexOf(@"\")); Directory.SetCurrentDirectory(destDir); string newFileName = newFilePath.Substring(newFilePath.LastIndexOf(@"\") + 1); FileInfo solFileObj = new FileInfo(newFileName); Logger.LogInfoMessage("[DownloadAndModifyListTemplate: ProcessStpFile] Extracting the List Template: " + objListCustOutput.ListTemplateName, true); //string cmd = "/e /a /y /L \"" + newFileName.Replace(".", "_") + "\" \"" + newFileName + "\""; //ProcessStartInfo pI = new ProcessStartInfo("extrac32.exe", cmd); //pI.WindowStyle = ProcessWindowStyle.Hidden; //Process p = Process.Start(pI); //p.WaitForExit(); //if (!destDir.EndsWith(@"\")) // cabDir = destDir + @"\" + newFileName.Replace(".", "_"); //else // cabDir = destDir + newFileName.Replace(".", "_"); //Directory.SetCurrentDirectory(newFileName.Replace(".", "_")); //if (!destDir.EndsWith(@"\")) // cabDir = destDir + @"\" + newFileName.Replace(".", "_"); //else // cabDir = destDir + newFileName.Replace(".", "_"); FileUtility.UnCab(solFileName.ToLower().Replace(".stp", ".cab"), destDir); Directory.SetCurrentDirectory(destDir); Logger.LogInfoMessage("[DownloadAndModifyListTemplate: ProcessStpFile] Extracted the List Template: " + objListCustOutput.ListTemplateName + " in path: " + cabDir, true); string[] webTempFiles = Directory.GetFiles(Directory.GetCurrentDirectory(), "Manifest.xml", SearchOption.AllDirectories); XmlDocument xmlReceiver = new XmlDocument(); string xmlString = webTempFiles[0]; Logger.LogInfoMessage("[DownloadAndModifyListTemplate: ProcessStpFile] Searching for customized elements in: " + xmlString, true); var reader = new XmlTextReader(xmlString); string xml; using (TextReader txtreader = new StreamReader(xmlString)) { xml = txtreader.ReadToEnd(); } xml = CommonUtility.SanitizeXmlString(xml); reader.Namespaces = false; reader.Read(); XmlDocument doc = new XmlDocument(); //doc.Load(reader); //doc.LoadXml(xml); try { doc = CommonUtility.GetXmlDocumentFromString(xml); } catch (Exception ex) { Logger.LogErrorMessage("[DownloadAndModifyListTemplate: ProcessStpFile]. Exception Message: " + ex.Message + ", Exception Comments: Exception while loading the XML File. XML File Path: " + xmlString + ". SolFileName: " + solFileName, true); ExceptionCsv.WriteException(objListCustOutput.WebApplication, objListCustOutput.SiteCollection, objListCustOutput.WebUrl, "ListTemplate", ex.Message, ex.ToString(), "ProcessStpFile", ex.GetType().ToString(), "Exception while loading the XML File. XML File Path: " + xmlString + ". SolFileName: " + solFileName); } //Initiallizing all the nodes required to check XmlNodeList receiverNodes = doc.SelectNodes("/ListTemplate/UserLists/List/MetaData/Receivers/Receiver"); XmlNodeList xmlCTReceivers = doc.SelectNodes("/ListTemplate/UserLists/List/MetaData/ContentTypes/ContentType"); XmlNodeList xmlFields = doc.SelectNodes("/ListTemplate/UserLists/List/MetaData/Fields/Field"); #region Custom_EventReceivers //Checking for Customization Logger.LogInfoMessage("[DownloadAndModifyListTemplate: ProcessStpFile] Searching for customized List Event Receivers", true); if (receiverNodes != null && receiverNodes.Count > 0) { if (lstCustomErs != null && lstCustomErs.Count > 0) { foreach (XmlNode node in receiverNodes) { try { string assemblyValue = node["Assembly"].InnerText; if (lstCustomErs.Where(c => assemblyValue.Equals(c, StringComparison.CurrentCultureIgnoreCase)).Any()) { isCustomEventReceiver = true; Logger.LogInfoMessage("[DownloadAndModifyListTemplate: ProcessStpFile] Customized List Event Receiver Found for " + objListCustOutput.ListTemplateName, true); break; } } catch (Exception ex) { Logger.LogErrorMessage("[DownloadAndModifyListTemplate: ProcessStpFile]. Exception Message: " + ex.Message + ", Exception Comments: Exception while reading List Receivers tag" + " SolFileName: " + solFileName + ". XML File Path: " + xmlString, true); ExceptionCsv.WriteException(objListCustOutput.WebApplication, objListCustOutput.SiteCollection, objListCustOutput.WebUrl, "ListTemplate", ex.Message, ex.ToString(), "ProcessStpFile", ex.GetType().ToString(), "Exception while reading List Receivers tag" + " SolFileName: " + solFileName + ". XML File Path: " + xmlString); } } } } #endregion Logger.LogInfoMessage("[DownloadAndModifyListTemplate: ProcessStpFile] Searching for customized Event Receivers associated with Content Types", true); if (xmlCTReceivers != null && xmlCTReceivers.Count > 0) { #region Custom ContentTypeEventReceivers //checking Event Receivers in Content Types if (lstCustomErs != null && lstCustomErs.Count > 0) { for (int i = 0; i < xmlCTReceivers.Count; i++) { try { //cTHavingCustomER.Append(xmlCTReceivers[i].Attributes["Name"].Value + ";"); var docList = xmlCTReceivers[i]["XmlDocuments"]; if (docList != null) { XmlNodeList xmlDocList = docList.ChildNodes; for (int j = 0; j < xmlDocList.Count; j++) { try { var namespaceURl = xmlDocList[j].Attributes["NamespaceURI"].Value; if (namespaceURl.Contains("http://schemas.microsoft.com/sharepoint/events")) { byte[] data = Convert.FromBase64String(xmlDocList[j].InnerText); string decodedString = Encoding.UTF8.GetString(data); XmlDocument docReceivers = new XmlDocument(); docReceivers.LoadXml(decodedString); XmlNamespaceManager nsmgr = new XmlNamespaceManager(docReceivers.NameTable); nsmgr.AddNamespace("spe", "http://schemas.microsoft.com/sharepoint/events"); XmlNodeList receiverChilds = docReceivers.SelectNodes("/spe:Receivers/Receiver", nsmgr); if (receiverChilds != null && receiverChilds.Count > 0) { for (int y = 0; y < receiverChilds.Count; y++) { try { string ctAssemblyValue = receiverChilds[y]["Assembly"].InnerText; if (lstCustomErs.Where(c => ctAssemblyValue.Equals(c, StringComparison.CurrentCultureIgnoreCase)).Any()) { //isCustomEventReceiver = true; cTHavingCustomER.Append(xmlCTReceivers[i].Attributes["Name"].Value + ";"); Logger.LogInfoMessage("[DownloadAndModifyListTemplate: ProcessStpFile] Customized Event Receiver associated with Content Type Found for : " + objListCustOutput.ListTemplateName, true); break; } } catch (Exception ex) { Logger.LogErrorMessage("[DownloadAndModifyListTemplate: ProcessStpFile]. Exception Message: " + ex.Message + ", Exception Comments: Exception while reading Receivers tag in Content Types" + " SolFileName: " + solFileName + ". XML File Path: " + xmlString, true); ExceptionCsv.WriteException(objListCustOutput.WebApplication, objListCustOutput.SiteCollection, objListCustOutput.WebUrl, "ListTemplate", ex.Message, ex.ToString(), "ProcessStpFile", ex.GetType().ToString(), "Exception while reading Receivers tag in Content Types" + " SolFileName: " + solFileName + ". XML File Path: " + xmlString); } } } } } catch (Exception ex) { Logger.LogErrorMessage("[DownloadAndModifyListTemplate: ProcessStpFile]. Exception Message: " + ex.Message + ", Exception Comments: Exception while reading Receivers tag in Content Types" + " SolFileName: " + solFileName + ". XML File Path: " + xmlString, true); ExceptionCsv.WriteException(objListCustOutput.WebApplication, objListCustOutput.SiteCollection, objListCustOutput.WebUrl, "ListTemplate", ex.Message, ex.ToString(), "ProcessStpFile", ex.GetType().ToString(), "Exception while reading Receivers tag in Content Types" + " SolFileName: " + solFileName + ". XML File Path: " + xmlString); } } } } catch (Exception ex) { Logger.LogErrorMessage("[DownloadAndModifyListTemplate: ProcessStpFile]. Exception Message: " + ex.Message + ", Exception Comments: Exception while reading Receivers tag in Content Types" + " SolFileName: " + solFileName + ". XML File Path: " + xmlString, true); ExceptionCsv.WriteException(objListCustOutput.WebApplication, objListCustOutput.SiteCollection, objListCustOutput.WebUrl, "ListTemplate", ex.Message, ex.ToString(), "ProcessStpFile", ex.GetType().ToString(), "Exception while reading Receivers tag in Content Types" + " SolFileName: " + solFileName + ". XML File Path: " + xmlString); } } } #endregion #region custom contenttypes if (lstContentTypeIDs != null && lstContentTypeIDs.Count > 0) { //Iterate all ContentTypes in manifest.xml Logger.LogInfoMessage("[DownloadAndModifyListTemplate: ProcessStpFile] Searching for customized Content Types", true); for (int i = 0; i < xmlCTReceivers.Count; i++) { try { var docList = xmlCTReceivers[i].Attributes["ID"].Value; //Remove contenttype tag if ContentTypeId present in custom ContentTypes file ContentTypes.csv if (lstContentTypeIDs.Where(c => docList.StartsWith(c)).Any()) { isCustomContentType = true; Logger.LogInfoMessage("[DownloadAndModifyListTemplate: ProcessStpFile] Customized Content Type Found for: " + objListCustOutput.ListTemplateName, true); break; } } catch (Exception ex) { Logger.LogErrorMessage("[DownloadAndModifyListTemplate: ProcessStpFile]. Exception Message: " + ex.Message + ", Exception Comments: Exception while reading Content Types" + " SolFileName: " + solFileName + ". XML File Path: " + xmlString, true); ExceptionCsv.WriteException(objListCustOutput.WebApplication, objListCustOutput.SiteCollection, objListCustOutput.WebUrl, "ListTemplate", ex.Message, ex.ToString(), "ProcessStpFile", ex.GetType().ToString(), "Exception while reading Content Types" + " SolFileName: " + solFileName + ". XML File Path: " + xmlString); } } } #endregion #region CustomFields_In_Contenttyeps if (lstCustomFieldIDs != null && lstCustomFieldIDs.Count > 0) { //Checking Site Columns presence in Content Types Logger.LogInfoMessage("[DownloadAndModifyListTemplate: ProcessStpFile] Searching for customized Site Columns associated with Content Types", true); for (int i = 0; i < xmlCTReceivers.Count; i++) { try { var fieldRefs = xmlCTReceivers[i]["FieldRefs"]; if (fieldRefs != null) { XmlNodeList xmlFieldRefList = fieldRefs.ChildNodes; for (int j = 0; j < xmlFieldRefList.Count; j++) { try { string fieldRefId = xmlFieldRefList[j].Attributes["ID"].Value; if (lstCustomFieldIDs.Where(c => fieldRefId.Equals(c)).Any()) { isCustomSiteColumn = true; Logger.LogInfoMessage("[DownloadAndModifyListTemplate: ProcessStpFile] Customized Site Column associated with Content Type Found for: " + objListCustOutput.ListTemplateName, true); break; } } catch (Exception ex) { Logger.LogErrorMessage("[DownloadAndModifyListTemplate: ProcessStpFile]. Exception Message: " + ex.Message + ", Exception Comments: Exception while reading Site Columns tag in Content Types" + " SolFileName: " + solFileName + ". XML File Path: " + xmlString, true); ExceptionCsv.WriteException(objListCustOutput.WebApplication, objListCustOutput.SiteCollection, objListCustOutput.WebUrl, "ListTemplate", ex.Message, ex.ToString(), "ProcessStpFile", ex.GetType().ToString(), "Exception while reading Site Columns tag in Content Types" + " SolFileName: " + solFileName + ". XML File Path: " + xmlString); } } } } catch (Exception ex) { Logger.LogErrorMessage("[DownloadAndModifyListTemplate: ProcessStpFile]. Exception Message: " + ex.Message + ", Exception Comments: Exception while reading Site Columns tag in Content Types" + " SolFileName: " + solFileName + ". XML File Path: " + xmlString, true); ExceptionCsv.WriteException(objListCustOutput.WebApplication, objListCustOutput.SiteCollection, objListCustOutput.WebUrl, "ListTemplate", ex.Message, ex.ToString(), "ProcessStpFile", ex.GetType().ToString(), "Exception while reading Site Columns tag in Content Types" + " SolFileName: " + solFileName + ". XML File Path: " + xmlString); } } } #endregion } #region CustomFields if (lstCustomFieldIDs != null && lstCustomFieldIDs.Count > 0 && !isCustomSiteColumn) { Logger.LogInfoMessage("[DownloadAndModifyListTemplate: ProcessStpFile] Searching for customized Site Columns", true); if (!isCustomSiteColumn && xmlFields != null && xmlFields.Count > 0) { //Get all fields Column in manifest.xml for (int i = 0; i < xmlFields.Count; i++) { try { var fieldList = xmlFields[i].Attributes["ID"].Value; //Remove contenttype tag if ContentTypeId present in custom ContentTypes file ContentTypes.csv if (lstCustomFieldIDs.Where(c => fieldList.Equals(c)).Any()) { isCustomSiteColumn = true; Logger.LogInfoMessage("[DownloadAndModifyListTemplate: ProcessStpFile] Customized Site ColumnFound for : " + objListCustOutput.ListTemplateName, true); break; } } catch (Exception ex) { Logger.LogErrorMessage("[DownloadAndModifyListTemplate: ProcessStpFile]. Exception Message: " + ex.Message + ", Exception Comments: Exception while reading Site Columns" + " SolFileName: " + solFileName + ". XML File Path: " + xmlString, true); ExceptionCsv.WriteException(objListCustOutput.WebApplication, objListCustOutput.SiteCollection, objListCustOutput.WebUrl, "ListTemplate", ex.Message, ex.ToString(), "ProcessStpFile", ex.GetType().ToString(), "Exception while reading Site Columns" + " SolFileName: " + solFileName + ". XML File Path: " + xmlString); } } } } #endregion if (isCustomContentType || isCustomEventReceiver || isCustomSiteColumn) { if (cTHavingCustomER != null && cTHavingCustomER.Length > 0) { cTHavingCustomER.Length -= 1; objListCustOutput.CTHavingCustomEventReceiver = cTHavingCustomER.ToString(); } else { objListCustOutput.CTHavingCustomEventReceiver = Constants.NotApplicable; } objListCustOutput.IsCustomizationPresent = "YES"; isCustomizationPresent = true; //cTHavingCustomER.Remove(cTHavingCustomER.Length-1, 1); if (lstCustomErs != null && lstCustomErs.Count > 0) objListCustOutput.IsCustomizedEventReceiver = isCustomEventReceiver ? "YES" : "NO"; else objListCustOutput.IsCustomizedEventReceiver = Constants.NoInputFile; if (lstContentTypeIDs != null && lstContentTypeIDs.Count > 0) objListCustOutput.IsCustomizedContentType = isCustomContentType ? "YES" : "NO"; else objListCustOutput.IsCustomizedContentType = Constants.NoInputFile; if (lstCustomFieldIDs != null && lstCustomFieldIDs.Count > 0) objListCustOutput.IsCustomizedSiteColumn = isCustomSiteColumn ? "YES" : "NO"; else objListCustOutput.IsCustomizedSiteColumn = Constants.NoInputFile; } else { if (cTHavingCustomER != null && cTHavingCustomER.Length > 0) { cTHavingCustomER.Length -= 1; objListCustOutput.CTHavingCustomEventReceiver = cTHavingCustomER.ToString(); objListCustOutput.IsCustomizationPresent = "YES"; isCustomizationPresent = true; objListCustOutput.IsCustomizedContentType = "NO"; objListCustOutput.IsCustomizedEventReceiver = "NO"; objListCustOutput.IsCustomizedSiteColumn = "NO"; } else { objListCustOutput.CTHavingCustomEventReceiver = Constants.NotApplicable; isCustomizationPresent = false; } } reader.Dispose(); cTHavingCustomER.Clear(); Directory.SetCurrentDirectory(downloadFolder); System.IO.DirectoryInfo directory = new System.IO.DirectoryInfo(downloadFolder); foreach (System.IO.FileInfo file in directory.GetFiles("*.*", SearchOption.AllDirectories)) { try { file.Delete(); } catch (Exception ex) { //As we are extracting .wsp file to local folder, no need to display any //exception while deleting these files. } } foreach (System.IO.DirectoryInfo subDirectory in directory.GetDirectories()) { try { subDirectory.Delete(true); } catch (Exception ex) { //As we are extracting .wsp file to local folder, no need to display any //exception while deleting these files. } } } catch (Exception ex) { Logger.LogErrorMessage("[DownloadAndModifyListTemplate: ProcessStpFile], Exception Message: " + ex.Message + " SolFileName: " + solFileName, true); ExceptionCsv.WriteException(objListCustOutput.WebApplication, objListCustOutput.SiteCollection, objListCustOutput.WebUrl, "ListTemplate", ex.Message, ex.ToString(), "ProcessStpFile", ex.GetType().ToString(), "SolFileName: " + solFileName); } return isCustomizationPresent; }
public static bool GetCustomizedListTemplate(ref ListTemplateFTCAnalysisOutputBase objListCustOutput, Microsoft.SharePoint.Client.File ltFile, string siteCollection, string webAppUrl) { bool isCustomizationPresent = false; string fileName = string.Empty; string listGalleryPath = string.Empty; try { fileName = ltFile.Name; listGalleryPath = ltFile.ServerRelativeUrl.Substring(0, ltFile.ServerRelativeUrl.LastIndexOf('/')); objListCustOutput.SiteCollection = siteCollection; objListCustOutput.WebApplication = GetWebapplicationUrlFromSiteCollectionUrl(siteCollection); objListCustOutput.WebUrl = siteCollection; objListCustOutput.ListTemplateName = fileName; objListCustOutput.ListGalleryPath = listGalleryPath; TempFolderName += 1; bool isDownloaded = DownloadListTemplate(outputPath + @"\" + Constants.DownloadPathListTemplates + @"\" + TempFolderName, listGalleryPath, ref fileName, objListCustOutput.WebUrl, objListCustOutput.WebUrl, TempFolderName.ToString()); if (isDownloaded) { isCustomizationPresent = ProcessStpFile(outputPath, outputPath + @"\" + Constants.DownloadPathListTemplates + @"\" + TempFolderName + @"\" + fileName.ToLower(), ref objListCustOutput); } } catch (Exception ex) { Logger.LogErrorMessage("[DownloadAndModifyListTemplate: GetCustomizedListTemplate] Exception Message: " + ex.Message, true); ExceptionCsv.WriteException(Constants.NotApplicable, objListCustOutput.SiteCollection, objListCustOutput.WebUrl, "ListTemplate", ex.Message, ex.ToString(), "GetCustomizedListTemplate", ex.GetType().ToString(), "Exception occured while getting the ListTemplates from Gallery "); } return isCustomizationPresent; }
public static void ProcessSiteCollectionUrl(string siteCollectionUrl, ref List<ListTemplateFTCAnalysisOutputBase> lstMissingListTempaltesInGalleryBase, string webApplicationUrl) { try { using (ClientContext userContext = Helper.CreateAuthenticatedUserContext(Program.AdminDomain, Program.AdminUsername, Program.AdminPassword, siteCollectionUrl)) { //userContext.ExecuteQuery(); Web web = userContext.Web; Folder folder = userContext.Web.GetFolderByServerRelativeUrl("_catalogs/lt"); userContext.Load(web.Folders); userContext.Load(folder); userContext.Load(folder.Files); userContext.Load(web); //Execute the query to the server userContext.ExecuteQuery(); // Loop through all the list templates foreach (Microsoft.SharePoint.Client.File ltFile in folder.Files) { try { bool isCustomizationPresent = false; ListTemplateFTCAnalysisOutputBase objListCustOutput = new ListTemplateFTCAnalysisOutputBase(); System.Console.WriteLine("File Name: " + ltFile.Name); isCustomizationPresent = GetCustomizedListTemplate(ref objListCustOutput, ltFile, siteCollectionUrl, webApplicationUrl); if (isCustomizationPresent) { userContext.Load(ltFile.Author); userContext.Load(ltFile.ModifiedBy); userContext.ExecuteQuery(); try { if (ltFile.Author != null) objListCustOutput.CreatedBy = ltFile.Author.LoginName; else objListCustOutput.CreatedBy = Constants.NotApplicable; } catch (Exception ex) { objListCustOutput.CreatedBy = Constants.NotApplicable; Logger.LogErrorMessage("[DownloadAndModifyListTemplate: ProcessSiteCollectionUrl]. Error recorded for Site Collection: " + siteCollectionUrl + " and for file: " + ltFile.Name + " Exception Message: " + ex.Message + ". Author is NULL.", true); ExceptionCsv.WriteException(webApplicationUrl, siteCollectionUrl, Constants.NotApplicable, "ListTemplate", ex.Message, ex.ToString(), "ProcessSiteCollectionUrl", ex.GetType().ToString(), "Error recorded for Site Collection: " + siteCollectionUrl + " and for file: " + ltFile.Name + " Exception Message: " + ex.Message + ". Author is NULL."); } try { if (ltFile.TimeCreated != null) objListCustOutput.CreatedDate = ltFile.TimeCreated.ToString(); else objListCustOutput.CreatedDate = Constants.NotApplicable; } catch (Exception ex) { objListCustOutput.CreatedDate = Constants.NotApplicable; Logger.LogErrorMessage("[DownloadAndModifyListTemplate: ProcessSiteCollectionUrl]. Error recorded for Site Collection: " + siteCollectionUrl + " and for file: " + ltFile.Name + " Exception Message: " + ex.Message + ". TimeCreated is NULL.", true); ExceptionCsv.WriteException(webApplicationUrl, siteCollectionUrl, Constants.NotApplicable, "ListTemplate", ex.Message, ex.ToString(), "ProcessSiteCollectionUrl", ex.GetType().ToString(), "Error recorded for Site Collection: " + siteCollectionUrl + " and for file: " + ltFile.Name + " Exception Message: " + ex.Message + ". TimeCreated is NULL."); } try { if (ltFile.ModifiedBy != null) objListCustOutput.ModifiedBy = ltFile.ModifiedBy.LoginName; else objListCustOutput.ModifiedBy = Constants.NotApplicable; } catch (Exception ex) { objListCustOutput.ModifiedBy = Constants.NotApplicable; Logger.LogErrorMessage("[DownloadAndModifyListTemplate: ProcessSiteCollectionUrl]. Error recorded for Site Collection: " + siteCollectionUrl + " and for file: " + ltFile.Name + " Exception Message: " + ex.Message + ". ModifiedBy is NULL.", true); ExceptionCsv.WriteException(webApplicationUrl, siteCollectionUrl, Constants.NotApplicable, "ListTemplate", ex.Message, ex.ToString(), "ProcessSiteCollectionUrl", ex.GetType().ToString(), "Error recorded for Site Collection: " + siteCollectionUrl + " and for file: " + ltFile.Name + " Exception Message: " + ex.Message + ". ModifiedBy is NULL."); } try { if (ltFile.TimeLastModified != null) objListCustOutput.ModifiedDate = ltFile.TimeLastModified.ToString(); else objListCustOutput.ModifiedDate = Constants.NotApplicable; } catch (Exception ex) { objListCustOutput.ModifiedDate = Constants.NotApplicable; Logger.LogErrorMessage("[DownloadAndModifyListTemplate: ProcessSiteCollectionUrl]. Error recorded for Site Collection: " + siteCollectionUrl + " and for file: " + ltFile.Name + " Exception Message: " + ex.Message + ". TimeLastModified is NULL.", true); ExceptionCsv.WriteException(webApplicationUrl, siteCollectionUrl, Constants.NotApplicable, "ListTemplate", ex.Message, ex.ToString(), "ProcessSiteCollectionUrl", ex.GetType().ToString(), "Error recorded for Site Collection: " + siteCollectionUrl + " and for file: " + ltFile.Name + " Exception Message: " + ex.Message + ". TimeLastModified is NULL."); } lstMissingListTempaltesInGalleryBase.Add(objListCustOutput); } objListCustOutput = null; } catch (Exception ex) { if ((ex.Message.ToLower()).Contains("access denied") || (ex.Message.ToLower()).Contains("unauthorized")) { System.Console.ForegroundColor = ConsoleColor.Yellow; Logger.LogErrorMessage("[DownloadAndModifyListTemplate: ProcessSiteCollectionUrl]. Error recorded for Site Collection: " + siteCollectionUrl + " and for file: " + ltFile.Name + " Exception Message: " + ex.Message, true); System.Console.ResetColor(); ExceptionCsv.WriteException(webApplicationUrl, siteCollectionUrl, Constants.NotApplicable, "ListTemplate", ex.Message, ex.ToString(), "ProcessSiteCollectionUrl", ex.GetType().ToString(), "Error recorded for Site Collection: " + siteCollectionUrl + " and for file: " + ltFile.Name); } else { Logger.LogErrorMessage("[DownloadAndModifyListTemplate: ProcessSiteCollectionUrl]. Error recorded for Site Collection: " + siteCollectionUrl + " and for file: " + ltFile.Name + " Exception Message: " + ex.Message, true); ExceptionCsv.WriteException(webApplicationUrl, siteCollectionUrl, Constants.NotApplicable, "ListTemplate", ex.Message, ex.ToString(), "ProcessSiteCollectionUrl", ex.GetType().ToString(), "Error recorded for Site Collection: " + siteCollectionUrl + " and for file: " + ltFile.Name); } } } } } catch (Exception ex) { if ((ex.Message.ToLower()).Contains("access denied") || (ex.Message.ToLower()).Contains("unauthorized")) { System.Console.ForegroundColor = ConsoleColor.Yellow; Logger.LogErrorMessage("[DownloadAndModifyListTemplate: ProcessSiteCollectionUrl]. Error recorded for Site Collection: " + siteCollectionUrl + " Exception Message: " + ex.Message, true); System.Console.ResetColor(); ExceptionCsv.WriteException(webApplicationUrl, siteCollectionUrl, Constants.NotApplicable, "ListTemplate", ex.Message, ex.ToString(), "ProcessSiteCollectionUrl", ex.GetType().ToString(), "Error recorded for Site Collection: " + siteCollectionUrl); } else { Logger.LogErrorMessage("[DownloadAndModifyListTemplate: ProcessSiteCollectionUrl]. Error recorded for Site Collection: " + siteCollectionUrl + " Exception Message: " + ex.Message, true); ExceptionCsv.WriteException(webApplicationUrl, siteCollectionUrl, Constants.NotApplicable, "ListTemplate", ex.Message, ex.ToString(), "ProcessSiteCollectionUrl", ex.GetType().ToString(), "Error recorded for Site Collection: " + siteCollectionUrl); } } }
public static void WriteOutputReport(List<ListTemplateFTCAnalysisOutputBase> ltListTemplateOutputBase, string csvFileName, ref bool headerOfCsv) { try { Logger.LogInfoMessage("[DownloadAndModifyListTemplate: WriteOutputReport] Writing the Output file " + csvFileName, true); if (System.IO.File.Exists(csvFileName)) System.IO.File.Delete(csvFileName); if (ltListTemplateOutputBase != null && ltListTemplateOutputBase.Any()) { //Export the result(Missing Workflow Details) in CSV file FileUtility.WriteCsVintoFile(csvFileName, ref ltListTemplateOutputBase, ref headerOfCsv); } else { headerOfCsv = false; ListTemplateFTCAnalysisOutputBase objListTemplatesNoInstancesFound = new ListTemplateFTCAnalysisOutputBase(); FileUtility.WriteCsVintoFile(csvFileName, objListTemplatesNoInstancesFound, ref headerOfCsv); objListTemplatesNoInstancesFound = null; } } catch (Exception ex) { Logger.LogErrorMessage("[DownloadAndModifyListTemplate: WriteOutputReport] Exception Message: " + ex.Message, true); ExceptionCsv.WriteException(Constants.NotApplicable, Constants.NotApplicable, Constants.NotApplicable, "ListTemplate", ex.Message, ex.ToString(), "WriteOutputReport", ex.GetType().ToString(), Constants.NotApplicable); } }