Ejemplo n.º 1
0
        protected override ActivityExecutionStatus Execute(ActivityExecutionContext executionContext)
        {
            try
            {
                using (SPSite site = new SPSite(WebURL, __Context.Web.CurrentUser.UserToken))
                {
                    using (SPWeb web = site.OpenWeb())
                    {
                        string[] templateIDs = TemplateIDs.Split(';');
                        Collection <SPWebTemplate> templateList = new Collection <SPWebTemplate>();
                        foreach (string templateid in templateIDs)
                        {
                            SPWebTemplate template = LookupTemplate(site, templateid);
                            if (template != null)
                            {
                                templateList.Add(template);
                            }
                            else
                            {
                                throw new Exception("Could not locate template, " + templateid + ", in site, " + WebURL + ".");
                            }
                        }
                        web.SetAvailableWebTemplates(templateList, LCID);
                        web.Update();

                        string message = "Web: " + WebURL + " templates restricted to: " + TemplateIDs;
                        WorkflowHistoryLogger.LogMessage(executionContext, SPWorkflowHistoryEventType.None, "Complete", UserID, message);
                    }
                }
            }
            catch (Exception ex)
            {
                WorkflowHistoryLogger.LogError(executionContext, UserID, ex);
                return(ActivityExecutionStatus.Faulting);
            }
            return(ActivityExecutionStatus.Closed);
        }
Ejemplo n.º 2
0
 public bool Can(Template Template)
 {
     if (Template == null)
     {
         return(false);
     }
     if (Options.DisablePermissions || IsAdmin || Template.TemplateID == -1)
     {
         return(true);
     }
     if (!IsPageEditor)
     {
         return(false);
     }
     if (Template.OwnerID == this.User.UserNo)
     {
         return(true);
     }
     if (TemplateIDs.Any(t => t == Template.TemplateID))
     {
         return(true);
     }
     return(false);
 }