Esempio n. 1
0
        protected void btnAdd_Click(object sender, EventArgs e)
        {
            string typeName      = this.txtTypeName.Text;
            string linkUrl       = this.txtLinkUrl.Text;
            int    fatherid      = Convert.ToInt32(this.ddlFatherType.SelectedValue);
            bool   IsDisplay     = this.chkIsDisplay.Checked;
            bool   IsArticleType = this.chkIsArticleType.Checked;
            //int spcId = Convert.ToInt32(this.ddlSpeciality.SelectedValue);
            int spcId = 0;

            if (Request.QueryString["spcId"] != null)
            {
                spcId = Convert.ToInt32(Request.QueryString["spcId"]);
            }
            if (this.ddlSpeciality.SelectedValue != "" && Convert.ToInt32(this.ddlSpeciality.SelectedValue) != spcId)
            {
                spcId = Convert.ToInt32(this.ddlSpeciality.SelectedValue);
            }
            if (theState == MyPageState.add)
            {
                bllarticletype.Add(new Model.ArticleType {
                    dbo_TypeName = typeName, dbo_Fatherid = fatherid, dbo_LinkUrl = linkUrl, dbo_IsDisplay = IsDisplay, dbo_IsArticleType = IsArticleType, dbo_SpecialityId = spcId
                });
            }
            else if (theState == MyPageState.edit)
            {
                int    typeid    = Convert.ToInt32(Request.QueryString["typeid"]);
                string typeids   = bllarticletype.getAllChildren(typeid);
                int    sourceSpc = (Request.QueryString["spcId"] == null ? 0 : Convert.ToInt32(Request.QueryString["spcId"]));

                if (Convert.ToInt32(sourceSpc) != spcId)
                {
                    bllarticletype.updateSpecialityId(typeids, spcId);
                    DataTable dt           = bllarticle.GetList("dbo_typeid in(" + typeids + ")").Tables[0];
                    string    sourceSpcDir = sys.getSpcDir(sourceSpc);
                    string    destSpcDir   = sys.getSpcDir(spcId);
                    sourceSpcDir = (sourceSpcDir == "" ? "" : sourceSpcDir + "\\");
                    destSpcDir   = (destSpcDir == "" ? "" : destSpcDir + "\\");

                    string sourceDir           = Server.MapPath("~/") + sourceSpcDir + "content\\";
                    string destDir             = Server.MapPath("~/") + destSpcDir + "content\\";
                    System.IO.DirectoryInfo di = new System.IO.DirectoryInfo(destDir);
                    if (!di.Exists)
                    {
                        di.Create();
                    }
                    for (int i = 0; i < dt.Rows.Count; i++)
                    {
                        sys.MoveArticleFile(sourceDir, destDir, Convert.ToDateTime(dt.Rows[i]["dbo_ptime"]), dt.Rows[i]["id"].ToString());
                    }
                }
                bllarticletype.Update(new Model.ArticleType {
                    dbo_TypeName = typeName, dbo_Fatherid = fatherid, dbo_LinkUrl = linkUrl, dbo_IsDisplay = IsDisplay, dbo_IsArticleType = IsArticleType, dbo_SpecialityId = spcId, ID = typeid
                });
            }
            Response.Write("<script>window.location.href='typelist.aspx?spcId=" + spcId.ToString() + "'</script>");
        }
Esempio n. 2
0
        /// <summary>
        /// 执行策略
        /// </summary>
        public override void DoWork <T>(T context)
        {
            var articleContext = context as XCLCMS.Data.BLL.Strategy.Article.ArticleContext;

            if (null == articleContext.Article)
            {
                return;
            }

            bool flag = false;

            XCLCMS.Data.BLL.ArticleType bll = new BLL.ArticleType();

            try
            {
                //删除分类关系
                bll.Delete(articleContext.Article.ArticleID);

                //添加分类关系
                flag = bll.Add(articleContext.Article.ArticleID, articleContext.ArticleTypeIDList, new Model.Custom.ContextModel()
                {
                    UserInfoID = articleContext.CurrentUserInfo.UserInfoID,
                    UserName   = articleContext.CurrentUserInfo.UserName
                });
            }
            catch (Exception ex)
            {
                flag = false;
                this.ResultMessage += string.Format("异常信息:{0}", ex.Message);
            }

            if (flag)
            {
                this.Result = StrategyLib.ResultEnum.SUCCESS;
            }
            else
            {
                this.Result        = StrategyLib.ResultEnum.FAIL;
                this.ResultMessage = string.Format("保存文章附件关系信息失败!{0}", this.ResultMessage);
            }
        }