Beispiel #1
0
 protected override void OnManagerResolved()
 {
     base.OnManagerResolved();
     try {
         SPModelProvisionOptions     opts = SPModelProvisionOptions.None;
         SPModelListProvisionOptions options;
         if (this.ListUrl != null)
         {
             options = new SPModelListProvisionOptions(this.ListUrl);
         }
         else
         {
             options = SPModelListProvisionOptions.Default;
         }
         if (this.Force.IsPresent)
         {
             opts = opts | SPModelProvisionOptions.ForceProvisionContentType;
         }
         if (this.SuppressList.IsPresent)
         {
             opts = opts | SPModelProvisionOptions.SuppressListCreation;
         }
         this.Descriptor.Provision(this.Web.Read(), opts, options);
     } catch (Exception ex) {
         ThrowTerminatingError(ex, ErrorCategory.NotSpecified);
     }
 }
Beispiel #2
0
        public SPModelUsageCollection Provision(SPWeb targetWeb, SPModelProvisionOptions options, SPModelListProvisionOptions listOptions)
        {
            CommonHelper.ConfirmNotNull(targetWeb, "targetWeb");
            CommonHelper.ConfirmNotNull(listOptions, "listOptions");
            if (contentTypeAttribute == null || !contentTypeAttribute.ExternalContentType)
            {
                bool provisionContentType = options.HasFlag(SPModelProvisionOptions.ForceProvisionContentType) || provisionedSites.TryAdd(targetWeb.Site.ID, true);
                bool provisionList        = !options.HasFlag(SPModelProvisionOptions.SuppressListCreation);
                if (provisionContentType || provisionList)
                {
                    string          siteUrl = targetWeb.Site.Url;
                    Guid            siteId  = targetWeb.Site.ID;
                    Guid            webId   = targetWeb.ID;
                    ProvisionResult result  = new ProvisionResult();

                    Thread thread = new Thread(() => Provision(siteUrl, siteId, webId, provisionContentType, provisionList, listOptions, result));
                    thread.Start();
                    if (!options.HasFlag(SPModelProvisionOptions.Asynchronous))
                    {
                        thread.Join();
                        if (result.Exception != null)
                        {
                            throw result.Exception.Rethrow();
                        }
                        return(new SPModelUsageCollection(targetWeb.Site, result.ProvisionedLists.ToArray()));
                    }
                }
            }
            return(new SPModelUsageCollection(targetWeb.Site, new SPModelUsage[0]));
        }