Exemple #1
0
        void rptContents_ItemDataBound(object sender, RepeaterItemEventArgs e)
        {
            if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem)
            {
                var logInfo = new VoteLogInfo(e.Item.DataItem);

                var ltlItemIndex        = e.Item.FindControl("ltlItemIndex") as Literal;
                var ltlItemIdCollection = e.Item.FindControl("ltlItemIDCollection") as Literal;
                var ltlUserName         = e.Item.FindControl("ltlUserName") as Literal;
                var ltlIpAddress        = e.Item.FindControl("ltlIPAddress") as Literal;
                var ltlWxOpenId         = e.Item.FindControl("ltlWXOpenID") as Literal;
                var ltlAddDate          = e.Item.FindControl("ltlAddDate") as Literal;

                ltlItemIndex.Text = (e.Item.ItemIndex + 1).ToString();

                var builder = new StringBuilder();
                foreach (var itemId in TranslateUtils.StringCollectionToIntList(logInfo.ItemIdCollection))
                {
                    if (_idTitleMap.ContainsKey(itemId))
                    {
                        builder.Append(_idTitleMap[itemId]).Append(",");
                    }
                }
                if (builder.Length > 0)
                {
                    builder.Length -= 1;
                }
                ltlItemIdCollection.Text = builder.ToString();
                ltlUserName.Text         = logInfo.UserName;
                ltlIpAddress.Text        = logInfo.IpAddress;
                ltlWxOpenId.Text         = logInfo.WxOpenId;
                ltlAddDate.Text          = DateUtils.GetDateAndTimeString(logInfo.AddDate);
            }
        }
Exemple #2
0
        public void Insert(VoteLogInfo logInfo)
        {
            IDataParameter[] parms = null;

            var SQL_INSERT = BaiRongDataProvider.TableStructureDao.GetInsertSqlString(logInfo.ToNameValueCollection(), ConnectionString, TABLE_NAME, out parms);

            ExecuteNonQuery(SQL_INSERT, parms);
        }
Exemple #3
0
        public void Insert(VoteLogInfo logInfo)
        {
            IDataParameter[] parms = null;

            var sqlInsert = BaiRongDataProvider.TableStructureDao.GetInsertSqlString(logInfo.ToNameValueCollection(), ConnectionString, TableName, out parms);

            ExecuteNonQuery(sqlInsert, parms);
        }
Exemple #4
0
        public static void Vote(int publishmentSystemID, int voteID, List <int> itemIDList, string ipAddress, string cookieSN, string wxOpenID, string userName)
        {
            DataProviderWx.VoteDao.AddUserCount(voteID);
            DataProviderWx.VoteItemDao.AddVoteNum(voteID, itemIDList);
            var logInfo = new VoteLogInfo {
                Id = 0, PublishmentSystemId = publishmentSystemID, VoteId = voteID, ItemIdCollection = TranslateUtils.ObjectCollectionToString(itemIDList), IpAddress = ipAddress, CookieSn = cookieSN, WxOpenId = wxOpenID, UserName = userName, AddDate = DateTime.Now
            };

            DataProviderWx.VoteLogDao.Insert(logInfo);
        }
Exemple #5
0
        public static int Add(VoteLogInfo entity)
        {
            int result;

            if (entity == null)
            {
                result = 0;
            }
            else
            {
                result = BizBase.dbo.InsertModel <VoteLogInfo>(entity);
            }
            return(result);
        }
Exemple #6
0
        public List <VoteLogInfo> GetVoteLogInfoList(int publishmentSystemId)
        {
            var voteLogInfoList = new List <VoteLogInfo>();

            string sqlWhere = $"WHERE {VoteLogAttribute.PublishmentSystemId} = {publishmentSystemId}";

            var sqlSelect = BaiRongDataProvider.TableStructureDao.GetSelectSqlString(ConnectionString, TableName, 0, SqlUtils.Asterisk, sqlWhere, null);

            using (var rdr = ExecuteReader(sqlSelect))
            {
                while (rdr.Read())
                {
                    var voteLogInfo = new VoteLogInfo(rdr);
                    voteLogInfoList.Add(voteLogInfo);
                }
                rdr.Close();
            }

            return(voteLogInfoList);
        }
Exemple #7
0
        public List <VoteLogInfo> GetVoteLogInfoList(int publishmentSystemID)
        {
            var voteLogInfoList = new List <VoteLogInfo>();

            string SQL_WHERE = $"WHERE {VoteLogAttribute.PublishmentSystemID} = {publishmentSystemID}";

            var SQL_SELECT = BaiRongDataProvider.TableStructureDao.GetSelectSqlString(ConnectionString, TABLE_NAME, 0, SqlUtils.Asterisk, SQL_WHERE, null);

            using (var rdr = ExecuteReader(SQL_SELECT))
            {
                while (rdr.Read())
                {
                    var voteLogInfo = new VoteLogInfo(rdr);
                    voteLogInfoList.Add(voteLogInfo);
                }
                rdr.Close();
            }

            return(voteLogInfoList);
        }
Exemple #8
0
        /// <summary>
        /// 系统添加票数 指定选手编号
        /// </summary>
        /// <param name="context"></param>
        /// <returns></returns>
        private string SysAddvoteCount(HttpContext context)
        {
            if (CurrentUserInfo.UserType.Equals(1))//超级管理员才可以操作
            {
                int number   = int.Parse(context.Request["Number"]);
                int addCount = int.Parse(context.Request["AddCount"]);
                int voteId   = int.Parse(context.Request["VoteId"]);
                //
                VoteObjectInfo voteObj = bllVote.Get <VoteObjectInfo>(string.Format(" Number={0} And VoteID={1} And Status=1 ", number, voteId));
                if (voteObj != null)
                {
                    for (int i = 0; i < addCount; i++)
                    {
                        Random rand = new Random();
                        //注册用户
                        DateTime regTime = DateTime.Now.AddMinutes(new Random().Next(1, 10));

                        #region 注册用户
                        //注册用户
                        UserInfo userInfo = new ZentCloud.BLLJIMP.Model.UserInfo();
                        userInfo.UserID          = string.Format("WXUser{0}{1}", ZentCloud.Common.StringHelper.GetDateTimeNum(), ZentCloud.Common.Rand.Str(5));//WXUser+时间字符串+随机5位数字
                        userInfo.Password        = ZentCloud.Common.Rand.Str_char(12);
                        userInfo.UserType        = 2;
                        userInfo.WebsiteOwner    = bllVote.WebsiteOwner;
                        userInfo.Regtime         = regTime;
                        userInfo.WXOpenId        = "zc" + ZentCloud.Common.Rand.Str_char(12) + "cl";
                        userInfo.WXScope         = "snsapi_base";
                        userInfo.RegIP           = bllVote.GetLit <UserInfo>(1, new Random().Next(1, 10000), "RegIP IS NOT NULL")[0].RegIP;
                        userInfo.LastLoginIP     = userInfo.RegIP;
                        userInfo.LastLoginDate   = regTime;
                        userInfo.LoginTotalCount = 1;
                        if (bllVote.Add(userInfo))
                        {
                            VoteLogInfo log = new VoteLogInfo();
                            log.UserID       = userInfo.UserID;
                            log.VoteID       = voteId;
                            log.VoteObjectID = voteObj.AutoID;
                            log.InsertDate   = ((DateTime)(userInfo.Regtime)).AddSeconds(rand.Next(2, 10));
                            log.CreateUserID = bllVote.WebsiteOwner;
                            log.WebsiteOwner = bllVote.WebsiteOwner;
                            log.VoteCount    = 1;
                            log.IP           = userInfo.RegIP;
                            log.IPLocation   = Common.MySpider.GetIPLocation(log.IP);
                            if (bllVote.Add(log))
                            {
                                if (bllVote.Update(new VoteObjectInfo(), "VoteCount+=1", string.Format(" AutoID={0}", voteObj.AutoID)) > 0)
                                {
                                    System.Threading.Thread.Sleep(100);
                                }
                            }
                        }

                        #endregion
                        //
                    }
                }
                else
                {
                    resp.errcode = 1;
                    resp.errmsg  = "选手编号不存在";
                }

                //
            }
            else
            {
                resp.errcode = 1;
            }
            return(Common.JSONHelper.ObjectToJson(resp));
        }
Exemple #9
0
        /// <summary>
        /// 投票
        /// </summary>
        /// <param name="voteId">投票ID</param>
        /// <param name="voteObjectId">选手ID</param>
        /// <param name="userId">用户ID</param>
        /// <param name="count">票数</param>
        /// <param name="msg">信息</param>
        /// <returns></returns>
        public bool UpdateVoteObjectVoteCount(int voteId, int voteObjectId, string userId, int count, out string msg)
        {
            msg = "false";
            VoteInfo voteInfo = GetVoteInfo(voteId);

            if (voteInfo.VoteStatus.Equals(0))
            {
                msg = "投票停止";
                return(false);
            }
            if (!string.IsNullOrEmpty(voteInfo.StopDate))
            {
                if (DateTime.Now >= (DateTime.Parse(voteInfo.StopDate)))
                {
                    msg = "投票结束";
                    return(false);
                }
            }

            VoteObjectInfo voteObj = GetVoteObjectInfo(voteObjectId);

            if (!voteObj.Status.Equals(1))
            {
                msg = "审核通过的选手才能投票";
                return(false);
            }
            //检查是否可以投票
            if (voteInfo.LimitType == 0)//每人最多可以投多少票
            {
                if ((GetCount <VoteLogInfo>(string.Format(" VoteId={0} And UserID='{1}' ", voteInfo.AutoID, userId)) >= voteInfo.FreeVoteCount))
                {
                    msg = "您已经投过票了";//总票数已经用完
                    return(false);
                }
            }
            else if (voteInfo.LimitType == 1)//每人每天可以投多少票
            {
                string toDay    = DateTime.Now.ToString("yyyy-MM-dd");
                string tomorrow = DateTime.Now.AddDays(1).ToString("yyyy-MM-dd");
                if (GetCount <VoteLogInfo>(string.Format(" VoteId={0} And UserID='{1}' And InsertDate>='{2}' And InsertDate<'{3}'", voteInfo.AutoID, userId, toDay, tomorrow)) >= voteInfo.FreeVoteCount)
                {
                    msg = "今天票数已经用完,明天再来吧";//总票数已经用完
                    return(false);
                }
            }
            if ((voteInfo.LimitType == 0) && GetCount <VoteLogInfo>(string.Format(" VoteId={0} And UserID='{1}' And VoteObjectID={2}", voteInfo.AutoID, userId, voteObjectId)) >= voteInfo.VoteObjectLimitVoteCount)
            {
                msg = "您已经投过票了";//每个选手最多可以投多少票
                return(false);
            }
            //检查是否可以投票
            ZentCloud.ZCBLLEngine.BLLTransaction tran = new ZCBLLEngine.BLLTransaction();
            try
            {
                VoteLogInfo log = new VoteLogInfo();
                log.UserID       = userId;
                log.VoteID       = voteId;
                log.VoteObjectID = voteObjectId;
                log.InsertDate   = DateTime.Now;
                log.CreateUserID = voteInfo.CreateUserID;
                log.WebsiteOwner = WebsiteOwner;
                log.VoteCount    = count;
                log.IP           = System.Web.HttpContext.Current.Request.UserHostAddress;
                log.IPLocation   = Common.MySpider.GetIPLocation(log.IP);
                if (!Add(log, tran))
                {
                    tran.Rollback();
                    return(false);
                }

                if (Update(voteObj, string.Format(" VoteCount+={0}", count), string.Format(" AutoID={0}", voteObj.AutoID)) > 0)
                {
                    tran.Commit();
                    msg = "投票成功";
                    return(true);
                }
                else
                {
                    tran.Rollback();
                    return(false);
                }
            }
            catch (Exception ex)
            {
                tran.Rollback();
                msg = ex.Message;
                return(false);
            }
        }
Exemple #10
0
        ///// <summary>
        ///// 更新投票数 OLD VERSION
        ///// </summary>
        ///// <returns></returns>
        //public bool UpdateVoteObjectVoteCount(int voteId,int voteObjectId,string userId,int count){
        //    ZentCloud.ZCBLLEngine.BLLTransaction tran = new ZCBLLEngine.BLLTransaction();
        //    try
        //    {
        //        VoteInfo VoteInfo = GetSingleVoteInfo(voteId);
        //        int VoteLogCount = GetVoteLogCount(voteId, userId);
        //        int AddCount = 0;
        //        if (VoteLogCount<=VoteInfo.FreeVoteCount)
        //        {
        //            AddCount = VoteInfo.FreeVoteCount - VoteLogCount;
        //        }

        //        if (VoteInfo==null||VoteInfo.VoteStatus.Equals(0))
        //        {
        //            return false;
        //        }

        //        bool logresult = false;
        //        int logcount = 0;
        //        for (int i =1; i <=count; i++)
        //        {
        //            VoteLogInfo log = new VoteLogInfo();
        //            log.UserID = userId;
        //            log.VoteID = voteId;
        //            log.VoteObjectID = voteObjectId;
        //            log.InsertDate = DateTime.Now;
        //            log.CreateUserID = VoteInfo.CreateUserID;
        //            log.WebsiteOwner = WebsiteOwner;
        //            log.VoteCount = count;
        //            if (Add(log,tran))
        //            {
        //                logcount++;
        //                VoteLogCount++;

        //            }

        //        }
        //        if (count!=logcount)
        //        {
        //            tran.Rollback();
        //            return false;
        //        }
        //        else
        //        {
        //            logresult = true;
        //        }

        //        if (logresult)
        //        {
        //            VoteObjectInfo model = GetSingleVoteObjectInfo(voteObjectId);
        //            model.VoteCount += count;
        //            if (Update(model))
        //            {

        //                if (VoteInfo.IsFree.Equals(0))//收费 检查是否需要扣除用户剩余票数
        //                {

        //                    int FreeVoteCount = VoteInfo.FreeVoteCount-VoteLogCount;
        //                    //计算应该扣除的点数



        //                    //计算应该扣除的点数
        //                    if (FreeVoteCount<0)//剩余票数不够,减掉用户购买的的票数
        //                    {

        //                        //
        //                        UserInfo userInfo = new BLLUser("").GetUserInfo(userId);
        //                        userInfo.AvailableVoteCount -=count-AddCount;

        //                        if (userInfo.AvailableVoteCount<0)
        //                        {
        //                            userInfo.AvailableVoteCount = 0;
        //                        }
        //                        if (Update(userInfo,tran))
        //                        {
        //                            tran.Commit();
        //                            return true;
        //                        }
        //                        else
        //                        {
        //                            tran.Rollback();
        //                            return false;
        //                        }


        // /                    }
        //                    else
        //                    {
        //                        tran.Commit();
        //                        return true;

        //                    }


        //                }
        //                else
        //                {
        //                    tran.Commit();
        //                    return true;

        //                }


        //            }
        //            else
        //            {
        //                tran.Rollback();
        //                return false;

        //            }
        //        }
        //        else
        //        {
        //            tran.Rollback();
        //            return false;

        //        }

        //    }
        //    catch (Exception)
        //    {

        //        tran.Rollback();
        //        return false;
        //    }


        //}


        /// <summary>
        /// 更新投票数 20140917
        /// </summary>
        /// <returns></returns>
        public bool UpdateVoteObjectVoteCount(int voteId, int voteObjectId, string userId, int count)
        {
            ZentCloud.ZCBLLEngine.BLLTransaction tran = new ZCBLLEngine.BLLTransaction();
            try
            {
                VoteInfo voteInfo = GetVoteInfo(voteId);



                //int voteLogCount = GetVoteLogCount(voteId, userId);
                //int addCount = 0;
                //if (voteLogCount <= voteInfo.FreeVoteCount)
                //{
                //    addCount = voteInfo.FreeVoteCount - voteLogCount;
                //}

                if (voteInfo == null || voteInfo.VoteStatus.Equals(0))
                {
                    return(false);
                }

                bool        logResult = false;//是否可以投票标识
                VoteLogInfo log       = new VoteLogInfo();
                log.UserID       = userId;
                log.VoteID       = voteId;
                log.VoteObjectID = voteObjectId;
                log.InsertDate   = DateTime.Now;
                log.CreateUserID = voteInfo.CreateUserID;
                log.WebsiteOwner = WebsiteOwner;
                log.VoteCount    = count;
                log.IP           = System.Web.HttpContext.Current.Request.UserHostAddress;
                log.IPLocation   = Common.MySpider.GetIPLocation(log.IP);
                if (!Add(log, tran))
                {
                    tran.Rollback();
                    return(false);
                }
                else
                {
                    //voteLogCount += count;
                    logResult = true;
                }



                if (logResult)
                {
                    VoteObjectInfo model = GetVoteObjectInfo(voteObjectId);
                    model.VoteCount += count;
                    if (Update(model))
                    {
                        //if (voteInfo.IsFree.Equals(0))//收费 检查是否需要扣除用户剩余票数
                        //{

                        //    int freeVoteCount = voteInfo.FreeVoteCount - voteLogCount;
                        //    //计算应该扣除的点数



                        //    //计算应该扣除的点数
                        //    if (freeVoteCount < 0)//剩余票数不够,减掉用户购买的的票数
                        //    {

                        //        //
                        //        UserInfo userInfo =  bllUser.GetUserInfo(userId);
                        //        userInfo.AvailableVoteCount -= count - addCount;
                        //        if (userInfo.AvailableVoteCount < 0)
                        //        {
                        //            userInfo.AvailableVoteCount = 0;
                        //        }
                        //        if (Update(userInfo, string.Format(" AvailableVoteCount={0}", userInfo.AvailableVoteCount), string.Format(" AutoID={0}", userInfo.AutoID), tran) > 0)
                        //        {
                        //            tran.Commit();
                        //            return true;
                        //        }
                        //        else
                        //        {
                        //            tran.Rollback();
                        //            return false;
                        //        }


                        //    }
                        //    else
                        //    {
                        //        tran.Commit();
                        //        return true;

                        //    }


                        //}
                        //else
                        //{
                        tran.Commit();
                        return(true);

                        //}
                    }
                    else
                    {
                        tran.Rollback();
                        return(false);
                    }
                }
                else
                {
                    tran.Rollback();
                    return(false);
                }
            }
            catch (Exception)
            {
                tran.Rollback();
                return(false);
            }
        }
Exemple #11
0
 /// <summary>
 /// 新增投票记录
 /// </summary>
 /// <param name="model"></param>
 /// <returns></returns>
 public bool AddVoteLogInfo(VoteLogInfo model)
 {
     return(Add(model));
 }
Exemple #12
0
 public static bool Update(VoteLogInfo entity)
 {
     return(entity != null && BizBase.dbo.UpdateModel <VoteLogInfo>(entity));
 }