Test Post

using System;
using System.ComponentModel;
using System.ComponentModel.Design;
using System.Collections;
using System.Linq;
using System.Workflow.ComponentModel;
using System.Workflow.ComponentModel.Design;
using System.Workflow.ComponentModel.Compiler;
using System.Workflow.ComponentModel.Serialization;
using System.Workflow.Runtime;
using System.Workflow.Activities;
using System.Workflow.Activities.Rules;
using Microsoft.SharePoint;
using Microsoft.SharePoint.Workflow;
using Microsoft.SharePoint.WorkflowActions;



namespace Create_Doc_Lib_Activity
{
    public partial class CreateDocumentLibrary : SequenceActivity
    {

        public static DependencyProperty UrlProperty = DependencyProperty.Register("Url", typeof(string), typeof(CreateDocumentLibrary), new PropertyMetadata(""));
        [DescriptionAttribute("Url of base site")]
        [BrowsableAttribute(true)]
        [DesignerSerializationVisibilityAttribute(DesignerSerializationVisibility.Visible)]
        [ValidationOption(ValidationOption.Optional)]
        public string Url
        {
            get
            {
                return ((string)(base.GetValue(CreateDocumentLibrary.UrlProperty)));
            }
            set
            {
                base.SetValue(CreateDocumentLibrary.UrlProperty, value);
            }
        }


        public static DependencyProperty DocLibNameProperty = DependencyProperty.Register("DocLibName", typeof(string), typeof(CreateDocumentLibrary), new PropertyMetadata(""));
        [DescriptionAttribute("Used as doc lib name")]
        [BrowsableAttribute(true)]
        [DesignerSerializationVisibilityAttribute(DesignerSerializationVisibility.Visible)]
        [ValidationOption(ValidationOption.Optional)]
        public string DocLibName
        {
            get
            {
                return ((string)(base.GetValue(CreateDocumentLibrary.DocLibNameProperty)));
            }
            set
            {
                base.SetValue(CreateDocumentLibrary.DocLibNameProperty, value);
            }
        }


        protected override ActivityExecutionStatus Execute(ActivityExecutionContext executionContext)
        {
            CreateDocLib();
            return ActivityExecutionStatus.Closed;
        }

        private void CreateDocLib()
        {
            using (SPSite sps = new SPSite(Url))
            {
                using (SPWeb spw = sps.RootWeb)
                {
                    Guid ID = spw.Lists.Add(DocLibName, DocLibName + " Document Library",
        SPListTemplateType.DocumentLibrary);
                    SPList spdl = spw.Lists[ID];
                    spdl.OnQuickLaunch = true;
                    spdl.Update();
                }
            }
        }



        public CreateDocumentLibrary()
        {
            InitializeComponent();
        }
    }
}

.csharpcode, .csharpcode pre
{
font-size: small;
color: black;
font-family: consolas, “Courier New”, courier, monospace;
background-color: #ffffff;
/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt
{
background-color: #f4f4f4;
width: 100%;
margin: 0em;
}
.csharpcode .lnum { color: #606060; }

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 )

Facebook photo

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

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.