Exemple #1
0
        public static bool UpdatePagePart(StaticBlock part)
        {
            StaticBlock sb        = GetPagePart(part.StaticBlockId);
            var         cacheName = CacheNames.GetStaticBlockCacheObjectName(sb.Key);

            if (CacheManager.Contains(cacheName))
            {
                CacheManager.Remove(cacheName);
            }

            SQLDataAccess.ExecuteNonQuery(
                "UPDATE [CMS].[StaticBlock] SET [Key] = @Key, [InnerName] = @InnerName, [Content] = @Content, [Modified] = GETDATE(), Enabled =@Enabled WHERE [StaticBlockID] = @StaticBlockID",
                CommandType.Text,
                new[]
            {
                new SqlParameter("@StaticBlockID", part.StaticBlockId),
                new SqlParameter("@Key", part.Key),
                new SqlParameter("@InnerName", part.InnerName),
                new SqlParameter("@Content", part.Content),
                new SqlParameter("@Enabled", part.Enabled)
            }
                );

            cacheName = CacheNames.GetStaticBlockCacheObjectName(part.Key);
            CacheManager.Insert(cacheName, part);

            return(true);
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!string.IsNullOrEmpty(SourceKey))
            {
                sb = StaticBlockService.GetPagePartByKeyWithCache(SourceKey);
            }

            this.Visible = sb != null && sb.Enabled;
        }
Exemple #3
0
 public static int AddStaticBlock(StaticBlock part)
 {
     return(SQLDataHelper.GetInt(SQLDataAccess.ExecuteScalar(
                                     "INSERT INTO [CMS].[StaticBlock] ([Key], [InnerName], [Content], [Added], [Modified],Enabled) VALUES (@Key, @InnerName, @Content, GETDATE(),GETDATE(),@Enabled); SELECT scope_identity();",
                                     CommandType.Text,
                                     new[]
     {
         new SqlParameter("@Key", part.Key),
         new SqlParameter("@InnerName", part.InnerName),
         new SqlParameter("@Content", part.Content),
         new SqlParameter("@Enabled", part.Enabled)
     }
                                     )));
 }
 public static int AddStaticBlock(StaticBlock part)
 {
     return SQLDataHelper.GetInt(SQLDataAccess.ExecuteScalar(
         "INSERT INTO [CMS].[StaticBlock] ([Key], [InnerName], [Content], [Added], [Modified],Enabled) VALUES (@Key, @InnerName, @Content, GETDATE(),GETDATE(),@Enabled); SELECT scope_identity();",
         CommandType.Text,
         new[]
                 {
                     new SqlParameter("@Key", part.Key),
                     new SqlParameter("@InnerName", part.InnerName),
                     new SqlParameter("@Content", part.Content),
                     new SqlParameter( "@Enabled", part .Enabled )
                 }
         ));
 }
        public static bool UpdatePagePart(StaticBlock part)
        {
            StaticBlock sb = GetPagePart(part.StaticBlockId);
            var cacheName = CacheNames.GetStaticBlockCacheObjectName(sb.Key);
            if (CacheManager.Contains(cacheName))
                CacheManager.Remove(cacheName);

            SQLDataAccess.ExecuteNonQuery(
                "UPDATE [CMS].[StaticBlock] SET [Key] = @Key, [InnerName] = @InnerName, [Content] = @Content, [Modified] = GETDATE(), Enabled =@Enabled WHERE [StaticBlockID] = @StaticBlockID",
                CommandType.Text,
                new[]
                        {
                            new SqlParameter("@StaticBlockID", part.StaticBlockId),
                            new SqlParameter("@Key", part.Key),
                            new SqlParameter("@InnerName", part.InnerName),
                            new SqlParameter("@Content", part.Content),
                            new SqlParameter("@Enabled", part.Enabled)
                        }
                );

            cacheName = CacheNames.GetStaticBlockCacheObjectName(part.Key);
            CacheManager.Insert(cacheName, part);

            return true;
        }
        private void SaveStaticBlock()
        {
            if (_mode == eStaicBlockMode.Err)
            {
                return;
            }

            if (!ValidateInput())
            {
                return;
            }

            var part = new StaticBlock(_staticBlockId)
                {
                    Content = CKEditorControl1.Text,
                    InnerName = txtPageTitle.Text,
                    Key = txtKey.Text,
                    Enabled = chbEnabled.Checked
                };

            if (!StaticBlockService.UpdatePagePart(part))
                MsgErr("Failed to save page part");
        }
        private int CreateStaticBlock()
        {
            // Validation
            MsgErr(true);

            if (!ValidateInput())
            {
                return 0;
            }

            var part = new StaticBlock
                {
                    Content = CKEditorControl1.Text,
                    InnerName = txtPageTitle.Text,
                    Key = txtKey.Text,
                    Enabled = chbEnabled.Checked
                };
            var id = StaticBlockService.AddStaticBlock(part);
            if (id != 0)
            {
                return id;
            }
            return 0;
        }