Example #1
0
        private ReportRow ScanWeb(SPWeb web)
        {
            ReportRow webRow = new ReportRow(this, web);

            foreach (SPField field in web.Fields)
            {
                this.GetFieldLabel(field, contentType: null);
            }

            foreach (SPList list in web.Lists.Cast <SPList>().OrderBy(l => l.ID).OrderBy(l => l.Title))
            {
                foreach (SPField field in list.Fields)
                {
                    this.GetFieldLabel(field, contentType: null);
                }

                ReportRow listRow = new ReportRow(this, list);
                listRow.ParentRow = webRow;
            }

            foreach (SPWeb childWeb in web.Webs.OrderBy(w => w.ServerRelativeUrl).OrderBy(w => w.Title))
            {
                ReportRow childWebRow = this.ScanWeb(childWeb); // recurse
                childWebRow.ParentRow = webRow;
            }

            return(webRow);
        }
Example #2
0
        public void WriteRowValues(StreamWriter streamWriter, Dictionary <string, string> rowValues,
                                   ReportRow row)
        {
            if (!this.reachedContentTypes && row != null && row.IsContentType)
            {
                this.reachedContentTypes = true;

                // Write a mini-header to delineate the Content Types section
                Dictionary <string, string> miniHeader = new Dictionary <string, string>();
                miniHeader["Path0"] = "CONTENT TYPES:";
                streamWriter.WriteLine();
                this.WriteRowValues(streamWriter, miniHeader, null);
            }

            for (int i = 0; i < this.ReportColumnKeysAndTitles.Count; ++i)
            {
                string key = this.ReportColumnKeysAndTitles[i].Key;

                if (i > 0)
                {
                    streamWriter.Write(",");
                }

                string value = string.Empty;
                if (rowValues.TryGetValue(key, out value))
                {
                    if (value.Contains("\"") || value.Contains(","))
                    {
                        value = "\"" + value.Replace("\"", "\"\"") + "\"";
                    }
                }
                streamWriter.Write(value);
            }
            streamWriter.WriteLine();
        }
Example #3
0
        public void BuildRowsAndFields(SPWeb rootWeb)
        {
            this.rootRow = ScanWeb(rootWeb);

            this.CollectContentTypes(rootWeb);

            ReportRow contentTypeRoot = this.rootRow.ChildRows.First(row => row.IsContentType);

            this.PostProcessContentTypes(contentTypeRoot);
        }
Example #4
0
        private void PostProcessContentTypes(ReportRow contentTypeRow)
        {
            List <ReportRow> childRows = contentTypeRow.ChildRows;

            // Sort the child rows
            var sortedRows = childRows
                             .OrderBy(row => row.Url)          // if names are the same, sort by URL
                             .OrderBy(row => row.ContentType.Name)
                             .OrderBy(row => row.List == null) // show list CT's before web CT's
                             .ToList();

            childRows.Clear();
            childRows.AddRange(sortedRows);

            contentTypeRow.PathName = contentTypeRow.ContentType.Name;

            foreach (ReportRow childRow in childRows)
            {
                this.PostProcessContentTypes(childRow); // recurse
            }
        }
Example #5
0
        private void CreateContentTypeRows(SPContentTypeCollection contentTypes)
        {
            foreach (SPContentType contentType in contentTypes)
            {
                ReportRow parentRow = null;

                if (!this.rowsByContentTypeId.TryGetValue(contentType.Id.Parent, out parentRow))
                {
                    if (!contentType.Id.Parent.Equals(contentType.Id))
                    {
                        throw new Exception("Cannot find parentRow for " + contentType.Name + " " + contentType.Id);
                    }

                    parentRow = this.rootRow;
                }

                ReportRow contentTypeRow = new ReportRow(this, contentType);
                contentTypeRow.ParentRow = parentRow;

                this.rowsByContentTypeId.Add(contentType.Id, contentTypeRow);
            }
        }