Пример #1
0
    //发布
    protected void btnFB_Click(object sender, EventArgs e)
    {
        if (this.Session["uid"].ToString() == "")
            this.Response.Redirect("../login.aspx");

        string ls_tip = "发布成功!";

        //新文档时
        TPortalClass.JpArticle JpArticle = new TPortalClass.JpArticle();
        TPortalClass.JpCommon JpCommon = new TPortalClass.JpCommon();
        JpArticle.cid = this.txtcid.Text;
        JpArticle.title = this.txttitle.Text;
        JpArticle.subhead = this.txttitle2.Text;
        JpArticle.ht_content = this.content1.Value;
        if (this.txtsummary.Text == "")
        {
            JpArticle.summary = JpCommon.OutPicGetStr(this.content1.Value, 150);
        }
        else
        {
            JpArticle.summary = this.txtsummary.Text;
        }
        JpArticle.author = this.Session["uname"].ToString();

        JpArticle.status = "发布";
        //JpArticle.ifindexdisplay = "";
        string lsfilename = FileUpload1.FileName;
        string lspath = "";
        string lsurl = "";
        string str_path = "";
        if (lsfilename != "")  //attsize
        {
            //SaveCommon(ls_path, ls_attsize, lsguid);
            //将附件上传到服务器目录下
            lspath = Server.MapPath("~/");//虚拟目录的位置
            lsurl = "/upload/indexpic"; //存放的文件夹
            Directory.CreateDirectory(lspath + "/" + lsurl);
            str_path = lspath + "/" + lsurl + "/" + lsfilename;
            FileUpload1.SaveAs(str_path);
            JpArticle.indexdisplaypicpath = lsurl + "/" + lsfilename;
        }
        else
        {
            this.txtpic.Value = JpCommon.GetImg(this.content1.Value);
            JpArticle.indexdisplaypicpath = this.txtpic.Value;
        }

        if (this.txtseotitle.Text == "")
        {
            JpArticle.seotitle = this.txttitle.Text;
        }
        else
        {
            JpArticle.seotitle = this.txtseotitle.Text;
        }
        if (this.txtseokeywords.Text == "")
        {
            JpArticle.seokeywords = this.txttitle.Text;
        }
        else
        {
            JpArticle.seokeywords = this.txtseokeywords.Text;
        }
        if (this.txtseodescription.Text == "")
        {
            JpArticle.seodescription = JpCommon.OutPicGetStr(this.content1.Value, 150);
        }
        else
        {
            JpArticle.seodescription = this.txtseodescription.Text;
        }
        JpArticle.asort = System.Int32.Parse(this.txtasort.Text);
        JpArticle.iftop = this.ddlsfzd.SelectedValue;
        JpArticle.topendtime = this.txttopendtime.Value;
        JpArticle.ifindexdisplay = this.ddlsfsyss.SelectedValue;
        JpArticle.ifcomment = "0";
        JpArticle.source = this.txtsource.Value;
        JpArticle.role_userid = this.txtrole_userid.Text;
        JpArticle.role_username = this.txtrole_username.Text;
        JpArticle.input = this.Session["uid"].ToString();
        JpArticle.GUID = this.txtguid.Text;
        if (ddllb.SelectedValue != "请选择")
        {
            JpArticle.map_cid = ddllb.SelectedValue;
        }
        else
        {
            JpArticle.map_cid = "";
        }
        JpArticle.map_aid = 0;
        JpArticle.targettype = "";
        JpArticle.hits = 0;
        JpArticle.goodnum = 0;
        if (radlist.SelectedValue == "否")
        {
            JpArticle.sfzwd = radlist.SelectedValue;
            JpArticle.zwdid = ddlwz.SelectedValue;
        }
        else
        {
            JpArticle.sfzwd = radlist.SelectedValue;
            JpArticle.zwdid = "";
        }
        if (this.txtendtime.Text != "")
        {
            JpArticle.endtime = this.txtendtime.Text;
        }
        else
        {
            JpArticle.endtime = System.DateTime.Now.AddYears(10).ToString();
        }
        if (this.txtpubtime.Text != "")
        {
            JpArticle.pubtime = this.txtpubtime.Text;
        }
        else
        {
            JpArticle.pubtime = System.DateTime.Now.ToString();
        }
        if (this.txtop.Value == "add")
        {
            //写系统日志
            string userip = Request.ServerVariables["HTTP_X_FORWARDED_FOR"];
            if (userip == null || userip == "")
            {
                userip = Request.ServerVariables["REMOTE_ADDR"];
            }
            JpCommon.WriteLog(userip, "审核新增", "审核新增文章记录[guid:" + this.txtguid.Text + "]", Session["uid"].ToString(), Session["uname"].ToString());

            JpArticle.Insert();
        }
        else
        {
            //写系统日志
            string userip = Request.ServerVariables["HTTP_X_FORWARDED_FOR"];
            if (userip == null || userip == "")
            {
                userip = Request.ServerVariables["REMOTE_ADDR"];
            }
            JpCommon.WriteLog(userip, "审核修改", "审核修改组织记录[id:" + this.txtguid.Text + "]", Session["uid"].ToString(), Session["uname"].ToString());
            JpArticle.aid = System.Int32.Parse(this.txtaid.Text);
            JpArticle.Update();
        }

        //静态发布
        TPortalClass.JpSite JpSite = new TPortalClass.JpSite();
        string ls_html = JpSite.fax;
        if (ls_html == "开启")
        {
            DataTable dt = JpArticle.GetArticleByGUID(this.txtguid.Text);
            if (dt.Rows.Count > 0)
            {
                JpArticle.PubAll("," + dt.Rows[0]["aid"].ToString() + ",", this.txtpubtime.Text, this.txtendtime.Text);
            }
        }
        Response.Write("<script>alert('" + ls_tip + "');window.location='" + this.txturl.Value + "'</script>");
    }
Пример #2
0
    //全部复制
    protected void btnallfz_Click(object sender, EventArgs e)
    {
        TPortalClass.JpCommon JpCommon = new TPortalClass.JpCommon();
        TPortalClass.JpArticle JpArticle = new TPortalClass.JpArticle();
        string ls_tip = "全部复制成功!";

        TPortalClass.JpSite JpSite = new TPortalClass.JpSite();
        string ls_html = JpSite.fax;
        string ls_ids = "";
        //根据栏目ID得到该栏目下所有文章
        DataTable dt = JpArticle.GetArticlesByCid_fb(this.txtcid.Text);
        for (int i = 0; i < dt.Rows.Count; i++)
        {
            int id = (int)dt.Rows[i]["aid"];
            string ls_cids = this.txtcheckcid.Text;
            string[] lv_cids = ls_cids.Split('+');
            for (int j = 0; j < lv_cids.Length; j++)
            {
                if (lv_cids[j] != "")
                {
                    JpArticle.cid = lv_cids[j];
                    JpArticle.title = dt.Rows[i]["title"].ToString();
                    JpArticle.subhead = dt.Rows[i]["subhead"].ToString();
                    JpArticle.ht_content = dt.Rows[i]["ht_content"].ToString();
                    JpArticle.summary = dt.Rows[i]["summary"].ToString();
                    JpArticle.author = dt.Rows[i]["author"].ToString();
                    JpArticle.status = dt.Rows[i]["status"].ToString();
                    JpArticle.indexdisplaypicpath = dt.Rows[i]["indexdisplaypicpath"].ToString();
                    JpArticle.seotitle = dt.Rows[i]["seotitle"].ToString();
                    JpArticle.seokeywords = dt.Rows[i]["seokeywords"].ToString();
                    JpArticle.seodescription = dt.Rows[i]["seodescription"].ToString();
                    JpArticle.asort = (int)dt.Rows[i]["asort"];
                    JpArticle.iftop = dt.Rows[i]["iftop"].ToString();
                    JpArticle.topendtime = dt.Rows[i]["topendtime"].ToString();
                    JpArticle.ifindexdisplay = dt.Rows[i]["ifindexdisplay"].ToString();
                    JpArticle.ifcomment = dt.Rows[i]["ifcomment"].ToString();
                    JpArticle.source = dt.Rows[i]["source"].ToString();
                    JpArticle.role_userid = dt.Rows[i]["role_userid"].ToString();
                    JpArticle.role_username = dt.Rows[i]["role_username"].ToString();
                    JpArticle.input = dt.Rows[i]["input"].ToString();
                    JpArticle.GUID = System.Guid.NewGuid().ToString();
                    JpArticle.map_cid = dt.Rows[i]["map_cid"].ToString();
                    JpArticle.map_aid = (int)dt.Rows[i]["map_aid"];
                    JpArticle.targettype = dt.Rows[i]["targettype"].ToString();
                    JpArticle.endtime = dt.Rows[i]["endtime"].ToString();
                    JpArticle.pubtime = dt.Rows[i]["pubtime"].ToString();
                    int ls_newaid = JpArticle.Insert();
                    if (ls_ids == "")
                    {
                        ls_ids = ls_newaid.ToString();
                    }
                    else
                    {
                        ls_ids = ls_ids + "," + ls_newaid.ToString();
                    }
                }

            }
        }
        string pageUrl = "";

        pageUrl = JpCommon.CombUrlTxt("list_article_fb.aspx", "page={0}&rnd={1}&cid={2}",
            "" + this.txtPage.Text + "", "" + System.Guid.NewGuid().ToString() + "", "" + this.txtcid.Text + "");

        if (ls_ids != "")
        {
            //静态发布时使用
            string ls_pubtime = System.DateTime.Now.ToString();
            string ls_endtime = System.DateTime.Now.AddYears(10).ToString();
            if (ls_html == "开启")
            {
                JpArticle.PubAll("," + ls_ids + ",", ls_pubtime, ls_endtime);
            }
            //写系统日志
            string userip = Request.ServerVariables["HTTP_X_FORWARDED_FOR"];
            if (userip == null || userip == "")
            {
                userip = Request.ServerVariables["REMOTE_ADDR"];
            }
            JpCommon.WriteLog(userip, "全部复制", "全部复制文章栏目ID:" + this.txtcid.Text, Session["uid"].ToString(), Session["uname"].ToString());
        }
        else
        {
            ls_tip = "全部复制失败!请选中复制源栏目和选择目标栏目。";
        }
        Response.Write("<script>alert('" + ls_tip + "');window.location='" + pageUrl + "';</script>");
    }
Пример #3
0
    //采集
    private bool GetTest(int testType)
    {
        string Pic = "/upload/images_collects/";
        System.Text.Encoding enType = System.Text.Encoding.Default;
        switch (WebEncode)
        {
            case "1":
                enType = System.Text.Encoding.GetEncoding("gb2312");
                break;
            case "2":
                enType = System.Text.Encoding.UTF8;
                break;
            case "3":
                enType = System.Text.Encoding.Unicode;
                break;
        }

        TPortalClass.Collection Cn = new TPortalClass.Collection();

        string testList = Cn.GetHttpPageCode(ListUrl, enType);
        if (testList == "$UrlIsFalse")
        {
            Response.Write("<script>alert('列表地址设置错误');window.location='list_collect.aspx?action=list&id=" + this.txtId.Text + "'</script");
            return false;
        }
        if (testList == "$GetFalse")
        {
            Response.Write("<script>alert('无法连接列表页或连接超时');window.location='list_collect.aspx?action=list&id=" + this.txtId.Text + "'</script");
            return false;
        }
        testList = Cn.GetBody(testList, ListStart, ListEnd, true, true);
        if (testList == "$StartFalse")
        {
            Response.Write("<script>alert('列表开始标记设置错误,请重新设置');window.location='list_collect.aspx?action=list&id=" + this.txtId.Text + "'</script");
            return false;
        }
        if (testList == "$EndFalse")
        {
            Response.Write("<script>alert('列表结束记设置错误,请重新设置');window.location='list_collect.aspx?action=list&id=" + this.txtId.Text + "'</script");
            return false;
        }
        if (testType == 0)
        {
            this.ltListTest.Text = testList;
        }
        else
        {
            ArrayList linkArray = Cn.GetLinkArray(testList, LinkStart, LinkEnd);
            if (linkArray.Count == 0)
            {
                Response.Write("<script>alert('未取到链接,请检查链接设置');window.location='list_collect.aspx?action=link&id=" + this.txtId.Text + "'</script");
                return false;
            }
            else
            {
                if (linkArray[0].ToString() == "$StartFalse")
                {
                    Response.Write("<script>alert('链接开始标记设置错误,请重新设置111');window.location='list_collect.aspx?action=link&id=" + this.txtId.Text + "'</script");
                    return false;
                }
                if (linkArray[0].ToString() == "$EndFalse")
                {
                    Response.Write("<script>alert('链接开始标记设置错误,请重新设置');window.location='list_collect.aspx?action=link&id=" + this.txtId.Text + "'</script");
                    return false;
                }
                if (linkArray[0].ToString() == "$NoneLink")
                {
                    Response.Write("<script>alert('未取到链接,请检查链接设置222');window.location='list_collect.aspx?action=link&id=" + this.txtId.Text + "'</script");
                    return false;
                }
                if (IsDesc == 1)
                {
                    linkArray.Reverse();
                }
                if (CollecNum > 0 && linkArray.Count > CollecNum)
                {
                    linkArray.RemoveRange(CollecNum, linkArray.Count - CollecNum);
                }
                string linkStr = string.Empty;

                if (testType == 1)//链接地址
                {
                    for (int i = 0; i < linkArray.Count; i++)
                    {
                        linkStr = Cn.DefiniteUrl(linkArray[i].ToString(), WebUrl);
                        if (linkStr != "$False")
                        {
                            linkStr = "<a href='" + linkStr + "' target=_blank>" + linkStr + "</a><br>";
                            ltLinkTest.Text += linkStr;
                        }
                    }
                }

                if (testType == 2)//测试
                {
                    linkStr = Cn.DefiniteUrl(linkArray[0].ToString(), WebUrl);
                    if (linkStr == "$False")
                    {
                        Response.Write("<script>alert('获取到的链接地址无效,请检查链接设置');window.location='list_collect.aspx?action=link&id=" + this.txtId.Text + "'</script");
                        return false;
                    }
                    string newsCode = Cn.GetHttpPageCode(linkStr, enType);
                    if (newsCode == "$UrlIsFalse")
                    {
                        Response.Write("<script>alert('获取到的链接地址无效,请检查链接设置');window.location='list_collect.aspx?action=link&id=" + this.txtId.Text + "'</script");
                        return false;
                    }
                    if (newsCode == "$GetFalse")
                    {
                        Response.Write("<script>alert('无法连接内容页或连接超时');window.location='list_collect.aspx?action=content&id=" + this.txtId.Text + "'</script");
                        return false;
                    }
                    string testTitle = Cn.GetBody(newsCode, TitleStart, TitleEnd, false, false);
                    string testKeyWord = Cn.GetBody(newsCode, KeyWordStart, KeyWordEnd, false, false);
                    string testDateTime = Cn.GetBody(newsCode, DateStart, DateEnd, false, false);
                    string testSource = Cn.GetBody(newsCode, SourceStart, SourceEnd, false, false);
                    //string testDateTime = Cn.GetRegValue(DateRegex, newsCode);
                    //string testSource = Cn.GetRegValue(SourceRegex, newsCode);
                    string testBody = Cn.GetBody(newsCode, ContentStart, ContentEnd, false, false);
                    if (testTitle == "$StartFalse")
                    {
                        Response.Write("<script>alert('标题开始标记设置错误,请重新设置');window.location='list_collect.aspx?action=content&id=" + this.txtId.Text + "'</script");
                        return false;
                    }
                    if (testTitle == "$EndFalse")
                    {
                        Response.Write("<script>alert('标题结束标记设置错误,请重新设置');window.location='list_collect.aspx?action=content&id=" + this.txtId.Text + "'</script");
                        return false;
                    }
                    if (testBody == "$StartFalse")
                    {
                        Response.Write("<script>alert('正文开始标记设置错误,请重新设置');window.location='list_collect.aspx?action=content&id=" + this.txtId.Text + "'</script");
                        return false;
                    }
                    if (testBody == "$EndFalse")
                    {
                        Response.Write("<script>alert('正文结束标记设置错误,请重新设置');window.location='list_collect.aspx?action=content&id=" + this.txtId.Text + "'</script");
                        return false;
                    }
                    if (RemoveTitle != "")
                    {
                        testTitle = testTitle.Replace(RemoveTitle, "");
                    }
                    this.ltTestTitle.Text = testTitle;
                    this.ltKeyWord.Text = testKeyWord;
                    this.ltDateTime.Text = testDateTime;
                    this.ltSource.Text = testSource;

                    //------------------获取详细页内容的下一页开始-------------------
                    string NewsNextUrl = Cn.GetRegValue(NextPageRegex, newsCode);
                    int PageCount = 0;
                    while (NewsNextUrl.Length > 0 && PageCount < 20)
                    {
                        string NewsPaingNextCode = string.Empty;
                        string ContentTemp = string.Empty;
                        NewsNextUrl = Cn.DefiniteUrl(NewsNextUrl, WebUrl);
                        NewsPaingNextCode = Cn.GetHttpPageCode(NewsNextUrl, enType);
                        ContentTemp = Cn.GetBody(NewsPaingNextCode, ContentStart, ContentEnd, false, false);
                        testBody = testBody + "<br>$PageNext$<br>" + ContentTemp;
                        string NewsNextUrl_1 = Cn.GetRegValue(NextPageRegex, NewsPaingNextCode);
                        if (NewsNextUrl_1.Length > 0)
                            NewsNextUrl = Cn.DefiniteUrl(NewsNextUrl_1, WebUrl);
                        else
                            break;
                        PageCount++;
                    }
                    //-----------------------获取详细页内容的下一页结束-------------------

                    //-------过滤正文开始-----------------------
                    if (RemoveBodyStart != "" && RemoveBodyEnd != "")
                    {
                        string[] removeBodyStartArr = RemoveBodyStart.Split('$');
                        string[] removeBodyEndArr = RemoveBodyEnd.Split('$');
                        if (removeBodyStartArr.Length > 1 && removeBodyEndArr.Length > 1)
                        {
                            if (removeBodyStartArr.Length != removeBodyEndArr.Length)
                            {
                                Response.Write("<script>alert('少了$请注意');window.location='list_collect.aspx'</script");
                                return false;
                            }
                            else
                            {
                                for (int i = 0; i < removeBodyStartArr.Length; i++)
                                {
                                    string remove = Cn.GetBody(testBody, removeBodyStartArr[i], removeBodyEndArr[i], true, true);
                                    testBody = testBody.Replace(remove, "");
                                }
                            }
                        }
                        else
                        {
                            string remove = Cn.GetBody(testBody, RemoveBodyStart, RemoveBodyEnd, true, true);
                            testBody = testBody.Replace(remove, "");
                        }
                    }
                    //--------------过滤正文结束---------------------------

                    ArrayList testBodyArray = Cn.ReplaceSaveRemoteFile(testBody, Pic, WebUrl, "0");

                    ltTestContent.Text = testBodyArray[0].ToString();
                    if (testBodyArray.Count == 2)
                    {
                        ltPhotoUrl.Text = testBodyArray[1].ToString();
                    }
                }

                if (testType == 3)//采集
                {
                    int falseNum = 0;
                    int successNum = 0;
                    SetProcessBar("从" + WebUrl + "采集信息", true);
                    for (int i = 0; i < linkArray.Count; i++)
                    {
                        int isImg = 0;
                        string photoUrl = string.Empty;
                        ProcessBar(i, linkArray.Count);
                        linkStr = Cn.DefiniteUrl(linkArray[i].ToString(), WebUrl);
                        if (linkStr == "$False$")
                        {
                            falseNum++;
                            continue;
                        }
                        string newsPageCode = Cn.GetHttpPageCode(linkStr, enType);
                        if (newsPageCode == "$UrlIsFalse" || newsPageCode == "$GetFalse")
                        {
                            falseNum++;
                            continue;
                        }
                        string cTitle = Cn.GetBody(newsPageCode, TitleStart, TitleEnd, false, false);
                        string cKeyWord = Cn.GetBody(newsPageCode, KeyWordStart, KeyWordEnd, false, false);
                        string cDateTime = Cn.GetBody(newsPageCode, DateStart, DateEnd, false, false);
                        string cSource = Cn.GetBody(newsPageCode, SourceStart, SourceEnd, false, false);
                        //string cDateTime = Cn.GetRegValue(DateRegex, newsPageCode);
                        //string cSource = Cn.GetRegValue(SourceRegex, newsPageCode);
                        string cBody = Cn.GetBody(newsPageCode, ContentStart, ContentEnd, false, false);
                        if (cTitle == "$StartFalse" || cBody == "$StartFalse" || cTitle == "$EndFalse" || cBody == "$EndFalse")
                        {
                            falseNum++;
                            continue;
                        }

                        //--------获取详细页内容的下一页开始---------------
                        string NewsNextUrl = Cn.GetRegValue(NextPageRegex, newsPageCode);
                        int PageCount = 0;
                        while (NewsNextUrl.Length > 0 && PageCount < 20)
                        {
                            string NewsPaingNextCode = string.Empty;
                            string ContentTemp = string.Empty;
                            NewsNextUrl = Cn.DefiniteUrl(NewsNextUrl, WebUrl);
                            NewsPaingNextCode = Cn.GetHttpPageCode(NewsNextUrl, enType);
                            ContentTemp = Cn.GetBody(NewsPaingNextCode, ContentStart, ContentEnd, false, false);
                            cBody = cBody + "<br>$PageNext$<br>" + ContentTemp;
                            string NewsNextUrl_1 = Cn.GetRegValue(NextPageRegex, NewsPaingNextCode);
                            if (NewsNextUrl_1.Length > 0)
                                NewsNextUrl = Cn.DefiniteUrl(NewsNextUrl_1, WebUrl);
                            else
                                break;
                            PageCount++;
                        }
                        //---------获取详细页内容的下一页结束--------------
                        //string url_ss = dt.Rows[0]["ListUrl"].ToString();
                        string dq_url = "/"+ListUrl.Substring(20,4);
                        string ls_newurl = WebUrl + dq_url;
                        Response.Write(dq_url + "||");

                        ArrayList bodyArray = Cn.ReplaceSaveRemoteFile(cBody, Pic, ls_newurl, IsSaveImg.ToString());
                        if (bodyArray.Count == 2)
                        {
                            isImg = 1;
                            photoUrl = bodyArray[1].ToString();
                        }
                        cBody = bodyArray[0].ToString();

                        cBody = cBody.Replace("'", "");

                        //-------过滤正文开始-----------------------
                        if (RemoveBodyStart != "" && RemoveBodyEnd != "")
                        {
                            string[] removeBodyStartArr = RemoveBodyStart.Split('$');
                            string[] removeBodyEndArr = RemoveBodyEnd.Split('$');
                            if (removeBodyStartArr.Length > 1 && removeBodyEndArr.Length > 1)
                            {
                                for (int j = 0; j < removeBodyStartArr.Length; j++)
                                {
                                    string remove = Cn.GetBody(cBody, removeBodyStartArr[j], removeBodyEndArr[j], true, true);
                                    cBody = cBody.Replace(remove, "");
                                }
                            }
                            else
                            {
                                string remove = Cn.GetBody(cBody, RemoveBodyStart, RemoveBodyEnd, true, true);
                                cBody = cBody.Replace(remove, "");
                            }
                        }
                        //--------------过滤正文结束---------------------------

                        //---------------过滤开始-----------IFRAME---------
                        if (Script_Iframe == 1)
                            cBody = Cn.ScriptHtml(cBody, "Iframe", 2);
                        if (Script_Object == 1)
                            cBody = Cn.ScriptHtml(cBody, "Object", 2);
                        if (Script_Script == 1)
                            cBody = Cn.ScriptHtml(cBody, "Script", 2);
                        if (Script_Div == 1)
                            cBody = Cn.ScriptHtml(cBody, "Div", 3);
                        if (Script_Table == 1)
                            cBody = Cn.ScriptHtml(cBody, "Table", 2);
                        if (Script_Span == 1)
                            cBody = Cn.ScriptHtml(cBody, "Span", 3);
                        if (Script_Img == 1)
                            cBody = Cn.ScriptHtml(cBody, "Img", 3);
                        if (Script_Font == 1)
                            cBody = Cn.ScriptHtml(cBody, "Font", 3);
                        if (Script_A == 1)
                            cBody = Cn.ScriptHtml(cBody, "A", 3);
                        if (Script_Html == 1)
                            cBody = Cn.HtmlScript(cBody);
                        //-------------------过滤结束-------------------------------
                        //采集的数据保存至JpArticle

                        //关键字
                        string ls_str = cKeyWord.Trim();
                        string ls_date = System.DateTime.Now.ToString();
                        string ls_ly = "本网站";
                        if (cDateTime != "")
                        {
                            ls_date = cDateTime;
                        }
                        //if (cSource != "")
                        //{
                        //    ls_ly = cSource;
                        //}
                        if (RemoveTitle != "")
                        {
                            cTitle = cTitle.Replace(RemoveTitle, "");
                        }

                        Int32 ld_aid = -1;
                        TPortalClass.JpArticle art = new TPortalClass.JpArticle(ld_aid);
                        art.cid = ClassId.ToString();  //栏目
                        art.title = cTitle;  //标题
                        art.subhead = "";    //小标题
                        art.ht_content = cBody;  //正文
                        art.summary = "";      //摘要
                        art.author = "系统管理员";
                        art.status = "发布";
                        art.crtime = ls_date;
                        art.modtime = ls_date;
                        art.pubtime = ls_date;
                        art.endtime = System.DateTime.Now.AddYears(20).ToString();
                        art.hits = 1;     //点击率
                        art.ifindexdisplay ="0";   //是否首页显示
                        art.indexdisplaypicpath = "0";//首页显示图片上传路径

                        art.seotitle = "";
                        art.seokeywords = "";
                        art.seodescription = "";

                        art.asort = 50 + successNum;    //排序号
                        art.iftop = "0";   //是否置顶
                        art.topcreatetime = ls_date;   //置顶时间
                        art.topendtime = ls_date;      //置顶结束时间
                        art.ifcomment = "0";    //是否启用评论
                        art.source = ls_ly;        //来源
                        art.role_userid = "";
                        art.role_username = "";
                        art.shtml_created = 0;  //是否已生成静态页面
                        art.GUID = System.Guid.NewGuid().ToString();  //随机数
                        art.map_aid = 0;
                        art.input = "admin";
                        art.targettype = "";
                        //art.hasimg = 0;
                        //art.set("artcontent", cBody);
                        //是否包含图片
                        //String artcontent = "";
                        //artcontent =
                        //String imgsrc = TPortalClass.JpRegx.parseIMG(artcontent);

                        //if (imgsrc.ToLower().IndexOf("<img") >= 0)
                        //    art.hasimg = 1;
                        //else
                        //    art.hasimg = 0;

                        art.Insert();

                        successNum++;

                    }
                    Response.Write("<script>alert('采集完成,成功 " + successNum + "条 ,失败 " + falseNum + "');window.location='list_collect.aspx'</script");
                }
            }
        }
        return true;
    }
Пример #4
0
    //批量复制
    protected void btnplfz_Click(object sender, EventArgs e)
    {
        TPortalClass.JpCommon JpCommon = new TPortalClass.JpCommon();
        TPortalClass.JpArticle JpArticle = new TPortalClass.JpArticle();
        string ls_tip = "批量复制成功!";

        TPortalClass.JpSite JpSite = new TPortalClass.JpSite();
        string ls_html = JpSite.fax;
        string ls_ids = "";
        for (int i = 0; i < rptList.Items.Count; i++)
        {
            int id = Convert.ToInt32(((HiddenField)rptList.Items[i].FindControl("hidId")).Value);
            if (ls_ids == "")
            {
                ls_ids = id.ToString();
            }
            else
            {
                ls_ids = ls_ids + "," + id.ToString();
            }
            //string id = ((HiddenField)rptList.Items[i].FindControl("hidId")).Value;
            CheckBox cb = (CheckBox)rptList.Items[i].FindControl("chkId");
            if (cb.Checked)
            {
                TPortalClass.JpArticle article = new TPortalClass.JpArticle(id);
                string ls_cids = this.txtcheckcid.Text;
                string[] lv_cids = ls_cids.Split('+');
                for (int j = 0; j < lv_cids.Length; j++)
                {
                    if (lv_cids[j] != "")
                    {
                        JpArticle.cid = lv_cids[j];
                        JpArticle.title = article.title;
                        JpArticle.subhead = article.subhead;
                        JpArticle.ht_content = article.ht_content;
                        JpArticle.summary = article.summary;
                        JpArticle.author = article.author;
                        JpArticle.status = article.status;
                        JpArticle.indexdisplaypicpath = article.indexdisplaypicpath;
                        JpArticle.seotitle = article.seotitle;
                        JpArticle.seokeywords = article.seokeywords;
                        JpArticle.seodescription = article.seodescription;
                        JpArticle.asort = article.asort;
                        JpArticle.iftop = article.iftop;
                        JpArticle.topendtime = article.topendtime;
                        JpArticle.ifindexdisplay = article.ifindexdisplay;
                        JpArticle.ifcomment = article.ifcomment;
                        JpArticle.source = article.source;
                        JpArticle.role_userid = article.role_userid;
                        JpArticle.role_username = article.role_username;
                        JpArticle.input = article.input;
                        JpArticle.GUID = System.Guid.NewGuid().ToString();
                        JpArticle.map_cid = article.map_cid;
                        JpArticle.map_aid = article.map_aid;
                        JpArticle.targettype = article.targettype;
                        JpArticle.endtime = article.endtime;
                        JpArticle.pubtime = article.pubtime;
                        int ls_newaid = JpArticle.Insert();
                        if (ls_ids == "")
                        {
                            ls_ids = ls_newaid.ToString();
                        }
                        else
                        {
                            ls_ids = ls_ids + "," + ls_newaid.ToString();
                        }
                    }
                }
            }
        }
        string pageUrl = "";

        pageUrl = JpCommon.CombUrlTxt("list_article_fb.aspx", "page={0}&rnd={1}&cid={2}",
            "" + this.txtPage.Text + "", "" + System.Guid.NewGuid().ToString() + "", "" + this.txtcid.Text + "");

        if (ls_ids != "")
        {
            //静态发布时使用
            string ls_pubtime = System.DateTime.Now.ToString();
            string ls_endtime = System.DateTime.Now.AddYears(10).ToString();
            if (ls_html == "开启")
            {
                JpArticle.PubAll("," + ls_ids + ",", ls_pubtime, ls_endtime);
            }
            //写系统日志
            string userip = Request.ServerVariables["HTTP_X_FORWARDED_FOR"];
            if (userip == null || userip == "")
            {
                userip = Request.ServerVariables["REMOTE_ADDR"];
            }
            JpCommon.WriteLog(userip, "复制", "批量复制文章ID:" + ls_ids, Session["uid"].ToString(), Session["uname"].ToString());
        }
        else
        {
            ls_tip = "批量复制失败!请选中复制源文章和选择目标栏目。";
        }
        Response.Write("<script>alert('" + ls_tip + "');window.location='" + pageUrl + "';</script>");
    }
Пример #5
0
    //保存
    protected void btnSave_Click(object sender, EventArgs e)
    {
        if (this.Session["uid"].ToString() == "")
            this.Response.Redirect("../login.aspx");

        string ls_tip = "保存成功!";

        //新文档时
        TPortalClass.JpArticle JpArticle = new TPortalClass.JpArticle();
        TPortalClass.JpCommon JpCommon = new TPortalClass.JpCommon();

        JpArticle.cid = this.ddlcolname.SelectedValue;
        JpArticle.title = this.txttitle.Text;
        JpArticle.subhead = this.txttitle2.Text;
        JpArticle.ht_content = this.content1.Value;
        if (this.txtsummary.Text == "")
        {
            JpArticle.summary = JpCommon.OutPicGetStr(this.content1.Value, 150);
        }
        else
        {
            JpArticle.summary = this.txtsummary.Text;
        }
        JpArticle.author = this.Session["uname"].ToString();

        if (this.txtstatus.Text == "")
        {
            JpArticle.status = "编辑";
        }
        else
        {
            JpArticle.status = this.txtstatus.Text;
        }
        //JpArticle.ifindexdisplay = "";
        string lsfilename = FileUpload1.FileName;
        string lspath = "", lsurl = "", lsurl2 = "", str_path = "", str_path2 = "";
        if (lsfilename != "")  //attsize
        {
            lsfilename = this.txtguid.Text + "_" + lsfilename;
            //SaveCommon(ls_path, ls_attsize, lsguid);
            //将附件上传到服务器目录下
            lspath = Server.MapPath("~/");  //虚拟目录的位置
            lsurl = "/upload/indexpic_yt";  //原图存放的文件夹
            lsurl2 = "/upload/indexpic";    //缩略图存放的文件夹
            Directory.CreateDirectory(lspath + "/" + lsurl);
            Directory.CreateDirectory(lspath + "/" + lsurl2);
            str_path = lspath + "/" + lsurl + "/" + lsfilename;
            str_path2 = lspath + "/" + lsurl2 + "/" + lsfilename;
            FileUpload1.SaveAs(str_path);
            //压缩图片处理
            MakeThumbnail(str_path, str_path2, 600, 600, "HW");
            JpArticle.indexdisplaypicpath = lsurl2 + "/" + lsfilename;
        }
        else
        {
            this.txtpic.Value = JpCommon.GetImg(this.content1.Value);
            JpArticle.indexdisplaypicpath = this.txtpic.Value;
        }

        if (this.txtseotitle.Text == "")
        {
            JpArticle.seotitle = this.txttitle.Text;
        }
        else
        {
            JpArticle.seotitle = this.txtseotitle.Text;
        }
        if (this.txtseokeywords.Text == "")
        {
            JpArticle.seokeywords = this.txttitle.Text;
        }
        else
        {
            JpArticle.seokeywords = this.txtseokeywords.Text;
        }
        if (this.txtseodescription.Text == "")
        {
            JpArticle.seodescription = JpCommon.OutPicGetStr(this.content1.Value, 150);
        }
        else
        {
            JpArticle.seodescription = this.txtseodescription.Text;
        }

        JpArticle.seodescription = this.txtseodescription.Text;
        JpArticle.asort = System.Int32.Parse(this.txtasort.Text);
        JpArticle.iftop = this.ddlsfzd.SelectedValue;
        JpArticle.topendtime = this.txttopendtime.Value;
        JpArticle.ifindexdisplay = this.ddlsfsyss.SelectedValue;
        JpArticle.ifcomment = "0";
        JpArticle.source = this.txtsource.Value;
        JpArticle.role_userid = this.txtrole_userid.Text;
        JpArticle.role_username = this.txtrole_username.Text;
        JpArticle.input = this.Session["uid"].ToString();
        JpArticle.GUID = this.txtguid.Text;
        if (ddllb.SelectedValue != "请选择")
        {
            JpArticle.map_cid = ddllb.SelectedValue;
        }
        else
        {
            JpArticle.map_cid = "";
        }

        JpArticle.map_aid = 0;
        JpArticle.targettype = "";
        JpArticle.hits = System.Int32.Parse(this.txthits.Text);
        JpArticle.goodnum = System.Int32.Parse(this.txtgoodnum.Text);

        if (txtcid_url.Text.Substring(0, 3) == "003" && txtcid_url.Text != "003004")
        {
            if (radlist.SelectedValue == "否")
            {
                JpArticle.sfzwd = radlist.SelectedValue;
                JpArticle.zwdid = ddlwz.SelectedValue;
            }
            else
            {
                JpArticle.sfzwd = radlist.SelectedValue;
                JpArticle.zwdid = "";
            }
        }
        else
        {
            JpArticle.sfzwd = "否";
            JpArticle.zwdid = "";
        }

        if (this.txtendtime.Text != "")
        {
            JpArticle.endtime = this.txtendtime.Text;
        }
        else
        {
            JpArticle.endtime = System.DateTime.Now.AddYears(10).ToString();
        }
        if (this.txtpubtime.Text != "")
        {
            JpArticle.pubtime = this.txtpubtime.Text;
        }
        else
        {
            JpArticle.pubtime = System.DateTime.Now.ToString();
        }
        if (this.txtop.Value == "add")
        {
            //写系统日志
            string userip = Request.ServerVariables["HTTP_X_FORWARDED_FOR"];
            if (userip == null || userip == "")
            {
                userip = Request.ServerVariables["REMOTE_ADDR"];
            }
            JpCommon.WriteLog(userip, "新增", "新增文章记录[guid:" + this.txtguid.Text + "]", Session["uid"].ToString(), Session["uname"].ToString());

            JpArticle.Insert();
        }
        else
        {
            //写系统日志
            string userip = Request.ServerVariables["HTTP_X_FORWARDED_FOR"];
            if (userip == null || userip == "")
            {
                userip = Request.ServerVariables["REMOTE_ADDR"];
            }
            JpCommon.WriteLog(userip, "修改", "修改文章记录[id:" + this.txtguid.Text + "]", Session["uid"].ToString(), Session["uname"].ToString());
            JpArticle.aid = System.Int32.Parse(this.txtaid.Text);
            JpArticle.Update();
        }
        //变化了栏目ID,返回路径也要变掉
        if (this.ddlcolname.SelectedValue != this.txtcid_url.Text)
        {
            this.txturl.Value = this.txturl.Value.Replace(this.txtcid_url.Text, this.ddlcolname.SelectedValue);
        }
        Response.Write("<script>alert('" + ls_tip + "');window.location='" + this.txturl.Value + "'</script>");
    }