private static void ReportContentTypeUsage(Web web, List list, string targetContentTypeId, string targetContentTypeName, string siteColUrl, string CTCFFileName)
        {
            try
            {
                ContentTypeCustomFieldOutput objCTCFOutput3 = new ContentTypeCustomFieldOutput();
                objCTCFOutput3.ComponentName = Constants.ContentTypes;
                objCTCFOutput3.ListId        = list.Id.ToString();
                objCTCFOutput3.ListTitle     = list.Title;
                objCTCFOutput3.ContentTypeOrCustomFieldId   = targetContentTypeId.ToString();
                objCTCFOutput3.ContentTypeOrCustomFieldName = targetContentTypeName;
                objCTCFOutput3.WebUrl         = web.Url;
                objCTCFOutput3.SiteCollection = siteColUrl;

                list.EnsureProperty(l => l.ContentTypesEnabled);

                if (!list.ContentTypesEnabled)
                {
                    return;
                }

                ContentTypeCollection ctCol = list.ContentTypes;
                list.Context.Load(ctCol);
                list.Context.ExecuteQuery();

                foreach (ContentType ct in ctCol)
                {
                    try
                    {
                        string contentTypeId = ct.Id.StringValue;
                        if (contentTypeId.StartsWith(targetContentTypeId, StringComparison.InvariantCultureIgnoreCase))
                        {
                            if (ct.Name.Equals(targetContentTypeName, StringComparison.InvariantCultureIgnoreCase))
                            {
                                Logger.LogSuccessMessage(String.Format("FOUND: Content Type [{2}] on LIST [{0}] of WEB: {1}", list.Title, web.Url, targetContentTypeName), true);
                                FileUtility.WriteCsVintoFile(CTCFFileName, objCTCFOutput3, ref headerContentType);
                            }
                            else
                            {
                                Logger.LogSuccessMessage(String.Format("FOUND: Child Content Type [{3}] of [{2}] on LIST [{0}] of WEB: {1}", list.Title, web.Url, targetContentTypeName, ct.Name), true);
                                FileUtility.WriteCsVintoFile(CTCFFileName, objCTCFOutput3, ref headerContentType);
                            }
                        }
                    }
                    catch (Exception ex)
                    {
                        Logger.LogErrorMessage(String.Format("ReportContentTypeUsage() failed on a Content Type of LIST [{0}] of WEB {1}: Error={2}", list.Title, web.Url, ex.Message), false);
                        ExceptionCsv.WriteException(Constants.NotApplicable, Constants.NotApplicable, web.Url, "ColumnORFieldAndTypeUsageReport", ex.Message, ex.ToString(), "ReportContentTypeUsage()", ex.GetType().ToString(), String.Format("ReportContentTypeUsage() failed on a Content Type of LIST [{0}] of WEB {1}: Error={2}", list.Title, web.Url, ex.Message));
                    }
                }
            }
            catch (Exception ex)
            {
                Logger.LogErrorMessage(String.Format("ReportContentTypeUsage() failed for LIST [{0}] of WEB {1}: Error={2}", list.Title, web.Url, ex.Message), false);
                ExceptionCsv.WriteException(Constants.NotApplicable, Constants.NotApplicable, web.Url, "ColumnORFieldAndTypeUsageReport", ex.Message, ex.ToString(), "ReportContentTypeUsage()", ex.GetType().ToString(), String.Format("ReportContentTypeUsage() failed for LIST [{0}] of WEB {1}: Error={2}", list.Title, web.Url, ex.Message));
            }
        }
        private static void ReportSiteColumnUsage(Web web, List list, Guid siteColumnId, string siteColumnName, string siteColUrl, string CTCFFileName)
        {
            ContentTypeCustomFieldOutput objCTCFOutput1 = new ContentTypeCustomFieldOutput();

            objCTCFOutput1.ComponentName = Constants.CustomFields;
            objCTCFOutput1.ListId        = list.Id.ToString();
            objCTCFOutput1.ListTitle     = list.Title;
            objCTCFOutput1.ContentTypeOrCustomFieldId   = siteColumnId.ToString();
            objCTCFOutput1.ContentTypeOrCustomFieldName = siteColumnName;
            objCTCFOutput1.WebUrl         = web.Url;
            objCTCFOutput1.SiteCollection = siteColUrl;

            if (list.FieldExistsById(siteColumnId) == true)
            {
                Logger.LogSuccessMessage(String.Format("FOUND: Site Column/Custom Field [{2}] on LIST [{0}] of WEB: {1}", list.Title, web.Url, siteColumnName), true);
                FileUtility.WriteCsVintoFile(CTCFFileName, objCTCFOutput1, ref headerContentType);
            }
        }