private void OnSave()
        {
            string sTitle = txtTitle.Value.Trim();

            if (string.IsNullOrEmpty(sTitle))
            {
                MessageBox.Messager(this.Page, this.Page.Controls[0], MessageContent.Submit_Params_InvalidError, "错误提示", "error");
                return;
            }
            string sParent       = txtParent.Value.Trim();
            Guid   contentTypeId = Guid.Empty;

            if (!string.IsNullOrEmpty(sParent))
            {
                Guid.TryParse(sParent, out contentTypeId);
            }
            string sContent = HttpUtility.UrlDecode(hEditor1.Value).Trim();

            hEditor1.Value = sContent;

            ContentDetail     bll   = new ContentDetail();
            ContentDetailInfo model = new ContentDetailInfo();

            model.Title           = sTitle;
            model.ContentTypeId   = contentTypeId;
            model.ContentText     = sContent;
            model.Sort            = 0;
            model.LastUpdatedDate = DateTime.Now;
            model.UserId          = Common.GetUserId(Context);

            int effectCount = -1;

            if (!gId.Equals(Guid.Empty))
            {
                model.Id    = gId;
                effectCount = bll.Update(model);
            }
            else
            {
                effectCount = bll.Insert(model);
            }

            if (effectCount == 110)
            {
                MessageBox.Messager(this.Page, this.Page.Controls[0], MessageContent.Submit_Exist, "系统提示", "error");
                return;
            }
            if (effectCount > 0)
            {
                MessageBox.MessagerShow(this.Page, this.Page.Controls[0], MessageContent.Submit_Success);
            }
            else
            {
                MessageBox.Messager(this.Page, this.Page.Controls[0], MessageContent.Submit_Error);
            }
        }
Пример #2
0
        public ResResultModel SaveContentDetail(ContentDetailFmModel model)
        {
            try
            {
                if (model == null)
                {
                    return(ResResult.Response(false, MC.Request_Params_InvalidError, null));
                }
                if (string.IsNullOrWhiteSpace(model.AppCode) || string.IsNullOrWhiteSpace(model.Title))
                {
                    return(ResResult.Response(false, MC.Request_Params_InvalidError, null));
                }
                Guid Id = Guid.Empty;
                if (model.Id != null)
                {
                    Guid.TryParse(model.Id.ToString(), out Id);
                }
                Guid contentTypeId = Guid.Empty;
                if (model.ContentTypeId != null)
                {
                    Guid.TryParse(model.ContentTypeId.ToString(), out contentTypeId);
                }
                var userId    = WebCommon.GetUserId();
                var currTime  = DateTime.Now;
                var modelInfo = new ContentDetailInfo(model.AppCode, Id, userId, contentTypeId, model.Title, model.Keyword, model.Descr, model.ContentText, model.Openness, model.Sort, currTime, currTime);

                var bll    = new ContentDetail();
                int effect = -1;

                if (Id.Equals(Guid.Empty))
                {
                    modelInfo.Id = Guid.NewGuid();
                    effect       = bll.InsertByOutput(modelInfo);
                }
                else
                {
                    effect = bll.Update(modelInfo);
                }
                if (effect < 1)
                {
                    return(ResResult.Response(false, MC.M_Save_Error, ""));
                }

                return(ResResult.Response(true, "", modelInfo.Id));
            }
            catch (Exception ex)
            {
                return(ResResult.Response(false, ex.Message, ""));
            }
        }
Пример #3
0
        /// <summary>
        /// 站点内容
        /// </summary>
        /// <param name="context"></param>
        private void SaveContentDetail(HttpContext context)
        {
            try
            {
                if (string.IsNullOrWhiteSpace(context.Request.Form["ctl00$cphMain$txtTitle"]))
                {
                    context.Response.Write("{\"success\": false,\"message\": \"" + MessageContent.Submit_Params_InvalidError + "\"}");
                    return;
                }
                if (string.IsNullOrWhiteSpace(context.Request.Form["contentTypeId"]))
                {
                    context.Response.Write("{\"success\": false,\"message\": \"" + MessageContent.Submit_Params_InvalidError + "\"}");
                    return;
                }

                Guid gId = Guid.Empty;
                if (!string.IsNullOrWhiteSpace(context.Request.Form["ctl00$cphMain$hId"].Trim()))
                {
                    Guid.TryParse(context.Request.Form["ctl00$cphMain$hId"].Trim(), out gId);
                }

                Guid contentTypeId = Guid.Empty;
                Guid.TryParse(context.Request.Form["contentTypeId"], out contentTypeId);
                Guid pictureId = Guid.Empty;
                if (!string.IsNullOrWhiteSpace(context.Request.Form["ctl00$cphMain$hPictureId"]))
                {
                    Guid.TryParse(context.Request.Form["ctl00$cphMain$hPictureId"], out pictureId);
                }
                int virtualViewCount = 0;
                if (!string.IsNullOrWhiteSpace(context.Request.Form["ctl00$cphMain$txtVirtualViewCount"]))
                {
                    int.TryParse(context.Request.Form["ctl00$cphMain$txtVirtualViewCount"], out virtualViewCount);
                }
                int sort = 0;
                if (!string.IsNullOrWhiteSpace(context.Request.Form["ctl00$cphMain$txtSort"]))
                {
                    int.TryParse(context.Request.Form["ctl00$cphMain$txtSort"], out sort);
                }
                bool isDisable = false;
                if (!string.IsNullOrWhiteSpace(context.Request.Form["isDisable"]))
                {
                    bool.TryParse(context.Request.Form["isDisable"], out isDisable);
                }

                ContentDetailInfo model = new ContentDetailInfo();
                model.Id = gId;
                model.LastUpdatedDate  = DateTime.Now;
                model.Title            = context.Request.Form["ctl00$cphMain$txtTitle"].Trim();
                model.PictureId        = pictureId;
                model.Descr            = context.Request.Form["ctl00$cphMain$txtaDescr"] == null ? "" : context.Request.Form["ctl00$cphMain$txtaDescr"].Trim();
                model.ContentText      = context.Request.Form["txtContent"] == null ? "" : HttpUtility.HtmlDecode(context.Request.Form["txtContent"].Trim());
                model.ContentTypeId    = contentTypeId;
                model.VirtualViewCount = virtualViewCount;
                model.Sort             = sort;
                model.IsDisable        = isDisable;

                ContentDetail bll    = new ContentDetail();
                int           effect = -1;

                using (TransactionScope scope = new TransactionScope())
                {
                    using (TransactionScope scope2 = new TransactionScope(TransactionScopeOption.Suppress))
                    {
                        if (bll.IsExist(model.ContentTypeId, model.Id))
                        {
                            scope2.Complete();
                            scope.Complete();
                            context.Response.Write("{\"success\": false,\"message\": \"已存在该类别的内容,请勿重复操作\"}");
                            return;
                        }
                    }
                    if (!gId.Equals(Guid.Empty))
                    {
                        effect = bll.Update(model);
                    }
                    else
                    {
                        effect = bll.Insert(model);
                    }

                    scope.Complete();
                }
                if (effect == 110)
                {
                    context.Response.Write("{\"success\": false,\"message\": \"" + MessageContent.Submit_Exist + "\"}");
                    return;
                }
                if (effect != 1)
                {
                    context.Response.Write("{\"success\": false,\"message\": \"操作失败,请正确输入\"}");
                    return;
                }

                context.Response.Write("{\"success\": true,\"message\": \"操作成功\"}");
            }
            catch (Exception ex)
            {
                context.Response.Write("{\"success\": false,\"message\": \"异常:" + ex.Message + "\"}");
            }
        }