Ejemplo n.º 1
0
        public void DeletePageLink(SPFile page, SPWeb web)
        {
            var wm       = page.GetLimitedWebPartManager(PersonalizationScope.Shared);
            var webparts = wm.WebParts;

            foreach (WebPart webpart in webparts)
            {
                if (webpart.WebBrowsableObject.ToString() == "CMICT.CSP.Web.BusinessSearch.BusinessSearch.BusinessSearch")
                {
                    CMICT.CSP.Web.BusinessSearch.BusinessSearch.BusinessSearch BS = (BusinessSearch.BusinessSearch)webpart;
                    if (string.IsNullOrEmpty(BS.TemplateID))
                    {
                        continue;
                    }
                    Guid        templateID = new Guid(BS.TemplateID);
                    string      selectSql  = "select templateid from BS_TEMPLATE_PAGES where Url=N'" + page.ServerRelativeUrl + "'";
                    string      sql        = "delete from BS_TEMPLATE_PAGES where Url=N'" + page.ServerRelativeUrl + "'";
                    DbHelperSQL dbhelper   = new DbHelperSQL();

                    DataTable templateDt = dbhelper.ExecuteTable(CommandType.Text, selectSql);

                    dbhelper.ExecuteNonQuery(CommandType.Text, sql);


                    if (templateDt != null && templateDt.Rows.Count > 0)
                    {
                        foreach (DataRow dr in templateDt.Rows)
                        {
                            RefreshTemplateStatus(Convert.ToString(dr["templateid"]));
                        }
                    }
                }
            }
        }
Ejemplo n.º 2
0
        public void AddPageLink(SPListItem item, SPWeb web)
        {
            SPFile page = item.File;

            var wm       = page.GetLimitedWebPartManager(PersonalizationScope.Shared);
            var webparts = wm.WebParts;

            foreach (WebPart webpart in webparts)
            {
                if (webpart.WebBrowsableObject.ToString() == "CMICT.CSP.Web.BusinessSearch.BusinessSearch.BusinessSearch")
                {
                    CMICT.CSP.Web.BusinessSearch.BusinessSearch.BusinessSearch BS = (BusinessSearch.BusinessSearch)webpart;
                    if (BS.TemplateID == null)
                    {
                        return;
                    }
                    Guid templateID            = new Guid(BS.TemplateID);
                    BS_TEMPLATE_PAGESBLL bll   = new BS_TEMPLATE_PAGESBLL();
                    BS_TEMPLATE_PAGES    model = new BS_TEMPLATE_PAGES();

                    model.Author   = item["Author"].ToString();
                    model.Created  = Convert.ToDateTime(item["Created"]);
                    model.Editor   = item["Editor"].ToString();
                    model.Modified = Convert.ToDateTime(item["Modified"]);

                    model.PageName   = item.Web.Title + "-" + item.Title;
                    model.TemplateID = templateID;
                    model.Url        = item.File.ServerRelativeUrl;

                    bll.Add(model);

                    RefreshTemplateStatus(BS.TemplateID);
                }
            }
        }