Esempio n. 1
0
        public int Add(string newsId)
        {
            int      ret = 0;
            DateTime dt  = DateTime.Now;

            cmsNews n = ns.GetModel(newsId);

            if (n == null)
            {
                throw new Exception("文章不存在!");
            }

            using (DbTrans t = ns.BeginTransaction())
            {
                n.Attach();
                n.Hits += 1;
                ns.UpdateModel(n);

                SetTransaction(t);

                cmsNewsHit h = GetModelWithWhere(
                    cmsNewsHit._.NewsId == newsId && (
                        cmsNewsHit._.HitDate.Year == dt.Year &&
                        cmsNewsHit._.HitDate.Month == dt.Month &&
                        cmsNewsHit._.HitDate.Day == dt.Day)
                    );
                if (h == null)
                {
                    h         = new cmsNewsHit();
                    h.NewsId  = newsId;
                    h.HitDate = DateTime.Now.Date;
                    h.Hits    = 1;
                    ret       = AddModel(h);
                }
                else
                {
                    h.Attach();
                    h.Hits += 1;
                    ret     = UpdateModel(h);
                }

                t.Commit();
            }
            return(ret);
        }
Esempio n. 2
0
        protected void btnSave_Click(object sender, EventArgs e)
        {
            try
            {
                news = ns.GetModel(id);

                if (news != null)
                {
                    news.Attach();

                    news.IsAudit = Convert.ToInt32(ddlResult.SelectedValue);
                    news.AuditComment = txtComment.Text;

                    ns.Save(news);

                    ScriptUtil.AlertAndCloseDialog("审核完成!", true);
                }
            }
            catch (Exception ex)
            {
                ScriptUtil.Alert(ex.Message);
            }
        }
Esempio n. 3
0
        protected void btnSave_Click(object sender, EventArgs e)
        {
            try
            {
                news = ns.GetModel(id);

                if (news != null)
                {
                    news.Attach();

                    news.IsAudit      = Convert.ToInt32(ddlResult.SelectedValue);
                    news.AuditComment = txtComment.Text;

                    ns.Save(news);

                    ScriptUtil.AlertAndCloseDialog("审核完成!", true);
                }
            }
            catch (Exception ex)
            {
                ScriptUtil.Alert(ex.Message);
            }
        }
Esempio n. 4
0
        protected override void btnSave_Click(object sender, EventArgs e)
        {
            if (string.IsNullOrEmpty(txtHits.Text.Trim()))
            {
                txtHits.Text = "0";
            }

            DateTime dt;

            if (!DateTime.TryParse(txtTime.Text.Trim(), out dt))
            {
                dt = DateTime.Now;
            }

            if (action.Equals("add"))
            {
                news = new cmsNews();

                news.RGuid   = Guid.NewGuid().ToString();
                news.AddUser = LoginUser.Id;
                news.AddTime = DateTime.Now;

                news.IsIndex = 0;
                news.IsTop   = 0;
            }
            else
            {
                news = ns.GetModel(id);
                news.Attach();
            }
            news.NodeCode = ddlCatalog.SelectedValue;
            news.Title    = txtTitle.Text.Trim();
            news.Content  = txtContent.Text.Trim();
            news.Summary  = txtSummary.Text.Trim();
            news.Tags     = txtTags.Text.Trim();
            news.SmallPic = hidImages1.Value;
            news.Author   = txtAuthor.Text;
            news.Source   = txtSource.Text;
            news.Hits     = Convert.ToInt32(txtHits.Text);
            news.OrderNo  = 0;
            news.EditUser = LoginUser.Id;
            news.EditTime = dt;
            news.IsAudit  = 0;
            if (true)//WebConfig.NoAudit
            {
                news.IsAudit   = 1;
                news.AuditUser = LoginUser.Id;
                news.AuditTime = DateTime.Now;

                news.IsIndex = 1;
            }
            news.LangId = CurrentLanguageId;
            List <int> ztList = new List <int>();

            foreach (ListItem item in cblZt.Items)
            {
                if (item.Selected)
                {
                    ztList.Add(Convert.ToInt32(item.Value));
                }
            }
            try
            {
                int r = ns.Save(news);

                ntrs.Save(news.RGuid, ztList.ToArray());

                if (action.Equals("add"))
                {
                    ScriptUtil.ConfirmAndRedirect(@"图片添加成功!\n“确定”继续添加,“取消”则跳转到列表页。", "ImageAdd.aspx?node=" + NodeCode, "ImageList.aspx?node=" + NodeCode);
                }
                else
                {
                    ScriptUtil.ConfirmAndRedirect(@"图片修改成功!\n“确定”留在本页,“取消”则跳转到列表页。", "ImageAdd.aspx?node=" + NodeCode + "&id=" + id + "&action=edit", "ImageList.aspx?node=" + NodeCode);
                }
            }
            catch (Exception ex)
            {
                ScriptUtil.Alert(ex.Message);

                Logger.Error(ex.Message);
            }
        }