Example #1
0
        public CollectionInvokeResult <ColumnWithArticle> HomePicArticles(ArticleColumn param)
        {
            CollectionInvokeResult <ColumnWithArticle> result = new CollectionInvokeResult <ColumnWithArticle> {
                Success = true
            };
            int rownum = 4;

            try
            {
                IList <ColumnWithArticle> list_columnWithArticle = null;
                IList <ArticleColumn>     columns = BuilderFactory.DefaultBulder(GetHttpHeader("ConnectId")).List <ArticleColumn>(param.ToStringObjectDictionary(false));
                if (columns.Count > 0)
                {
                    list_columnWithArticle = new List <ColumnWithArticle>();
                    foreach (var column in columns)
                    {
                        if (column.COL_Path == null)
                        {
                            column.COL_Path = column.COL_Name;
                        }
                        IList <Col_Article> articles = BuilderFactory.DefaultBulder(GetHttpHeader("ConnectId")).List <Col_Article>("Cms_Article_ByColumn", new { ROWNUM = rownum, ColumnId = column.ColumnId }.ToStringObjectDictionary(false));
                        foreach (var article in articles)
                        {
                            IList <Attachment> attachments = BuilderFactory.DefaultBulder(GetHttpHeader("ConnectId")).List <Attachment>("Cms_Attachment_ByArticle", new { ROWNUM = 1, SourceId = article.ArticleId, SourceTable = "Pub_Article", AttachmentTag = "ArticlePic" }.ToStringObjectDictionary(false));
                            article.Attachments = attachments;
                        }
                        list_columnWithArticle.Add(new ColumnWithArticle {
                            Column = column, Articles = articles
                        });
                    }
                }
                result.rows = list_columnWithArticle;
            }
            catch (Exception ex)
            {
                result.Success      = false;
                result.ErrorMessage = ex.Message;
            }
            return(result);
        }
        public InvokeResult NullifySelected(string strColumnIds)
        {
            InvokeResult result = new InvokeResult {
                Success = true
            };

            try
            {
                List <IBatisNetBatchStatement> statements = new List <IBatisNetBatchStatement>();
                string[] arrColumnIds = strColumnIds.Split("|".ToCharArray(), StringSplitOptions.RemoveEmptyEntries);
                if (arrColumnIds.Length == 0)
                {
                    result.Success   = false;
                    result.ErrorCode = 59996;
                    return(result);
                }
                string statementName = new ArticleColumn().GetUpdateMethodName();
                foreach (string strColumnId in arrColumnIds)
                {
                    ArticleColumn articleColumn = new ArticleColumn {
                        ColumnId = strColumnId.ToGuid(), Status = 0
                    };
                    /***********************begin 自定义代码*******************/
                    articleColumn.OperatedBy = NormalSession.UserId.ToGuid();
                    articleColumn.OperatedOn = DateTime.Now;

                    /***********************end 自定义代码*********************/
                    statements.Add(new IBatisNetBatchStatement {
                        StatementName = statementName, ParameterObject = articleColumn.ToStringObjectDictionary(false), Type = SqlExecuteType.UPDATE
                    });
                }
                BuilderFactory.DefaultBulder(GetHttpHeader("ConnectId")).ExecuteNativeSqlNoneQuery(statements);
            }
            catch (Exception ex)
            {
                result.Success      = false;
                result.ErrorMessage = ex.Message;
            }
            return(result);
        }
        public ModelInvokeResult <ArticleColumnPK> Update(string strColumnId, ArticleColumn articleColumn)
        {
            ModelInvokeResult <ArticleColumnPK> result = new ModelInvokeResult <ArticleColumnPK> {
                Success = true
            };

            try
            {
                List <IBatisNetBatchStatement> statements = new List <IBatisNetBatchStatement>();
                Guid?_ColumnId = strColumnId.ToGuid();
                if (_ColumnId == null)
                {
                    result.Success   = false;
                    result.ErrorCode = 59996;
                    return(result);
                }
                articleColumn.ColumnId = _ColumnId;
                /***********************begin 自定义代码*******************/
                articleColumn.OperatedBy = NormalSession.UserId.ToGuid();
                articleColumn.OperatedOn = DateTime.Now;

                /***********************end 自定义代码*********************/
                statements.Add(new IBatisNetBatchStatement {
                    StatementName = articleColumn.GetUpdateMethodName(), ParameterObject = articleColumn.ToStringObjectDictionary(false), Type = SqlExecuteType.UPDATE
                });
                /***********************begin 自定义代码*******************/
                /***********************此处添加自定义代码*****************/
                /***********************end 自定义代码*********************/
                BuilderFactory.DefaultBulder(GetHttpHeader("ConnectId")).ExecuteNativeSqlNoneQuery(statements);
                result.instance = new ArticleColumnPK {
                    ColumnId = _ColumnId
                };
            }
            catch (Exception ex)
            {
                result.Success      = false;
                result.ErrorMessage = ex.Message;
            }
            return(result);
        }
 /// <summary>
 /// 保存删除或修改栏目的信息
 /// </summary>
 /// <param name="source"></param>
 /// <param name="e"></param>
 protected void RepArticlec_ItemCommand(object source, RepeaterCommandEventArgs e)
 {
     //删除操作
     if (e.CommandName == "Delete")
     {
         int id = int.Parse((e.Item.FindControl("btnDel") as LinkButton).CommandArgument.ToString());
         ArticleColumnManager.DeleteArticleColumn(id);
         DataBing_();
     }
     //修改栏目信息
     else if (e.CommandName == "Update")
     {
         lblColumn.Text = "修改栏目信息";
         int           id = int.Parse(((e.Item.FindControl("btnUpdate")) as LinkButton).CommandArgument.ToString());
         ArticleColumn ac = ArticleColumnManager.GetArticleColumnById(id);
         if (ac == null)
         {
             return;
         }
         txtName.Text   = ac.Name;
         txtDepict.Text = ac.Description;
         DropName.Text  = ac.ResponsibelUserId.ToString();
         lblId.Text     = ac.Id.ToString();
     }
     //删除所选项栏目信息
     else if (e.CommandName == "DeleteAll")
     {
         for (int i = 0; i < RepArticlec.Items.Count; i++)
         {
             int id;
             if ((RepArticlec.Items[i].FindControl("chb") as CheckBox).Checked)
             {
                 id = int.Parse((RepArticlec.Items[i].FindControl("ArticleColumn_ID") as Label).Text);
                 ArticleColumnManager.DeleteArticleColumn(id);
             }
         }
         DataBing_();
     }
 }
Example #5
0
        /// <summary>
        /// ��ȡ�Ӳ˵�
        /// </summary>
        /// <param name="database"></param>
        /// <param name="baseNode"></param>
        public void CreateTreeNodeRecursive(TreeNode baseNode)
        {
            DataTable dt = SqliteHelper.ExecuteDataset(Constants.DB_PATH, "SELECT id,name,content_url,parent_id,isroot,updatetime,code,cache_count FROM tree WHERE parent_id='" + baseNode.Name + "' ORDER BY id").Tables[0];
            foreach (DataRow dr in dt.Rows)
            {
                TreeNode node = new TreeNode();
                ArticleColumn article = new ArticleColumn();
                string name = SqliteHelper.DBToString(dr["name"]);
                if (string.IsNullOrEmpty(name))
                    continue;
                article.Id = dr["id"].ToString();
                article.Name = name;
                article.ContentUrl = SqliteHelper.DBToString(dr["content_url"]);
                article.ParentId = SqliteHelper.DBToString(dr["parent_id"], "0");
                article.IsRoot = SqliteHelper.DBToString(dr["isroot"]) == "1";
                article.Updatetime = SqliteHelper.DBToString(dr["updatetime"]);
                article.Code = SqliteHelper.DBToString(dr["code"]);
                article.CacheCount = int.Parse(SqliteHelper.DBToString(dr["cache_count"]));
                //article.AuthorId = SqliteHelper.DBToString(dr["author_id"]);
                //article.IsManualUpdate = dr.IsNull("tree_id");
                //node.ToolTipText = dr[2].ToString();
                node.Text = article.Name;
                node.Name = article.Id; //id
                node.Tag = article;  //path

                if (article.IsRoot)
                {
                    //node.Nodes.Add("");
                    node.ImageIndex = 0;
                }
                else
                    node.ImageIndex = 2;
                if (article.IsRoot)
                    CreateTreeNodeRecursive(node);
                baseNode.Nodes.Add(node);
            }
        }
        public InvokeResult DeleteSelected(string strColumnIds)
        {
            InvokeResult result = new InvokeResult {
                Success = true
            };

            try
            {
                List <IBatisNetBatchStatement> statements = new List <IBatisNetBatchStatement>();
                string[] arrColumnIds = strColumnIds.Split("|".ToCharArray(), StringSplitOptions.RemoveEmptyEntries);
                if (arrColumnIds.Length == 0)
                {
                    result.Success   = false;
                    result.ErrorCode = 59996;
                    return(result);
                }
                string statementName = new ArticleColumn().GetDeleteMethodName();
                foreach (string strColumnId in arrColumnIds)
                {
                    ArticleColumnPK pk = new ArticleColumnPK {
                        ColumnId = strColumnId.ToGuid()
                    };
                    DeleteCascade(statements, pk);
                    statements.Add(new IBatisNetBatchStatement {
                        StatementName = statementName, ParameterObject = pk, Type = SqlExecuteType.DELETE
                    });
                }
                BuilderFactory.DefaultBulder(GetHttpHeader("ConnectId")).ExecuteNativeSqlNoneQuery(statements);
            }
            catch (Exception ex)
            {
                result.Success      = false;
                result.ErrorMessage = ex.Message;
            }
            return(result);
        }
        public ModelInvokeResult <ArticleColumnPK> Create(ArticleColumn articleColumn)
        {
            ModelInvokeResult <ArticleColumnPK> result = new ModelInvokeResult <ArticleColumnPK> {
                Success = true
            };

            try
            {
                List <IBatisNetBatchStatement> statements = new List <IBatisNetBatchStatement>();
                if (articleColumn.ColumnId == GlobalManager.GuidAsAutoGenerate)
                {
                    articleColumn.ColumnId = Guid.NewGuid();
                }
                /***********************begin 自定义代码*******************/
                articleColumn.OperatedBy = NormalSession.UserId.ToGuid();
                articleColumn.OperatedOn = DateTime.Now;

                /***********************end 自定义代码*********************/
                statements.Add(new IBatisNetBatchStatement {
                    StatementName = articleColumn.GetCreateMethodName(), ParameterObject = articleColumn.ToStringObjectDictionary(false), Type = SqlExecuteType.INSERT
                });
                /***********************begin 自定义代码*******************/
                /***********************此处添加自定义代码*****************/
                /***********************end 自定义代码*********************/
                BuilderFactory.DefaultBulder(GetHttpHeader("ConnectId")).ExecuteNativeSqlNoneQuery(statements);
                result.instance = new ArticleColumnPK {
                    ColumnId = articleColumn.ColumnId
                };
            }
            catch (Exception ex)
            {
                result.Success      = false;
                result.ErrorMessage = ex.Message;
            }
            return(result);
        }
Example #8
0
        /// <summary>
        /// ��ȡRSS��Ŀ
        /// </summary>
        /// <returns></returns>
        public TreeNode[] GetTree(bool OnlyRoot)
        {
            DataTable dt = SqliteHelper.ExecuteDataset(Constants.DB_PATH, "SELECT id,name,content_url,parent_id,isroot,updatetime,code,cache_count FROM tree WHERE parent_id=0 ORDER BY id").Tables[0];
            //��ȡ����Ŀ¼
            //DataRow[] drs = dt.Rows;// dt.Select("parent_id=0", "name");
            TreeNode[] result = new TreeNode[dt.Rows.Count];
            for (int i = 0, j = dt.Rows.Count; i < j; i++)
            {
                DataRow dr = dt.Rows[i];
                ArticleColumn article = new ArticleColumn();
                string name = SqliteHelper.DBToString(dr["name"]);
                if (string.IsNullOrEmpty(name))
                    continue;
                article.Id = dr["id"].ToString();
                article.Name = name;
                article.ContentUrl = SqliteHelper.DBToString(dr["content_url"]);
                article.ParentId = SqliteHelper.DBToString(dr["parent_id"], "0");
                article.IsRoot = SqliteHelper.DBToString(dr["isroot"]) == "1";
                article.Updatetime = SqliteHelper.DBToString(dr["updatetime"]);
                article.Code = SqliteHelper.DBToString(dr["code"]);
                article.CacheCount = SqliteHelper.DBToInt(dr["cache_count"]);
                //article.AuthorId = SqliteHelper.DBToString(dr["author_id"]);
                //article.IsManualUpdate = dr.IsNull("tree_id");
                TreeNode node = new TreeNode();
                node.Text = article.Name;
                node.ToolTipText = "F2�༭���ƣ��Ҽ���Ӻ�ɾ��";
                node.Name = article.Id; //id
                node.Tag = article; //path
                node.Expand();
                if (article.IsRoot)
                {
                    //node.Nodes.Add("");
                    CreateTreeNodeRecursive(node);
                    node.ImageIndex = 0;
                }
                else
                    node.ImageIndex = 2;

                result[i] = node;
            }
            return result;
        }
 /// <summary>
 /// 更新稿件栏目信息
 /// </summary>
 /// <param name="articleColumn"></param>
 /// <returns></returns>
 public static int UpdateArticleColumn(ArticleColumn articleColumn)
 {
     return(ArticleColumnService.UpdateArticleColumn(articleColumn));
 }
 /// <summary>
 /// 插入新稿件栏目信息
 /// </summary>
 /// <param name="articleColumn"></param>
 /// <returns></returns>
 public static int InsertArticleColumn(ArticleColumn articleColumn)
 {
     return(ArticleColumnService.InsertArticleColumn(articleColumn));
 }