예제 #1
0
        Article AddWapArticle()
        {
            Article sourceArticle = ArticleHelper.GetArticle(ArticleID, null);
            Article wap           = ArticleHelper.CopyToWapArticle(sourceArticle);

            wap.OwnerID   = WapOidTextBox.Text.Trim();
            wap.AccountID = AccountID;
            ArticleHelper.AddArticle(wap);
            return(wap);
        }
예제 #2
0
        void QuoteArticles(string id)
        {
            Article a = ArticleHelper.GetArticle(id, null);

            a.Content     = "";
            a.ContentType = (int)TypeOfArticle.LinkArticle;

            Channel ch = ChannelHelper.GetChannel(a.OwnerID, null);

            a.ContentUrl  = ch.FullUrl + a.FullUrl;
            a.OwnerID     = QuoteOwnerID;
            a.EnumState   = ch.EnumState;
            a.ChannelName = ch.FullPath;

            ArticleHelper.AddArticle(a);
        }
예제 #3
0
파일: Test.aspx.cs 프로젝트: jiaping/JPCMS
        //测试2
        protected override void OnLoad(EventArgs e)
        {
            ModelDBHelper helper = ModelDBHelper.Create("Subjects.Paper");
            List <Order>  os     = new List <Order>();

            os.Add(new Order("ID"));
            DataTable dt = helper.Query(new Criteria(CriteriaType.MoreThan, "Created", DateTime.MinValue), os, 0, 0);

            ArticleHelper ah = HelperFactory.Instance.GetHelper <ArticleHelper>();

            foreach (DataRow row in dt.Rows)
            {
                Article a = new Article();
                a.Icon    = row["ID"].ToString();
                a.OwnerID = row["OwnerID"].ToString();
                a.State   = 1;
                a.Title   = row["Title"].ToString();
                ah.AddArticle(a);
            }
        }
예제 #4
0
    protected void Button1_Click(object sender, EventArgs e)
    {
        //以用户输入构建Article对象
        Article ar;

        if (CheckBox1.Checked)
        {
            ar = new Article
            {
                Title      = tbTitle.Text,
                SubTitle   = tbSubTitle.Text,
                AuthorID   = ((User)Session["User"]).UserID,
                Author     = DropDownList3.SelectedValue == "我自己" ? UserHelper.RtnName(((User)Session["User"]).UserID) : DropDownList3.SelectedValue,
                Source     = DropDownList4.SelectedValue == "我自己" ? UserHelper.RtnName(((User)Session["User"]).UserID) : DropDownList4.SelectedValue,
                Link       = tbLink.Text,
                Type       = Label11.Visible ? Label11.Text : Request.QueryString["type"] + ":" + subTypes.SelectedValue,//例如:党建工作:党员发展
                OnTop      = cbTop.Checked,
                Hot        = cbHot.Checked,
                Attachment = cbAttach.Checked,
                UpdateTime = GetTime(tyear.Text, tmonth.Text, tday.Text) ?? DateTime.Now,
                Deleted    = false,
                Content    = "&nbsp;",
                ImgUrl     = null // HiddenField1.Value == "" ? null : HiddenField1.Value,CheckBox2.Checked?GetImgUrl(CKEditor1.Text):
            }
        }
        ;

        else
        {
            string saveContent = Server.HtmlDecode(myEditor11.InnerHtml);
            if (Label11.Text.Equals("学术报告:学术报告") || subTypes.SelectedValue.Equals("学术报告"))
            {
                saveContent = dplYear.SelectedValue + "-" + Convert.ToInt32(dplMonth.SelectedValue).ToString("D2") + "-" + Convert.ToInt32(dplDay.SelectedValue).ToString("D2") + "!" + dplHour.SelectedValue + ":" + dplMinute.SelectedValue + "!" + txtPlace.Text.Trim() + "#" + Server.HtmlDecode(myEditor11.InnerHtml);
            }
            ar = new Article
            {
                Title    = tbTitle.Text,
                SubTitle = tbSubTitle.Text,
                AuthorID = ((User)Session["User"]).UserID,
                Author   = DropDownList3.SelectedValue == "我自己" ? UserHelper.RtnName(((User)Session["User"]).UserID) : DropDownList3.SelectedValue,
                Source   = DropDownList4.SelectedValue == "我自己" ? UserHelper.RtnName(((User)Session["User"]).UserID) : DropDownList4.SelectedValue,

                Link       = null,
                Type       = Label11.Visible ? Label11.Text : Request.QueryString["type"] + ":" + subTypes.SelectedValue,//例如:党建工作:党员发展
                OnTop      = cbTop.Checked,
                Hot        = cbHot.Checked,
                Attachment = cbAttach.Checked,
                UpdateTime = GetTime(tyear.Text, tmonth.Text, tday.Text) ?? DateTime.Now,
                Deleted    = false,
                //Content = dplYear.SelectedValue + "-" + Convert.ToInt32(dplMonth.SelectedValue).ToString("D2") + "-" + Convert.ToInt32(dplDay.SelectedValue).ToString("D2") + "!" + dplHour.SelectedValue + ":" + dplMinute.SelectedValue + "!" + txtPlace.Text.Trim() + "#" + Server.HtmlDecode(myEditor11.InnerHtml),
                Content = saveContent,

                ImgUrl = CheckBox2.Checked ? GetImgUrl(Server.HtmlDecode(myEditor11.InnerHtml)) : null
            };
        }

        //增加是否官方的新闻
        if (dplNewsSource.Visible == true)
        {
            if (dplNewsSource.Text.Contains("学院官方"))
            {
                ar.isOfficial = true;
            }
            else
            {
                ar.isOfficial = false;
            }
        }

        // 判断是添加还是修改,修改数据库
        string Pattern = @"(http|https)://[^\s]*";
        Regex  r       = new Regex(Pattern);

        if (courseID == 0)
        {
            if (panelAcademic.Visible == true && string.Equals(string.Empty, txtPlace.Text.Trim()))
            {
                Response.Write(JSHelper.ShowAlert("请检查举办地点!"));
            }
            else if (tbTitle.Text.Trim() == "")
            {
                Response.Write(JSHelper.ShowAlert("标题不能为空!"));
            }
            else if (CheckBox1.Checked == true && tbLink.Text.Trim() == "")
            {
                Response.Write(JSHelper.ShowAlert("转向链接不能为空!"));
            }
            else if (CheckBox1.Checked == true && r.IsMatch(tbLink.Text.Trim()) == false)
            {
                Response.Write(JSHelper.ShowAlert("转向链接格式有误!"));
            }
            else if (CheckBox1.Checked == false && Server.HtmlDecode(myEditor11.InnerHtml).Length == 0)
            {
                Response.Write(JSHelper.ShowAlert("正文不能为空!"));
            }
            else if (ArticleHelper.AddArticle(ar))
            {
                if (ar.Type.Equals("就业工作:招聘信息"))
                {
                    CHelper.Cread(ar.ArticleID, ar.Title, ar.Type);
                }
                else
                {
                    Response.Write(JSHelper.ShowAlert("添加成功"));
                }
                JSHelper.Redirect("MyArticles.aspx", true);
            }
            else
            {
                Response.Write(JSHelper.ShowAlert("添加失败"));
            }
        }
        else
        {
            Article tem = ArticleHelper.GetArticleByID(courseID);
            ar.Hit       = tem.Hit;
            ar.ArticleID = courseID;
            //处理修改的时候type叠加
            ar.Type = ArticleHelper.GetArticleByID(courseID).Type;
            if (panelAcademic.Visible = true && string.Equals(string.Empty, txtPlace.Text.Trim()))
            {
                Response.Write(JSHelper.ShowAlert("请检举办地点!"));
            }
            else if (tbTitle.Text.Trim() == "")
            {
                Response.Write(JSHelper.ShowAlert("标题不能为空!"));
            }
            else if (CheckBox1.Checked == true && tbLink.Text.Trim() == "")
            {
                Response.Write(JSHelper.ShowAlert("转向链接不能为空!"));
            }
            else if (CheckBox1.Checked == true && r.IsMatch(tbLink.Text.Trim()) == false)
            {
                Response.Write(JSHelper.ShowAlert("转向链接格式有误!"));
            }
            else if (CheckBox1.Checked == false && Server.HtmlDecode(myEditor11.InnerHtml).Length == 0)
            {
                Response.Write(JSHelper.ShowAlert("正文不能为空!"));
            }
            else if (ArticleHelper.UpdateArticle(ar))
            {
                Response.Write(JSHelper.ShowAlert("修改成功"));
                JSHelper.Redirect("MyArticles.aspx", true);
            }
            else
            {
                Response.Write(JSHelper.ShowAlert("修改失败"));
            }
        }
    }
예제 #5
0
        public override object Do(PanelContext data)
        {
            string oid = data.Objects["oid"] as string;

            if (We7Helper.IsEmptyID(oid))
            {
                throw new Exception("不能添加到根栏目");
            }

            if (!string.IsNullOrEmpty(oid))
            {
                Channel targetChannel = HelperFactory.GetHelper <ChannelHelper>().GetChannel(oid, null);
                //if (targetChannel != null && !String.IsNullOrEmpty(targetChannel.ModelName))
                if (targetChannel != null)
                {
                    //ModelInfo modelInfo = ModelHelper.GetModelInfo(targetChannel.ModelName);
                    //We7DataTable dt = modelInfo.DataSet.Tables[0];

                    List <DataKey> dataKeys = data.State as List <DataKey>;
                    foreach (DataKey key in dataKeys)
                    {
                        string id = key["ID"] as string;

                        //SingleTableLinkTo(data, dt, id);

                        Article a = ArticleHelper.GetArticle(id);
                        if (a != null)
                        {
                            DataSet ds  = BaseDataProvider.CreateDataSet(data.Model);
                            DataRow row = ds.Tables[data.Table.Name].NewRow();
                            ds.Tables[data.Table.Name].Rows.Add(row);

                            a.OwnerID = oid;
                            if (row.Table.Columns.Contains("OwnerID"))
                            {
                                row["OwnerID"] = oid;
                            }
                            if (row.Table.Columns.Contains("Title"))
                            {
                                row["Title"] = a.Title;
                            }
                            if (row.Table.Columns.Contains("Description"))
                            {
                                row["Description"] = a.Description;
                            }
                            a.ContentType = (int)TypeOfArticle.LinkArticle;
                            if (row.Table.Columns.Contains("ContentType"))
                            {
                                row["ContentType"] = a.ContentType;
                            }
                            a.ContentUrl = GetContentUrl(a);
                            if (row.Table.Columns.Contains("ContentUrl"))
                            {
                                row["ContentUrl"] = a.ContentUrl;
                            }
                            a.Content = "";
                            if (row.Table.Columns.Contains("Content"))
                            {
                                row["Content"] = "";
                            }
                            a.SourceID = a.ID;
                            if (row.Table.Columns.Contains("SourceID"))
                            {
                                row["SourceID"] = a.ID;
                            }
                            a.Updated = DateTime.Now;
                            if (row.Table.Columns.Contains("Updated"))
                            {
                                row["Updated"] = a.Updated;
                            }

                            a.Created = DateTime.Now;
                            if (row.Table.Columns.Contains("Created"))
                            {
                                row["Created"] = a.Created;
                            }

                            a.Overdue = DateTime.Now.AddYears(2);
                            if (row.Table.Columns.Contains("Overdue"))
                            {
                                row["Overdue"] = a.Overdue;
                            }

                            Channel ch = ChannelHelper.GetChannel(oid, null);
                            if (ch != null)
                            {
                                a.ChannelFullUrl = ch.FullUrl;
                                if (row.Table.Columns.Contains("ChannelFullUrl"))
                                {
                                    row["ChannelFullUrl"] = a.ChannelFullUrl;
                                }
                                a.ChannelName = ch.FullPath;
                                if (row.Table.Columns.Contains("ChannelName"))
                                {
                                    row["ChannelName"] = a.ChannelName;
                                }
                                a.FullChannelPath = ch.FullFolderPath;
                                if (row.Table.Columns.Contains("FullChannelPath"))
                                {
                                    row["FullChannelPath"] = a.FullChannelPath;
                                }
                                a.State = ch.Process != null && ch.Process == "1" ? 2 : a.State;
                                if (row.Table.Columns.Contains("State"))
                                {
                                    row["State"] = a.State;
                                }
                            }
                            a.ID = We7Helper.CreateNewID();
                            if (row.Table.Columns.Contains("ID"))
                            {
                                row["ID"] = a.ID;
                            }
                            a.ModelXml = BaseDataProvider.GetXml(ds);
                            ArticleHelper.AddArticle(a);
                            // 往全文检索里更新数据
                            ArticleIndexHelper.InsertData(a.ID, 0);
                        }
                    }
                }
            }
            return(null);
        }
예제 #6
0
        public override bool Insert(PanelContext data)
        {
            CheckModelData(data);

            Article article = new Article();

            article.ID             = GetValue <string>(data, "ID");
            article.Title          = GetValue <string>(data, "Title");
            article.Description    = GetValue <string>(data, "Description");
            article.SubTitle       = GetValue <string>(data, "SubTitle");
            article.Index          = GetValue <int>(data, "Index");
            article.AllowComments  = GetValue <int>(data, "AllowComments");
            article.Author         = GetValue <string>(data, "Author");
            article.ContentType    = GetValue <int>(data, "ContentType");
            article.ContentUrl     = GetValue <string>(data, "ContentUrl");
            article.Content        = GetValue <string>(data, "Content");
            article.KeyWord        = GetValue <string>(data, "KeyWord");
            article.DescriptionKey = GetValue <string>(data, "DescriptionKey");
            article.Overdue        = GetValue <DateTime>(data, "Overdue");
            article.OwnerID        = GetValue <string>(data, "OwnerID");
            article.Tags           = GetValue <string>(data, "Tags");
            article.PrivacyLevel   = GetValue <int>(data, "PrivacyLevel");
            article.Source         = SiteConfigs.GetConfig().SiteName;
            article.Created        = DateTime.Now;
            article.Updated        = DateTime.Now;
            article.Thumbnail      = GetValue <string>(data, "Thumbnail");
            article.ListKeys       = GetValue <string>(data, "ListKeys");
            article.ListKeys2      = GetValue <string>(data, "ListKeys2");
            article.ListKeys3      = GetValue <string>(data, "ListKeys3");
            article.ListKeys4      = GetValue <string>(data, "ListKeys4");
            article.ListKeys5      = GetValue <string>(data, "ListKeys5");

            string config, schema;

            article.ModelXml    = GetModelDataXml(data, article.ModelXml, out schema, out config);//获取模型数据
            article.ModelConfig = config;
            article.ModelSchema = schema;

            if (article.ModelXml.Length >= MaxCount)
            {
                UIHelper.Message.AppendInfo(MessageType.ERROR, "输入内容过长,请重新输入");
                Logger.WriteLine();
                Logger.WriteDate();
                Logger.Write("输入内容过长");
                Logger.Write(article.ModelXml);
                return(false);
            }

            article.ModelName = data.Model.ModelName;
            article.TableName = data.Table.Name;
            article.State     = GetValue <int>(data, "State");

            if (!String.IsNullOrEmpty(article.OwnerID))
            {
                Channel ch = ChannelHelper.GetChannel(article.OwnerID, null);
                if (ch != null)
                {
                    article.ChannelFullUrl  = ch.FullUrl;
                    article.ChannelName     = ch.FullPath;
                    article.FullChannelPath = ch.FullPath;
                    article.State           = ch.Process != null && ch.Process == "1" ? 2 : article.State;
                }
            }
            int type = 0;

            article.EnumState = StateMgr.StateProcess(article.EnumState, EnumLibrary.Business.ArticleType, type);

            article.AccountID = GetValue <string>(data, "AccountID");
            if (String.IsNullOrEmpty(article.AccountID))
            {
                try
                {
                    article.AccountID = Security.CurrentAccountID;
                }
                catch { }
            }

            ArticleHelper.AddArticle(article);
            ArticleIndexHelper.InsertData(article.ID, 0);
            return(true);
        }