Ejemplo n.º 1
0
        public void ToStaticContent(int count)
        {
            int[] ids = bllarticletype.getTypeIdsBySpcId(spcId);
            if (ids.Length == 0)
            {
                this.lblMessage.Text = "没有内容可以生成!";
                return;
            }

            string strIds = string.Empty;

            for (int i = 0; i < ids.Length; i++)
            {
                strIds += ids[i].ToString();
                if (i != ids.Length - 1)
                {
                    strIds += ",";
                }
            }
            DataTable dt     = bllarticle.GetList("dbo_typeid in(" + strIds + ") order by id desc").Tables[0];
            string    strDir = sys.getSpcDir(spcId);

            for (int i = 0; i < dt.Rows.Count; i++)
            {
                sys.ToStaticContent(strDir, Convert.ToInt32(dt.Rows[i]["id"]), Convert.ToDateTime(dt.Rows[i]["dbo_ptime"]));
            }
            this.lblMessage.Text = "频道内容页生成成功!生成" + dt.Rows.Count.ToString() + "页.执行时间:" + DateTime.Now.ToString("yyyy年MM月dd日hh时mm分ss秒");
        }
Ejemplo n.º 2
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>");
        }
Ejemplo n.º 3
0
        protected void btnDelSelected_Click(object sender, EventArgs e)
        {
            string selectItems = getSelectedItemsId();

            if (selectItems != "")
            {
                //1.删除文章并且获取需要重新生成的类型id集合。2.从数据库中删除。3.重新生成相关页面

                string[] ids     = selectItems.Split(',');
                int[]    typeids = new int[ids.Length];
                int      length  = 0; //不重复的typeid数目
                // DateTime[] articlePtime = new DateTime[ids.Length];

                int spcId = 0;
                if (Request.QueryString["spcId"] != null)
                {
                    spcId = Convert.ToInt32(Request.QueryString["spcId"]);
                }

                string strDir = string.Empty;

                //不论是否静态生成都尝试删除已有的文件
                //if (sys.IsStatic)
                //{
                strDir = sys.getSpcDir(spcId);
                DataTable dt = bllarticle.GetList("id in (" + selectItems + ")").Tables[0];
                for (int i = 0; i < dt.Rows.Count; i++)
                {
                    int  typeid      = Convert.ToInt32(dt.Rows[i]["dbo_typeid"]);
                    bool ExistTypeId = false;
                    for (int j = 0; j < length; j++)
                    {
                        if (typeid == typeids[j])
                        {
                            ExistTypeId = true;
                        }
                    }
                    if (!ExistTypeId)
                    {
                        typeids[length] = typeid;
                        length++;
                    }
                    //articlePtime[i] = Convert.ToDateTime(dt.Rows[i]["ptime"]);
                    sys.deleteArticleFile(Convert.ToInt32(ids[i]), strDir, Convert.ToDateTime(dt.Rows[i]["dbo_ptime"]));
                }
                //}
                bllarticle.DeleteList(selectItems);
                bllarticleimg.DeleteByArticleIdList(selectItems);


                if (sys.IsStatic)
                {
                    for (int i = 0; i < length; i++)
                    {
                        sys.ToStaticListWithArticleEdit(typeids[i], strDir);
                    }

                    if (Request.QueryString["spcId"] != null)
                    {
                        spcId = Convert.ToInt32(Request.QueryString["spcId"]);
                    }
                    sys.ToStaticPageWithActive(Convert.ToInt32(spcId));
                }
            }
            this.BindData();
        }