Example #1
0
        public JsonResult AskSubmit(short fid, string title, string content, string vercode, int rate = 0, int id = 0)
        {
            ResultModel <string> model = new ResultModel <string>();

            _service.Command <MainOutsourcing>((db, o) =>
            {
                Check.Exception(fid == 0 || title.IsNullOrEmpty() || content.IsNullOrEmpty() || vercode.IsNullOrEmpty(), "参数不合法!");
                Check.Exception(title.Length < 5 && content.Length < 20 || content.Length > 1000000, "参数不合法!");
                Check.Exception(base.GetForumsList != null && base.GetForumsList.Any(it => it.Fid == fid).IsFalse(), "参数不合法!");
                var sm          = SessionManager <string> .GetInstance();
                var severCode   = sm[PubConst.SessionVerifyCode];
                model.IsSuccess = false;
                if (vercode != severCode)
                {
                    model.ResultInfo = "验证码错误!";
                }
                else if (IsLogin.IsFalse())
                {
                    model.ResultInfo = "对不起您还没有登录!";
                }
                else
                {
                    try
                    {
                        db.BeginTran();
                        var isAdd = id == 0;
                        if (isAdd)
                        {
                            //插贴子标题
                            BBS_Topics t = o.GetTopics(fid, title, rate, _userInfo);
                            var tid      = db.Insert(t).ObjToInt();
                            t.Tid        = tid;
                            //插贴子主体
                            BBS_Posts p = o.GetPosts(fid, content, _userInfo, t);
                            db.Insert(p);
                        }
                        else
                        {
                            var topics = db.Queryable <BBS_Topics>().InSingle(id);
                            Check.Exception(topics.Posterid != _userInfo.Id && _userInfo.RoleId == PubEnum.RoleType.User.TryToInt(), "您没有权限修改!");
                            db.Update <BBS_Topics>(new { Title = title, Rate = rate, Fid = fid }, it => it.Tid == id);
                            db.Update <BBS_Posts>(new { Title = title, Rate = rate, Fid = fid, Message = content }, it => it.Tid == id && it.Parentid == 0);
                        }
                        db.CommitTran();
                        model.IsSuccess = true;
                        base.RemoveForumsStatisticsCache();//清除统计缓存
                    }
                    catch (Exception ex)
                    {
                        model.ResultInfo = "发布失败!";
                        db.RollbackTran();
                        PubMethod.WirteExp(ex);
                    }
                }
            });
            return(Json(model));
        }
Example #2
0
 public ActionResult Ask()
 {
     if (IsLogin.IsFalse())
     {
         return(this.Redirect("/Home/Login"));
     }
     ViewBag.ForList = base.GetForumsList;
     return(View());
 }
Example #3
0
        //public bool _isValid = isGQ();

        //public static bool isGQ()
        //{
        //    TimeSpan ts = DateTime.Now - CreateDate;
        //    return ts.TotalSeconds <= 180; //180秒(3分钟)之内有效
        //}

        ///// <summary>
        ///// 判断是否有效,有效时间为190秒
        ///// </summary>
        ///// <returns></returns>
        //public bool IsValid
        //{
        //    get
        //    {
        //        TimeSpan ts = DateTime.Now - CreateDate;
        //        return ts.TotalSeconds <= 180; //180秒(3分钟)之内有效
        //    }
        //    set {
        //        _isValid = value;
        //    }
        //}

        /// <summary>
        /// 转换为json字符串
        /// </summary>
        /// <param name="connectionId"></param>
        /// <returns></returns>
        public string ToJson(string connectionId, QRCodeTypes qrCodeType, string targetUrl)
        {
            StringBuilder result = new StringBuilder();

            result.Append("{");
            result.AppendFormat("\"connectionid\":\"{0}\",", connectionId);
            result.AppendFormat("\"uuid\":\"{0}\",", UUID);

            result.AppendFormat("\"targetUrl\":\"{0}\",", targetUrl);

            //result.AppendFormat("\"userName\":\"{0}\",", UserName);
            //result.AppendFormat("\"password\":\"{0}\",", Password);

            result.AppendFormat("\"qrCodeType\":\"{0}\",", qrCodeType);

            result.AppendFormat("\"islogin\":{0},", IsLogin.ToString().ToLower().Equals("false") ? 0 : 1);
            result.AppendFormat("\"isvalid\":{0}", IsValid().ToString().ToLower().Equals("false") ? 0 : 1);

            //result.AppendFormat("\"createdate\":\"{0}\"", CreateDate.ToString(CultureInfo.InvariantCulture).ToLower());
            //result.AppendFormat("\"nowdate\":\"{0}\"", DateTime.Now.ToString(CultureInfo.InvariantCulture).ToLower());
            result.Append("}");
            return(result.ToString());

            //var isLogin = IsLogin.ToString().ToLower().Equals("false") ? false  : true;
            //var isvalid = IsValid().ToString().ToLower().Equals("false") ? false : true;
            //var obj = new JsonRes()
            //{
            //    Connectionid = connectionId,
            //    QRCodeType = qrCodeType,
            //    UUID = UUID,
            //    IsLogin = isLogin,
            //    IsValid = isvalid,
            //    UserName = UserName,
            //    Password = Password
            //};
            //var jsonStr = JsonHelper.JsonSerialize.ObjectToJsonByDCJS(obj);
            //return jsonStr;
        }