Beispiel #1
0
 protected string get_article_field(string call_index, string field_name)
 {
     if (string.IsNullOrEmpty(call_index))
     {
         return(string.Empty);
     }
     Rain.BLL.article article = new Rain.BLL.article();
     if (!article.Exists(call_index))
     {
         return(string.Empty);
     }
     Rain.Model.article model = article.GetModel(call_index);
     if (model != null && model.fields.ContainsKey(field_name))
     {
         return(model.fields[field_name]);
     }
     return(string.Empty);
 }
Beispiel #2
0
        private bool DoEdit(int _id)
        {
            bool flag = false;

            Rain.BLL.article   article = new Rain.BLL.article();
            Rain.Model.article model   = article.GetModel(_id);
            model.channel_id      = this.channel_id;
            model.category_id     = Utils.StrToInt(this.ddlCategoryId.SelectedValue, 0);
            model.call_index      = this.txtCallIndex.Text.Trim();
            model.title           = this.txtTitle.Text.Trim();
            model.link_url        = this.txtLinkUrl.Text.Trim();
            model.img_url         = this.txtImgUrl.Text;
            model.seo_title       = this.txtSeoTitle.Text.Trim();
            model.seo_keywords    = this.txtSeoKeywords.Text.Trim();
            model.seo_description = this.txtSeoDescription.Text.Trim();
            model.zhaiyao         = !string.IsNullOrEmpty(this.txtZhaiyao.Text.Trim()) ? Utils.DropHTML(this.txtZhaiyao.Text, (int)byte.MaxValue) : Utils.DropHTML(this.txtContent.Value, (int)byte.MaxValue);
            model.content         = this.txtContent.Value;
            model.sort_id         = Utils.StrToInt(this.txtSortId.Text.Trim(), 99);
            model.click           = int.Parse(this.txtClick.Text.Trim());
            model.status          = Utils.StrToInt(this.rblStatus.SelectedValue, 0);
            model.is_msg          = 0;
            model.is_top          = 0;
            model.is_red          = 0;
            model.is_hot          = 0;
            model.is_slide        = 0;
            if (this.cblItem.Items[0].Selected)
            {
                model.is_msg = 1;
            }
            if (this.cblItem.Items[1].Selected)
            {
                model.is_top = 1;
            }
            if (this.cblItem.Items[2].Selected)
            {
                model.is_red = 1;
            }
            if (this.cblItem.Items[3].Selected)
            {
                model.is_hot = 1;
            }
            if (this.cblItem.Items[4].Selected)
            {
                model.is_slide = 1;
            }
            model.add_time    = Utils.StrToDateTime(this.txtAddTime.Text.Trim());
            model.update_time = new DateTime?(DateTime.Now);
            model.fields      = this.SetFieldValues(this.channel_id);
            if (this.txtImgUrl.Text.Trim() == "")
            {
                model.img_url = this.hidFocusPhoto.Value;
            }
            if (model.albums != null)
            {
                model.albums.Clear();
            }
            string[] values1 = this.Request.Form.GetValues("hid_photo_name");
            string[] values2 = this.Request.Form.GetValues("hid_photo_remark");
            if (values1 != null)
            {
                List <article_albums> articleAlbumsList = new List <article_albums>();
                for (int index = 0; index < values1.Length; ++index)
                {
                    string[] strArray = values1[index].Split('|');
                    int      num      = Utils.StrToInt(strArray[0], 0);
                    if (strArray.Length == 3)
                    {
                        if (!string.IsNullOrEmpty(values2[index]))
                        {
                            articleAlbumsList.Add(new article_albums()
                            {
                                id            = num,
                                article_id    = _id,
                                original_path = strArray[1],
                                thumb_path    = strArray[2],
                                remark        = values2[index]
                            });
                        }
                        else
                        {
                            articleAlbumsList.Add(new article_albums()
                            {
                                id            = num,
                                article_id    = _id,
                                original_path = strArray[1],
                                thumb_path    = strArray[2]
                            });
                        }
                    }
                }
                model.albums = articleAlbumsList;
            }
            if (model.attach != null)
            {
                model.attach.Clear();
            }
            string[] values3 = this.Request.Form.GetValues("hid_attach_id");
            string[] values4 = this.Request.Form.GetValues("hid_attach_filename");
            string[] values5 = this.Request.Form.GetValues("hid_attach_filepath");
            string[] values6 = this.Request.Form.GetValues("hid_attach_filesize");
            string[] values7 = this.Request.Form.GetValues("txt_attach_point");
            if (values3 != null && values4 != null && (values5 != null && values6 != null) && (values7 != null && values3.Length > 0 && (values4.Length > 0 && values5.Length > 0)) && values6.Length > 0 && values7.Length > 0)
            {
                List <Rain.Model.article_attach> articleAttachList = new List <Rain.Model.article_attach>();
                for (int index = 0; index < values4.Length; ++index)
                {
                    int    num1    = Utils.StrToInt(values3[index], 0);
                    int    num2    = Utils.StrToInt(values6[index], 0);
                    string fileExt = Utils.GetFileExt(values5[index]);
                    int    num3    = Utils.StrToInt(values7[index], 0);
                    articleAttachList.Add(new Rain.Model.article_attach()
                    {
                        id         = num1,
                        article_id = _id,
                        file_name  = values4[index],
                        file_path  = values5[index],
                        file_size  = num2,
                        file_ext   = fileExt,
                        point      = num3
                    });
                }
                model.attach = articleAttachList;
            }
            List <user_group_price> userGroupPriceList = new List <user_group_price>();

            for (int index = 0; index < this.rptPrice.Items.Count; ++index)
            {
                int num1 = 0;
                if (!string.IsNullOrEmpty(((HiddenField)this.rptPrice.Items[index].FindControl("hidePriceId")).Value))
                {
                    num1 = Convert.ToInt32(((HiddenField)this.rptPrice.Items[index].FindControl("hidePriceId")).Value);
                }
                int     int32 = Convert.ToInt32(((HiddenField)this.rptPrice.Items[index].FindControl("hideGroupId")).Value);
                Decimal num2  = Convert.ToDecimal(((TextBox)this.rptPrice.Items[index].FindControl("txtGroupPrice")).Text.Trim());
                userGroupPriceList.Add(new user_group_price()
                {
                    id         = num1,
                    article_id = _id,
                    group_id   = int32,
                    price      = num2
                });
            }
            model.group_price = userGroupPriceList;
            if (article.Update(model))
            {
                this.AddAdminLog(DTEnums.ActionEnum.Edit.ToString(), "修改" + this.channel_name + "频道内容:" + model.title);
                flag = true;
            }
            return(flag);
        }