Esempio n. 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();
        }
Esempio n. 2
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())
            {
                LayoutNBlockInfo layoutNBlockInfo = new LayoutNBlockInfo();
                layoutNBlockInfo.Language = drlLanguages.SelectedValue;
                layoutNBlockInfo.BlockId = blockInfo.Id;
                layoutNBlockInfo.LayoutId = ValidationHelper.GetInteger(drlLayout.SelectedValue, 0);
                layoutNBlockInfo.WebPartZoneName = drlWebPartZoneName.SelectedValue;
                layoutNBlockInfo.Order = ValidationHelper.GetInteger(drlOrder.SelectedValue, 0);
                _layoutNBlockProvider.Create(layoutNBlockInfo, ErrorList);
                LayoutInfo layoutInfo = _layoutProvider.Select(layoutNBlockInfo.LayoutId, ErrorList);
                _layoutProvider.DeleteObjectFromCache(layoutInfo);
            }
            return CheckErrors();
        }
Esempio n. 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();
        }