Example #1
0
        protected override bool Insert()
        {
            ArticleInfo articleInfo = new ArticleInfo();
            articleInfo.Title = txtTitle.Text;
            articleInfo.Code = txtCode.Text;
            articleInfo.Text = fckEditor.Value.ToHtmlEncode();
            articleInfo.Language = drlLanguages.SelectedValue;
            articleInfo.PageId = ValidationHelper.GetInteger(drlPages.SelectedValue, 0);
            articleInfo.PageZone = GetControlValue(drlPageZones.ID); ;
            articleInfo.PageLayoutId = ValidationHelper.GetInteger(drlPageLayouts.SelectedValue, 0);
            articleInfo.PageLayoutZone = drlPageLayoutZones.SelectedValue;
            articleInfo.SiteLayoutId = ValidationHelper.GetInteger(drlSiteLayouts.SelectedValue, 0);
            articleInfo.SiteLayoutZone = drlSiteLayoutZones.SelectedValue;
            articleInfo.CreatedBy = CoreSettings.CurrentUserName;
            articleInfo.CreatedDate = DateTime.Now;
            articleInfo.ModifiedBy = CoreSettings.CurrentUserName;
            articleInfo.ModifiedDate = DateTime.Now;
            object id = _articleProvider.Create(articleInfo, ErrorList);
            if (CheckErrors())
            {
                BlockInfo blockInfo = new BlockInfo();
                blockInfo.WebPartId = CoreSettings.CurrentSite.ArticleWebpartId;
                blockInfo.Name = string.Format("ARTICLE:{0}", articleInfo.Code);
                blockInfo.Properties = string.Format("<properties><property name=\"ArticleId\">{0}</property></properties>", id);
                object blockId = _blockProvider.Create(blockInfo, ErrorList);
                if (CheckErrors())
                {
                    int pageBlockId = 0;
                    int pageLayoutNBlock = 0;
                    int siteLayoutNBlock = 0;
                    if (drlPages.SelectedValue != "0" && !string.IsNullOrEmpty(GetControlValue(drlPageZones.ID)))
                    {
                        PageNBlockProvider pageNBlockProvider = new PageNBlockProvider();
                        PageNBlockInfo pageNBlockInfo = new PageNBlockInfo();
                        pageNBlockInfo.Language = articleInfo.Language;
                        pageNBlockInfo.BlockId = ValidationHelper.GetInteger(blockId, 0);
                        pageNBlockInfo.PageId = ValidationHelper.GetInteger(drlPages.SelectedValue, 0);
                        pageNBlockInfo.WebPartZoneName = GetControlValue(drlPageZones.ID);
                        pageNBlockInfo.Order = ValidationHelper.GetInteger(drlPageOrder.SelectedValue, 0);
                        pageBlockId = ValidationHelper.GetInteger(pageNBlockProvider.Create(pageNBlockInfo, ErrorList), 0);
                    }

                    if (drlPageLayouts.SelectedValue != "0" && !string.IsNullOrEmpty(GetControlValue(drlPageLayoutZones.ID)))
                    {
                        LayoutNBlockProvider layoutNBlockProvider = new LayoutNBlockProvider();
                        LayoutNBlockInfo layoutNBlockInfo = new LayoutNBlockInfo();
                        layoutNBlockInfo.Language = articleInfo.Language;
                        layoutNBlockInfo.BlockId = ValidationHelper.GetInteger(blockId, 0);
                        layoutNBlockInfo.LayoutId = ValidationHelper.GetInteger(drlPageLayouts.SelectedValue, 0);
                        layoutNBlockInfo.WebPartZoneName = GetControlValue(drlPageLayoutZones.ID);
                        layoutNBlockInfo.Order = ValidationHelper.GetInteger(drlPageLayoutOrder.SelectedValue, 0);
                        pageLayoutNBlock = ValidationHelper.GetInteger(layoutNBlockProvider.Create(layoutNBlockInfo, ErrorList), 0);
                    }

                    if (drlSiteLayouts.SelectedValue != "0" && !string.IsNullOrEmpty(GetControlValue(drlSiteLayoutZones.ID)))
                    {
                        LayoutNBlockProvider layoutNBlockProvider = new LayoutNBlockProvider();
                        LayoutNBlockInfo layoutNBlockInfo = new LayoutNBlockInfo();
                        layoutNBlockInfo.Language = articleInfo.Language;
                        layoutNBlockInfo.BlockId = ValidationHelper.GetInteger(blockId, 0);
                        layoutNBlockInfo.LayoutId = ValidationHelper.GetInteger(drlSiteLayouts.SelectedValue, 0);
                        layoutNBlockInfo.WebPartZoneName = GetControlValue(drlSiteLayoutZones.ID);
                        layoutNBlockInfo.Order = ValidationHelper.GetInteger(drlSiteLayoutOrder.SelectedValue, 0);
                        siteLayoutNBlock = ValidationHelper.GetInteger(layoutNBlockProvider.Create(layoutNBlockInfo, ErrorList), 0);
                    }

                    articleInfo.Id = ValidationHelper.GetInteger(id, 0);
                    articleInfo.PageNBlockId = pageBlockId;
                    articleInfo.PageLayoutNBlockId = pageLayoutNBlock;
                    articleInfo.SiteLayoutNBlockId = siteLayoutNBlock;
                    articleInfo.BlockId = ValidationHelper.GetInteger(blockId, 0);
                    _articleProvider.Update(articleInfo, ErrorList);
                }
            }
            CacheHelper.ClearCaches();
            return CheckErrors();
        }
Example #2
0
        protected override bool Update()
        {
            ArticleInfo articleInfo = _articleProvider.Select(ValidationHelper.GetInteger(Id, 0), ErrorList);
            if (articleInfo != null)
            {
                articleInfo.Title = txtTitle.Text;
                articleInfo.Code = txtCode.Text;
                articleInfo.Text = fckEditor.Value.ToHtmlEncode();
                articleInfo.Language = drlLanguages.SelectedValue;
                articleInfo.PageId = ValidationHelper.GetInteger(drlPages.SelectedValue, 0);
                articleInfo.PageZone = GetControlValue(drlPageZones.ID);
                articleInfo.PageLayoutId = ValidationHelper.GetInteger(drlPageLayouts.SelectedValue, 0);
                articleInfo.PageLayoutZone = drlPageLayoutZones.SelectedValue;
                articleInfo.SiteLayoutId = ValidationHelper.GetInteger(drlSiteLayouts.SelectedValue, 0);
                articleInfo.SiteLayoutZone = drlSiteLayoutZones.SelectedValue;
                articleInfo.ModifiedBy = CoreSettings.CurrentUserName;
                articleInfo.ModifiedDate = DateTime.Now;
                int blockId = 0;
                if (CheckErrors())
                {
                    PageNBlockProvider pageNBlockProvider = new PageNBlockProvider();
                    if (articleInfo.PageId == 0 && articleInfo.PageNBlockId != 0)
                    {
                        pageNBlockProvider.Delete(articleInfo.PageNBlockId, ErrorList);
                    }
                    else
                    {
                        PageNBlockInfo pageNBlockInfo = pageNBlockProvider.Select(articleInfo.PageNBlockId, ErrorList);
                        if (pageNBlockInfo != null)
                        {
                            pageNBlockInfo.Language = articleInfo.Language;
                            pageNBlockInfo.PageId = ValidationHelper.GetInteger(drlPages.SelectedValue, 0);
                            pageNBlockInfo.WebPartZoneName = GetControlValue(drlPageZones.ID);
                            pageNBlockInfo.Order = ValidationHelper.GetInteger(drlPageOrder.SelectedValue, 0);
                            pageNBlockProvider.Update(pageNBlockInfo, ErrorList);
                        }
                        else
                        {
                            if (drlPages.SelectedValue != "0" && !string.IsNullOrEmpty(GetControlValue(drlPageZones.ID)))
                            {
                                pageNBlockInfo = new PageNBlockInfo();
                                pageNBlockInfo.BlockId = articleInfo.BlockId;
                                pageNBlockInfo.Language = articleInfo.Language;
                                pageNBlockInfo.PageId = ValidationHelper.GetInteger(drlPages.SelectedValue, 0);
                                pageNBlockInfo.WebPartZoneName = GetControlValue(drlPageZones.ID);
                                pageNBlockInfo.Order = ValidationHelper.GetInteger(drlPageOrder.SelectedValue, 0);
                                object pagenBlockid = pageNBlockProvider.Create(pageNBlockInfo, ErrorList);
                                articleInfo.PageNBlockId = ValidationHelper.GetInteger(pagenBlockid, 0);
                                articleInfo.PageZone = pageNBlockInfo.WebPartZoneName;
                            }
                        }
                    }

                    LayoutNBlockProvider layoutNBlockProvider = new LayoutNBlockProvider();
                    if (articleInfo.PageLayoutId == 0 && articleInfo.PageLayoutNBlockId != 0)
                    {
                        layoutNBlockProvider.Delete(articleInfo.PageLayoutNBlockId, ErrorList);
                    }
                    else
                    {
                        LayoutNBlockInfo layoutNBlockInfo = layoutNBlockProvider.Select(articleInfo.PageLayoutNBlockId, ErrorList);
                        if (layoutNBlockInfo != null)
                        {
                            layoutNBlockInfo.Language = articleInfo.Language;
                            layoutNBlockInfo.LayoutId = ValidationHelper.GetInteger(drlPageLayouts.SelectedValue, 0);
                            layoutNBlockInfo.WebPartZoneName = GetControlValue(drlPageLayoutZones.ID);
                            layoutNBlockInfo.Order = ValidationHelper.GetInteger(drlPageLayoutOrder.SelectedValue, 0);
                            articleInfo.PageLayoutZone = layoutNBlockInfo.WebPartZoneName;
                            layoutNBlockProvider.Update(layoutNBlockInfo, ErrorList);
                        }
                        else
                        {
                            if (drlPageLayouts.SelectedValue != "0" && !string.IsNullOrEmpty(GetControlValue(drlPageLayoutZones.ID)))
                            {
                                layoutNBlockInfo = new LayoutNBlockInfo();
                                layoutNBlockInfo.BlockId = articleInfo.BlockId;
                                layoutNBlockInfo.Language = articleInfo.Language;
                                layoutNBlockInfo.LayoutId = ValidationHelper.GetInteger(drlPageLayouts.SelectedValue, 0);
                                layoutNBlockInfo.WebPartZoneName = GetControlValue(drlPageLayoutZones.ID);
                                layoutNBlockInfo.Order = ValidationHelper.GetInteger(drlPageLayoutOrder.SelectedValue, 0);
                                object result = layoutNBlockProvider.Create(layoutNBlockInfo, ErrorList);
                                articleInfo.PageLayoutZone = layoutNBlockInfo.WebPartZoneName;
                                articleInfo.PageLayoutNBlockId = ValidationHelper.GetInteger(result, 0);
                            }
                        }
                    }

                    if (articleInfo.SiteLayoutId == 0 && articleInfo.SiteLayoutNBlockId != 0)
                    {
                        layoutNBlockProvider.Delete(articleInfo.SiteLayoutNBlockId, ErrorList);
                    }
                    else
                    {
                        LayoutNBlockInfo layoutNBlockInfo = layoutNBlockProvider.Select(articleInfo.SiteLayoutNBlockId, ErrorList);
                        if (layoutNBlockInfo != null)
                        {
                            layoutNBlockInfo.Language = articleInfo.Language;
                            layoutNBlockInfo.LayoutId = ValidationHelper.GetInteger(drlSiteLayouts.SelectedValue, 0);
                            layoutNBlockInfo.WebPartZoneName = GetControlValue(drlSiteLayoutZones.ID);
                            layoutNBlockInfo.Order = ValidationHelper.GetInteger(drlSiteLayoutOrder.SelectedValue, 0);
                            layoutNBlockProvider.Update(layoutNBlockInfo, ErrorList);
                        }
                        else
                        {
                            if (drlSiteLayouts.SelectedValue != "0" && !string.IsNullOrEmpty(GetControlValue(drlSiteLayoutZones.ID)))
                            {
                                layoutNBlockInfo = new LayoutNBlockInfo();
                                layoutNBlockInfo.BlockId = articleInfo.BlockId;
                                layoutNBlockInfo.Language = articleInfo.Language;
                                layoutNBlockInfo.LayoutId = ValidationHelper.GetInteger(drlSiteLayouts.SelectedValue, 0);
                                layoutNBlockInfo.WebPartZoneName = GetControlValue(drlSiteLayoutZones.ID);
                                layoutNBlockInfo.Order = ValidationHelper.GetInteger(drlSiteLayoutOrder.SelectedValue, 0);
                                object result = layoutNBlockProvider.Create(layoutNBlockInfo, ErrorList);
                                articleInfo.SiteLayoutNBlockId = ValidationHelper.GetInteger(result, 0);
                                articleInfo.SiteLayoutZone = layoutNBlockInfo.WebPartZoneName;
                            }
                        }
                    }

                }
                _articleProvider.Update(articleInfo, ErrorList);
            }
            CacheHelper.ClearCaches();
            return CheckErrors();
        }
Example #3
0
        protected override bool Insert()
        {
            BlockInfo blockInfo = new BlockInfo();
            blockInfo.Name = txtName.Text;
            RenderWebPart();
            FWebPartEdit webPartControl = pnlWebPart.FindControl("webPartEditControl") as FWebPartEdit;
            if (webPartControl != null)
            {
                blockInfo.Properties = webPartControl.GetAttributes();
            }
            blockInfo.WebPartId = ValidationHelper.GetInteger(drlWebPart.SelectedValue, 0);
            blockInfo.Order = ValidationHelper.GetInteger(drlOrder.SelectedValue, 0);
            _blockProvider.Create(blockInfo, ErrorList);

            if (CheckErrors())
            {
                PageNBlockInfo pageNBlockInfo = new PageNBlockInfo();
                pageNBlockInfo.BlockId = blockInfo.Id;
                pageNBlockInfo.PageId = ValidationHelper.GetInteger(drlPage.SelectedValue, 0);
                pageNBlockInfo.WebPartZoneName = drlWebPartZoneName.SelectedValue;
                pageNBlockInfo.Order = ValidationHelper.GetInteger(drlOrder.SelectedValue, 0);
                pageNBlockInfo.Language = drlLanguages.SelectedValue;
                _pageNBlockProvider.Create(pageNBlockInfo, ErrorList);

            }
            return CheckErrors();
        }