Example #1
0
        public override void FeatureActivated(SPFeatureReceiverProperties properties)
        {
            SPWeb web = properties.Feature.Parent as SPWeb;

            if (web != null)
            {
                SPList taskList         = web.Lists[Lists.RegistrationApprovalTasks];
                SPList historyList      = web.Lists[Lists.WorkflowHistory];
                SPList registrationList = web.Lists[Lists.Registrations];

                SPWorkflowAssociation existingAssociation = null;
                existingAssociation = registrationList.WorkflowAssociations.GetAssociationByName(WorkflowTemplates.RegistrationApprovalNameV2, CultureInfo.CurrentCulture);
                if (existingAssociation == null)
                {
                    //Create a worklow manager and associate the Course Registration Approval Workflow template
                    //to our Registrations list.
                    SPWorkflowManager            workflowManager = web.Site.WorkflowManager;
                    SPWorkflowTemplateCollection templates       = workflowManager.GetWorkflowTemplatesByCategory(web, null);
                    SPWorkflowTemplate           template        = templates.GetTemplateByBaseID(new Guid(WorkflowTemplates.RegistrationApprovalBaseIdV2));
                    SPWorkflowAssociation        association     = SPWorkflowAssociation.CreateListAssociation(template, template.Name, taskList, historyList);
                    association.AllowManual     = true;
                    association.AutoStartCreate = true;
                    registrationList.AddWorkflowAssociation(association);
                    registrationList.Update();
                    association.Enabled = true;
                }
            }
        }
Example #2
0
        public override void FeatureActivated(SPFeatureReceiverProperties properties)
        {
            SPWeb web = properties.Feature.Parent as SPWeb;

            IConfigManager hierarchicalConfig = SharePointServiceLocator.Current.GetInstance <IConfigManager>();

            hierarchicalConfig.SetInPropertyBag(Constants.SubSiteCreationConfigSiteKey, web.Url, SPFarm.Local);

            SPList taskList    = web.Lists[taskListName];
            SPList historyList = web.Lists[workflowHistoryName];
            SPList subSiteCreationRequestList = web.Lists[subSiteRequestsListName];

            var existingAssociation = subSiteCreationRequestList.WorkflowAssociations.GetAssociationByName(workflowTemplateName, CultureInfo.CurrentCulture);

            if (existingAssociation == null)
            {
                SPWorkflowManager            workflowManager = web.Site.WorkflowManager;
                SPWorkflowTemplateCollection templates       = workflowManager.GetWorkflowTemplatesByCategory(web, null);
                SPWorkflowTemplate           template        = templates.GetTemplateByBaseID(workflowTemplateId);
                SPWorkflowAssociation        association     = SPWorkflowAssociation.CreateListAssociation(template, template.Name, taskList, historyList);
                association.AllowManual     = true;
                association.AutoStartCreate = true;
                subSiteCreationRequestList.AddWorkflowAssociation(association);
                subSiteCreationRequestList.Update();
                association.Enabled = true;
            }

            ServiceLocatorConfig typeMappings = new ServiceLocatorConfig();

            typeMappings.RegisterTypeMapping <IBusinessEventTypeConfigurationRepository, BusinessEventTypeConfigurationRepository>();
            typeMappings.RegisterTypeMapping <ISubSiteCreationRequestRepository, SubSiteCreationRequestsRepository>();
        }
Example #3
0
        public SPWorkflowTemplateCollectionInstance GetWorkflowTemplatesByCategory(SPWebInstance web, string strReqCaegs)
        {
            if (web == null)
            {
                throw new JavaScriptException(this.Engine, "Error",
                                              "An instance of a SPWeb object must be supplied as the first argument.");
            }

            var result = m_workflowManager.GetWorkflowTemplatesByCategory(web.Web, strReqCaegs);

            return(result == null
                ? null
                : new SPWorkflowTemplateCollectionInstance(this.Engine.Object.InstancePrototype, result));
        }