当前位置: 首页>>代码示例>>C#>>正文


C# SPWeb.GetCatalog方法代码示例

本文整理汇总了C#中SPWeb.GetCatalog方法的典型用法代码示例。如果您正苦于以下问题:C# SPWeb.GetCatalog方法的具体用法?C# SPWeb.GetCatalog怎么用?C# SPWeb.GetCatalog使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在SPWeb的用法示例。


在下文中一共展示了SPWeb.GetCatalog方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: CreateWebPart

        public static System.Web.UI.WebControls.WebParts.WebPart CreateWebPart(SPWeb web, string webPartName, SPLimitedWebPartManager webPartManager)
        {
            SPQuery qry = new SPQuery();

               qry.Query = String.Format(CultureInfo.CurrentCulture,
               "<Where><Eq><FieldRef Name='FileLeafRef'/><Value Type='File'>{0}</Value></Eq></Where>",
               webPartName);

               SPList webPartGallery = null;

               if (null == web.ParentWeb)
               {
               webPartGallery = web.GetCatalog(SPListTemplateType.WebPartCatalog);
               }

               else
               {
               webPartGallery = web.Site.RootWeb.GetCatalog(SPListTemplateType.WebPartCatalog);
               }

               SPListItemCollection webParts = webPartGallery.GetItems(qry);

               XmlReader xmlReader = new XmlTextReader(webParts[0].File.OpenBinaryStream());

               string errorMsg;

               System.Web.UI.WebControls.WebParts.WebPart webPart = webPartManager.ImportWebPart(xmlReader, out errorMsg);

               return webPart;
        }
开发者ID:kawalgrover,项目名称:MARTA-Projects,代码行数:30,代码来源:BoardMeetingReceiver.cs

示例2: UpdateCurrentComposedLookItem

        private static void UpdateCurrentComposedLookItem(SPWeb web, ComposedLook composedLook)
        {
            var catalog = web.GetCatalog(SPListTemplateType.DesignCatalog);
            var items = catalog.GetItems(new SPQuery
            {
                RowLimit = 1u,
                Query = "<Where><Eq><FieldRef Name='DisplayOrder'/><Value Type='Number'>0</Value></Eq></Where>",
                ViewFields = "<FieldRef Name='DisplayOrder'/>",
                ViewFieldsOnly = true
            });

            // Delete current composed look item
            if (items.Count == 1)
            {
                items[0].Delete();
            }

            // Create the new composed look item
            var item = catalog.AddItem();
            item[BuiltInFields.DisplayOrderName] = 0;
            item[SPBuiltInFieldId.Name] = SPResource.GetString(web.UICulture, "DesignGalleryCurrentItemName");
            item[SPBuiltInFieldId.Title] = SPResource.GetString(web.UICulture, "DesignGalleryCurrentItemName");
            item[BuiltInFields.MasterPageUrlName] = HttpUtility.UrlDecode(new Uri(composedLook.MasterPagePath.Url).AbsolutePath);
            item[BuiltInFields.ThemeUrlName] = HttpUtility.UrlDecode(new Uri(composedLook.ThemePath.Url).AbsolutePath);
            item[BuiltInFields.ImageUrlName] = composedLook.ImagePath == null ? string.Empty : HttpUtility.UrlDecode(new Uri(composedLook.ImagePath.Url).AbsolutePath);
            item[BuiltInFields.FontSchemeUrlName] = HttpUtility.UrlDecode(new Uri(composedLook.FontSchemePath.Url).AbsolutePath);
            item.Update();
        }
开发者ID:andresglx,项目名称:Dynamite,代码行数:28,代码来源:WebExtensions.cs

示例3: Create

        /// <summary>
        /// Creates the specified composed look.
        /// </summary>
        /// <param name="web">The web.</param>
        /// <param name="entity">The entity.</param>
        /// <returns>
        /// The newly created composed look.
        /// </returns>
        public ComposedLook Create(SPWeb web, ComposedLook entity)
        {
            var designCatalog = web.GetCatalog(SPListTemplateType.DesignCatalog);
            var item = designCatalog.Items.Add();
            this._binder.FromEntity(entity, item);
            item.Update();

            return this._binder.Get<ComposedLook>(item);
        }
开发者ID:andresglx,项目名称:Dynamite,代码行数:17,代码来源:ComposedLookRepository.cs

示例4: GetByName

        /// <summary>
        /// Retrieves a composed look by name.
        /// </summary>
        /// <param name="web">The current web.</param>
        /// <param name="name">The name of the composed look.</param>
        /// <returns>
        /// Returns a composed look by name.
        /// </returns>
        public ComposedLook GetByName(SPWeb web, string name)
        {
            var designCatalog = web.GetCatalog(SPListTemplateType.DesignCatalog);
            var items = designCatalog.GetItems(new SPQuery()
            {
                RowLimit = 1u,
                ViewFields = @"
                    <FieldRef Name=""Name"" />
                    <FieldRef Name=" + BuiltInFields.MasterPageUrlName + @" />
                    <FieldRef Name=" + BuiltInFields.ThemeUrlName + @" />
                    <FieldRef Name=" + BuiltInFields.ImageUrlName + @" />
                    <FieldRef Name=" + BuiltInFields.FontSchemeUrlName + @" />",
                Query = @"
                    <Where>
                        <Eq>
                            <FieldRef Name=""Name"" />
                            <Value Type=""Text"">" + name + @"</Value>
                        </Eq>
                    </Where>"
            });

            return items.Count != 1 ? null : this._binder.Get<ComposedLook>(items[0]);
        }
开发者ID:andresglx,项目名称:Dynamite,代码行数:31,代码来源:ComposedLookRepository.cs

示例5: CreateDefaultWebPart

        //public virtual void ExportWebPart(WebPart webPart, XmlWriter writer)
        //{
        //    if (webPart == null)
        //    {
        //        throw new ArgumentNullException("webPart");
        //    }
        //    if (!this.Controls.Contains(webPart))
        //    {
        //        throw new ArgumentException(SR.GetString("UnknownWebPart"), "webPart");
        //    }
        //    if (writer == null)
        //    {
        //        throw new ArgumentNullException("writer");
        //    }
        //    if (webPart.ExportMode == WebPartExportMode.None)
        //    {
        //        throw new ArgumentException(SR.GetString("WebPartManager_PartNotExportable"), "webPart");
        //    }
        //    bool arg_79_0 = (webPart.ExportMode != WebPartExportMode.NonSensitiveData) ? false : (this.Personalization.Scope != PersonalizationScope.Shared);
        //    bool flag = arg_79_0;
        //    writer.WriteStartElement("webParts");
        //    writer.WriteStartElement("webPart");
        //    writer.WriteAttributeString("xmlns", "http://schemas.microsoft.com/WebPart/v3");
        //    writer.WriteStartElement("metaData");
        //    writer.WriteStartElement("type");
        //    Control control = webPart.ToControl();
        //    UserControl userControl = control as UserControl;
        //    if (userControl == null)
        //    {
        //        writer.WriteAttributeString("name", WebPartUtil.SerializeType(control.GetType()));
        //    }
        //    else
        //    {
        //        writer.WriteAttributeString("src", userControl.AppRelativeVirtualPath);
        //    }
        //    writer.WriteEndElement();
        //    writer.WriteElementString("importErrorMessage", webPart.ImportErrorMessage);
        //    writer.WriteEndElement();
        //    writer.WriteStartElement("data");
        //    IDictionary personalizablePropertyValues = PersonalizableAttribute.GetPersonalizablePropertyValues(webPart, PersonalizationScope.Shared, flag);
        //    writer.WriteStartElement("properties");
        //    if (!(webPart is GenericWebPart))
        //    {
        //        this.ExportIPersonalizable(writer, webPart, flag);
        //        this.ExportToWriter(personalizablePropertyValues, writer);
        //    }
        //    else
        //    {
        //        this.ExportIPersonalizable(writer, control, flag);
        //        IDictionary personalizablePropertyValues2 = PersonalizableAttribute.GetPersonalizablePropertyValues(control, PersonalizationScope.Shared, flag);
        //        this.ExportToWriter(personalizablePropertyValues2, writer);
        //        writer.WriteEndElement();
        //        writer.WriteStartElement("genericWebPartProperties");
        //        this.ExportIPersonalizable(writer, webPart, flag);
        //        this.ExportToWriter(personalizablePropertyValues, writer);
        //    }
        //    writer.WriteEndElement();
        //    writer.WriteEndElement();
        //    writer.WriteEndElement();
        //    writer.WriteEndElement();
        //}
        private static void CreateDefaultWebPart(SPWeb web, SPLimitedWebPartManager webPartManager, WebpartDefinition wp, System.Web.UI.WebControls.WebParts.WebPart concerateWP)
        {
            //TODO : find a solution to create default webpart late
            return;
            if (wp is XSLTListViewWP)
            {
                XSLTListViewWP xstlWP = wp as XSLTListViewWP;
                if (xstlWP.CreateDefaultWP)
                {
                    using (MemoryStream ms = new MemoryStream())
                    {

                        XmlWriter writer = new XmlTextWriter(ms, Encoding.UTF8);
                        concerateWP.ExportMode = System.Web.UI.WebControls.WebParts.WebPartExportMode.All;

                        webPartManager.ExportWebPart(concerateWP, writer);

                        var webPartGallery = web.GetCatalog(SPListTemplateType.WebPartCatalog);

                        //var fileStream
                        SPFile spfile = webPartGallery.RootFolder.Files.Add(wp.Title + ".webpart", ms.GetBuffer(), true);

                        // Commit
                        webPartGallery.RootFolder.Update();
                        webPartGallery.Update();

                    }

                }
            }
        }
开发者ID:chutinhha,项目名称:tvmcorptvs,代码行数:92,代码来源:WebPartHelper.cs

示例6: CreateWebPart

 public static WebPart CreateWebPart(SPWeb web, string webPartName)
 {
     var query = new SPQuery
     {
         Query =
             String.Format(
             "<Where><Eq><FieldRef Name='FileLeafRef'/><Value Type='string'>{0}</Value></Eq></Where>",
             webPartName)
     };
     SPList webPartGallery = web.ParentWeb == null ? web.GetCatalog(SPListTemplateType.WebPartCatalog) : web.ParentWeb.GetCatalog(SPListTemplateType.WebPartCatalog);
     SPListItemCollection webParts = webPartGallery.GetItems(query);
     if (webParts.Count > 0)
     {
         string typeName = webParts[0].GetFormattedValue("ows_WebPartTypeName");
         string assemblyName = webParts[0].GetFormattedValue("ows_WebPartAssembly");
         if (assemblyName != "")
         {
             System.Runtime.Remoting.ObjectHandle webPartHandle = Activator.CreateInstance(assemblyName, typeName);
             {
                 var webPart = (WebPart)webPartHandle.Unwrap();
                 webPart.Title = webPartName;
                 return webPart;
             }
         }
         return null;
     }
     return null;
 }
开发者ID:Santhoshonet,项目名称:SP2010Library,代码行数:28,代码来源:WebPart.cs

示例7: Update

 /// <summary>
 /// Updates the specified composed look.
 /// </summary>
 /// <param name="web">The web.</param>
 /// <param name="entity">The entity.</param>
 public void Update(SPWeb web, ComposedLook entity)
 {
     var designCatalog = web.GetCatalog(SPListTemplateType.DesignCatalog);
     var item = designCatalog.Items.GetItemById(entity.Id);
     this._binder.FromEntity(entity, item);
     item.Update();
 }
开发者ID:andresglx,项目名称:Dynamite,代码行数:12,代码来源:ComposedLookRepository.cs

示例8: GetById

 /// <summary>
 /// Gets the composed look by id.
 /// </summary>
 /// <param name="web">The web.</param>
 /// <param name="id">The id.</param>
 /// <returns>The composed look.</returns>
 public ComposedLook GetById(SPWeb web, int id)
 {
     var designCatalog = web.GetCatalog(SPListTemplateType.DesignCatalog);
     var composedLook = this._binder.Get<ComposedLook>(designCatalog.GetItemById(id));
     return DecodeUrls(composedLook);
 }
开发者ID:andresglx,项目名称:Dynamite,代码行数:12,代码来源:ComposedLookRepository.cs

示例9: Delete

 /// <summary>
 /// Deletes the specified composed look.
 /// </summary>
 /// <param name="web">The web.</param>
 /// <param name="entity">The entity.</param>
 public void Delete(SPWeb web, ComposedLook entity)
 {
     var designCatalog = web.GetCatalog(SPListTemplateType.DesignCatalog);
     var item = designCatalog.GetItemById(entity.Id);
     item.Delete();
 }
开发者ID:andresglx,项目名称:Dynamite,代码行数:11,代码来源:ComposedLookRepository.cs


注:本文中的SPWeb.GetCatalog方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。