Ejemplo n.º 1
0
        public override object Do(PanelContext data)
        {
            string oid = data.Objects["oid"] as string;

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

            ChannelHelper chHelper = HelperFactory.GetHelper <ChannelHelper>();
            Channel       channel  = chHelper.GetChannel(oid, null);

            if (channel == null)
            {
                throw new Exception("当前栏目不存在");
            }
            if (channel.ModelName != data.ModelName)
            {
                throw new Exception("移动到的栏目类型与当前栏目类型不一致");
            }

            if (!string.IsNullOrEmpty(oid))
            {
                List <DataKey> dataKeys = data.State as List <DataKey>;
                foreach (DataKey key in dataKeys)
                {
                    string  id = key["ID"] as string;
                    Article a  = ArticleHelper.GetArticle(id);
                    if (a != null)
                    {
                        DataSet ds = BaseDataProvider.CreateDataSet(data.Model);
                        BaseDataProvider.ReadXml(ds, a.ModelXml);
                        if (ds.Tables[data.Table.Name].Rows.Count > 0)
                        {
                            DataRow row = ds.Tables[data.Table.Name].Rows[0];
                            a.OwnerID = oid;
                            if (row.Table.Columns.Contains("OwnerID"))
                            {
                                row["OwnerID"] = oid;
                            }
                            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.ModelXml = BaseDataProvider.GetXml(ds);
                        }
                    }
                    if (DbHelper.CheckTableExits(data.Table.Name))
                    {
                        DbHelper.ExecuteSql(String.Format("UPDATE [{0}] SET [OwnerID]='{2}' WHERE [ID]='{1}'", data.Table.Name, id, oid));
                    }
                    ArticleHelper.UpdateArticle(a, new string[] { "ID", "OwnerID", "ChannelFullUrl", "ChannelName", "FullChannelPath", "ModelXml" });
                    // 往全文检索里更新数据
                    ArticleIndexHelper.InsertData(id, 1);
                }
            }
            UIHelper.SendMessage("移动成功");
            CacheRecord.Create(data.ModelName).Release();
            return(null);
        }
Ejemplo n.º 2
0
        void SaveArticle()
        {
            try
            {
                if (CDHelper.Config.EnableLoginAuhenCode == "true" && this.ValidateTextBox.Text != Request.Cookies["AreYouHuman"].Value)
                {
                    Messages.ShowError("错误:您输入的验证码不正确,请重新输入!");
                    // Clear the input and create a new random code.
                    this.ValidateTextBox.Text             = "";
                    Response.Cookies["AreYouHuman"].Value = CaptchaImage.GenerateRandomCode();
                    return;
                }

                string ownerId = OwnerID;
                if (ownerId == null)
                {
                    ownerId = ChannelDropDownList.SelectedValue;
                }

                if (String.IsNullOrEmpty(ownerId))
                {
                    Messages.ShowError("文章栏目不能为空!");
                    return;
                }

                Article a = ThisArticle;
                a.Description = DescriptionTextBox.Value;
                a.Title       = TitleTextBox.Value;
                a.SubTitle    = SubTitleTextBox.Value;
                a.Color       = ddlColor.SelectedValue;
                a.FontStyle   = chkItalic.Checked ? "Italic" : "";
                a.FontWeight  = chkBold.Checked ? "Bold" : "";
                //a.ID = ArticleID;
                if (IndexTextBox.Value.Trim() == "")
                {
                    a.Index = 0;
                }
                else
                {
                    a.Index = Convert.ToInt32(IndexTextBox.Value);
                }
                a.Source        = SourceTextBox.Value;
                a.AllowComments = AllowCommentsCheckBox.Checked ? 1 : 0;
                //if (IsShowCheckBox.Checked)
                //{
                //    a.EnumState = StateMgr.StateInitialize();
                //    a.EnumState = StateMgr.StateProcess(a.EnumState, EnumLibrary.Business.HomeRecommend, 1);
                //}
                //a.IsShow = IsShowCheckBox.Checked ? 1 : 0;
                a.Author      = AuthorTextBox.Value;
                a.State       = Convert.ToInt32(StateDropDownList.SelectedValue);
                a.ContentType = Convert.ToInt32(ActicleTypeDropDownList.SelectedValue);
                //a.IsImage = (TypeOfArticle)a.ContentType == TypeOfArticle.QuoteArticle || (TypeOfArticle)a.ContentType == TypeOfArticle.ShareArticle ? 1 : 0;
                a.ContentUrl     = ContentUrlTextBox.Value;
                a.Content        = We7Helper.ConvertPageBreakFromVisualToChar(ContentTextBox.Value);
                a.KeyWord        = KeywordTextBox.Value;
                a.DescriptionKey = DescriptionKeyTextBox.Value;

                if (GeneralConfigs.GetConfig().AllowParentArticle&& !string.IsNullOrEmpty(ParentArticleID.Value))
                {
                    a.ParentID = ParentArticleID.Value;
                }
                else
                {
                    a.ParentID = We7Helper.EmptyGUID;
                }

                if (UpdatedTextBox.Value.Trim() == "")
                {
                    a.Updated = DateTime.Now;
                }
                else
                {
                    a.Updated = Convert.ToDateTime(UpdatedTextBox.Value);
                }
                if (txtInvalidDate.Value != "")
                {
                    a.Overdue = Convert.ToDateTime(txtInvalidDate.Value.Trim());
                }
                else
                {
                    GeneralConfigInfo si = GeneralConfigs.GetConfig();
                    int OverdueDateTime  = si.OverdueDateTime;
                    a.Overdue = a.Updated.AddDays(OverdueDateTime);
                }
                if (ArticleID == null)
                {
                    a.AccountID = AccountID;
                    a.OwnerID   = ownerId;
                    Channel ch = ChannelHelper.GetChannel(ownerId, null);
                    if (ch.FullUrl != null && ch.FullUrl != "")
                    {
                        a.ChannelFullUrl = ch.FullUrl;
                    }
                    if (ch.Process != null && ch.Process == "1")
                    {
                        a.State = 2;
                    }
                    //a.ChannelName = ch.ChannelName;
                    /*这儿把上面一句注了,改成了下面的。上面一句与老系统不兼容*/
                    a.ChannelName     = ch.Name;
                    a.FullChannelPath = ch.FullPath;
                    //int type = StateMgr.GetStateValue(ch.EnumState, EnumLibrary.Business.ChannelContentType);
                    //a.EnumState = StateMgr.StateProcess(a.EnumState, EnumLibrary.Business.ArticleType, type);
                    // a.State = 0;

                    //如果禁用
                    if (StateDropDownList.SelectedValue == "0")
                    {
                        a.state = 0;
                    }
                    Article article = ArticleHelper.AddArticles(a);
                    // 往全文检索里插入数据

                    ArticleIndexHelper.InsertData(article.ID, 0);

                    #region 自动提交一审(mxy2011-10-18)
                    if (ch.Process != null && ch.Process == "1" && StateDropDownList.SelectedValue != "0")
                    {
                        Processing ap = ArticleProcessHelper.GetArticleProcess(article);
                        if (ap.ArticleState != ArticleStates.Checking)
                        {
                            string accName = AccountHelper.GetAccount(AccountID, new string[] { "LastName" }).LastName;
                            ap.ProcessState     = ProcessStates.FirstAudit;
                            ap.ProcessDirection = ((int)ProcessAction.Next).ToString();
                            ap.ProcessAccountID = AccountID;
                            ap.ApproveName      = accName;
                            ArticleProcessHelper.SaveFlowInfoToDB(article, ap);
                        }
                    }
                    #endregion

                    //记录日志
                    string content = string.Format("新建文章:“{0}”", a.Title);
                    AddLog("新建文章", content);
                }
                else
                {
                    Channel  ch     = ChannelHelper.GetChannel(ownerId, null);
                    string[] fields = new string[] { "Description", "Title", "Content", "Updated", "Index", "Source", "AllowComments", "Author", "State", "IsShow", "IsImage", "SubTitle", "ContentUrl", "ContentType", "IsDeleted", "Overdue", "KeyWord", "DescriptionKey", "ParentID", "FullChannelPath", "ChannelFullUrl", "Color", "FontWeight", "FontStyle" };

                    ArticleHelper.UpdateArticle(a, fields);

                    // 往全文检索里更新数据
                    ArticleIndexHelper.InsertData(a.ID, 0);

                    if (ch.Process != null && ch.Process == "1" && StateDropDownList.SelectedValue != "0")
                    {
                        Processing ap = ArticleProcessHelper.GetArticleProcess(a);
                        if (ap.ArticleState != ArticleStates.Checking && ap.ProcessState != ProcessStates.EndAudit)
                        {
                            //编辑审核启用
                            if (ch.Process != null && ch.Process == "1" && StateDropDownList.SelectedValue != "0")
                            {
                                a.State = 2;
                                ArticleHelper.UpdateArticle(a, new string[] { "State" });
                            }

                            string accName = AccountHelper.GetAccount(AccountID, new string[] { "LastName" }).LastName;
                            ap.ProcessState     = ProcessStates.FirstAudit;
                            ap.ProcessDirection = ((int)ProcessAction.Next).ToString();
                            ap.ProcessAccountID = AccountID;
                            ap.ApproveName      = accName;
                            ArticleProcessHelper.SaveFlowInfoToDB(a, ap);
                        }
                    }
                    //记录日志
                    string content = string.Format("修改了文章“{0}”", a.Title);
                    AddLog("编辑文章", content);
                }

                string rawurl = We7Helper.RemoveParamFromUrl(Request.RawUrl, "saved");
                if (!String.IsNullOrEmpty(ArticleID))
                {
                    rawurl = We7Helper.AddParamToUrl(rawurl, "saved", "1");
                    rawurl = We7Helper.AddParamToUrl(rawurl, "Submit", "1");
                }
                else
                {
                    rawurl = We7Helper.RemoveParamFromUrl(Request.RawUrl, "oid");
                    rawurl = We7Helper.RemoveParamFromUrl(rawurl, "ParentID");
                    rawurl = We7Helper.AddParamToUrl(rawurl, "id", a.ID);
                    rawurl = We7Helper.AddParamToUrl(rawurl, "Submit", "0");
                }

                Response.Redirect(rawurl);
            }
            catch (FormatException)
            {
                Messages.ShowError("无法保存文章信息:可能是文章排序或修改日期格式不正确。");
                return;
            }
            catch (Exception ex)
            {
                Messages.ShowError("无法保存文章信息:" + ex.Message);
            }
        }
Ejemplo n.º 3
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);
        }
Ejemplo n.º 4
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);
        }
Ejemplo n.º 5
0
        public override bool Update(PanelContext data)
        {
            try
            {
                CheckModelData(data);

                Article article = ArticleHelper.GetArticle(GetValue <string>(data, "ID"));
                if (article == null)
                {
                    Insert(data);
                }
                else
                {
                    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.IsShow         = GetValue <int>(data, "IsShow");
                    article.Tags           = GetValue <string>(data, "Tags");
                    article.OwnerID        = GetValue <string>(data, "OwnerID");
                    article.PrivacyLevel   = GetValue <int>(data, "PrivacyLevel");
                    article.Source         = SiteConfigs.GetConfig().SiteName;
                    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");

                    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;
                        }
                    }
                    int type = 0;
                    article.EnumState = StateMgr.StateProcess(article.EnumState, EnumLibrary.Business.ArticleType, type);

                    article.Updated = DateTime.Now;

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

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

                    article.ModelName = data.Model.ModelName;
                    article.TableName = data.Table.Name;
                    string[] updatefields = new string[] { "OwnerID", "ChannelFullUrl", "ChannelName", "FullChannelPath", "Description", "Title", "Content", "ListKeys", "ListKeys2", "ListKeys3", "ListKeys4", "ListKeys5", "Updated", "Index", "EnumState", "Source", "AllowComments", "Author", "State", "IsShow", "SubTitle", "ContentUrl", "ContentType", "Overdue", "Tags", "KeyWord", "DescriptionKey", "ModelXml", "ModelName", "TableName", "ModelConfig", "ModelSchema" };
                    ArticleHelper.UpdateArticle(article, updatefields);

                    // 往全文检索里更新数据
                    ArticleIndexHelper.InsertData(article.ID, 1);
                }
            }
            catch { }

            return(true);
        }