예제 #1
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                int itemId = Convert.ToInt32(Request.Params["id"]);

                if (itemId != 0)
                {
                    Model.Article item = DataHelper.GetOneArticle(itemId);

                    TextBoxDate.Text = item.WhenDate.ToString("dd.MM.yyyy");

                    TextBoxHead.Text = item.Head;

                    NewsText.Text = item.Text;

                    LabelAuthor.Text = DataHelper.GetUser(item.UserId).UserName;
                }
                else
                {
                    LabelAuthor.Text = User.UserName;

                    TextBoxDate.Text = DateTime.Now.ToString("dd.MM.yyyy");
                }
            }
        }
예제 #2
0
        protected void Page_Load(object sender, EventArgs e)
        {
            var articleService = unity.GetInstance <IArticleService>();

            int id = 0;

            try
            {
                id = Convert.ToInt32(Request.QueryString["id"]);
            }
            catch
            {
                Response.Redirect("/");
            }

            Model = articleService.GetArticle(id);



            if (Model == null)
            {
                Response.Redirect("/");
            }
            else
            {
                Model.Click += 1;
                articleService.Modify(Model);
            }

            //获取顶置文章
            var articles2 = articleService.GetList(new Model.Article.Query {
                Cate_Id = Model.Cate_Id, Is_Hot = 1, Status = 1
            }, 5);
        }
예제 #3
0
        public ActionResult GetJQGridJson(int rows, int page, string sidx, string sord, string queryJson = "")
        {
            Model.Article query = new Model.Article();
            if (!string.IsNullOrEmpty(queryJson))
            {
                query = Newtonsoft.Json.JsonConvert.DeserializeObject <Model.Article>(queryJson);
            }
            #region ==获得记录==
            l_article              = new List <Model.Article>();
            p                      = new Model.Pages();
            p.Page                 = page;
            p.Ps                   = rows;
            m                      = new Model.Article();
            m.s_Alive              = query.s_Alive;
            m.s_Hot                = s_hot;
            m.s_Recommend          = s_recommend;
            m.s_d1                 = d1;
            m.s_d2                 = d2;
            m.s_Keywords           = query.s_Keywords;
            m.s_Kind               = Kind.ToString();
            m.s_Asid               = Asid;
            m.s_Order              = sidx + " " + sord;
            m.s_Main_parameter     = "Aid,Atitle,Url,Source,Author,Alive,Kind,Layer,Ainfo,Atime,Pic1,Pic2,Summary,Hot,Recommend,Asid,ieTitle,seoKeywords,seoDescription";
            m.s_Extended_parameter = "Stitle";
            l_article              = Bll.Article.Select_List(m, ref p, ref Rc);
            #endregion

            return(Json(new { page = p.Page.ToString(), total = p.Pc, records = Rc.ToString(), rows = l_article }));
        }
예제 #4
0
파일: Article.cs 프로젝트: XiaoYaTech/Demo
        public Expose178.Com.Model.Article GetArticle(string strArticleID)
        {
            Expose178.Com.Model.Article art = new Model.Article();
            DataSet dsArticle = GetArticleByID(strArticleID);

            if (Gadget.DatatSetIsNotNullOrEmpty(dsArticle))
            {
                art.ArticleID        = strArticleID;
                art.ArticleTile      = Gadget.GetDataRowStringValue(dsArticle.Tables[0].Rows[0], "ArticleTile");
                art.ArticleDate      = Gadget.GetDataRowDateTimeValue(dsArticle.Tables[0].Rows[0], "ArticleDate");
                art.ArticleBody      = Gadget.GetDataRowStringValue(dsArticle.Tables[0].Rows[0], "ArticleBody");
                art.BackgroundImgUrl = Gadget.GetDataRowStringValue(dsArticle.Tables[0].Rows[0], "BackgroundImgUrl");
                art.IsDraft          = Gadget.GetDataRowBoolValue(dsArticle.Tables[0].Rows[0], "IsDraft");
                art.IsValidated      = Gadget.GetDataRowBoolValue(dsArticle.Tables[0].Rows[0], "IsValidated");
                art.LastUpdatedDate  = Gadget.GetDataRowDateTimeValue(dsArticle.Tables[0].Rows[0], "LastUpdatedDate");

                string       strUID = Gadget.GetDataRowStringValue(dsArticle.Tables[0].Rows[0], "UpdatedByUserID");
                string       strstrAritcleTypeCode = Gadget.GetDataRowStringValue(dsArticle.Tables[0].Rows[0], "AritcleTypeCode");
                string       strReadRoleTypeCode   = Gadget.GetDataRowStringValue(dsArticle.Tables[0].Rows[0], "ReadRoleTypeCode");
                ArticleReply reply = new ArticleReply();
                User         user  = new User();
                art.ListReply    = reply.GetListReplyToArticle(strArticleID);
                art.ReadRoleType = GetReadRoleType(strReadRoleTypeCode);
                art.User         = user.GetUserByUID(strUID);
                art.AritcleType  = GetAritcleType(strstrAritcleTypeCode);
            }
            return(art);
        }
예제 #5
0
        public void Post ([FromBody] ArticleData formdata) {

            Model.Article a = new Model.Article () {
                IsPublished = true,
                ImagePath = formdata.ImagePath,
                Aricledate = DateTime.Now
            };
            Model.ArticleLanguage ar_item = new Model.ArticleLanguage () {
                Body = "test core",
                LangName = "ar",
                Intro = "test core",
                Title = formdata.ArticleTitle,
                FkArticleId = 2
            };
            a.ArticleLanguage.Add (ar_item);
            try {
                _context.Add (a);
                // _context.Add (ar_item);
                _context.SaveChanges ();
            } catch (Exception ex) {
                throw ex;

            } finally {

            }

        } //end post method
 public int AddArticle(Model.Article article)
 {
     if (_roleService.AddArticlePower())
     {
         if (string.IsNullOrEmpty(article.Title))
         {
             throw new DomainException("Title", "文章标题不能为空!");
         }
         else if (string.IsNullOrEmpty(article.Content))
         {
             throw new DomainException("Content", "文章内容不能为空!");
         }
         else if (article.Categorys.Count == 0)
         {
             throw new DomainException("Category", "文章必须要有一个分类!");
         }
         article.Status = ArticleStatus.Open;
         article.Author = _userService.GetLoginUser();
         IList <Category> categorys = article.Categorys;
         article.Categorys = null;
         int id = _articleRepository.Add(article);
         article.Categorys = categorys;
         _articleRepository.Update(article);
         return(id);
     }
     else
     {
         throw new DomainException("NoPower", "对不起,您没有权限添加文章。");
     }
 }
예제 #7
0
        /// <summary>
        /// 获取文章内容
        /// </summary>
        /// <param name="acNo"></param>
        /// <returns></returns>
        public Article.Model.Article GetArticleFromWeb(string acNo)
        {
            Article.Model.Article article = new Model.Article();
            string json = webutil.GetArticle(acNo);

            article = getModelFromJson(json);
            return(article);
        }
예제 #8
0
 /// <summary>
 /// 更新点击次数
 /// </summary>
 /// <param name="nv"></param>
 public void updateClicks(NameValueCollection nv)
 {
     for (int i = 0; i < nv.Count; i++)
     {
         model           = GetModel(Convert.ToInt32(nv.GetKey(i)));
         model.dbo_Click = Convert.ToInt32(nv[nv.GetKey(i)]);
         Update(model);
     }
 }
예제 #9
0
        public ActionResult Views(string id)
        {
            if (id.ToLower().Equals("views"))
            {
                return(RedirectToAction("article", "Java21"));
            }
            JavaDLL dll = new JavaDLL();

            Model.Article mod = dll.getArticle(Convert.ToInt32(id.Split('.')[0]));
            return(View(mod));
        }
예제 #10
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                int itemId = Convert.ToInt32(Request.Params["id"]);

                if (itemId != 0)
                {
                    ArticleItem = DataHelper.GetOneArticle(itemId);
                }
            }
        }
예제 #11
0
        private void FillContent()
        {
            modelarticle = bllarticle.GetModel(Convert.ToInt32(Request.QueryString["id"].ToString()));
            if (modelarticle != null)
            {
                this.txtTitle.Text   = modelarticle.dbo_Title;
                this.txtAuthor.Text  = modelarticle.dbo_Author;
                this.txtSource.Text  = modelarticle.dbo_Source;
                this.txtClick.Text   = modelarticle.dbo_Click.ToString();
                this.fckContent.Text = modelarticle.dbo_Content;
                string strfujian = modelarticle.dbo_Fujian;

                if (bllarticleimg.GetRecordCount("dbo_articleId=" + Request.QueryString["id"]) > 0)
                {
                    this.chkIsAddImgToDb.Checked = true;
                }

                this.chkIsLock.Checked = modelarticle.dbo_IsLock;
                this.chkIsTop.Checked  = modelarticle.dbo_IsTop;
                if (strfujian != null && strfujian != "")
                {
                    StringBuilder sb      = new StringBuilder();
                    string        appPath = sys.AppPath;
                    string[]      fujians = strfujian.Split('/');
                    sb.Append("本文已有附件:");
                    sb.Append("<ul id='fujian'>\n");
                    for (int i = 0; i < fujians.Length; i++)
                    {
                        string filePath = appPath + "uploads/" + fujians[i];
                        sb.Append("<li><a href='" + filePath + "' target='_blank'>" + fujians[i] + "</a><input style='margin-left:20px;' type='button' value='删除' onclick='javascript:deleteFile(this)' /></li>\n");
                        //sb.Append("<div class='fujian'>本文附件:<a href='" + appPath + "uploads/" + strfujian + "'>" + strfujian + "</a></div>");
                    }
                    sb.Append("</ul>\n");
                    this.litFujian.Text = sb.ToString();
                }
                string type = modelarticle.dbo_Typeid.ToString();

                for (int i = 0; i < this.ddlType.Items.Count; i++)
                {
                    if (type == this.ddlType.Items[i].Value)
                    {
                        this.ddlType.Items[i].Selected = true;
                    }
                }
            }
        }
        public void UpdateArticle(Model.Article article)
        {
            Article article2 = _articleRepository.Get(article.ArticleId);

            if (article2 == null)
            {
                throw new DomainException("NoFind", "对不起,该文章不存在或已经被删除。");
            }
            if (!_roleService.EditArticlePower())
            {
                throw new DomainException("NoPower", "对不起,您没有权限编辑该文章。");
            }
            else
            {
                article.ModifyDate = DateTime.Now;
                _articleRepository.Update(article);
            }
        }
예제 #13
0
        protected void Page_Load(object sender, EventArgs e)
        {
            var articleService = unity.GetInstance <IArticleService>();

            ModelList = articleService.GetList(new Wuyiju.Model.Article.Query {
                Cate_Id = 46
            });

            ModelList = ModelList.OrderByDescending(d => d.Add_Time).ToList();

            int id = 0;

            try
            {
                id = Convert.ToInt32(Request.QueryString["id"]);
            }
            catch
            {
                Response.Redirect("/");
            }

            if (ModelList == null || ModelList.Count == 0)
            {
                Response.Redirect("/");
            }

            if (id > 0)
            {
                Model = articleService.GetArticle(id);
                if (Model.Cate_Id != 46)
                {
                    Model = ModelList[0];
                }
            }
            else
            {
                Model = ModelList[0];
            }
        }
예제 #14
0
        protected void ButtonSave_Click(object sender, EventArgs e)
        {
            Model.Article item = new Model.Article();

            int itemId = 0;

            try
            {
                itemId = Convert.ToInt32(Request.Params["id"]);
            }
            catch (System.Exception ex)
            {
                DataHelper.AddException(ex);
            }

            if (itemId != 0)
            {
                item.Id = itemId;
            }

            try
            {
                var myDate = DateTime.ParseExact(TextBoxDate.Text, "dd.MM.yyyy", System.Globalization.CultureInfo.InvariantCulture, System.Globalization.DateTimeStyles.None);

                item.WhenDate = myDate;
                item.Head     = TextBoxHead.Text;
                item.Text     = NewsText.Text;
                item.UserId   = User.UserId;

                DataHelper.SubmitArticle(item);
            }
            catch (System.Exception ex)
            {
                DataHelper.AddException(ex);
            }

            Response.Redirect("Articles.aspx");
        }
예제 #15
0
        protected void GridView1_RowDeleting(object sender, GridViewDeleteEventArgs e)
        {
            string id = this.GridView1.DataKeys[e.RowIndex].Value.ToString();

            int      typeid       = 0;
            DateTime articlePtime = DateTime.Now;

            modelarticle = bllarticle.GetModel(Convert.ToInt32(id));
            if (modelarticle != null)
            {
                typeid       = Convert.ToInt32(modelarticle.dbo_Typeid);
                articlePtime = Convert.ToDateTime(modelarticle.dbo_Ptime);
            }

            bllarticle.Delete(Convert.ToInt32(id));
            bllarticleimg.DeleteByArticleId(Convert.ToInt32(id));

            string strDir = sys.getSpcDir(Convert.ToInt32(spcId));

            if (typeid != 0)
            {
                sys.deleteArticleFile(Convert.ToInt32(id), strDir, articlePtime);
            }

            if (sys.IsStatic)
            {
                if (typeid != 0)
                {
                    sys.ToStaticListWithArticleEdit(typeid, strDir);
                }
            }
            else//判断是否需要生成首页
            {
                sys.ToStaticPageWithActive(Convert.ToInt32(spcId));
            }
            this.BindData();
        }
예제 #16
0
 public Article(Model.Article a) : base(a)
 {
 }
예제 #17
0
 public ArticleModel(Article article)
 {
     Article = article;
 }
예제 #18
0
 public Model.ResultEntity AddArticle(Model.Article article)
 {
     return(articleDal.AddArticle(article));
 }
예제 #19
0
        /// <summary>
        /// 查询详细。
        /// </summary>
        /// <param name="m">d_系列</param>
        public static Model.Article Select_Detail(Model.Article m)
        {
            #region ==返回参数处理==
            string[] return_value = Common.Functions.Parameters_Filter(m.s_Total_parameter, m.s_Main_parameter, m.s_Extended_parameter, demand);
            m.s_Main_parameter     = return_value[0];
            m.s_Extended_parameter = return_value[1];
            #endregion

            DataTable dt = Dal.Article.Select_Detail(m.s_Main_parameter, m.s_Extended_parameter, m.d_Aid, m.d_Alive);
            m = new Model.Article();
            try
            {
                DataRow dr = dt.Rows[0];
                #region 主参数
                if (Common.Functions.checkHave(return_value[0], "Aid"))
                {
                    m.Aid = Common.Functions.ConvertInt64(dr["Aid"]);
                }
                if (Common.Functions.checkHave(return_value[0], "Atitle"))
                {
                    m.Atitle = Common.Functions.ConvertString(dr["Atitle"]);
                }
                if (Common.Functions.checkHave(return_value[0], "Url"))
                {
                    m.Url = dr["Url"].ToString();
                }
                if (Common.Functions.checkHave(return_value[0], "Source"))
                {
                    m.Source = Common.Functions.ConvertString(dr["Source"]);
                }
                if (Common.Functions.checkHave(return_value[0], "Author"))
                {
                    m.Author = Common.Functions.ConvertString(dr["Author"]);
                }
                if (Common.Functions.checkHave(return_value[0], "Alive"))
                {
                    m.Alive = Convert.ToBoolean(dr["Alive"]);
                }
                if (Common.Functions.checkHave(return_value[0], "Hot"))
                {
                    m.Hot = Convert.ToBoolean(dr["Hot"]);
                }
                if (Common.Functions.checkHave(return_value[0], "Recommend"))
                {
                    m.Recommend = Convert.ToBoolean(dr["Recommend"]);
                }
                if (Common.Functions.checkHave(return_value[0], "Kind"))
                {
                    m.Kind = Common.Functions.ConvertInt16(dr["Kind"], 0);
                }
                if (Common.Functions.checkHave(return_value[0], "Layer"))
                {
                    m.Layer = Common.Functions.ConvertInt64(dr["Layer"], 0);
                }
                if (Common.Functions.checkHave(return_value[0], "Ainfo"))
                {
                    m.Ainfo = dr["Ainfo"].ToString();
                }
                if (Common.Functions.checkHave(return_value[0], "Atime"))
                {
                    m.Atime = Common.Functions.ConvertDateTime(dr["Atime"], Convert.ToDateTime(Common.Para.dt_def));
                }
                if (Common.Functions.checkHave(return_value[0], "Pic1"))
                {
                    m.Pic1 = dr["Pic1"].ToString();
                }
                if (Common.Functions.checkHave(return_value[0], "Pic2"))
                {
                    m.Pic2 = dr["Pic2"].ToString();
                }
                if (Common.Functions.checkHave(return_value[0], "Summary"))
                {
                    m.Summary = dr["Summary"].ToString();
                }
                if (Common.Functions.checkHave(return_value[0], "Asid"))
                {
                    m.Asid = Common.Functions.ConvertInt64(dr["Asid"]);
                }
                if (Common.Functions.checkHave(return_value[0], "ieTitle"))
                {
                    m.ieTitle = dr["ieTitle"].ToString();
                }
                if (Common.Functions.checkHave(return_value[0], "seoKeywords"))
                {
                    m.seoKeywords = dr["seoKeywords"].ToString();
                }
                if (Common.Functions.checkHave(return_value[0], "seoDescription"))
                {
                    m.seoDescription = dr["seoDescription"].ToString();
                }
                #endregion

                #region 扩展参数
                if (Common.Functions.checkHave(return_value[1], "Stitle"))
                {
                    m.Stitle = dr["Stitle"].ToString();
                }
                #endregion
            }
            catch
            {
                m.Aid            = 0;
                m.Atitle         = "";
                m.Url            = "";
                m.Source         = "";
                m.Author         = "";
                m.Alive          = false;
                m.Hot            = false;
                m.Recommend      = false;
                m.Alive          = true;
                m.Kind           = 0;
                m.Layer          = 0;
                m.Ainfo          = "";
                m.Atime          = Convert.ToDateTime(Common.Para.dt_def);
                m.Pic1           = "";
                m.Pic2           = "";
                m.Summary        = "";
                m.Asid           = 0;
                m.ieTitle        = "";
                m.seoKeywords    = "";
                m.seoDescription = "";
            }
            dt.Dispose();
            return(m);
        }
예제 #20
0
        /// <summary>
        /// 查询列表(带分页)。返回List
        /// </summary>
        /// <param name="m">s_系列</param>
        /// <param name="p">Model.Pages</param>
        /// <param name="Rc">返回表记录总数量</param>
        public static List <Model.Article> Select_List(Model.Article m, ref Model.Pages p, ref long Rc)
        {
            #region ==返回参数处理==
            string[] return_value = Common.Functions.Parameters_Filter(m.s_Total_parameter, m.s_Main_parameter, m.s_Extended_parameter, demand);
            m.s_Main_parameter     = return_value[0];
            m.s_Extended_parameter = return_value[1];
            #endregion

            DataTable            dt = Dal.Article.Select_List(ref p, m.s_Main_parameter, m.s_Extended_parameter, m.s_Keywords, m.s_Kind, m.s_Alive, m.s_d1, m.s_d2, m.s_Aid, m.s_Asid, m.s_Order, m.s_Hot, m.s_Recommend, ref Rc);
            DataRow              dr;
            List <Model.Article> l = new List <Model.Article>();
            for (int i = 0; i < dt.Rows.Count; i++)
            {
                dr = dt.Rows[i];
                m  = new Model.Article();
                #region 主参数
                if (Common.Functions.checkHave(return_value[0], "Aid"))
                {
                    m.Aid = Common.Functions.ConvertInt64(dr["Aid"]);
                }
                if (Common.Functions.checkHave(return_value[0], "Atitle"))
                {
                    m.Atitle = Common.Functions.ConvertString(dr["Atitle"]);
                }
                if (Common.Functions.checkHave(return_value[0], "Url"))
                {
                    m.Url = dr["Url"].ToString();
                }
                if (Common.Functions.checkHave(return_value[0], "Source"))
                {
                    m.Source = Common.Functions.ConvertString(dr["Source"]);
                }
                if (Common.Functions.checkHave(return_value[0], "Author"))
                {
                    m.Author = Common.Functions.ConvertString(dr["Author"]);
                }
                if (Common.Functions.checkHave(return_value[0], "Alive"))
                {
                    m.Alive = Convert.ToBoolean(dr["Alive"]);
                }
                if (Common.Functions.checkHave(return_value[0], "Hot"))
                {
                    m.Hot = Convert.ToBoolean(dr["Hot"]);
                }
                if (Common.Functions.checkHave(return_value[0], "Recommend"))
                {
                    m.Recommend = Convert.ToBoolean(dr["Recommend"]);
                }
                if (Common.Functions.checkHave(return_value[0], "Kind"))
                {
                    m.Kind = Common.Functions.ConvertInt16(dr["Kind"], 0);
                }
                if (Common.Functions.checkHave(return_value[0], "Layer"))
                {
                    m.Layer = Common.Functions.ConvertInt64(dr["Layer"], 0);
                }
                if (Common.Functions.checkHave(return_value[0], "Ainfo"))
                {
                    m.Ainfo = dr["Ainfo"].ToString();
                }
                if (Common.Functions.checkHave(return_value[0], "Atime"))
                {
                    m.Atime = Common.Functions.ConvertDateTime(dr["Atime"], Convert.ToDateTime(Common.Para.dt_def));
                }
                if (Common.Functions.checkHave(return_value[0], "Pic1"))
                {
                    m.Pic1 = dr["Pic1"].ToString();
                }
                if (Common.Functions.checkHave(return_value[0], "Pic2"))
                {
                    m.Pic2 = dr["Pic2"].ToString();
                }
                if (Common.Functions.checkHave(return_value[0], "Summary"))
                {
                    m.Summary = dr["Summary"].ToString();
                }
                if (Common.Functions.checkHave(return_value[0], "Asid"))
                {
                    m.Asid = Common.Functions.ConvertInt64(dr["Asid"]);
                }
                if (Common.Functions.checkHave(return_value[0], "ieTitle"))
                {
                    m.ieTitle = dr["ieTitle"].ToString();
                }
                if (Common.Functions.checkHave(return_value[0], "seoKeywords"))
                {
                    m.seoKeywords = dr["seoKeywords"].ToString();
                }
                if (Common.Functions.checkHave(return_value[0], "seoDescription"))
                {
                    m.seoDescription = dr["seoDescription"].ToString();
                }
                #endregion

                #region 扩展参数
                if (Common.Functions.checkHave(return_value[1], "Stitle"))
                {
                    m.Stitle = dr["Stitle"].ToString();
                }
                #endregion
                l.Add(m);
            }
            dt.Dispose();
            return(l);
        }
예제 #21
0
 /// <summary>
 /// 修改推荐文章状态
 /// </summary>
 /// <param name="m">d_Aid</param>
 public static void Recommend(Model.Article m)
 {
     Dal.Article.Recommend(m.d_Aid);
 }
예제 #22
0
 /// <summary>
 /// 修改基本资料
 /// </summary>
 /// <param name="m">d_Aid+修改项</param>
 public static void Modify(Model.Article m)
 {
     Dal.Article.Modify(m.d_Aid, m.Atitle, m.Url, m.Source, m.Author, m.Ainfo, m.Atime.ToString("yyyy-MM-dd HH:mm:ss"), m.Pic1, m.Pic2, m.Summary, m.Asid, m.ieTitle, m.seoKeywords, m.seoDescription);
 }
예제 #23
0
        protected void btnSubmit_Click(object sender, EventArgs e)
        {
            string             strTitle   = this.txtTitle.Text;
            string             strAuthor  = this.txtAuthor.Text;
            string             strClick   = this.txtClick.Text;
            string             strSource  = this.txtSource.Text;
            string             strType    = this.ddlType.SelectedValue;
            string             strContent = this.fckContent.Text;
            HttpFileCollection thefiles   = Request.Files;

            bool IsAddImgToDb = this.chkIsAddImgToDb.Checked;

            if (strType == "0" || strType == "")
            {
                this.lblTypeMessage.Text = "请选择文章分类";
                Page.ClientScript.RegisterStartupScript(Page.GetType(), "alert", "alert(\"请选择文章分类!\")", true);
                return;
            }

            //检查所有文件的后缀名是否为允许上传的类型
            for (int ifile = 0; ifile < thefiles.Count; ifile++)
            {
                HttpPostedFile file     = thefiles[ifile];
                string         fileName = file.FileName.ToLower();
                if (fileName != "" && file.ContentLength != 0)
                {
                    string fileExtension = System.IO.Path.GetExtension(fileName);    //扩展名
                    fileName = System.IO.Path.GetFileNameWithoutExtension(fileName); //文件名
                    bool     AllowUpload = false;
                    string   strFileType = System.Configuration.ConfigurationManager.AppSettings["AllowFileTypes"].ToString();
                    string[] filetypes   = strFileType.Split(',');

                    for (int i = 0; i < filetypes.Length; i++)
                    {
                        if (fileExtension == "." + filetypes[i].ToLower())
                        {
                            AllowUpload = true; break;
                        }
                    }
                    if (!AllowUpload)
                    {
                        Page.ClientScript.RegisterStartupScript(Page.GetType(), "alertfileNotAllow", "alert('您上传的附件中含有不允许上传的附件类型,请重新添加')", true);
                        return;
                    }
                }
            }

            string uploadFileNames = string.Empty;

            for (int ifile = 0; ifile < thefiles.Count; ifile++)
            {
                HttpPostedFile file     = thefiles[ifile];
                string         fileName = file.FileName;
                if (file.ContentLength != 0)
                {
                    fileName = fileName.ToLower();
                    string fileExtension = System.IO.Path.GetExtension(fileName);    //扩展名
                    fileName = System.IO.Path.GetFileNameWithoutExtension(fileName); //文件名
                    //fileName = fileName.Substring(fileName.LastIndexOf('\\'), fileName.LastIndexOf('.')); //文件名

                    //判断文件是否已经存在,如果存在则重命名,直到文件名不存在
                    string fileRename = fileName + fileExtension;
                    int    tryTimes   = 0;
                    while (File.Exists(Server.MapPath("../../") + "uploads/" + fileRename))
                    {
                        tryTimes++;
                        fileRename = fileName + "(" + tryTimes.ToString() + ")" + fileExtension;
                    }

                    uploadFileNames += (uploadFileNames == string.Empty) ? fileRename : "/" + fileRename; //多个文件用符号‘/’隔开

                    string fullFileName = Server.MapPath("../../") + "uploads/" + fileRename;
                    file.SaveAs(fullFileName);
                }
            }

            string oldFujian = Request.Form["_fujianOld"];

            if (oldFujian != "")
            {
                uploadFileNames += (uploadFileNames == string.Empty) ? oldFujian : "/" + oldFujian; //多个文件用符号‘/’隔开
            }


            string[] strSrcs = getPics(ref strContent);
            this.fckContent.Text = strContent;
            int articleId;

            if (theState == MyPageState.add)
            {
                articleId = bllarticle.Add_ReturnID(new Model.Article {
                    dbo_Title = strTitle, dbo_Typeid = Convert.ToInt32(strType), dbo_Content = strContent, dbo_Author = strAuthor, dbo_Source = strSource, dbo_Click = Convert.ToInt32(strClick), dbo_Fujian = uploadFileNames, dbo_IsLock = this.chkIsLock.Checked, dbo_IsTop = this.chkIsTop.Checked, dbo_Ptime = DateTime.Now
                });

                //只添加一张图片到数据库中
                if (strSrcs.Length > 0 && IsAddImgToDb)
                {
                    bllarticleimg.Add(new Model.ArticleImg {
                        dbo_ImgSrc = strSrcs[0], dbo_articleId = articleId, dbo_ImgBigSrc = strSrcs[0], dbo_SpecialityId = Convert.ToInt32(Request.QueryString["spcId"]), dbo_ImgArt = strTitle
                    });
                }
            }
            else
            {
                articleId                = Convert.ToInt32(Request.QueryString["id"]);
                modelarticle             = bllarticle.GetModel(articleId);
                modelarticle.dbo_Title   = strTitle;
                modelarticle.dbo_Content = strContent;
                modelarticle.dbo_Author  = strAuthor;
                modelarticle.dbo_Source  = strSource;
                modelarticle.dbo_Click   = strClick == ""?0:Convert.ToInt32(strClick);
                modelarticle.dbo_Fujian  = uploadFileNames;
                modelarticle.dbo_IsLock  = this.chkIsLock.Checked;
                modelarticle.dbo_IsTop   = this.chkIsTop.Checked;
                modelarticle.dbo_Ptime   = DateTime.Now;
                bllarticle.Update(modelarticle);
                bllarticleimg.DeleteByArticleId(articleId);

                //只添加一张图片到数据库中
                if (strSrcs.Length > 0 && IsAddImgToDb)
                {
                    bllarticleimg.Add(new Model.ArticleImg {
                        dbo_ImgSrc = strSrcs[0], dbo_articleId = articleId, dbo_ImgBigSrc = strSrcs[0], dbo_SpecialityId = Convert.ToInt32(Request.QueryString["spcId"]), dbo_ImgArt = strTitle
                    });
                }
            }

            string spcId = "0";

            if (Request.QueryString["spcId"] != null)
            {
                spcId = Request.QueryString["spcId"].ToString();
            }

            if (sys.IsStatic)
            {
                string strDir = sys.getSpcDir(Convert.ToInt32(spcId));
                sys.ToStaticListWithArticleEdit(Convert.ToInt32(this.ddlType.SelectedValue), strDir);
                sys.ToStaticContent(strDir, articleId, DateTime.Now);
            }
            else //判断是否需要生成首页
            {
                sys.ToStaticPageWithActive(Convert.ToInt32(spcId));
            }

            Response.Redirect("articleList.aspx?spcId=" + spcId);
        }
예제 #24
0
        /// <summary>
        /// Import the file in the database
        /// </summary>
        /// <param name="Path"></param>
        /// <returns></returns>
        public static bool ImportFile(String Path, ProgressBar Progress)
        {
            try
            {
                using (var reader = new StreamReader(Path, Encoding.Default))
                {
                    Console.WriteLine("We are importing this file " + Path);

                    ArticleControl     ACont  = new ArticleControl();
                    FamilleControl     FCont  = new FamilleControl();
                    SousFamilleControl SFCont = new SousFamilleControl();
                    MarqueControl      MCont  = new MarqueControl();

                    Progress.Maximum = reader.ReadLine().Count() - 1;// remove the first line

                    while (!reader.EndOfStream)
                    {
                        Progress.PerformStep();
                        Model.Marque      Mark    = new Model.Marque();
                        Model.Article     Artic   = new Model.Article();
                        Model.SousFamille SousFam = new Model.SousFamille();
                        Model.Famille     Fam     = new Model.Famille();

                        /*
                         * Parser
                         *
                         */
                        var Line = reader.ReadLine();
                        //Console.WriteLine(line);
                        string[] values = Line.Split(';');

                        /*
                         * Create a "Marque" in the Database and get the Id
                         */

                        Mark.Nom = values[MARQUE];

                        // the "Marque" object is not in the Database
                        if (!MCont.Exist(Mark))
                        {
                            // Create one
                            MCont.Insert(Mark);
                        }

                        // get it
                        Mark = MCont.GetByName(Mark);


                        /*
                         * Create a "Famille" in the Database and get the ID
                         */

                        Fam.Nom = values[FAMILLE];

                        if (!FCont.Exist(Fam))
                        {
                            FCont.Insert(Fam);
                        }

                        Fam = FCont.GetByName(Fam);


                        /*
                         * Create a "SousFamille" in the Database and get the ID
                         */
                        SousFam.Nom     = values[SOUSFAMILLE];
                        SousFam.Famille = Fam;
                        if (!SFCont.Exist(SousFam))
                        {
                            SFCont.Insert(SousFam);
                        }
                        SousFam = SFCont.GetByName(SousFam);

                        /*
                         * Create the "Article" and stock it in the database
                         */
                        Artic.RefArticle = values[REF];
                        Artic.PrixHT     = float.Parse(values[PRIXHT].Replace('.', ','));
                        //Console.WriteLine(Artic.PrixHT);
                        Artic.Description = values[DESCRIPTION];
                        Artic.Marque      = Mark;
                        Artic.SousFamille = SousFam;

                        // the Article object need to be update in the Database
                        if (ACont.Exist(Artic))
                        {
                            //Console.WriteLine("Update");
                            ACont.Update(Artic);
                        }
                        else
                        {
                            //Console.WriteLine("Insert");
                            ACont.Insert(Artic);
                        }
                    }
                    Progress.Value = Progress.Maximum;
                }
                return(true);
            }
            catch (Exception e)
            {
                Console.WriteLine(e.StackTrace);
                return(false);
            }
        }
예제 #25
0
 /// <summary>
 /// 修改序号
 /// </summary>
 /// <param name="m">d_Aid+Layer</param>
 public static void Layer(Model.Article m)
 {
     Dal.Article.Layer(m.d_Aid, m.Layer);
 }
예제 #26
0
 /// <summary>
 /// 修改屏蔽状态
 /// </summary>
 /// <param name="m">d_Aid</param>
 public static void Alive(Model.Article m)
 {
     Dal.Article.Alive(m.d_Aid);
 }
예제 #27
0
        /// <summary>
        /// 添加。返回新纪录主码值
        /// </summary>
        /// <param name="m">添加项</param>
        public static long Add(Model.Article m)
        {
            long Aid = Dal.Article.Add(m.Atitle, m.Url, m.Source, m.Author, m.Kind, m.Ainfo, m.Atime.ToString("yyyy-MM-dd HH:mm:ss"), m.Pic1, m.Pic2, m.Summary, m.Asid, m.ieTitle, m.seoKeywords, m.seoDescription);

            return(Aid);
        }
예제 #28
0
 /// <summary>
 /// 返回Article数量
 /// kind 栏目
 /// Alive 是否屏蔽
 public static long GetCount(Model.Article m)
 {
     return(Dal.Article.GetCount(m.s_Alive, m.s_Kind));
 }
예제 #29
0
 /// <summary>
 /// 修改热点文章状态
 /// </summary>
 /// <param name="m">d_Aid</param>
 public static void Hot(Model.Article m)
 {
     Dal.Article.Hot(m.d_Aid);
 }