WSS: A console program

Here is a console app, that demonstrates two things:

  • You can code towards a site from outside of its boundaries just by adding the URL of the site. 
  • You can see how the some of the internal objects hierarchies compared to the “All Site Content” page.  

 The code:

Site Architecture
Site Architecture
using System;
using Microsoft.SharePoint;
namespace WSSConsole{
  class Program {
    static void Main() {
        Console.WriteLine("A WSS console program");
        using (SPSite siteColl = new SPSite("http://spvm/")){
          using (SPWeb site = siteColl.RootWeb) { //top-level site
              Console.WriteLine("Title: " + site.Title);
              Console.WriteLine("Url: " + site.Url);
              Console.WriteLine("IsRootWeb: " + site.IsRootWeb.ToString());
              Console.WriteLine("Name: " + site.Name);
              Console.WriteLine("PortalName: " + site.PortalName);
              Console.WriteLine("CurrentUser: " + site.CurrentUser.LoginName);
              Console.WriteLine("Description: " + site.Description);

              Console.WriteLine("Lists: ");
              foreach (SPList list in site.Lists) {
                  Console.WriteLine("  List: " + list.Title + " - " + list.BaseType.ToString()+" - count: " + list.Items.Count);
              }

              Console.WriteLine("ContentTypes: ");
              foreach (SPContentType ct in site.ContentTypes)
              {
                  Console.WriteLine("  ContentType: " + ct.Name);
              }

              Console.WriteLine("Features: ");
              foreach (SPFeature feat in site.Features)
              {
                  Console.WriteLine("  Feature: " + feat.Definition.DisplayName);
              }

              Console.WriteLine("Modules: ");
              foreach (SPModule mod in site.Modules)
              {
                  Console.WriteLine("  Module: " + mod.Name + " - url: " + mod.Url);
              }

              Console.WriteLine("Fields: "); //Long list
              foreach (SPField field in site.Fields)
              {
                  Console.WriteLine("  Field: " + field.Title);
              }

              Console.WriteLine("Users: ");
              foreach (SPUser usr in site.Users)
              {
                  Console.WriteLine("  LoginName: " + usr.LoginName);
              }

              Console.WriteLine("Groups: ");
              foreach (SPGroup role in site.Groups)
              {
                  Console.WriteLine("  Group/Role: " + role.Name);
              }

              Console.WriteLine("AllProperties: ");
              foreach (System.Collections.DictionaryEntry prop in site.AllProperties)
              {
                  Console.WriteLine("  key: " + prop.Key.ToString() + " - val: " + prop.Value.ToString());
              }

              Console.WriteLine("Properties: ");
              foreach (System.Collections.DictionaryEntry prop in site.Properties)
              {
                  Console.WriteLine("  key: " + prop.Key.ToString() + " - val: " + prop.Value.ToString());
              }

              Console.WriteLine("Webs: ");
              foreach (SPWeb childsite in site.Webs)
              {
                  Console.WriteLine("  Title: " + childsite.Title);
                  Console.WriteLine("  Url: " + childsite.Url);
                  Console.WriteLine("  IsRootWeb: " + childsite.IsRootWeb.ToString());
              }
          }
      }
      Console.WriteLine("Press Enter to Exit");
      Console.ReadLine();
    }
  }
}

The output:

A WSS console program
Title: Team Site
Url: http://spvm
IsRootWeb: True
Name:
PortalName:
CurrentUser: SPVM\administrator
Description:
Lists:
  List: Announcements - GenericList - count: 2
  List: Calendar - GenericList - count: 0
  List: Links - GenericList - count: 0
  List: List Template Gallery - DocumentLibrary - count: 0
  List: Master Page Gallery - DocumentLibrary - count: 1
  List: Shared Documents - DocumentLibrary - count: 0
  List: Site Template Gallery - DocumentLibrary - count: 0
  List: Tasks - GenericList - count: 0
  List: Team Discussion - GenericList - count: 0
  List: User Information List - GenericList - count: 5
  List: Web Part Gallery - DocumentLibrary - count: 8
ContentTypes:
  ContentType: System
  ContentType: Item
  ContentType: Document
  ContentType: Office Data Connection File
  ContentType: Universal Data Connection File
  ContentType: Form
  ContentType: Picture
  ContentType: Unknown Document Type
  ContentType: Master Page
  ContentType: User Workflow Document
  ContentType: Wiki Page
  ContentType: Basic Page
  ContentType: Web Part Page
  ContentType: Link to a Document
  ContentType: Dublin Core Columns
  ContentType: Event
  ContentType: Issue
  ContentType: Announcement
  ContentType: Link
  ContentType: Contact
  ContentType: Message
  ContentType: Task
  ContentType: Workflow Task
  ContentType: Administrative Task
  ContentType: Workflow History
  ContentType: Person
  ContentType: SharePointGroup
  ContentType: DomainGroup
  ContentType: Post
  ContentType: Comment
  ContentType: Far East Contact
  ContentType: Folder
  ContentType: RootOfList
  ContentType: Discussion
Features:
  Feature: WebPageLibrary
  Feature: IssuesList
  Feature: WorkflowHistoryList
  Feature: NoCodeWorkflowLibrary
  Feature: SurveysList
  Feature: GridList
  Feature: GanttTasksList
  Feature: LinksList
  Feature: MobilityRedirect
  Feature: workflowProcessList
  Feature: TasksList
  Feature: TeamCollab
  Feature: AnnouncementsList
  Feature: PictureLibrary
  Feature: ContactsList
  Feature: CustomList
  Feature: DocumentLibrary
  Feature: DiscussionsList
  Feature: DataSourceLibrary
  Feature: EventsList
  Feature: XmlFormLibrary
Modules:
  Module: Default - url:
Fields:
  Field: Other Address Country
  Field: Categories
  Field: Manager's Name
  Field: Children's Names
  Field: Date Modified
  Field: Company
  Field: Event Canceled
  Field: UID
  Field: Home Address State Or Province
  Field: Author
  Field: Checked out User
  Field: Toggle Quoted Text
  Field: Primary Phone
  Field: Title
  Field: Full Name
  Field: File Type
  Field: ID
  Field: TimeZone
  Field: Profession
  Field: URL Path
  Field: Base Association Guid
  Field: Organizational ID Number
  Field: Threading
  Field: Level
  Field: ProgId
  Field: Posted By
  Field: E-Mail To
  Field: Outcome
  Field: User ID
  Field: ScopeId
  Field: Form_URN
  Field: Date Picture Taken
  Field: GUID
  Field: Birthday
  Field: Document Created By
  Field: Web Preview
  Field: Name
  Field: Related Issues
  Field: Business Phone
  Field: Subject
  Field: Middle Name
  Field: ISDN
  Field: Version
  Field: E-Mail Calendar Sequence
  Field: Anniversary
  Field: Body
  Field: Account
  Field: Is Signed
  Field: External Participant
  Field: Show Combine View
  Field: Location
  Field: Assistant's Phone
  Field: Date Occurred
  Field: Picture Height
  Field: $Resources:XomlUrl
  Field: Title
  Field: Assigned To
  Field: Thumbnail
  Field: UDC Purpose
  Field: Source Name (Converted Document)
  Field: Business Phone 2
  Field: Has Custom Email Body
  Field: Category
  Field: Shortest Thread-Index
  Field: Telex
  Field: Priority
  Field: Associated Service
  Field: User Field 3
  Field: Indentation
  Field: Subject
  Field: Body
  Field: % Complete
  Field: Home Address Street
  Field: UI Version
  Field: Message ID
  Field: Quoted Text Was Expanded
  Field: Show Repair View
  Field: Status
  Field: Task Type
  Field: FullBody
  Field: WorkspaceUrl
  Field: Form Data
  Field: System Task
  Field: Name
  Field: Required Field
  Field: E-Mail
  Field: Type
  Field: Assistant's Name
  Field: Radio Phone
  Field: Keywords
  Field: Job Title
  Field: End Date
  Field: Email Body
  Field: Category
  Field: Append-Only Comments
  Field: Description
  Field: Link
  Field: Department
  Field: Relation
  Field: Created By
  Field: ZIP/Postal Code
  Field: Description
  Field: Recurrence
  Field: Last Updated
  Field: Content Type
  Field: Home Address City
  Field: Posting Information
  Field: Callback Number
  Field: Issue ID
  Field: Home Fax
  Field: Total Work
  Field: Expires
  Field: Issue Status
  Field: SIP Address
  Field: Home Phone 2
  Field: Duration
  Field: Item Type
  Field: Resource Identifier
  Field: Completed
  Field: E-Mail From
  Field: Web Image URL
  Field: owshiddenversion
  Field: E-Mail Calendar UID
  Field: Workflow Item ID
  Field: Correct Body To Show
  Field: Billing Information
  Field: Has Copy Destinations
  Field: Name
  Field: Last Name Phonetic
  Field: Copy Source
  Field: FTP Site
  Field: Indentation Level
  Field: Workflow History Parent Instance
  Field: Resource Type
  Field: Threading Controls
  Field: Pager
  Field: Body Was Expanded
  Field: Event Type
  Field: Check In Comment
  Field: Picture
  Field: Hobbies
  Field: Limited Body
  Field: Contributor
  Field: Name
  Field: Relink
  Field: URL
  Field: Actual Work
  Field: Post
  Field: Replies
  Field: Group Type
  Field: City
  Field: Published
  Field: Workflow Association ID
  Field: Shortest Thread-Index Id
  Field: Company Main Phone
  Field: Description
  Field: Content Type ID
  Field: MasterSeriesItemID
  Field: HTML File Type
  Field: Country/Region
  Field: Select
  Field: Initials
  Field: About Me
  Field: Name
  Field: Gender
  Field: Company Phonetic
  Field: Workflow List ID
  Field: Comments
  Field: List ID
  Field: Task Group
  Field: Start Date
  Field: Address
  Field: Other Address City
  Field: Related Company
  Field: Custom ID Number
  Field: Status
  Field: Trimmed Body
  Field: Connection Type
  Field: More Link
  Field: Property Bag
  Field: Data
  Field: Other Phone
  Field: Computer Network Name
  Field: Revision
  Field: Discussion Title
  Field: Select
  Field: Source Url
  Field: Response
  Field: User Field 2
  Field: Workflow Template ID
  Field: Html File Link
  Field: Merge
  Field: Contact Photo
  Field: Suffix
  Field: Instance ID
  Field: File Size
  Field: External Participant Reason
  Field: Car Phone
  Field: References
  Field: First Name Phonetic
  Field: Referred By
  Field: Edit
  Field: Preview
  Field: Duration
  Field: Order
  Field: $Resources:RulesUrl
  Field: Publisher
  Field: Thumbnail URL
  Field: Event Type
  Field: Is Site Admin
  Field: Office
  Field: Wiki Content
  Field: Other Fax
  Field: E-Mail Subject
  Field: Picture Size
  Field: Version
  Field: Virus Status
  Field: E-Mail Calendar Date Stamp
  Field: Workflow Version
  Field: Other Address State Or Province
  Field: E-mail 3
  Field: Less Link
  Field: Edit Menu Table Start
  Field: Parent Folder Id
  Field: Coverage
  Field: File Size
  Field: Is Root Post
  Field: Pending Modification Time
  Field: Order
  Field: Date Completed
  Field: Due Date
  Field: Other Address Street
  Field: Task Status
  Field: Comments
  Field: Subject
  Field: Modified
  Field: Home Address Postal Code
  Field: Template Link
  Field: Last Printed
  Field: Encoded Absolute URL
  Field: Discussion Subject
  Field: Title
  Field: Modified
  Field: Fax Number
  Field: E-mail 2
  Field: Government ID Number
  Field: Selection Checkbox
  Field: User Field 4
  Field: Created
  Field: Workflow Name
  Field: Rights Management
  Field: Email Messages
  Field: Server Relative URL
  Field: Category
  Field: Department
  Field: Workflow Instance ID
  Field: RecurrenceData
  Field: Primary Item ID
  Field: Modified By
  Field: Web Page
  Field: State/Province
  Field: URL
  Field: First Name
  Field: XMLTZone
  Field: Nickname
  Field: Home Address Country
  Field: Personal Website
  Field: Thread Topic
  Field: Event Address
  Field: Is Active
  Field: Source
  Field: Format
  Field: Unique Id
  Field: Spouse
  Field: Deleted
  Field: Date Created
  Field: Extended Properties
  Field: Reply
  Field: Document Modified By
  Field: Action
  Field: Is Current Version
  Field: Language
  Field: Shared File Index
  Field: Approver Comments
  Field: Home Phone
  Field: Approval Status
  Field: URL
  Field: Effective Permissions Mask
  Field: Posted By
  Field: Edit Menu Table End
  Field: Thread Index
  Field: Mobile Phone
  Field: TTY-TDD Phone
  Field: Role
  Field: Mileage
  Field: Send Email Notification
  Field: End Time
  Field: File Type
  Field: E-Mail Cc
  Field: Attachments
  Field: All Day Event
  Field: User Field 1
  Field: Path
  Field: IM Address
  Field: Other Address Postal Code
  Field: Workspace
  Field: Picture Width
  Field: Outcome
  Field: E-Mail Sender
  Field: Title
  Field: Source Version (Converted Document)
  Field: Shortest Thread-Index Id Lookup
  Field: Created
  Field: Recurrence ID
Users:
Groups:
  Group/Role: Team Site Members
  Group/Role: Team Site Owners
  Group/Role: Team Site Visitors
AllProperties:
  key: vti_extenderversion - val: 12.0.0.6219
  key: vti_approvallevels - val: Approved Rejected Pending\ Review
  key: vti_associatevisitorgroup - val: 4
  key: vti_categories - val: Business Competition Expense\ Report Goals/Objectiv
es Ideas In\ Process Miscellaneous Planning Schedule Travel VIP Waiting
  key: vti_associatemembergroup - val: 5
  key: vti_defaultlanguage - val: en-us
  key: vti_associateownergroup - val: 3
  key: vti_associategroups - val: 5;4;3
  key: vti_createdassociategroups - val: 3;4;5
Properties:
  key: vti_createdassociategroups - val: 3;4;5
  key: vti_extenderversion - val: 12.0.0.6219
  key: vti_associatevisitorgroup - val: 4
  key: vti_defaultlanguage - val: en-us
  key: vti_associategroups - val: 5;4;3
  key: vti_associateownergroup - val: 3
  key: vti_associatemembergroup - val: 5
Webs:
Press Enter to Exit

The “All Site Content” page

The End.

Advertisements

Leave a Reply

Please log in using one of these methods to post your comment:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: