Пример #1
0
        public ApiResponse CallbackShareInfo([FromBody] ShareInfoReq model)
        {
            ShareLog shareLog = new ShareLog();

            shareLog.AddTime      = DateTime.Now;
            shareLog.ShareContent = model.ShareContent;
            shareLog.ShareImgUrl  = model.ShareImgUrl;
            shareLog.ShareTitle   = model.ShareTitle;
            shareLog.ShareUrl     = model.ShareUrl;
            shareLog.Source       = model.Source;
            shareLog.UserId       = GetCurrentUserId();
            ncBase.CurrentEntities.AddToShareLog(shareLog);
            ncBase.CurrentEntities.SaveChanges();

            int    gainPoints    = 0;
            string gainPointsMsg = "";

            DoTask(GetCurrentUserId(), PointsEnum.First_ShareHouse_App, out gainPoints);
            DoTask(GetCurrentUserId(), PointsEnum.EveryDay_ShareHouse_App, out gainPoints);
            gainPointsMsg = "完成“每日分享”任务";
            var result = new
            {
                GainPoints    = gainPoints,
                GainPointsMsg = gainPointsMsg
            };

            return(new ApiResponse(Metas.SUCCESS, result));
        }
Пример #2
0
        public IHttpActionResult Post(ShareLogModel model)
        {
            var log = new ShareLog
            {
                CreatedDate = DateTime.Now,
                Category    = model.Category,
                CategoryId  = model.CategoryId
            };

            db.ShareLog.Add(log);

            db.SaveChanges();

            return(Ok(log.Id));
        }
Пример #3
0
        /// <summary>
        /// 保存分享记录
        /// </summary>
        /// <param name="shareLog"></param>
        /// <returns></returns>
        public static bool AddShareLog(ShareLog shareLog)
        {
            var cmdText = string.Empty;
            List <MySqlParameter> parameters = new List <MySqlParameter>();

            cmdText = @"insert into ShareLog
                                        (
                                        UserId,
                                        Type,
                                        TypeId,
                                        Content,
                                        CreateTime
                                        ) 
                                        values 
                                        (
                                        ?UserId,
                                        ?Type,
                                        ?TypeId,
                                        ?Content,
                                        ?CreateTime
                                        )";
            parameters.Add(new MySqlParameter("?UserId", shareLog.UserId));
            parameters.Add(new MySqlParameter("?Type", shareLog.Type));
            parameters.Add(new MySqlParameter("?TypeId", shareLog.TypeId));
            parameters.Add(new MySqlParameter("?Content", shareLog.Content));
            parameters.Add(new MySqlParameter("?CreateTime", shareLog.CreateTime));
            try
            {
                var num = MySqlHelper.ExecuteNonQuery(Utility._gameDbConn, CommandType.Text, cmdText, parameters.ToArray());
                return(num > 0);
            }
            catch (System.Exception ex)
            {
                throw;
            }
            return(false);
        }
Пример #4
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));
        }
Пример #5
0
        public void ProcessRequest(HttpContext context)
        {
            context.Response.ContentType = "application/json";

            Pageinexinfo sharerindex = new Pageinexinfo();
            ShareLog     mylog       = new ShareLog();

            int    sharecounts, shareinfoid;
            string UserID, ShareUrl;

            try
            {
                UserID              = context.Request.Form["UserID"];   //context.Request.QueryString["UserID"]; //
                ShareUrl            = context.Request.Form["ShareUrl"]; //context.Request.QueryString["ShareUrl"];//
                shareinfoid         = int.Parse(weitang.StringExtensions.GetNumber(ShareUrl.Substring(ShareUrl.LastIndexOf('/') + 1)).ToString());
                mylog.userID        = UserID;
                mylog.shareUrl      = ShareUrl;
                mylog.shareinfoID   = shareinfoid;
                mylog.BrowseType    = DN.Framework.Utility.ClientHelper.GetUserAgent();
                mylog.ClientIp      = DN.Framework.Utility.ClientHelper.ClientIP();
                mylog.IsMobile      = DN.Framework.Utility.ClientHelper.GetIsMobileDevice() ? 1 : 0;
                mylog.OsName        = DN.Framework.Utility.ClientHelper.GetOsName();
                mylog.BrowseName    = DN.Framework.Utility.ClientHelper.GetBrowseName();
                mylog.BrowseVersion = DN.Framework.Utility.ClientHelper.GetBrowseVersion();

                var ipinfo = DN.WeiAd.Business.Services.IpTaoBaoHelper.GetIpResult(mylog.ClientIp);
                if (ipinfo != null)
                {
                    if (ipinfo.code == 0 && ipinfo.data != null)
                    {
                        mylog.Country = ipinfo.data.country;
                        mylog.Area    = ipinfo.data.area;
                        mylog.City    = ipinfo.data.city;
                        mylog.Region  = ipinfo.data.region;
                        mylog.County  = ipinfo.data.county;
                        mylog.Isp     = ipinfo.data.isp;
                    }
                }

                mylog.InputDate = System.DateTime.Now;
            }
            catch (Exception ex)
            {
                DN.Framework.Utility.LogHelper.Write(ex.Message.ToString());
                throw;
            }


            try
            {
                string cmd = string.Format(@" insert into ShareLog(userID, shareUrl, shareinfoID, BrowseType, ClientIp, IsMobile, OsName, BrowseName, BrowseVersion, Country,
                                                                        Area, City, Region, County, Isp,InputDate ) 
                                               values (N'{0}',N'{1}',N'{2}',N'{3}',N'{4}',{5},N'{6}',N'{7}',N'{8}',N'{9}',N'{10}',N'{11}',N'{12}',N'{13}',N'{14}',N'{15}')
                                              ",
                                           mylog.userID, mylog.shareUrl, mylog.shareinfoID, mylog.BrowseType, mylog.ClientIp, mylog.IsMobile, mylog.OsName, mylog.BrowseName,
                                           mylog.BrowseVersion, mylog.Country, mylog.Area, mylog.City, mylog.Region, mylog.County, mylog.Isp, mylog.InputDate
                                           );

                if (SQLServerHelper.ExcuteSql(cmd) > 0)
                {
                }
            }
            catch (Exception ex)
            {
                DN.Framework.Utility.LogHelper.Write(ex.Message);
            }

            WechatEntities wechat = new WechatEntities();

            sharecounts = wechat.ShareLogs.Where(a => a.userID == UserID && a.shareUrl == ShareUrl).ToList().Count;
            sharerindex = wechat.Pageinexinfo.Where(a => a.shareinfoID == shareinfoid).FirstOrDefault();

            //
            string result = JsonConvert.SerializeObject(new ApiResponse
            {
                r = "1",
                d = new
                {
                    sharenums    = sharecounts,
                    sharerequest = sharerindex is null ? 0 : sharerindex.SharesRequirements,
                    shareimages  = sharerindex is null ? "" : sharerindex.friendimages
                },