Пример #1
0
 /// <summary>
 /// 申请提现处理
 /// </summary>
 public ActionResult ApplyMoneyDeal()
 {
     try
     {
         var id    = ZNRequest.GetInt("ID");
         var model = db.Single <ApplyMoney>(x => x.ID == id);
         if (model != null)
         {
             model.Status = Enum_Status.Approved;
             var result = db.Update <ApplyMoney>(model);
             if (result > 0)
             {
                 return(Json(new { result = true, message = "成功" }, JsonRequestBehavior.AllowGet));
             }
         }
         else
         {
             return(Json(new { result = false, message = "当前记录不存在" }, JsonRequestBehavior.AllowGet));
         }
     }
     catch (Exception ex)
     {
         LogHelper.ErrorLoger.Error("SystemController_ApplyMoneyDeal:" + ex.Message);
     }
     return(Json(new { result = false, message = "失败" }, JsonRequestBehavior.AllowGet));
 }
Пример #2
0
 public ActionResult EditArticleTemp()
 {
     try
     {
         var ArticleID = ZNRequest.GetInt("ArticleID");
         var Template  = ZNRequest.GetInt("Template");
         var result    = new SubSonic.Query.Update <Article>(provider).Set("Template").EqualTo(Template).Where <Article>(x => x.ID == ArticleID).Execute() > 0;
         if (result)
         {
             //取消自定义模板启用
             string ArticleNumber = ZNRequest.GetString("ArticleNumber");
             if (!string.IsNullOrWhiteSpace(ArticleNumber) && Template != 1)
             {
                 var list = db.Find <Background>(x => x.ArticleNumber == ArticleNumber && x.IsUsed == Enum_Used.Approved).ToList();
                 if (list.Count > 0)
                 {
                     list.ForEach(x =>
                     {
                         x.IsUsed = Enum_Used.Audit;
                     });
                     db.UpdateMany <Background>(list);
                 }
             }
             return(Json(new { result = true, message = "成功" }, JsonRequestBehavior.AllowGet));
         }
     }
     catch (Exception ex)
     {
         LogHelper.ErrorLoger.Error("ArticleController_EditArticleTemp:" + ex.Message);
     }
     return(Json(new { result = false, message = "失败" }, JsonRequestBehavior.AllowGet));
 }
Пример #3
0
 public ActionResult EditArticleType()
 {
     try
     {
         var ArticleID = ZNRequest.GetInt("ArticleID");
         var TypeID    = ZNRequest.GetInt("ArticleType");
         if (TypeID <= 0)
         {
             return(Json(new { result = false, message = "参数异常" }, JsonRequestBehavior.AllowGet));
         }
         var articleType = AppHelper.GetArticleType().FirstOrDefault <ArticleType>(x => x.ID == TypeID);
         if (articleType == null)
         {
             return(Json(new { result = false, message = "不存在当前类型" }, JsonRequestBehavior.AllowGet));
         }
         var result = new SubSonic.Query.Update <Article>(provider).Set("TypeID").EqualTo(TypeID).Set("TypeIDList").EqualTo(articleType.ParentIDList).Where <Article>(x => x.ID == ArticleID).Execute() > 0;
         if (result)
         {
             return(Json(new { result = true, message = "成功" }, JsonRequestBehavior.AllowGet));
         }
     }
     catch (Exception ex)
     {
         LogHelper.ErrorLoger.Error("ArticleController_EditArticleType:" + ex.Message);
     }
     return(Json(new { result = false, message = "失败" }, JsonRequestBehavior.AllowGet));
 }
Пример #4
0
        public string Detail()
        {
            ApiResult result = new ApiResult();

            try
            {
                var id = ZNRequest.GetInt("ID");
                if (id <= 0)
                {
                    result.message = "参数异常";
                    return(JsonConvert.SerializeObject(result));
                }
                var model = db.Single <Comment>(x => x.ID == id);
                if (model == null)
                {
                    result.message = "数据异常";
                    return(JsonConvert.SerializeObject(result));
                }
                var user = db.Single <User>(x => x.Number == model.CreateUserNumber);
                model.UserID         = user == null ? 0 : user.ID;
                model.UserNumber     = user == null ? "" : user.Number;
                model.NickName       = user == null ? "" : user.NickName;
                model.Avatar         = user == null ? "" : user.Avatar;
                model.ArticleID      = model.ArticleID;
                model.CreateDateText = FormatTime(model.CreateDate);
                result.result        = true;
                result.message       = model;
            }
            catch (Exception ex)
            {
                LogHelper.ErrorLoger.Error("Api_Comment_Detail:" + ex.Message);
                result.message = ex.Message;
            }
            return(JsonConvert.SerializeObject(result));
        }
Пример #5
0
 /// <summary>
 /// 删除
 /// </summary>
 public ActionResult Delete()
 {
     try
     {
         User user = GetUserInfo();
         if (user == null)
         {
             return(Json(new { result = false, message = "用户信息验证失败", code = Enum_ErrorCode.UnLogin }, JsonRequestBehavior.AllowGet));
         }
         var     id      = ZNRequest.GetInt("ArticleID");
         Article article = db.Single <Article>(x => x.ID == id);
         if (article == null)
         {
             return(Json(new { result = false, message = "文章信息异常" }, JsonRequestBehavior.AllowGet));
         }
         if (article.CreateUserNumber != user.Number)
         {
             return(Json(new { result = false, message = "没有权限", code = Enum_ErrorCode.NoPower }, JsonRequestBehavior.AllowGet));
         }
         var result = new SubSonic.Query.Update <Article>(provider).Set("Status").EqualTo(Enum_Status.Delete).Set("Submission").EqualTo(Enum_Submission.TemporaryApproved).Where <Article>(x => x.ID == article.ID).Execute() > 0;
         if (result)
         {
             return(Json(new { result = true, message = "成功" }, JsonRequestBehavior.AllowGet));
         }
     }
     catch (Exception ex)
     {
         LogHelper.ErrorLoger.Error("ArticleController_Delete:" + ex.Message);
     }
     return(Json(new { result = false, message = "失败" }, JsonRequestBehavior.AllowGet));
 }
Пример #6
0
        public override void OnActionExecuting(ActionExecutingContext filterContext)
        {
            var id = ZNRequest.GetInt("ID");

            if (id == 0)
            {
                filterContext.HttpContext.Response.Cache.SetCacheability(HttpCacheability.NoCache);
                filterContext.Result = new JsonResult()
                {
                    Data = new { result = false, message = "用户信息验证失败", code = Enum_ErrorCode.UnLogin }, JsonRequestBehavior = JsonRequestBehavior.AllowGet
                };
                return;
            }
            User user = db.Single <User>(x => x.ID == id);

            if (user == null)
            {
                filterContext.HttpContext.Response.Cache.SetCacheability(HttpCacheability.NoCache);
                filterContext.Result = new JsonResult()
                {
                    Data = new { result = false, message = "用户信息验证失败", code = Enum_ErrorCode.UnLogin }, JsonRequestBehavior = JsonRequestBehavior.AllowGet
                };
                return;
            }
            var ArticleID = ZNRequest.GetInt("ArticleID");

            if (ArticleID <= 0)
            {
                filterContext.HttpContext.Response.Cache.SetCacheability(HttpCacheability.NoCache);
                filterContext.Result = new JsonResult()
                {
                    Data = new { result = false, message = "参数异常" }, JsonRequestBehavior = JsonRequestBehavior.AllowGet
                };
                return;
            }
            Article article = db.Single <Article>(x => x.ID == ArticleID);

            if (article == null)
            {
                filterContext.HttpContext.Response.Cache.SetCacheability(HttpCacheability.NoCache);
                filterContext.Result = new JsonResult()
                {
                    Data = new { result = false, message = "文章信息异常" }, JsonRequestBehavior = JsonRequestBehavior.AllowGet
                };
                return;
            }
            if (article.CreateUserNumber != user.Number)
            {
                filterContext.HttpContext.Response.Cache.SetCacheability(HttpCacheability.NoCache);
                filterContext.Result = new JsonResult()
                {
                    Data = new { result = false, message = "没有权限", code = Enum_ErrorCode.NoPower }, JsonRequestBehavior = JsonRequestBehavior.AllowGet
                };
                return;
            }
            base.OnActionExecuting(filterContext);
            return;
        }
Пример #7
0
        public ActionResult Recommend()
        {
            try
            {
                var UserNumber    = ZNRequest.GetString("UserNumber");
                var ArticleNumber = ZNRequest.GetString("ArticleNumber");
                var ArticlePower  = ZNRequest.GetInt("ArticlePower");
                if (string.IsNullOrWhiteSpace(UserNumber) || string.IsNullOrWhiteSpace(ArticleNumber))
                {
                    return(Json(new { result = false, message = "参数异常" }, JsonRequestBehavior.AllowGet));
                }

                //判断文章权限,公开的才可以投稿
                var article = db.Single <Article>(x => x.Number == ArticleNumber);
                if (article == null)
                {
                    return(Json(new { result = false, message = "文章信息异常" }, JsonRequestBehavior.AllowGet));
                }
                if (article.TypeID == 0)
                {
                    return(Json(new { result = false, message = "请选择文章分类" }, JsonRequestBehavior.AllowGet));
                }
                if (article.ArticlePower != Enum_ArticlePower.Public)
                {
                    if (ArticlePower != Enum_ArticlePower.Public)
                    {
                        return(Json(new { result = false, message = "公开文章才可以投稿哦" }, JsonRequestBehavior.AllowGet));
                    }
                }
                var time = DateTime.Now.AddDays(-1);
                var log  = db.Single <ArticleRecommend>(x => x.CreateUserNumber == UserNumber && x.ArticleNumber == ArticleNumber && x.CreateDate > time);
                if (log != null)
                {
                    return(Json(new { result = false, message = "每天只有1次投稿机会,上次投稿时间为:" + log.CreateDate.ToString("yyyy-MM-dd hh:mm:ss") }, JsonRequestBehavior.AllowGet));
                }

                //修改文章投稿记录
                var result = new SubSonic.Query.Update <Article>(provider).Set("Submission").EqualTo(Enum_Submission.Audit).Set("ArticlePower").EqualTo(Enum_ArticlePower.Public).Where <Article>(x => x.ID == article.ID).Execute() > 0;

                ArticleRecommend model = new ArticleRecommend();
                model.ArticleNumber    = ArticleNumber;
                model.CreateUserNumber = UserNumber;
                model.CreateDate       = DateTime.Now;
                model.CreateIP         = Tools.GetClientIP;
                model.Status           = Enum_Status.Audit;
                result = Tools.SafeInt(db.Add <ArticleRecommend>(model)) > 0;
                if (result)
                {
                    return(Json(new { result = true, message = "成功" }, JsonRequestBehavior.AllowGet));
                }
            }
            catch (Exception ex)
            {
                LogHelper.ErrorLoger.Error("ArticleController_Recommend:" + ex.Message);
            }
            return(Json(new { result = false, message = "失败" }, JsonRequestBehavior.AllowGet));
        }
Пример #8
0
        /// <summary>
        /// APP访问用户信息
        /// </summary>
        protected User GetUserInfo()
        {
            var id = ZNRequest.GetInt("ID");

            if (id == 0)
            {
                return(null);
            }
            return(db.Single <User>(x => x.ID == id));
        }
Пример #9
0
        /// <summary>
        /// 清除推送信息
        /// </summary>
        public ActionResult Clear()
        {
            var number   = ZNRequest.GetString("number");
            var pushtype = ZNRequest.GetInt("pushtype");

            if (string.IsNullOrWhiteSpace(number))
            {
                return(Json(false, JsonRequestBehavior.AllowGet));
            }
            var list = new List <PushLog>();

            list = logdb.Find <PushLog>(x => x.PushType == pushtype && x.Number == number).ToList();
            logdb.DeleteMany <PushLog>(list);
            return(Json(true, JsonRequestBehavior.AllowGet));
        }
Пример #10
0
        /// <summary>
        /// 管理员打赏红包
        /// </summary>
        public ActionResult AdminRed()
        {
            try
            {
                var number = ZNRequest.GetString("number");
                if (string.IsNullOrWhiteSpace(number))
                {
                    return(Json(new { result = false, message = "参数异常" }, JsonRequestBehavior.AllowGet));
                }
                var exist = db.Find <Red>(x => x.ToUserNumber == number && x.RedType == Enum_RedType.Admin).ToList().Exists(x => x.CreateDate.ToString("yyyyMMdd") == DateTime.Now.ToString("yyyyMMdd"));
                if (exist)
                {
                    return(Json(new { result = false, message = "今日已打赏红包" }, JsonRequestBehavior.AllowGet));
                }
                var model = new Red();
                model.ToUserNumber = number;
                model.Price        = ZNRequest.GetInt("price");
                if (model.Price <= 0 || model.Price > 500)
                {
                    model.Price = new Random().Next(10, 500);
                    if (model.Price <= 0)
                    {
                        model.Price = 10;
                    }
                    if (model.Price > 500)
                    {
                        model.Price = 500;
                    }
                }
                model.Status     = Enum_Red.Audit;
                model.Number     = Guid.NewGuid().ToString("N");
                model.RedType    = Enum_RedType.Admin;
                model.CreateDate = DateTime.Now;
                db.Add <Red>(model);

                //推送消息
                new AppHelper().Push(model.ToUserNumber, 0, "", "", Enum_PushType.Red);

                //用户新增红包
                return(Json(new { result = true, message = model.Price }, JsonRequestBehavior.AllowGet));
            }
            catch (Exception ex)
            {
                LogHelper.ErrorLoger.Error("Red_AdminRed:" + ex.Message);
                return(Json(new { result = false, message = ex.Message }, JsonRequestBehavior.AllowGet));
            }
        }
Пример #11
0
        public string All()
        {
            ApiResult result = new ApiResult();

            try
            {
                var type = ZNRequest.GetInt("type");
                result.result  = true;
                result.message = AppHelper.GetHelp().FindAll(x => x.HelpType == type);
            }
            catch (Exception ex)
            {
                LogHelper.ErrorLoger.Error("Api_Help_All:" + ex.Message);
                result.message = ex.Message;
            }
            return(JsonConvert.SerializeObject(result));
        }
Пример #12
0
 public ActionResult EditBackground()
 {
     try
     {
         var ArticleID  = ZNRequest.GetInt("ArticleID");
         var background = ZNRequest.GetString("Background");
         var result     = new SubSonic.Query.Update <Article>(provider).Set("Background").EqualTo(background).Where <Article>(x => x.ID == ArticleID).Execute() > 0;
         if (result)
         {
             return(Json(new { result = true, message = "成功" }, JsonRequestBehavior.AllowGet));
         }
     }
     catch (Exception ex)
     {
         LogHelper.ErrorLoger.Error("ArticleController_EditBackground:" + ex.Message);
     }
     return(Json(new { result = false, message = "失败" }, JsonRequestBehavior.AllowGet));
 }
Пример #13
0
 public ActionResult EditShare()
 {
     try
     {
         var ArticleID       = ZNRequest.GetInt("ArticleID");
         var ArticleNumber   = ZNRequest.GetString("ArticleNumber");
         var TypeID          = ZNRequest.GetInt("ArticleType");
         var ArticlePower    = ZNRequest.GetInt("ArticlePower", Enum_ArticlePower.Myself);
         var ArticlePowerPwd = ZNRequest.GetString("ArticlePowerPwd");
         if (ArticlePower < 0)
         {
             return(Json(new { result = false, message = "请选择文章权限" }, JsonRequestBehavior.AllowGet));
         }
         if (TypeID <= 0)
         {
             return(Json(new { result = false, message = "请选择文章类别" }, JsonRequestBehavior.AllowGet));
         }
         var articleType = AppHelper.GetArticleType().FirstOrDefault <ArticleType>(x => x.ID == TypeID);
         if (articleType == null)
         {
             return(Json(new { result = false, message = "不存在当前类型" }, JsonRequestBehavior.AllowGet));
         }
         var result = new SubSonic.Query.Update <Article>(provider)
                      .Set("TypeID").EqualTo(TypeID)
                      .Set("TypeIDList").EqualTo(articleType.ParentIDList)
                      .Set("ArticlePower").EqualTo(ArticlePower)
                      .Set("ArticlePowerPwd").EqualTo(ArticlePowerPwd)
                      .Where <Article>(x => x.ID == ArticleID).Execute() > 0;
         if (result)
         {
             //用户相册是否展示
             var status = ArticlePower == Enum_ArticlePower.Public ? Enum_Status.Approved : Enum_Status.Audit;
             new SubSonic.Query.Update <ArticlePart>(provider).Set("Status").EqualTo(status).Where <ArticlePart>(x => x.ArticleNumber == ArticleNumber).Execute();
             return(Json(new { result = true, message = "成功" }, JsonRequestBehavior.AllowGet));
         }
     }
     catch (Exception ex)
     {
         LogHelper.ErrorLoger.Error("ArticleController_EditShare:" + ex.Message);
     }
     return(Json(new { result = false, message = "失败" }, JsonRequestBehavior.AllowGet));
 }
Пример #14
0
 /// <summary>
 /// 校验权限
 /// </summary>
 public ActionResult CheckPowerPwd()
 {
     try
     {
         var ArticleID = ZNRequest.GetInt("ArticleID");
         if (ArticleID <= 0)
         {
             return(Json(new { result = false, message = "参数异常" }, JsonRequestBehavior.AllowGet));
         }
         var pwd    = ZNRequest.GetString("ArticlePowerPwd");
         var result = db.Exists <Article>(x => x.ID == ArticleID && x.ArticlePower == Enum_ArticlePower.Password && x.ArticlePowerPwd == pwd && x.Status == Enum_Status.Approved);
         if (result)
         {
             return(Json(new { result = true, message = "成功" }, JsonRequestBehavior.AllowGet));
         }
     }
     catch (Exception ex)
     {
         LogHelper.ErrorLoger.Error("ArticleController_CheckPowerPwd:" + ex.Message);
     }
     return(Json(new { result = false, message = "失败" }, JsonRequestBehavior.AllowGet));
 }
Пример #15
0
 public ActionResult EditArticleCover()
 {
     try
     {
         var ArticleID = ZNRequest.GetInt("ArticleID");
         var Cover     = ZNRequest.GetString("Cover");
         if (string.IsNullOrWhiteSpace(Cover))
         {
             return(Json(new { result = false, message = "参数异常" }, JsonRequestBehavior.AllowGet));
         }
         var result = new SubSonic.Query.Update <Article>(provider).Set("Cover").EqualTo(Cover).Where <Article>(x => x.ID == ArticleID).Execute() > 0;
         if (result)
         {
             return(Json(new { result = true, message = "成功" }, JsonRequestBehavior.AllowGet));
         }
     }
     catch (Exception ex)
     {
         LogHelper.ErrorLoger.Error("ArticleController_EditArticleCover:" + ex.Message);
     }
     return(Json(new { result = false, message = "失败" }, JsonRequestBehavior.AllowGet));
 }
Пример #16
0
        public ActionResult EditArticlePower()
        {
            try
            {
                var     ArticleID       = ZNRequest.GetInt("ArticleID");
                Article article         = db.Single <Article>(x => x.ID == ArticleID);
                var     ArticlePower    = ZNRequest.GetInt("ArticlePower", Enum_ArticlePower.Myself);
                var     ArticlePowerPwd = ZNRequest.GetString("ArticlePowerPwd");
                var     result          = new SubSonic.Query.Update <Article>(provider).Set("ArticlePower").EqualTo(ArticlePower).Set("ArticlePowerPwd").EqualTo(ArticlePowerPwd).Where <Article>(x => x.ID == ArticleID).Execute() > 0;
                if (result)
                {
                    //用户相册是否展示
                    var status = ArticlePower == Enum_ArticlePower.Public ? Enum_Status.Approved : Enum_Status.Audit;
                    new SubSonic.Query.Update <ArticlePart>(provider).Set("Status").EqualTo(status).Where <ArticlePart>(x => x.ArticleNumber == article.Number).Execute();

                    return(Json(new { result = true, message = "成功" }, JsonRequestBehavior.AllowGet));
                }
            }
            catch (Exception ex)
            {
                LogHelper.ErrorLoger.Error("ArticleController_EditArticlePower:" + ex.Message);
            }
            return(Json(new { result = false, message = "失败" }, JsonRequestBehavior.AllowGet));
        }
Пример #17
0
        /// <summary>
        /// 编辑
        /// ShareType(0:文章,1:用户,2:新手红包,3:banner)
        /// </summary>
        public ActionResult Edit()
        {
            try
            {
                var      UserNumber = ZNRequest.GetString("UserNumber");
                var      Number     = ZNRequest.GetString("Number");
                var      ShareType  = ZNRequest.GetInt("ShareType");
                ShareLog model      = new ShareLog();
                model.CreateDate       = DateTime.Now;
                model.CreateUserNumber = UserNumber;
                model.CreateIP         = Tools.GetClientIP;
                model.ArticleNumber    = ShareType == 0 ? Number : "";
                model.UserNumber       = ShareType == 1 ? Number : "";
                model.Source           = ZNRequest.GetString("Source");
                var result = false;

                result = Tools.SafeInt(db.Add <ShareLog>(model)) > 0;
                if (result)
                {
                    if (ShareType == 0 && !string.IsNullOrWhiteSpace(Number))
                    {
                        Article article = new SubSonic.Query.Select(provider, "ID", "Shares", "Number").From <Article>().Where <Article>(x => x.Number == Number).ExecuteSingle <Article>();
                        if (article != null)
                        {
                            result = new SubSonic.Query.Update <Article>(provider).Set("Shares").EqualTo(article.Shares + 1).Where <Article>(x => x.ID == article.ID).Execute() > 0;
                        }
                    }
                }
                return(Json(new { result = true, message = "成功" }, JsonRequestBehavior.AllowGet));
            }
            catch (Exception ex)
            {
                LogHelper.ErrorLoger.Error("ShareLogController_Edit:" + ex.Message);
            }
            return(Json(new { result = false, message = "失败" }, JsonRequestBehavior.AllowGet));
        }
Пример #18
0
        public string Edit()
        {
            ApiResult result = new ApiResult();

            try
            {
                User user = GetUserInfo();
                if (user == null)
                {
                    result.message = EnumBase.GetDescription(typeof(Enum_ErrorCode), Enum_ErrorCode.UnLogin);
                    result.code    = Enum_ErrorCode.UnLogin;
                    return(JsonConvert.SerializeObject(result));
                }
                var ArticleNumber = ZNRequest.GetString("ArticleNumber");
                if (string.IsNullOrWhiteSpace(ArticleNumber))
                {
                    result.message = "文章信息异常";
                    return(JsonConvert.SerializeObject(result));
                }

                var summary = SqlFilter(ZNRequest.GetString("Summary"), false, false);
                if (string.IsNullOrWhiteSpace(summary))
                {
                    result.message = "请填写评论内容";
                    return(JsonConvert.SerializeObject(result));
                }
                summary = CutString(summary, 2000);
                var dirtyword = AppHelper.HasDirtyWord(summary);
                if (!string.IsNullOrWhiteSpace(dirtyword))
                {
                    result.message = "您的输入内容含有敏感内容[" + dirtyword + "],请检查后重试哦";
                    return(JsonConvert.SerializeObject(result));
                }

                Article article = new SubSonic.Query.Select(provider, "ID", "Number", "CreateUserNumber").From <Article>().Where <Article>(x => x.Number == ArticleNumber).ExecuteSingle <Article>();
                if (article == null)
                {
                    result.message = "文章信息异常";
                    return(JsonConvert.SerializeObject(result));
                }

                //判断是否拉黑
                var black = db.Exists <Black>(x => x.CreateUserNumber == article.CreateUserNumber && x.ToUserNumber == user.Number);
                if (black)
                {
                    result.code    = Enum_ErrorCode.NoPower;
                    result.message = "没有权限";
                    return(JsonConvert.SerializeObject(result));
                }

                Comment model = new Comment();
                model.ArticleNumber       = article.Number;
                model.ArticleUserNumber   = article.CreateUserNumber;
                model.Summary             = summary;
                model.Number              = BuildNumber();
                model.CreateDate          = DateTime.Now;
                model.CreateUserNumber    = user.Number;
                model.CreateIP            = Tools.GetClientIP;
                model.ParentCommentNumber = ZNRequest.GetString("ParentCommentNumber");
                model.ParentUserNumber    = ZNRequest.GetString("ParentUserNumber");

                model.Province     = ZNRequest.GetString("Province");
                model.City         = ZNRequest.GetString("City");
                model.District     = ZNRequest.GetString("District");
                model.Street       = ZNRequest.GetString("Street");
                model.DetailName   = ZNRequest.GetString("DetailName");
                model.CityCode     = ZNRequest.GetString("CityCode");
                model.Latitude     = Tools.SafeDouble(ZNRequest.GetString("Latitude"));
                model.Longitude    = Tools.SafeDouble(ZNRequest.GetString("Longitude"));
                model.ShowPosition = ZNRequest.GetInt("ShowPosition");
                model.ID           = Tools.SafeInt(db.Add <Comment>(model));
                if (model.ID > 0)
                {
                    result.result  = true;
                    result.message = model.ID;

                    //推送
                    new AppHelper().Push(article.CreateUserNumber, article.ID, article.Number, user.NickName, Enum_PushType.Comment, false);
                }
            }
            catch (Exception ex)
            {
                LogHelper.ErrorLoger.Error("Api_Comment_Edit:" + ex.Message);
                result.message = ex.Message;
            }
            return(JsonConvert.SerializeObject(result));
        }
Пример #19
0
        public string ArticleComment()
        {
            ApiResult result = new ApiResult();

            try
            {
                var pager         = new Pager();
                var id            = ZNRequest.GetInt("NewId");
                var ArticleNumber = ZNRequest.GetString("ArticleNumber");
                if (string.IsNullOrWhiteSpace(ArticleNumber))
                {
                    result.message = "参数异常";
                    return(JsonConvert.SerializeObject(result));
                }
                var UserNumber = ZNRequest.GetString("UserNumber");

                var query       = new SubSonic.Query.Select(provider).From <Comment>().Where <Comment>(x => x.ArticleNumber == ArticleNumber && x.ParentCommentNumber == "");
                var recordCount = query.GetRecordCount();
                if (recordCount == 0)
                {
                    result.result  = true;
                    result.message = new { records = recordCount, totalpage = 1 };
                    return(JsonConvert.SerializeObject(result));
                }
                if (recordCount == 1 && id > 0)
                {
                    result.result  = true;
                    result.message = new { records = recordCount, totalpage = 1 };
                    return(JsonConvert.SerializeObject(result));
                }
                query = query.And("ID").IsNotEqualTo(id);

                var totalPage = recordCount % pager.Size == 0 ? recordCount / pager.Size : recordCount / pager.Size + 1;

                var isNew = ZNRequest.GetInt("New");
                var list  = new List <Comment>();
                if (isNew > 0)
                {
                    list = query.Paged(pager.Index, pager.Size).OrderDesc("ID").ExecuteTypedList <Comment>();
                }
                else
                {
                    list = query.Paged(pager.Index, pager.Size).OrderAsc("ID").ExecuteTypedList <Comment>();
                }
                var users                  = new SubSonic.Query.Select(provider, "ID", "NickName", "Avatar", "Number").From <User>().Where("Number").In(list.Select(x => x.CreateUserNumber).Distinct().ToArray()).ExecuteTypedList <User>();
                var parentComments         = new SubSonic.Query.Select(provider, "ID", "ParentCommentNumber", "Number", "CreateUserNumber").From <Comment>().Where("ParentCommentNumber").In(list.Select(x => x.Number).ToArray()).ExecuteTypedList <Comment>();
                var zans                   = db.Find <CommentZan>(x => x.CreateUserNumber == UserNumber).ToList();
                List <CommentJson> newlist = new List <CommentJson>();
                list.ForEach(x =>
                {
                    CommentJson model = new CommentJson();
                    var user          = users.FirstOrDefault(y => y.Number == x.CreateUserNumber);
                    if (user == null)
                    {
                        return;
                    }
                    model.ID             = x.ID;
                    model.Summary        = x.Summary;
                    model.Goods          = x.Goods;
                    model.Number         = x.Number;
                    model.CreateDateText = FormatTime(x.CreateDate);
                    model.ShowPosition   = x.ShowPosition;
                    model.City           = x.City;
                    if (string.IsNullOrWhiteSpace(model.City))
                    {
                        model.ShowPosition = 0;
                    }
                    model.UserID          = user.ID;
                    model.UserNumber      = user.Number;
                    model.NickName        = user.NickName;
                    model.Avatar          = user.Avatar;
                    model.SubCommentCount = parentComments.Count(y => y.ParentCommentNumber == x.Number);
                    if (model.SubCommentCount == 1)
                    {
                        var subuser = db.Single <User>(y => y.Number == parentComments[0].CreateUserNumber);
                        var comment = db.Single <Comment>(y => y.Number == parentComments[0].Number);
                        if (subuser == null && comment == null)
                        {
                            model.SubCommentCount = 0;
                        }
                        if (subuser != null)
                        {
                            model.SubUserName = subuser.NickName;
                        }
                        if (comment != null)
                        {
                            model.SubSummary = comment.Summary;
                        }
                    }
                    model.ArticleNumber = x.ArticleNumber;
                    model.IsZan         = zans.Count(y => y.CommentNumber == x.Number);
                    newlist.Add(model);
                });
                result.result  = true;
                result.message = new
                {
                    currpage  = pager.Index,
                    records   = recordCount,
                    totalpage = totalPage,
                    list      = newlist
                };
            }
            catch (Exception ex)
            {
                LogHelper.ErrorLoger.Error("Api_ArticleComment_All:" + ex.Message);
                result.message = ex.Message;
            }
            return(JsonConvert.SerializeObject(result));
        }
Пример #20
0
        public string List()
        {
            ApiResult result = new ApiResult();

            try
            {
                var ActionID   = ZNRequest.GetInt("ActionID");
                var UserNumber = ZNRequest.GetString("UserNumber");
                if (string.IsNullOrWhiteSpace(UserNumber))
                {
                    result.message = "参数异常";
                    return(JsonConvert.SerializeObject(result));
                }

                //我的关注
                var follows = db.Find <Fan>(x => x.CreateUserNumber == UserNumber).ToList();
                if (follows.Count == 0)
                {
                    result.message = new { records = 0, totalpage = 1 };
                    return(JsonConvert.SerializeObject(result));
                }

                var pager = new Pager();
                var query = new SubSonic.Query.Select(provider).From <UserAction>().Where("CreateUserNumber").In(follows.Select(x => x.ToUserNumber).ToArray());
                //if (ActionID > 0)
                //{
                //    query = query.And("ID").IsLessThan(ActionID);
                //}
                var recordCount = query.GetRecordCount();
                if (recordCount == 0)
                {
                    result.message = new { records = recordCount, totalpage = 1 };
                    return(JsonConvert.SerializeObject(result));
                }

                var totalPage = recordCount % pager.Size == 0 ? recordCount / pager.Size : recordCount / pager.Size + 1;
                var list      = query.Paged(pager.Index, pager.Size).OrderDesc("ID").ExecuteTypedList <UserAction>();

                var like     = Enum_ActionType.Like;
                var follow   = Enum_ActionType.Follow;
                var keep     = Enum_ActionType.Keep;
                var userList = new List <string>();
                list.ForEach(x =>
                {
                    userList.Add(x.CreateUserNumber);
                });
                var newlist = new List <UserActionJson>();
                if (list.Count > 0)
                {
                    var allUser = new SubSonic.Query.Select(provider, "ID", "NickName", "Avatar", "Cover", "Number").From <User>().Where <User>(y => y.Status == Enum_Status.Approved).And("Number").In(userList.Distinct().ToArray()).ExecuteTypedList <User>();
                    list.ForEach(x =>
                    {
                        var userModel = allUser.FirstOrDefault(y => y.Number == x.CreateUserNumber);
                        if (userModel != null)
                        {
                            UserActionJson action  = new UserActionJson();
                            action.ID              = x.ID;
                            action.Number          = x.CreateUserNumber;
                            action.NickName        = userModel.NickName;
                            action.Avatar          = userModel.Avatar;
                            action.Cover           = userModel.Cover;
                            action.CreateTime      = FormatTime(x.CreateTime);
                            action.ActionType      = x.ActionType;
                            action.ArticleInfoJson = new List <ArticleInfoJson>();
                            action.UserInfoJson    = new List <UserInfoJson>();
                            //喜欢、收藏
                            if (x.ActionType == like || x.ActionType == keep)
                            {
                                var articles = new SubSonic.Query.Select(provider, "ID", "Number", "Cover", "ArticlePower", "CreateUserNumber", "Status", "Title").From <Article>().Where("Number").In(x.ActionInfo.Split(',')).And("Status").IsEqualTo(Enum_Status.Approved).And("ArticlePower").IsEqualTo(Enum_ArticlePower.Public).And("Submission").IsGreaterThan(Enum_Submission.Audit).ExecuteTypedList <Article>();
                                if (articles.Count > 0)
                                {
                                    articles.ForEach(y =>
                                    {
                                        ArticleInfoJson article = new ArticleInfoJson();
                                        article.ID           = y.ID;
                                        article.Title        = y.Title;
                                        article.Number       = y.Number;
                                        article.Cover        = y.Cover;
                                        article.ArticlePower = y.ArticlePower;
                                        action.ArticleInfoJson.Add(article);
                                    });

                                    action.ArticleInfoJson.Reverse();

                                    newlist.Add(action);
                                }
                            }
                            //关注
                            if (x.ActionType == follow)
                            {
                                var users = new SubSonic.Query.Select(provider, "ID", "NickName", "Avatar", "Cover", "Number").From <User>().Where <User>(y => y.Status == Enum_Status.Approved).And("Number").In(x.ActionInfo.Split(',')).ExecuteTypedList <User>();
                                if (users.Count > 0)
                                {
                                    users.ForEach(y =>
                                    {
                                        UserInfoJson user = new UserInfoJson();
                                        user.ID           = y.ID;
                                        user.NickName     = y.NickName;
                                        user.Number       = y.Number;
                                        user.Avatar       = y.Avatar;
                                        user.Cover        = y.Cover;
                                        action.UserInfoJson.Add(user);
                                    });

                                    action.ArticleInfoJson.Reverse();

                                    newlist.Add(action);
                                }
                            }
                        }
                    });
                }
                result.result  = true;
                result.message = new
                {
                    currpage  = pager.Index,
                    records   = recordCount,
                    totalpage = totalPage,
                    list      = newlist
                };
            }
            catch (Exception ex)
            {
                LogHelper.ErrorLoger.Error("Api/UserAction/List:" + ex.Message);
                result.message = ex.Message;
            }
            return(JsonConvert.SerializeObject(result));
        }
Пример #21
0
        public string Edit()
        {
            ApiResult result = new ApiResult();

            try
            {
                User user = GetUserInfo();
                if (user == null)
                {
                    result.message = EnumBase.GetDescription(typeof(Enum_ErrorCode), Enum_ErrorCode.UnLogin);
                    result.code    = Enum_ErrorCode.UnLogin;
                    return(JsonConvert.SerializeObject(result));
                }
                var number = ZNRequest.GetString("ArticleNumber");
                var url    = ZNRequest.GetString("Url");
                if (string.IsNullOrWhiteSpace(number) || string.IsNullOrWhiteSpace(url))
                {
                    result.message = "信息异常";
                    return(JsonConvert.SerializeObject(result));
                }
                var        id    = ZNRequest.GetInt("EditID");
                Background model = new Background();
                if (id > 0)
                {
                    model = db.Single <Background>(x => x.ID == id);
                }
                else
                {
                    model.Number           = BuildNumber();
                    model.ArticleNumber    = number;
                    model.CreateUserNumber = user.Number;
                    model.IsUsed           = Enum_Used.Approved;
                }
                model.Full         = ZNRequest.GetInt("Full");
                model.High         = ZNRequest.GetInt("High");
                model.Transparency = ZNRequest.GetInt("Transparency");
                model.Url          = url;
                var success = false;
                if (id == 0)
                {
                    success = Tools.SafeInt(db.Add <Background>(model)) > 0;
                    if (success)
                    {
                        //取消启用
                        var list = db.Find <Background>(x => x.ArticleNumber == number && x.Number != model.Number && x.IsUsed == Enum_Used.Approved).ToList();
                        if (list.Count > 0)
                        {
                            list.ForEach(x =>
                            {
                                x.IsUsed = Enum_Used.Audit;
                            });
                            db.UpdateMany <Background>(list);
                        }
                    }
                }
                else
                {
                    success = db.Update <Background>(model) > 0;
                }
                if (success)
                {
                    result.result  = true;
                    result.message = model.Number;
                }
            }
            catch (Exception ex)
            {
                LogHelper.ErrorLoger.Error("Api_Background_Edit" + ex.Message);
                result.message = ex.Message;
            }
            return(JsonConvert.SerializeObject(result));
        }
Пример #22
0
        public ActionResult AddWxOrder()
        {
            try
            {
                //创建订单
                Order order = new Order();
                order.OrderNumber = Guid.NewGuid().ToString("N");
                order.CreateDate  = DateTime.Now;
                order.PayType     = 2;
                order.Status      = Enum_Status.Audit;
                order.Summary     = "我的微篇-打赏";
                order.Price       = ZNRequest.GetInt("Money", 0);//单位:分
                if (order.Price == 0)
                {
                    order.Price = 1;
                }
                order.Anony            = ZNRequest.GetInt("Anony", 0);
                order.CreateUserNumber = ZNRequest.GetString("UserNumber");
                order.ToArticleNumber  = ZNRequest.GetString("ArticleNumber");
                if (string.IsNullOrWhiteSpace(order.ToArticleNumber))
                {
                    order.ToUserNumber = ZNRequest.GetString("ArticleUserNumber");
                }
                else
                {
                    var toUserNumber = db.Single <Article>(x => x.Number == order.ToArticleNumber);
                    order.ToUserNumber = toUserNumber == null ? "" : toUserNumber.CreateUserNumber;
                }
                order.CreateIP = Tools.GetClientIP;
                db.Add <Order>(order);

                string wx_prepay = "https://api.mch.weixin.qq.com/pay/unifiedorder";

                string body         = order.Summary;
                string nonce_str    = GetMD5(DateTime.Now.ToString("yyyyMMddhhmmssffff"));
                string notify_url   = Base_Url + "Notify/WxPay/";//支付成功回调
                string out_trade_no = order.OrderNumber;
                string appid        = System.Configuration.ConfigurationManager.AppSettings["wxappid"];
                string partner      = System.Configuration.ConfigurationManager.AppSettings["wxapppartner"];
                string partnerKey   = System.Configuration.ConfigurationManager.AppSettings["wxapppartnerkey"];

                string spbill_create_ip = Tools.GetClientIP;
                string total_fee        = order.Price.ToString();//总金额。

                string signString = "appid=" + appid + "&attach=" + body + "&body=" + body + "&mch_id=" + partner + "&nonce_str=" + nonce_str + "&notify_url=" + notify_url + "&out_trade_no=" + out_trade_no + "&spbill_create_ip=" + spbill_create_ip + "&total_fee=" + total_fee + "&trade_type=APP" + "&key=" + partnerKey;

                string md5SignValue = GetMD5(signString);

                StringBuilder strXML = new StringBuilder();
                strXML.Append("<xml>");
                strXML.Append("<appid>" + appid + "</appid>");
                strXML.Append("<attach>" + body + "</attach>");
                strXML.Append("<body>" + body + "</body>");
                strXML.Append("<mch_id>" + partner + "</mch_id>");
                strXML.Append("<nonce_str>" + nonce_str + "</nonce_str>");
                strXML.Append("<notify_url>" + notify_url + "</notify_url>");
                strXML.Append("<out_trade_no>" + out_trade_no + "</out_trade_no>");
                strXML.Append("<spbill_create_ip>" + spbill_create_ip + "</spbill_create_ip>");
                strXML.Append("<total_fee>" + total_fee + "</total_fee>");
                strXML.Append("<trade_type>APP</trade_type>");
                strXML.Append("<sign>" + md5SignValue + "</sign>");
                strXML.Append("</xml>");

                //LogHelper.ErrorLoger.Error("NotifyController_AddWxOrder1:" + strXML.ToString());

                string strSource = GetHttp(wx_prepay, strXML.ToString());

                //LogHelper.ErrorLoger.Error("NotifyController_AddWxOrder2:" + strSource);

                if (strSource.IndexOf("prepay_id") > 0)
                {
                    XmlDocument doc = new XmlDocument();
                    doc.LoadXml(strSource);
                    XmlNode node_prepay_id = doc.LastChild.ChildNodes.Item(7);
                    string  prepayid       = node_prepay_id.InnerText;
                    long    timeStamp      = MakeTimestamp();

                    Hashtable paySignReqHandler = new Hashtable();
                    paySignReqHandler.Add("appid", appid);
                    paySignReqHandler.Add("partnerid", partner);
                    paySignReqHandler.Add("prepayid", prepayid);
                    paySignReqHandler.Add("noncestr", nonce_str);
                    paySignReqHandler.Add("package", "Sign=WXPay");
                    paySignReqHandler.Add("timestamp", timeStamp.ToString());
                    var paySign = CreateMd5Sign(paySignReqHandler, partnerKey);

                    //LogHelper.ErrorLoger.Error("NotifyController_AddWxOrder3:" + paySign);

                    var obj = new { appid = appid, noncestr = nonce_str, package = "Sign=WXPay", partnerid = partner, prepayid = prepayid, timestamp = timeStamp, sign = paySign };

                    return(Content(Newtonsoft.Json.JsonConvert.SerializeObject(obj)));
                }
                else
                {
                    return(Content(string.Empty));
                }
            }
            catch (Exception ex)
            {
                LogHelper.ErrorLoger.Error("NotifyController_AddWxOrder_Error:" + ex.Message);
                return(Content(string.Empty));
            }
        }
Пример #23
0
 public Pager()
 {
     this.Index = ZNRequest.GetInt("page", 1);
     this.Size  = ZNRequest.GetInt("rows", 15);
 }
Пример #24
0
        public string Detail()
        {
            ApiResult result = new ApiResult();

            try
            {
                string UserNumber = ZNRequest.GetString("Number");
                if (string.IsNullOrWhiteSpace(UserNumber))
                {
                    result.message = "参数异常";
                    return(JsonConvert.SerializeObject(result));
                }
                var user = db.Single <User>(x => x.Number == UserNumber);
                if (user == null)
                {
                    result.code    = Enum_ErrorCode.UnLogin;
                    result.message = "参数异常";
                    return(JsonConvert.SerializeObject(result));
                }
                int id = ZNRequest.GetInt("ArticleID");
                if (id == 0)
                {
                    result.message = "参数异常";
                    return(JsonConvert.SerializeObject(result));
                }
                Article model = db.Single <Article>(x => x.ID == id);
                if (model == null)
                {
                    result.message = "文章信息异常";
                    return(JsonConvert.SerializeObject(result));
                }
                if (model.Status == Enum_Status.Audit)
                {
                    result.message = "当前文章未通过审核";
                    return(JsonConvert.SerializeObject(result));
                }

                //非本人
                if ((model.Status == Enum_Status.Delete || model.Status == Enum_Status.DeleteCompletely) && UserNumber != model.CreateUserNumber)
                {
                    result.code    = Enum_ErrorCode.Delete;
                    result.message = "当前文章已删除";
                    return(JsonConvert.SerializeObject(result));
                }

                //判断黑名单
                if (db.Exists <Black>(x => x.ToUserNumber == UserNumber && x.CreateUserNumber == model.CreateUserNumber))
                {
                    result.message = "没有访问权限";
                    return(JsonConvert.SerializeObject(result));
                }

                string password = ZNRequest.GetString("ArticlePassword");

                //浏览数
                new SubSonic.Query.Update <Article>(provider).Set("Views").EqualTo(model.Views + 1).Where <Article>(x => x.ID == model.ID).Execute();
                model.Pays     = new SubSonic.Query.Select(provider).From <Order>().Where <Order>(x => x.ToArticleNumber == model.Number && x.Status == Enum_Status.Approved).GetRecordCount();
                model.Keeps    = new SubSonic.Query.Select(provider).From <Keep>().Where <Keep>(x => x.ArticleNumber == model.Number).GetRecordCount();
                model.Comments = new SubSonic.Query.Select(provider).From <Comment>().Where <Comment>(x => x.ArticleNumber == model.Number).GetRecordCount();

                //创建人
                User createUser = db.Single <User>(x => x.Number == model.CreateUserNumber);
                if (createUser != null)
                {
                    model.UserID    = createUser.ID;
                    model.NickName  = createUser.NickName;
                    model.Avatar    = createUser.Avatar;
                    model.AutoMusic = createUser.AutoMusic;
                    model.UserCover = createUser.Cover;
                    model.ShareNick = createUser.ShareNick;
                    model.IsPay     = createUser.IsPay;
                }


                //是否收藏
                model.IsKeep = new SubSonic.Query.Select(provider, "ID").From <Keep>().Where <Keep>(x => x.CreateUserNumber == UserNumber && x.ArticleNumber == model.Number).GetRecordCount() == 0 ? 0 : 1;

                //是否关注
                model.IsFollow = new SubSonic.Query.Select(provider, "ID").From <Fan>().Where <Fan>(x => x.CreateUserNumber == UserNumber && x.ToUserNumber == model.CreateUserNumber).GetRecordCount() == 0 ? 0 : 1;

                //是否点赞
                model.IsZan = new SubSonic.Query.Select(provider, "ID").From <ArticleZan>().Where <ArticleZan>(x => x.CreateUserNumber == UserNumber && x.ArticleNumber == model.Number).GetRecordCount() == 0 ? 0 : 1;

                //类型
                ArticleType articleType = AppHelper.GetArticleType().FirstOrDefault <ArticleType>(x => x.ID == model.TypeID);
                model.TypeName = articleType == null ? string.Empty : articleType.Name;

                //文章部分
                model.ArticlePart = db.Find <ArticlePart>(x => x.ArticleNumber == model.Number).OrderBy(x => x.SortID).ToList();

                model.CreateDateText = model.CreateDate.ToString("yyyy-MM-dd");
                model.ShareUrl       = System.Configuration.ConfigurationManager.AppSettings["share_url"] + model.Number;

                //模板配置
                model.BackgroundJson = db.Single <Background>(x => x.ArticleNumber == model.Number && x.IsUsed == Enum_Used.Approved);

                //模板预览
                var previewTemp = ZNRequest.GetInt("Template", -1);
                if (previewTemp >= 0)
                {
                    model.TemplateJson = AppHelper.GetArticleTemplate().FirstOrDefault(x => x.ID == previewTemp);
                }
                else
                {
                    if (model.Template >= 0)
                    {
                        model.TemplateJson = AppHelper.GetArticleTemplate().FirstOrDefault(x => x.ID == model.Template);
                    }
                }

                //主题色预览
                var previewColorTemp = ZNRequest.GetInt("ColorTemplate", 0);
                if (previewColorTemp > 0)
                {
                    model.ColorTemplateJson = AppHelper.GetColorTemplate().FirstOrDefault(x => x.ID == previewColorTemp);
                }
                else
                {
                    if (model.ColorTemplate > 0)
                    {
                        model.ColorTemplateJson = AppHelper.GetColorTemplate().FirstOrDefault(x => x.ID == model.ColorTemplate);
                    }
                }

                //漂浮装扮
                var custom = db.Single <ArticleCustom>(x => x.ArticleNumber == model.Number);
                if (custom != null)
                {
                    model.Showy        = custom.ShowyUrl;
                    model.MusicID      = custom.MusicID;
                    model.MusicName    = custom.MusicName;
                    model.MusicUrl     = custom.MusicUrl;
                    model.Transparency = custom.Transparency;
                    model.MarginTop    = custom.MarginTop;
                }

                result.result  = true;
                result.message = model;
            }
            catch (Exception ex)
            {
                LogHelper.ErrorLoger.Error("Api_Article_Detail:" + ex.Message);
                result.message = ex.Message;
            }
            return(JsonConvert.SerializeObject(result));
        }
Пример #25
0
        /// <summary>
        /// 检查更新
        /// </summary>
        public ActionResult CheckUpdate()
        {
            try
            {
                var client  = ZNRequest.GetString("client");
                var version = ZNRequest.GetString("version");
                var source  = ZNRequest.GetInt("source", 1);

                if (string.IsNullOrWhiteSpace(client) || string.IsNullOrWhiteSpace(version))
                {
                    return(Json(new { result = false, message = "失败" }, JsonRequestBehavior.AllowGet));
                }

                var currVersion = "";
                var currUrl     = "";
                if (client == "android")
                {
                    switch (source)
                    {
                    case 1:
                    case 2:
                    case 3:
                    case 4:
                    case 5:
                        currVersion = System.Configuration.ConfigurationManager.AppSettings["curr_android_version_" + source.ToString()];
                        currUrl     = System.Configuration.ConfigurationManager.AppSettings["curr_android_url_" + source.ToString()];
                        break;

                    default:
                        currVersion = System.Configuration.ConfigurationManager.AppSettings["curr_android_version_1"];
                        currUrl     = System.Configuration.ConfigurationManager.AppSettings["curr_android_url_1"];
                        break;
                    }
                }
                else
                {
                    switch (source)
                    {
                    case 1:
                    case 2:
                    case 3:
                    case 4:
                    case 5:
                        currVersion = System.Configuration.ConfigurationManager.AppSettings["curr_ios_version_" + source.ToString()];
                        currUrl     = System.Configuration.ConfigurationManager.AppSettings["curr_ios_url_" + source.ToString()];
                        break;

                    default:
                        currVersion = System.Configuration.ConfigurationManager.AppSettings["curr_ios_version_1"];
                        currUrl     = System.Configuration.ConfigurationManager.AppSettings["curr_ios_url_1"];
                        break;
                    }
                }
                if (Tools.SafeDouble(version) >= Tools.SafeDouble(currVersion))
                {
                    return(Json(new { result = false, message = "当前已是最新版本" }, JsonRequestBehavior.AllowGet));
                }
                return(Json(new { result = true, version = currVersion, url = currUrl, remark = System.Configuration.ConfigurationManager.AppSettings["curr_version_remark"] }, JsonRequestBehavior.AllowGet));
            }
            catch (Exception ex)
            {
                LogHelper.ErrorLoger.Error("SystemController_CheckUpdate:" + ex.Message);
            }
            return(Json(new { result = false, message = "失败" }, JsonRequestBehavior.AllowGet));
        }
Пример #26
0
        public string Edit()
        {
            ApiResult result = new ApiResult();

            try
            {
                User user = GetUserInfo();
                if (user == null)
                {
                    result.message = EnumBase.GetDescription(typeof(Enum_ErrorCode), Enum_ErrorCode.UnLogin);
                    result.code    = Enum_ErrorCode.UnLogin;
                    return(JsonConvert.SerializeObject(result));
                }
                var articleID = ZNRequest.GetInt("ArticleID");
                if (articleID <= 0)
                {
                    result.message = "参数异常";
                    return(JsonConvert.SerializeObject(result));
                }
                Article article = new SubSonic.Query.Select(provider, "ID", "CreateUserNumber", "Number").From <Article>().Where <Article>(x => x.ID == articleID).ExecuteSingle <Article>();
                if (article == null)
                {
                    result.message = "文章信息异常";
                    return(JsonConvert.SerializeObject(result));
                }
                Keep model = db.Single <Keep>(x => x.CreateUserNumber == user.Number && x.ArticleNumber == article.Number);
                if (model == null)
                {
                    model                  = new Keep();
                    model.CreateDate       = DateTime.Now;
                    model.CreateUserNumber = user.Number;
                    model.CreateIP         = Tools.GetClientIP;
                }
                else
                {
                    result.result  = true;
                    result.message = "";
                    return(JsonConvert.SerializeObject(result));
                }
                model.ArticleNumber     = article.Number;
                model.ArticleUserNumber = article.CreateUserNumber;
                var success = Tools.SafeInt(db.Add <Keep>(model)) > 0;
                if (success)
                {
                    result.result  = true;
                    result.message = user.Follows;


                    //操作记录
                    var now    = DateTime.Now.ToString("yyyy-MM-dd");
                    var action = db.Single <UserAction>(x => x.CreateUserNumber == user.Number && x.CreateTimeText == now && x.ActionType == Enum_ActionType.Keep);
                    if (action == null)
                    {
                        action = new UserAction();
                        action.CreateUserNumber = user.Number;
                        action.ActionType       = Enum_ActionType.Keep;
                        action.CreateTime       = DateTime.Now;
                        action.CreateTimeText   = now;
                        action.ActionInfo       = article.Number;
                        db.Add <UserAction>(action);
                    }
                    else
                    {
                        if (!action.ActionInfo.Contains(article.Number))
                        {
                            action.ActionInfo += "," + article.Number;
                            db.Update <UserAction>(action);
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                LogHelper.ErrorLoger.Error("Api_Keep_Edit:" + ex.Message);
                result.message = ex.Message;
            }
            return(JsonConvert.SerializeObject(result));
        }
Пример #27
0
        public string PcDetail()
        {
            ApiResult result = new ApiResult();

            try
            {
                User user = GetUserInfo();
                if (user == null)
                {
                    result.code    = Enum_ErrorCode.UnLogin;
                    result.message = "用户信息验证失败";
                    return(JsonConvert.SerializeObject(result));
                }
                int     id    = ZNRequest.GetInt("ArticleID");
                Article model = db.Single <Article>(x => x.ID == id);
                if (model == null)
                {
                    model = new Article();
                    model.CreateDateText = DateTime.Now.ToString("yyyy-MM-dd");
                    model.Number         = BuildNumber();
                    model.Recommend      = Enum_ArticleRecommend.None;
                    model.ArticlePower   = Enum_ArticlePower.Myself;
                    model.Submission     = Enum_Submission.TemporaryApproved;
                }
                else
                {
                    //判断权限
                    if (user.UserRole == Enum_UserRole.Common)
                    {
                        if (user.Number != model.CreateUserNumber)
                        {
                            result.code    = Enum_ErrorCode.NoPower;
                            result.message = "没有权限";
                            return(JsonConvert.SerializeObject(result));
                        }
                    }

                    //浏览数
                    new SubSonic.Query.Update <Article>(provider).Set("Views").EqualTo(model.Views + 1).Where <Article>(x => x.ID == model.ID).Execute();
                    model.Pays     = new SubSonic.Query.Select(provider).From <Order>().Where <Order>(x => x.ToArticleNumber == model.Number && x.Status == Enum_Status.Approved).GetRecordCount();
                    model.Keeps    = new SubSonic.Query.Select(provider).From <Keep>().Where <Keep>(x => x.ArticleNumber == model.Number).GetRecordCount();
                    model.Comments = new SubSonic.Query.Select(provider).From <Comment>().Where <Comment>(x => x.ArticleNumber == model.Number).GetRecordCount();

                    //是否收藏
                    model.IsKeep = new SubSonic.Query.Select(provider, "ID").From <Keep>().Where <Keep>(x => x.CreateUserNumber == user.Number && x.ArticleNumber == model.Number).GetRecordCount() == 0 ? 0 : 1;

                    //是否关注
                    model.IsFollow = new SubSonic.Query.Select(provider, "ID").From <Fan>().Where <Fan>(x => x.CreateUserNumber == user.Number && x.ToUserNumber == model.CreateUserNumber).GetRecordCount() == 0 ? 0 : 1;

                    //是否点赞
                    model.IsZan = new SubSonic.Query.Select(provider, "ID").From <ArticleZan>().Where <ArticleZan>(x => x.CreateUserNumber == user.Number && x.ArticleNumber == model.Number).GetRecordCount() == 0 ? 0 : 1;

                    //类型
                    ArticleType articleType = AppHelper.GetArticleType().FirstOrDefault <ArticleType>(x => x.ID == model.TypeID);
                    model.TypeName = articleType == null ? string.Empty : articleType.Name;

                    //文章部分
                    model.ArticlePart = db.Find <ArticlePart>(x => x.ArticleNumber == model.Number).OrderBy(x => x.SortID).ToList();

                    //漂浮装扮
                    var custom = db.Single <ArticleCustom>(x => x.ArticleNumber == model.Number);
                    if (custom != null)
                    {
                        model.Showy        = custom.ShowyUrl;
                        model.MusicID      = custom.MusicID;
                        model.MusicName    = custom.MusicName;
                        model.MusicUrl     = custom.MusicUrl;
                        model.Transparency = custom.Transparency;
                        model.MarginTop    = custom.MarginTop;
                    }

                    model.CreateDateText = model.CreateDate.ToString("yyyy-MM-dd");
                }

                //创建人
                model.UserID    = user.ID;
                model.NickName  = user.NickName;
                model.Avatar    = user.Avatar;
                model.AutoMusic = user.AutoMusic;
                model.UserCover = user.Cover;
                model.ShareNick = user.ShareNick;
                model.IsPay     = user.IsPay;

                model.ShareUrl = System.Configuration.ConfigurationManager.AppSettings["share_url"] + model.Number;

                //模板配置
                model.BackgroundJson = db.Single <Background>(x => x.ArticleNumber == model.Number && x.IsUsed == Enum_Used.Approved);

                //模板预览
                var previewTemp = ZNRequest.GetInt("Template", -1);
                if (previewTemp >= 0)
                {
                    model.TemplateJson = AppHelper.GetArticleTemplate().FirstOrDefault(x => x.ID == previewTemp);
                }
                else
                {
                    if (model.Template >= 0)
                    {
                        model.TemplateJson = AppHelper.GetArticleTemplate().FirstOrDefault(x => x.ID == model.Template);
                    }
                }

                //主题色预览
                var previewColorTemp = ZNRequest.GetInt("ColorTemplate", 0);
                if (previewColorTemp > 0)
                {
                    model.ColorTemplateJson = AppHelper.GetColorTemplate().FirstOrDefault(x => x.ID == previewColorTemp);
                }
                else
                {
                    if (model.ColorTemplate > 0)
                    {
                        model.ColorTemplateJson = AppHelper.GetColorTemplate().FirstOrDefault(x => x.ID == model.ColorTemplate);
                    }
                }

                result.result  = true;
                result.message = model;
            }
            catch (Exception ex)
            {
                LogHelper.ErrorLoger.Error("Api_Article_Detail:" + ex.Message);
                result.message = ex.Message;
            }
            return(JsonConvert.SerializeObject(result));
        }
Пример #28
0
        public string All()
        {
            ApiResult result = new ApiResult();

            try
            {
                var pager = new Pager();
                var query = new SubSonic.Query.Select(provider).From <Article>().Where <Article>(x => x.Status == Enum_Status.Approved);

                //昵称
                var title = SqlFilter(ZNRequest.GetString("Title"));
                if (!string.IsNullOrWhiteSpace(title))
                {
                    query.And("Title").Like("%" + title + "%");
                }
                var CreateUserNumber = ZNRequest.GetString("CreateUserNumber");
                if (!string.IsNullOrWhiteSpace(CreateUserNumber))
                {
                    query = query.And("CreateUserNumber").IsEqualTo(CreateUserNumber);
                }

                //其他用户的文章
                var CurrUserNumber = ZNRequest.GetString("CurrUserNumber");
                if (CreateUserNumber != CurrUserNumber || string.IsNullOrWhiteSpace(CreateUserNumber))
                {
                    query = query.And("ArticlePower").IsEqualTo(Enum_ArticlePower.Public);
                    query = query.And("Submission").IsGreaterThan(Enum_Submission.Audit);
                }

                //文章类型
                var TypeID = ZNRequest.GetInt("TypeID");
                if (TypeID > 0)
                {
                    query = query.And("TypeIDList").Like("%-0-" + TypeID.ToString() + "-%");
                }

                //过滤黑名单
                if (!string.IsNullOrWhiteSpace(CurrUserNumber))
                {
                    var black = db.Find <Black>(x => x.CreateUserNumber == CurrUserNumber);
                    if (black.Count > 0)
                    {
                        var userids = black.Select(x => x.ToUserNumber).ToArray();
                        query = query.And("CreateUserNumber").NotIn(userids);
                    }
                }
                var recordCount = query.GetRecordCount();
                if (recordCount == 0)
                {
                    result.message = new { records = recordCount, totalpage = 1 };
                    return(JsonConvert.SerializeObject(result));
                }
                var totalPage = recordCount % pager.Size == 0 ? recordCount / pager.Size : recordCount / pager.Size + 1;

                var sort = new string[] { "Recommend", "ID" };
                if (CreateUserNumber == CurrUserNumber)
                {
                    sort = new string[] { "ID" };
                }
                var Source = ZNRequest.GetString("Source");
                if (!string.IsNullOrWhiteSpace(Source))
                {
                    sort = new string[] { "Views" };
                }

                var list = query.Paged(pager.Index, pager.Size).OrderDesc(sort).ExecuteTypedList <Article>();
                List <ArticleJson> newlist = ArticleListInfo(list, CurrUserNumber);
                result.result  = true;
                result.message = new
                {
                    currpage  = pager.Index,
                    records   = recordCount,
                    totalpage = totalPage,
                    list      = newlist
                };
            }
            catch (Exception ex)
            {
                LogHelper.ErrorLoger.Error("Api_Article_All:" + ex.Message);
                result.message = ex.Message;
            }
            return(JsonConvert.SerializeObject(result));
        }
Пример #29
0
        public string MusicTop()
        {
            ApiResult result = new ApiResult();

            try
            {
                var totalPage = 1;
                var hottype   = ZNRequest.GetInt("hottype");
                var list      = new List <Music>();
                if (CacheHelper.Exists("MusicTop" + hottype))
                {
                    list = (List <Music>)CacheHelper.GetCache("MusicTop" + hottype);
                }
                else
                {
                    string str      = string.Empty;
                    string filePath = System.Web.HttpContext.Current.Server.MapPath("~/Config/Music/music" + hottype + ".config");
                    if (System.IO.File.Exists(filePath))
                    {
                        StreamReader sr = new StreamReader(filePath, Encoding.Default);
                        str = sr.ReadToEnd();
                        sr.Close();
                    }
                    var arr = Newtonsoft.Json.JsonConvert.DeserializeObject <JArray>(str);
                    foreach (JObject model in arr)
                    {
                        var music = new Music();

                        music.ID   = Tools.SafeInt(model["id"]);
                        music.Name = model["name"].ToString();
                        var artists = JArray.Parse(model["artists"].ToString());
                        music.Author = ((JObject)artists[0])["name"].ToString();
                        var album = JObject.Parse(model["album"].ToString());
                        music.Remark = album["name"].ToString();
                        music.Cover  = album["picUrl"].ToString() + "?param=100y100";
                        var dic2 = new Dictionary <string, object>();
                        dic2.Add("url", "http://music.163.com/#/song?id=" + music.ID);
                        var filrurl = HttpUtil.Post("http://i.oppsu.cn/link/geturl.php", dic2);//阿里云解析 http://i.oppsu.cn/link/
                        try
                        {
                            var file = JObject.Parse(filrurl);
                            if (Tools.SafeInt(file["status"]) == 1)
                            {
                                music.FileUrl = file["data"].ToString();
                            }
                        }
                        catch (Exception ex)
                        {
                            music.FileUrl = "";
                        }
                        list.Add(music);
                    }
                    if (list.Count > 0)
                    {
                        CacheHelper.Insert("MusicTop" + hottype, list, TimeSpan.FromDays(7));
                    }
                }
                result.result  = true;
                result.message = new
                {
                    currpage  = 1,
                    records   = list.Count,
                    totalpage = totalPage,
                    list      = list
                };
            }
            catch (Exception ex)
            {
                LogHelper.ErrorLoger.Error("Api_Music_MusicTop:" + ex.Message);
                result.message = ex.Message;
            }
            return(JsonConvert.SerializeObject(result));
        }
Пример #30
0
        public string Edit()
        {
            ApiResult result = new ApiResult();

            try
            {
                User user = GetUserInfo();
                if (user == null)
                {
                    result.message = EnumBase.GetDescription(typeof(Enum_ErrorCode), Enum_ErrorCode.UnLogin);
                    result.code    = Enum_ErrorCode.UnLogin;
                    return(JsonConvert.SerializeObject(result));
                }
                var articleID = ZNRequest.GetInt("ArticleID");
                if (articleID <= 0)
                {
                    result.message = "参数异常";
                    return(JsonConvert.SerializeObject(result));
                }
                Article article = new SubSonic.Query.Select(provider, "ID", "CreateUserNumber", "Goods", "Number").From <Article>().Where <Article>(x => x.ID == articleID).ExecuteSingle <Article>();
                if (article == null)
                {
                    result.message = "文章信息异常";
                    return(JsonConvert.SerializeObject(result));
                }

                //判断是否拉黑
                var black = db.Exists <Black>(x => x.CreateUserNumber == article.CreateUserNumber && x.ToUserNumber == user.Number);
                if (black)
                {
                    result.code    = Enum_ErrorCode.NoPower;
                    result.message = "没有权限";
                    return(JsonConvert.SerializeObject(result));
                }

                var success = 0;
                var model   = db.Single <ArticleZan>(x => x.CreateUserNumber == user.Number && x.ArticleNumber == article.Number);
                var goods   = model == null ? article.Goods + 1 : article.Goods - 1;

                //是否新增
                var isadd = model == null ? 0 : 1;
                if (model == null)
                {
                    model                   = new ArticleZan();
                    model.CreateDate        = DateTime.Now;
                    model.CreateUserNumber  = user.Number;
                    model.CreateIP          = Tools.GetClientIP;
                    model.ArticleNumber     = article.Number;
                    model.ArticleUserNumber = article.CreateUserNumber;
                    success                 = Tools.SafeInt(db.Add <ArticleZan>(model));

                    //操作记录
                    var now    = DateTime.Now.ToString("yyyy-MM-dd");
                    var action = db.Single <UserAction>(x => x.CreateUserNumber == user.Number && x.CreateTimeText == now && x.ActionType == Enum_ActionType.Like);

                    LogHelper.ErrorLoger.Error(JsonConvert.SerializeObject(action));

                    if (action == null)
                    {
                        action = new UserAction();
                        action.CreateUserNumber = user.Number;
                        action.ActionType       = Enum_ActionType.Like;
                        action.CreateTime       = DateTime.Now;
                        action.CreateTimeText   = now;
                        action.ActionInfo       = article.Number;
                        db.Add <UserAction>(action);
                    }
                    else
                    {
                        if (!action.ActionInfo.Contains(article.Number))
                        {
                            action.ActionInfo += "," + article.Number;
                            db.Update <UserAction>(action);
                        }
                    }
                }
                else
                {
                    success = db.Delete <ArticleZan>(model.ID);
                }
                if (success > 0)
                {
                    if (goods < 0)
                    {
                        goods = 0;
                    }
                    new SubSonic.Query.Update <Article>(provider).Set("Goods").EqualTo(goods).Where <Article>(x => x.ID == articleID).Execute();
                    result.result  = true;
                    result.message = isadd + "|" + goods;
                }
            }
            catch (Exception ex)
            {
                LogHelper.ErrorLoger.Error("Api_Zan_ArticleZanEdit" + ex.Message);
                result.message = ex.Message;
            }
            return(JsonConvert.SerializeObject(result));
        }