Пример #1
0
 private void ProvisionList(string siteUrl, Guid siteId, Guid webId, SPModelListProvisionOptions listOptions, HashSet <SPModelUsage> deferredListUrls)
 {
     if (checksum == null)
     {
         checksum = ComputeCheckSum();
     }
     using (SPModelProvisionHelper helper = new SPModelProvisionHelper(siteId, GetProvisionEventReceiver(true))) {
         SPList targetList = null;
         if (listOptions.TargetListId != Guid.Empty)
         {
             targetList = helper.ObjectCache.GetList(listOptions.TargetWebId, listOptions.TargetListId);
             if (targetList == null)
             {
                 return;
             }
             helper.UpdateList(targetList, listAttribute.Clone(targetList), contentTypeAttribute, fieldAttributes, hiddenFields.ToArray(), new SPContentTypeId[0], checksum);
         }
         else
         {
             SPListAttribute implListAttribute = listOptions.ListAttributeOverrides ?? listAttribute;
             if (listOptions.TargetListUrl != null)
             {
                 implListAttribute = implListAttribute.Clone(listOptions.TargetListUrl);
             }
             else
             {
                 implListAttribute = implListAttribute.Clone();
             }
             if (listOptions.TargetListTitle != null)
             {
                 implListAttribute.Title = listOptions.TargetListTitle;
             }
             List <SPContentTypeId> contentTypes;
             targetList = helper.EnsureList(helper.ObjectCache.GetWeb(webId), implListAttribute, out contentTypes);
             helper.UpdateList(targetList, implListAttribute, contentTypeAttribute, fieldAttributes, hiddenFields.ToArray(), contentTypes, checksum);
         }
         foreach (SPContentType ct in targetList.ContentTypes)
         {
             if (ct.Id.Parent == contentTypeAttribute.ContentTypeId)
             {
                 deferredListUrls.Add(SPModelUsage.Create(targetList, ct.Id).GetWithoutList());
                 break;
             }
         }
     }
 }
Пример #2
0
 private void ProvisionList(string siteUrl, Guid siteId, Guid webId, SPModelListProvisionOptions listOptions, HashSet <SPModelUsage> deferredListUrls)
 {
     using (SPModelProvisionHelper helper = new SPModelProvisionHelper(siteId, GetProvisionEventReceiver(true))) {
         SPList targetList = null;
         if (listOptions.TargetListId != Guid.Empty)
         {
             targetList = helper.TargetSite.AllWebs[listOptions.TargetWebId].Lists[listOptions.TargetListId];
         }
         SPListAttribute implListAttribute = listOptions.ListAttributeOverrides ?? listAttribute;
         if (targetList != null)
         {
             implListAttribute = listAttribute.Clone(targetList.RootFolder.Url);
             helper.UpdateList(targetList, implListAttribute, contentTypeAttribute, fieldAttributes, hiddenFields.ToArray(), new SPContentTypeId[0]);
         }
         else
         {
             if (listOptions.TargetListUrl != null)
             {
                 implListAttribute = implListAttribute.Clone(listOptions.TargetListUrl);
             }
             else
             {
                 implListAttribute = implListAttribute.Clone();
             }
             if (listOptions.TargetListTitle != null)
             {
                 implListAttribute.Title = listOptions.TargetListTitle;
             }
             using (SPWeb targetWeb = helper.TargetSite.OpenWeb(webId)) {
                 List <SPContentTypeId> contentTypes;
                 targetList = helper.EnsureList(targetWeb, implListAttribute, out contentTypes);
                 helper.UpdateList(targetList, implListAttribute, contentTypeAttribute, fieldAttributes, hiddenFields.ToArray(), contentTypes);
             }
         }
         foreach (SPContentType ct in targetList.ContentTypes)
         {
             if (ct.Id.Parent == contentTypeAttribute.ContentTypeId)
             {
                 deferredListUrls.Add(SPModelUsage.Create(targetList, ct.Id).GetWithoutList());
                 break;
             }
         }
     }
 }