public List <AgentDistributionRelation> GetAgentDistributionRelationList(string starttime, string endtime, string loginid, int agentqrcodeid, int agentid, int pageIndex, int pageSize, ref int count, bool reflesh = false)
        {
            string accountids = "";

            if (!string.IsNullOrEmpty(loginid))
            {
                Account accountlist = AccountBLL.SingleModel.GetModelByLoginid(loginid);
                if (accountlist == null)
                {
                    return(new List <AgentDistributionRelation>());
                }
                accountids = "'" + accountlist.Id + "'";
                reflesh    = true;
            }
            if (!string.IsNullOrEmpty(starttime) || !string.IsNullOrEmpty(endtime))
            {
                reflesh = true;
            }

            RedisModel <AgentDistributionRelation> model = new RedisModel <AgentDistributionRelation>();

            model = RedisUtil.Get <RedisModel <AgentDistributionRelation> >(string.Format(_redis_AgentDistributionRelationKey, agentid, agentqrcodeid, pageSize, pageIndex));
            int dataversion = RedisUtil.GetVersion(string.Format(_redis_AgentDistributionRelationVersion, agentid));

            if (reflesh || model == null || model.DataList == null || model.DataList.Count <= 0 || model.DataVersion != dataversion)
            {
                model = new RedisModel <AgentDistributionRelation>();

                List <AgentDistributionRelation> list = new List <AgentDistributionRelation>();

                string sqlcount = $" select Count(*) from AgentDistributionRelation ad left join agentinfo a on ad.agentid = a.id ";
                string sql      = $" select ad.*,a.useraccountid,a.LastDeposit,a.name agentname from AgentDistributionRelation ad left join agentinfo a on ad.agentid = a.id ";
                string sqlwhere = $" where ad.state>=0 and ad.ParentAgentId = {agentid} and qrcodeid={agentqrcodeid}";
                if (accountids.Length > 0)
                {
                    sqlwhere += $" and useraccountid in ({accountids}) ";
                }
                if (!string.IsNullOrEmpty(starttime))
                {
                    sqlwhere += $" and ad.addtime>='{starttime}' ";
                }
                if (!string.IsNullOrEmpty(endtime))
                {
                    sqlwhere += $" and ad.addtime<='{endtime} 23:59' ";
                }

                string sqllimit = $" ORDER BY ad.addtime desc LIMIT {(pageIndex - 1) * pageSize},{pageSize} ";

                using (MySqlDataReader dr = SqlMySql.ExecuteDataReaderMaster(connName, CommandType.Text, sql + sqlwhere + sqllimit, null))
                {
                    while (dr.Read())
                    {
                        AgentDistributionRelation amodel = base.GetModel(dr);
                        amodel.UserAccountId = dr["useraccountid"].ToString();
                        amodel.UserName      = dr["agentname"].ToString();
                        if (dr["LastDeposit"] != DBNull.Value)
                        {
                            amodel.LastDeposit = Convert.ToInt32(dr["LastDeposit"]);
                        }
                        AgentFollowLog agentlogmodel = AgentFollowLogBLL.SingleModel.GetLastModel(amodel.Id);
                        if (agentlogmodel != null)
                        {
                            amodel.Desc = agentlogmodel.Desc;
                        }
                        list.Add(amodel);
                    }
                }

                if (list == null || list.Count <= 0)
                {
                    return(new List <AgentDistributionRelation>());
                }

                //查找来源
                string qrcodeid = string.Join(",", list.Select(s => s.QrCodeId).Distinct());
                List <AgentCustomerRelation> customerRelationlist = AgentCustomerRelationBLL.SingleModel.GetListByQrCodeId(qrcodeid);
                string cruserids = "'" + string.Join("','", customerRelationlist.Select(s => s.useraccountid)) + "'";
                string userids   = "'" + string.Join("','", list.Select(s => s.UserAccountId)) + "'";
                if (cruserids.Length > 0)
                {
                    userids = userids + "," + cruserids;
                }
                List <Account> accountlist = AccountBLL.SingleModel.GetListByAccountids(userids);
                foreach (AgentDistributionRelation item in list)
                {
                    Account aitem = accountlist?.Where(w => w.Id.ToString() == item.UserAccountId).FirstOrDefault();
                    item.LoginId = aitem?.LoginId;
                    item.Phone   = aitem?.ConsigneePhone;
                    AgentCustomerRelation crmodel = customerRelationlist?.Where(w => w.QrcodeId == item.QrCodeId).FirstOrDefault();
                    Account critem = accountlist?.Where(w => w.Id.ToString() == crmodel?.useraccountid).FirstOrDefault();
                    item.SourceFrom = crmodel?.username + "/" + (string.IsNullOrEmpty(critem?.ConsigneePhone) ? "未绑定手机号" : critem?.ConsigneePhone);
                }

                count             = base.GetCountBySql(sqlcount + sqlwhere);
                model.DataList    = list;
                model.DataVersion = dataversion;
                model.Count       = count;
                if (!reflesh)
                {
                    RedisUtil.Set <RedisModel <AgentDistributionRelation> >(string.Format(_redis_AgentDistributionRelationKey, agentid, agentqrcodeid, pageSize, pageIndex), model);
                }
            }
            else
            {
                count = model.Count;
            }

            return(model.DataList);
        }
Esempio n. 2
0
 public static bool IsHaveNewOrder(string accountid)
 {
     return(RedisUtil.Get <bool>(string.Format(_redis_HaveNewOrder_Key, accountid)));
 }
        public int GetRankingsByGameId(int game_id)
        {
            int total_rank = RedisUtil.GetGameRanking(game_id) + 1;

            return(total_rank);
        }
Esempio n. 4
0
        public void RemoveRedis(int id)
        {
            string key = string.Format(_redis_XcxAppAccountRelationModelKey, id);

            RedisUtil.Remove(key);
        }
Esempio n. 5
0
        /// <summary>
        /// 获取商品评论
        /// </summary>
        /// <param name="aid"></param>
        /// <param name="goodsid"></param>
        /// <param name="storeid"></param>
        /// <param name="pageIndex"></param>
        /// <param name="pageSize"></param>
        /// <param name="count"></param>
        /// <param name="reflesh"></param>
        /// <returns></returns>
        public List <GoodsComment> GetGoodsCommentListApi(int aid, int goodsid, int userid, int storeid, int pageIndex, int pageSize, int haveimg, ref int count, bool reflesh = true)
        {
            string paramsqlwhere = "";

            if (haveimg >= 0)
            {
                paramsqlwhere = $" and gc.haveimg={haveimg}";
                reflesh       = true;
            }

            RedisModel <GoodsComment> model = new RedisModel <GoodsComment>();

            model = RedisUtil.Get <RedisModel <GoodsComment> >(string.Format(_redis_GoodsCommentApiKey, aid, storeid, goodsid, pageSize, pageIndex));
            int dataversion = RedisUtil.GetVersion(string.Format(_redis_GoodsCommentVersion, aid));

            if (reflesh || model == null || model.DataList == null || model.DataList.Count <= 0 || model.DataVersion != dataversion)
            {
                model = new RedisModel <GoodsComment>();
                List <GoodsComment> list = new List <GoodsComment>();

                string sqlcount = $" select Count(*) from GoodsComment gc";
                string sql      = $" select gc.*,cu.HeadImgUrl from GoodsComment gc left join c_userinfo cu on gc.userid = cu.Id ";
                string sqlwhere = $" where gc.state>-1 and gc.aid = {aid} and gc.storeid={storeid} and gc.goodsid={goodsid} and gc.hidden=0 {paramsqlwhere}";
                string sqllimit = $" ORDER BY gc.addtime desc LIMIT {(pageIndex - 1) * pageSize},{pageSize} ";

                using (MySqlDataReader dr = SqlMySql.ExecuteDataReaderMaster(connName, CommandType.Text, sql + sqlwhere + sqllimit))
                {
                    while (dr.Read())
                    {
                        GoodsComment amodel = base.GetModel(dr);
                        if (amodel != null)
                        {
                            amodel.HeadImgUrl  = dr["HeadImgUrl"].ToString();
                            amodel.CommentImgs = C_AttachmentBLL.SingleModel.GetListByCache(amodel.Id, (int)AttachmentItemType.小程序商品评论轮播图);
                            list.Add(amodel);
                        }
                    }
                }

                if (list == null || list.Count <= 0)
                {
                    return(new List <GoodsComment>());
                }

                //点赞
                string ids = string.Join(",", list.Select(s => s.Id));
                List <CityUserFavoriteMsg> pointslist = CityUserFavoriteMsgBLL.SingleModel.GetListByaidAndMIds(aid, userid, ids, 1, (int)PointsDataType.评论);
                if (pointslist != null && pointslist.Count > 0)
                {
                    foreach (GoodsComment item in list)
                    {
                        CityUserFavoriteMsg pmodel = pointslist.FirstOrDefault(f => f.msgId == item.Id);
                        if (pmodel != null && pmodel.state == 0)
                        {
                            item.UserPoints = true;
                        }
                    }
                }

                count             = base.GetCountBySql(sqlcount + sqlwhere);
                model.DataList    = list;
                model.DataVersion = dataversion;
                model.Count       = count;

                if (paramsqlwhere == "")
                {
                    RedisUtil.Set <RedisModel <GoodsComment> >(string.Format(_redis_GoodsCommentApiKey, aid, storeid, goodsid, pageSize, pageIndex), model);
                }
            }
            else
            {
                count = model.Count;
            }


            return(model.DataList);
        }
Esempio n. 6
0
 public void RemoveCache(int minisnsId)
 {
     RedisUtil.Remove(string.Format(MemCacheKey.MinisnsDetailKey, minisnsId));
 }
Esempio n. 7
0
 public int GetSubscribeCacheVer(int flashDealId)
 {
     return(RedisUtil.GetVersion(GetSubsribeVerKey(flashDealId)));
 }
Esempio n. 8
0
        private void Del()
        {
            switch (this.RedisType)
            {
            case RedisType.String:
            {
                if (MessageBox.Show("要删除 " + this.RedisKey + " 吗?", "ask", MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button2) == DialogResult.Yes)
                {
                    RedisUtil.Execute(this.RedisServer.ConnStr, (db) =>
                        {
                            if (db.KeyDelete(this.RedisKey))
                            {
                                MessageBox.Show("success");
                            }
                            else
                            {
                                MessageBox.Show("fail");
                            }
                        }, (ex) =>
                        {
                            MessageBox.Show(ex.Message);
                        });
                }
                break;
            }

            case RedisType.Hash:
            {
                if (this.DGVData.CurrentRow == null)
                {
                    return;
                }
                var field = (string)this.DGVData.CurrentRow.Cells["name"].Value;
                if (MessageBox.Show("要删除 " + this.RedisKey + ":" + field + " 吗?", "ask", MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button2) == DialogResult.Yes)
                {
                    RedisUtil.Execute(this.RedisServer.ConnStr, (db) =>
                        {
                            if (db.HashDelete(this.RedisKey, field))
                            {
                                MessageBox.Show("success");
                            }
                            else
                            {
                                MessageBox.Show("fail");
                            }
                        }, (ex) =>
                        {
                            MessageBox.Show(ex.Message);
                        });
                }
                break;
            }

            case RedisType.List:
            {
                if (this.DGVData.CurrentRow == null)
                {
                    return;
                }
                var field = (string)this.DGVData.CurrentRow.Cells["item"].Value;
                if (MessageBox.Show("要删除 " + this.RedisKey + ":" + field + " 吗?", "ask", MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button2) == DialogResult.Yes)
                {
                    RedisUtil.Execute(this.RedisServer.ConnStr, (db) =>
                        {
                            if (db.ListRemove(this.RedisKey, field) >= 0)
                            {
                                MessageBox.Show("success");
                            }
                            else
                            {
                                MessageBox.Show("fail");
                            }
                        }, (ex) =>
                        {
                            MessageBox.Show(ex.Message);
                        });
                }
                break;
            }

            case RedisType.Set:
            {
                if (this.DGVData.CurrentRow == null)
                {
                    return;
                }
                var field = (string)this.DGVData.CurrentRow.Cells["members"].Value;
                if (MessageBox.Show("要删除 " + this.RedisKey + ":" + field + " 吗?", "ask", MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button2) == DialogResult.Yes)
                {
                    RedisUtil.Execute(this.RedisServer.ConnStr, (db) =>
                        {
                            if (db.SetRemove(this.RedisKey, field))
                            {
                                MessageBox.Show("success");
                            }
                            else
                            {
                                MessageBox.Show("fail");
                            }
                        }, (ex) =>
                        {
                            MessageBox.Show(ex.Message);
                        });
                }
                break;
            }

            case RedisType.SortedSet:
            {
                if (this.DGVData.CurrentRow == null)
                {
                    return;
                }
                var field = (string)this.DGVData.CurrentRow.Cells["Element"].Value;
                if (MessageBox.Show("要删除 " + this.RedisKey + ":" + field + " 吗?", "ask", MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button2) == DialogResult.Yes)
                {
                    RedisUtil.Execute(this.RedisServer.ConnStr, (db) =>
                        {
                            if (db.SortedSetRemove(this.RedisKey, field))
                            {
                                MessageBox.Show("success");
                            }
                            else
                            {
                                MessageBox.Show("fail");
                            }
                        }, (ex) =>
                        {
                            MessageBox.Show(ex.Message);
                        });
                }
                break;
            }
            }
        }
Esempio n. 9
0
 public void RemoveCachByKey(string key)
 {
     RedisUtil.Remove(key);
 }
Esempio n. 10
0
        public bool AddSubscribeMark(FlashDealItem flashItem, int userId)
        {
            int currVer = GetSubscribeCacheVer(flashItem.DealId);

            return(RedisUtil.Set <int?>(GetSubsribeMarkKey(flashItem.Id, userId), currVer, TimeSpan.FromDays(7)));
        }
Esempio n. 11
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="aid">权限表ID</param>
 /// <param name="storeid">多门店备用,店铺ID</param>
 /// <param name="have">有新订单_订单类型(EntGoodsType)</param>
 /// <returns></returns>
 public static bool RemoveIsHaveNewOrder(int aid, int storeid = 0, string have = "1_0")
 {
     return(RedisUtil.Set(string.Format(_redis_FoodGoodsOrder_HaveNewOrder_Key, aid, storeid), have));
 }
Esempio n. 12
0
 public static string IsHaveNewOrder(int aid, int storeid = 0)
 {
     return(RedisUtil.Get <string>(string.Format(_redis_FoodGoodsOrder_HaveNewOrder_Key, aid, storeid)));
 }
Esempio n. 13
0
 public static bool RemoveIsHaveNewOrder(string accountid, bool have = true)
 {
     return(RedisUtil.Set(string.Format(_redis_HaveNewOrder_Key, accountid), have));
 }
Esempio n. 14
0
        private void BtnSearch_Click(object sender, EventArgs e)
        {
            if (RedisServer == null)
            {
                return;
            }
            var key = this.TBSearchKey.Text;

            if (string.IsNullOrWhiteSpace(key))
            {
                return;
            }

            if (!EntityTableEngine.LocalEngine.Exists(Global.TBName_SearchLog, key))
            {
                EntityTableEngine.LocalEngine.Insert <SearchLog>(Global.TBName_SearchLog, new SearchLog
                {
                    Key        = key,
                    Mark       = string.Empty,
                    ServerName = this.RedisServer.ServerName,
                });
            }

            DateTime time = DateTime.Now;

            RedisUtil.Execute(RedisServer.ConnStr, (client) =>
            {
                tabControl1.SelectedTab = TabPageData;
                TBMsg.Text     = "";
                var keytype    = client.KeyType(key);
                this.RedisType = keytype;
                this.RedisKey  = key;
                switch (keytype)
                {
                case RedisType.Unknown:
                case RedisType.None:
                    {
                        tabControl1.SelectedTab = TabPageInfo;
                        TBMsg.Text = string.Format("键 {0} 不存在", key);
                        break;
                    }

                case RedisType.String:
                    {
                        var str      = (string)client.StringGet(key);
                        DataTable dt = new DataTable();

                        dt.Columns.Add("key");
                        dt.Columns.Add("value");
                        dt.Columns.Add("valuetype");
                        dt.Rows.Add(TBSearchKey.Text, str, "str");
                        this.DGVData.DataSource = dt;

                        break;
                    }

                case RedisType.Hash:
                    {
                        DataTable dt = new DataTable();
                        dt.Columns.Add("name");
                        dt.Columns.Add("nametype");
                        dt.Columns.Add("value");
                        dt.Columns.Add("valuetype");
                        if (string.IsNullOrWhiteSpace(GetSubKey))
                        {
                            var hashs = client.HashGetAll(key);

                            foreach (var hash in hashs)
                            {
                                dt.Rows.Add(hash.Name, hash.Name.IsInteger?"int":"str", hash.Value, hash.Value.IsInteger?"int":"str");
                            }
                        }
                        else
                        {
                            var value = client.HashGet(key, GetSubKey);
                            if (value.HasValue)
                            {
                                dt.Rows.Add(GetSubKey, "str", value, value.IsInteger?"int":"str");
                            }
                            else
                            {
                                RedisValue rv = RedisValue.Null;
                                if (RedisUtil.TryParseNumber(GetSubKey, out rv))
                                {
                                    dt.Rows.Add(GetSubKey, "int", value, value.IsInteger?"int":"str");
                                }
                            }
                        }
                        this.DGVData.DataSource = dt;
                        break;
                    }

                case RedisType.Set:
                    {
                        DataTable dt = new DataTable();
                        dt.Columns.Add("members");
                        dt.Columns.Add("valuetype");

                        if (string.IsNullOrWhiteSpace(GetSubKey))
                        {
                            var sets = client.SetMembers(key);

                            foreach (var set in sets)
                            {
                                dt.Rows.Add(set, set.IsInteger?"int":"str");
                            }
                        }
                        else
                        {
                            var value = client.SetContains(key, GetSubKey);
                            if (value)
                            {
                                dt.Rows.Add(GetSubKey, "str");
                            }
                            else
                            {
                                RedisValue rv = RedisValue.Null;
                                if (RedisUtil.TryParseNumber(GetSubKey, out rv))
                                {
                                    value = client.SetContains(key, GetSubKey);
                                    if (value)
                                    {
                                        dt.Rows.Add(GetSubKey, "int");
                                    }
                                }
                            }
                        }
                        this.DGVData.DataSource = dt;
                        break;
                    }

                case RedisType.List:
                    {
                        var list     = client.ListRange(key, 0, 2000);
                        DataTable dt = new DataTable();
                        dt.Columns.Add("item");
                        dt.Columns.Add("valuetype");
                        foreach (var item in list)
                        {
                            dt.Rows.Add(item, item.IsInteger?"int":"str");
                        }
                        this.DGVData.DataSource = dt;
                        break;
                    }

                case RedisType.SortedSet:
                    {
                        DataTable dt = new DataTable();
                        dt.Columns.Add("Element");
                        dt.Columns.Add("ElementType");
                        dt.Columns.Add("Score");

                        if (string.IsNullOrWhiteSpace(GetSubKey))
                        {
                            //var ssets = client.SortedSetRangeByRankWithScores(key, 0, 100);
                            var ssets = client.SortedSetRangeByRankWithScores(key, 0, 2000);

                            foreach (var set in ssets)
                            {
                                dt.Rows.Add(set.Element, set.Element.IsInteger ? "int" : "str", set.Score);
                            }
                        }
                        else
                        {
                            var sset = client.SortedSetScore(key, GetSubKey);
                            if (sset.HasValue)
                            {
                                dt.Rows.Add(GetSubKey, "str", sset.Value);
                            }
                            else
                            {
                                RedisValue rv = RedisValue.Null;
                                if (RedisUtil.TryParseNumber(GetSubKey, out rv))
                                {
                                    sset = client.SortedSetScore(key, rv);
                                    if (sset.HasValue)
                                    {
                                        dt.Rows.Add(GetSubKey, "int", sset.Value);
                                    }
                                }
                            }
                        }
                        this.DGVData.DataSource = dt;
                        break;
                    }
                }

                TBMsg.Text += string.Format("\r\n查询用时{0}ms", DateTime.Now.Subtract(time).TotalMilliseconds);
            }, (ex) =>
            {
                tabControl1.SelectedTab = TabPageInfo;
                TBMsg.Text = ex.ToString();
                //TBMsg.Text = string.Format("查询用时{0}ms", DateTime.Now.Subtract(time).TotalMilliseconds);
            });
        }
Esempio n. 15
0
 public void UpdateSubscribeCacheVer(int flashDealId)
 {
     RedisUtil.SetVersion(GetSubsribeVerKey(flashDealId));
 }
Esempio n. 16
0
        private void 统计条数ToolStripMenuItem_Click(object sender, EventArgs e)
        {
            if (RedisServer == null)
            {
                return;
            }
            var key = this.TBSearchKey.Text;

            if (string.IsNullOrWhiteSpace(key))
            {
                return;
            }

            if (!EntityTableEngine.LocalEngine.Exists(Global.TBName_SearchLog, key))
            {
                EntityTableEngine.LocalEngine.Insert <SearchLog>(Global.TBName_SearchLog, new SearchLog
                {
                    Key        = key,
                    Mark       = string.Empty,
                    ServerName = this.RedisServer.ServerName,
                });
            }

            DateTime time = DateTime.Now;

            RedisUtil.Execute(RedisServer.ConnStr, (client) =>
            {
                tabControl1.SelectedTab = TabPageData;
                TBMsg.Text     = "";
                var keytype    = client.KeyType(key);
                this.RedisType = keytype;
                this.RedisKey  = key;
                switch (keytype)
                {
                case RedisType.Unknown:
                case RedisType.None:
                    {
                        break;
                    }

                case RedisType.Hash:
                    {
                        MessageBox.Show("总条数" + client.HashLength(key));
                        break;
                    }

                case RedisType.Set:
                    {
                        MessageBox.Show("总条数" + client.SetLength(key));
                        break;
                    }

                case RedisType.List:
                    {
                        MessageBox.Show("总条数" + client.ListLength(key));
                        break;
                    }

                case RedisType.SortedSet:
                    {
                        MessageBox.Show("总条数" + client.SortedSetLength(key));
                        break;
                    }
                }

                TBMsg.Text += string.Format("\r\n查询用时{0}ms", DateTime.Now.Subtract(time).TotalMilliseconds);
            }, (ex) =>
            {
                tabControl1.SelectedTab = TabPageInfo;
                TBMsg.Text = ex.ToString();
                //TBMsg.Text = string.Format("查询用时{0}ms", DateTime.Now.Subtract(time).TotalMilliseconds);
            });
        }
Esempio n. 17
0
        /// <summary>
        /// 获取历史消息
        /// </summary>
        /// <param name="id"></param>
        /// <param name="fuserId"></param>
        /// <param name="tuserId"></param>
        /// <returns></returns>
        public List <ImMessage> GetHistory(int id, int fuserId, int tuserId, int fuserType, int ver)
        {
            List <ImMessage> messageList = new List <ImMessage>();
            string           fkey        = string.Empty;
            string           tkey        = string.Empty;

            //客户
            if (fuserType == 0)
            {
                if (ver == 0)
                {
                    fkey = $"immessagekey_{fuserId}_{tuserId}_1";//0跟1取决于接收消息的人的用户类型
                }
                else
                {
                    fkey = $"immessagekey_{fuserId}_{tuserId}_0";
                }
                messageList = RedisUtil.GetRange <ImMessage>(fkey);
                tkey        = $"immessagekey_{tuserId}_{fuserId}_0";//0跟1取决于接收消息的人的用户类型
                messageList.AddRange(RedisUtil.GetRange <ImMessage>(tkey));
                // log4net.LogHelper.WriteInfo(GetType(), $"{fuserId},{tuserId},{ver}");
                if (ver == 0)
                {
                    if (id <= 0)
                    {
                        messageList.AddRange(GetList($"((fuserid={fuserId} and tuserid={tuserId} and tusertype=1)or(fuserid={tuserId} and tuserid={fuserId} and tusertype=0))", 20, 1, "*", "senddate desc"));
                    }
                    else
                    {
                        messageList.AddRange(GetList($"((fuserid={fuserId} and tuserid={tuserId} and tusertype=1)or(fuserid={tuserId} and tuserid={fuserId} and tusertype=0)) and id<{id}", 20, 1, "*", "senddate desc"));
                    }
                }
                else
                {
                    if (id <= 0)
                    {
                        messageList.AddRange(GetList($"((fuserid={fuserId} and tuserid={tuserId} and tusertype=0)or(fuserid={tuserId} and tuserid={fuserId} and tusertype=0))", 20, 1, "*", "senddate desc"));
                    }
                    else
                    {
                        messageList.AddRange(GetList($"((fuserid={fuserId} and tuserid={tuserId} and tusertype=0)or(fuserid={tuserId} and tuserid={fuserId} and tusertype=0)) and id<{id}", 20, 1, "*", "senddate desc"));
                    }
                }
            }
            //技师
            else if (fuserType == 1)
            {
                fkey        = $"immessagekey_{fuserId}_{tuserId}_0";
                messageList = RedisUtil.GetRange <ImMessage>(fkey);
                tkey        = $"immessagekey_{tuserId}_{fuserId}_1";
                messageList.AddRange(RedisUtil.GetRange <ImMessage>(tkey));

                messageList = messageList.Where(msg => (msg.fuserId == fuserId && msg.tuserId == tuserId && msg.tuserType == 0) || (msg.tuserId == fuserId && msg.fuserId == tuserId && msg.tuserType == 1)).ToList();
                if (id <= 0)
                {
                    messageList.AddRange(GetList($"((fuserid={fuserId} and tuserid={tuserId} and tusertype=0)or(fuserid={tuserId} and tuserid={fuserId} and tusertype=1))", 20, 1, "*", "senddate desc"));
                }
                else
                {
                    messageList.AddRange(GetList($"((fuserid={fuserId} and tuserid={tuserId} and tusertype=0)or(fuserid={tuserId} and tuserid={fuserId} and tusertype=1)) and id<{id}", 20, 1, "*", "senddate desc"));
                }
            }
            messageList = messageList.OrderBy(x => x.sendDate).ToList();
            return(messageList);
        }
Esempio n. 18
0
 /// <summary>
 /// 删除缓存
 /// </summary>
 /// <param name="itemId"></param>
 /// <param name="itemType"></param>
 public void RemoveRedis(int itemId, int itemType)
 {
     RedisUtil.Remove(string.Format(CVideoKey, itemId, itemType));
 }
Esempio n. 19
0
        /// <summary>
        /// 缓存获取针对某个人的未读消息数
        /// </summary>
        /// <param name="tuserId"></param>
        /// <param name="fuserId"></param>
        /// <returns></returns>
        public int GetUserNoReadCount(int tuserId, int fuserId)
        {
            string key = string.Format(_redis_UserMessageCount, tuserId, fuserId);

            return(RedisUtil.Get <int>(key));
        }
Esempio n. 20
0
        /// <summary>
        /// 后台获取该模板商品的评论
        /// </summary>
        /// <param name="goodsname"></param>
        /// <param name="aid"></param>
        /// <param name="storeid"></param>
        /// <param name="pageIndex"></param>
        /// <param name="pageSize"></param>
        /// <param name="count"></param>
        /// <param name="reflesh"></param>
        /// <returns></returns>
        public List <GoodsComment> GetGoodsCommentList(string goodsname, int aid, int storeid, int pageIndex, int pageSize, ref int count, bool reflesh = true)
        {
            List <MySqlParameter> parms = new List <MySqlParameter>();
            string extrawhere           = "";

            if (!string.IsNullOrEmpty(goodsname))
            {
                extrawhere += $" and goodsname like @goodsname ";
                reflesh     = true;
                parms.Add(new MySqlParameter("goodsname", "%" + goodsname + "%"));
            }

            RedisModel <GoodsComment> model = new RedisModel <GoodsComment>();

            model = RedisUtil.Get <RedisModel <GoodsComment> >(string.Format(_redis_GoodsCommentKey, aid, storeid, pageSize, pageIndex));
            int dataversion = RedisUtil.GetVersion(string.Format(_redis_GoodsCommentVersion, aid));

            if (reflesh || model == null || model.DataList == null || model.DataList.Count <= 0 || model.DataVersion != dataversion)
            {
                model = new RedisModel <GoodsComment>();
                List <GoodsComment> list = new List <GoodsComment>();

                string sqlcount = $" select Count(*) from GoodsComment";
                string sql      = $" select * from GoodsComment";
                string sqlwhere = $" where state>-1 and aid = {aid} and storeid={storeid} {extrawhere}";


                string sqllimit = $" ORDER BY addtime desc LIMIT {(pageIndex - 1) * pageSize},{pageSize} ";

                using (MySqlDataReader dr = SqlMySql.ExecuteDataReaderMaster(connName, CommandType.Text, sql + sqlwhere + sqllimit, parms.ToArray()))
                {
                    while (dr.Read())
                    {
                        GoodsComment amodel = base.GetModel(dr);
                        //if(amodel!=null)
                        //{
                        //    amodel.CommentImgs = C_AttachmentBLL.SingleModel.GetListByCache(amodel.Id, (int)AttachmentItemType.小程序商品评论轮播图);
                        //    list.Add(amodel);
                        //}
                        list.Add(amodel);
                    }
                }

                if (list == null || list.Count <= 0)
                {
                    return(new List <GoodsComment>());
                }

                count             = base.GetCountBySql(sqlcount + sqlwhere, parms.ToArray());
                model.DataList    = list;
                model.DataVersion = dataversion;
                model.Count       = count;
                if (extrawhere == "")
                {
                    RedisUtil.Set <RedisModel <GoodsComment> >(string.Format(_redis_GoodsCommentKey, aid, storeid, pageSize, pageIndex), model);
                }
            }
            else
            {
                count = model.Count;
            }

            return(model.DataList);
        }
Esempio n. 21
0
        /// <summary>
        /// 删除缓存获取针对某个人的未读消息数
        /// </summary>
        /// <param name="tuserId"></param>
        /// <param name="fuserId"></param>
        /// <returns></returns>
        public void RemoveUserNoReadCount(int tuserId, int fuserId)
        {
            string key = string.Format(_redis_UserMessageCount, fuserId, tuserId);

            RedisUtil.Set <int>(key, 0);
        }
        public ActionResult <List <GameResult> > GetRankings()
        {
            var topRankings = RedisUtil.GetTopRankings(0, 9);

            return(topRankings);
        }
Esempio n. 23
0
        public List <StoreGoods> GetListByStoreId(int sid, int typeid, int pageindex = 1, int pagesize = 10, int orderbyid = 0, string goodname = "")
        {
            List <MySqlParameter> listParam = new List <MySqlParameter>();

            string models_key     = string.Format(Redis_StoreGoodsList, sid, typeid, pageindex, pagesize);
            string version_key    = string.Format(Redis_StoreGoodsList_version, sid);
            int    version        = RedisUtil.GetVersion(version_key);
            bool   noWhereOrderby = true;//是否默认条件及排序

            string where = $" StoreId=@StoreId and State>=0 and IsSell = 1 ";
            listParam.Add(new MySqlParameter("@StoreId", sid));
            if (typeid > 0)
            {
                where += $" and TypeId = @TypeId";
                listParam.Add(new MySqlParameter("@TypeId", typeid));

                noWhereOrderby = false;
            }
            if (!string.IsNullOrEmpty(goodname))
            {
                where += $" and GoodsName like @GoodsName";
                listParam.Add(new MySqlParameter("@GoodsName", "%" + goodname + "%"));

                noWhereOrderby = false;
            }
            string orderstr = "Sort Desc,Id Desc";

            switch (orderbyid)
            {
            case 0:
                orderstr = "Sort Desc,Id Desc";
                break;

            case 1:
                orderstr = "Price Desc";

                noWhereOrderby = false;
                break;

            case 2:
                orderstr = "Price asc";

                noWhereOrderby = false;
                break;

            case 3:
                orderstr = "Inventory Desc";

                noWhereOrderby = false;
                break;

            case 4:
                orderstr = "Inventory asc";

                noWhereOrderby = false;
                break;

            case 5:
                orderstr = "(Inventory - Stock) Desc";

                noWhereOrderby = false;
                break;

            case 6:
                orderstr = "(Inventory - Stock) asc";

                noWhereOrderby = false;
                break;
            }
            listParam.Add(new MySqlParameter("@pageindex", (pageindex - 1) * pagesize));
            listParam.Add(new MySqlParameter("@pagesize", pagesize));


            RedisModel <StoreGoods> redisModel_StoreGoods = RedisUtil.Get <RedisModel <StoreGoods> >(models_key);

            //if (!noWhereOrderby || redisModel_StoreGoods == null
            //        || redisModel_StoreGoods.DataList == null || redisModel_StoreGoods.DataList.Count <= 0 || redisModel_StoreGoods.DataVersion != version)
            //{
            redisModel_StoreGoods = new RedisModel <StoreGoods>();

            string sql = $@"select * from StoreGoods
                           where {where} ORDER BY {orderstr}  LIMIT @pageindex,@pagesize";

            List <StoreGoods> list = new List <StoreGoods>();

            using (MySqlDataReader dr = SqlMySql.ExecuteDataReaderMaster(connName, CommandType.Text, sql, listParam.ToArray()))
            {
                while (dr.Read())
                {
                    var model = GetModel(dr);
                    list.Add(model);
                }
            }

            redisModel_StoreGoods.DataList    = list;
            redisModel_StoreGoods.DataVersion = version;
            redisModel_StoreGoods.Count       = list.Count;

            if (noWhereOrderby)    //只写默认条件的缓存
            {
                RedisUtil.Set <RedisModel <StoreGoods> >(models_key, redisModel_StoreGoods, TimeSpan.FromHours(12));
            }
            //}

            return(redisModel_StoreGoods.DataList);
        }
Esempio n. 24
0
        public void RemoveVersion(int agentId)
        {
            string key = string.Format(_redis_XcxAppAccountRelationModelVersion, agentId);

            RedisUtil.SetVersion(key);
        }
Esempio n. 25
0
        private void DelMul()
        {
            switch (this.RedisType)
            {
            case RedisType.String:
            {
                if (MessageBox.Show("要删除 " + this.RedisKey + " 吗?", "ask", MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button2) == DialogResult.Yes)
                {
                    RedisUtil.Execute(this.RedisServer.ConnStr, (db) =>
                        {
                            if (db.KeyDelete(this.RedisKey))
                            {
                                MessageBox.Show("success");
                            }
                            else
                            {
                                MessageBox.Show("fail");
                            }
                        }, (ex) =>
                        {
                            MessageBox.Show(ex.Message);
                        });
                }
                break;
            }

            case RedisType.Hash:
            {
                if (this.DGVData.CurrentRow == null)
                {
                    return;
                }

                if (MessageBox.Show("要删除 " + this.RedisKey + ":选择的项吗?", "ask", MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button2) == DialogResult.Yes)
                {
                    int delcount  = 0;
                    int failcount = 0;
                    foreach (DataGridViewRow item in DGVData.SelectedRows)
                    {
                        var field = (string)item.Cells["name"].Value;
                        RedisUtil.Execute(this.RedisServer.ConnStr, (db) =>
                            {
                                if (db.HashDelete(this.RedisKey, field))
                                {
                                    //MessageBox.Show("success");
                                    delcount++;
                                }
                                else
                                {
                                    //MessageBox.Show("fail");
                                    failcount++;
                                }
                            }, (ex) =>
                            {
                                MessageBox.Show(ex.Message);
                            });
                    }
                    MessageBox.Show("success:" + delcount + ",fail:" + failcount);
                }
                break;
            }

            case RedisType.List:
            {
                if (this.DGVData.CurrentRow == null)
                {
                    return;
                }

                if (MessageBox.Show("要删除 " + this.RedisKey + ":选定的项吗?", "ask", MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button2) == DialogResult.Yes)
                {
                    int delcount = 0, failcount = 0;
                    foreach (DataGridViewRow row in DGVData.SelectedRows)
                    {
                        var field = (string)row.Cells["item"].Value;
                        RedisUtil.Execute(this.RedisServer.ConnStr, (db) =>
                            {
                                if (db.ListRemove(this.RedisKey, field) >= 0)
                                {
                                    //MessageBox.Show("success");
                                    delcount++;
                                }
                                else
                                {
                                    //MessageBox.Show("fail");
                                    failcount++;
                                }
                            }, (ex) =>
                            {
                                MessageBox.Show(ex.Message);
                            });
                    }

                    MessageBox.Show("success:" + delcount + ",fail:" + failcount);
                }
                break;
            }

            case RedisType.Set:
            {
                if (this.DGVData.CurrentRow == null)
                {
                    return;
                }

                if (MessageBox.Show("要删除 " + this.RedisKey + ":选定的项吗?", "ask", MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button2) == DialogResult.Yes)
                {
                    int delcount = 0, failcount = 0;
                    foreach (DataGridViewRow row in DGVData.SelectedRows)
                    {
                        var field = (string)row.Cells["members"].Value;
                        RedisUtil.Execute(this.RedisServer.ConnStr, (db) =>
                            {
                                if (db.SetRemove(this.RedisKey, field))
                                {
                                    //MessageBox.Show("success");
                                    delcount++;
                                }
                                else
                                {
                                    //MessageBox.Show("fail");
                                    failcount++;
                                }
                            }, (ex) =>
                            {
                                MessageBox.Show(ex.Message);
                            });
                    }
                    MessageBox.Show("success:" + delcount + ",fail:" + failcount);
                }
                break;
            }

            case RedisType.SortedSet:
            {
                if (this.DGVData.CurrentRow == null)
                {
                    return;
                }

                if (MessageBox.Show("要删除 " + this.RedisKey + ":选定的项 吗?", "ask", MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button2) == DialogResult.Yes)
                {
                    int delcount = 0, failcount = 0;
                    foreach (DataGridViewRow row in DGVData.SelectedRows)
                    {
                        var field = (string)row.Cells["Element"].Value;
                        RedisUtil.Execute(this.RedisServer.ConnStr, (db) =>
                            {
                                if (db.SortedSetRemove(this.RedisKey, field))
                                {
                                    //MessageBox.Show("success");
                                    delcount++;
                                }
                                else
                                {
                                    //MessageBox.Show("fail");
                                    failcount++;
                                }
                            }, (ex) =>
                            {
                                MessageBox.Show(ex.Message);
                            });
                    }
                    MessageBox.Show("success:" + delcount + ",fail:" + failcount);
                }
                break;
            }
            }
        }
Esempio n. 26
0
        public void RemoveRedis(int id)
        {
            string key = string.Format(_redis_XcxTemplateModelKey, id);

            RedisUtil.Remove(key);
        }
Esempio n. 27
0
        private void RedisUpdate()
        {
            SubUpdateForm subform = null;

            switch (this.RedisType)
            {
            case RedisType.String:
            {
                subform          = new SubUpdateForm();
                subform.Key      = this.RedisKey;
                subform.OldValue = (string)DGVData.Rows[0].Cells[1].Value;
                subform.IsNumber = false;
                if (subform.ShowDialog() == DialogResult.Yes)
                {
                    RedisUtil.Execute(this.RedisServer.ConnStr, (db) =>
                        {
                            if (db.StringSet(this.RedisKey, subform.NewValue))
                            {
                                MessageBox.Show("success");
                            }
                            else
                            {
                                MessageBox.Show("fail");
                            }
                        }, (ex) =>
                        {
                            MessageBox.Show(ex.Message);
                        });
                }
                break;
            }

            case RedisType.Hash:
            {
                if (this.DGVData.CurrentRow == null)
                {
                    return;
                }
                subform = new SubUpdateForm();

                var field = (string)this.DGVData.CurrentRow.Cells["name"].Value;
                subform.Key      = this.RedisKey + ":" + field;
                subform.OldValue = this.DGVData.CurrentRow.Cells["value"].Value.ToString();
                if (subform.ShowDialog() == DialogResult.Yes)
                {
                    RedisUtil.Execute(this.RedisServer.ConnStr, (db) =>
                        {
                            db.HashSet(this.RedisKey, field, subform.NewValue);
                            MessageBox.Show("success");
                        }, (ex) =>
                        {
                            MessageBox.Show(ex.Message);
                        });
                }
                break;
            }

            case RedisType.SortedSet:
            {
                if (this.DGVData.CurrentRow == null)
                {
                    return;
                }
                subform = new SubUpdateForm();
                var field = (string)this.DGVData.CurrentRow.Cells["Element"].Value;
                subform.Key      = this.RedisKey + ":" + field;
                subform.OldValue = this.DGVData.CurrentRow.Cells["Score"].Value.ToString();
                subform.IsNumber = true;
                if (subform.ShowDialog() == DialogResult.Yes)
                {
                    RedisUtil.Execute(this.RedisServer.ConnStr, (db) =>
                        {
                            db.SortedSetAdd(RedisKey, field, (double)subform.NewValue);

                            MessageBox.Show("success");
                        }, (ex) =>
                        {
                            MessageBox.Show(ex.Message);
                        });
                }
                break;
            }
            }
        }
Esempio n. 28
0
        public ActionResult SaveUserInfo()
        {
            string password      = Utility.IO.Context.GetRequest("password", string.Empty);
            string phone         = Utility.IO.Context.GetRequest("phone", string.Empty);
            string code          = Utility.IO.Context.GetRequest("code", string.Empty);
            string address       = Utility.IO.Context.GetRequest("address", string.Empty);
            string sourcefrom    = Utility.IO.Context.GetRequest("sourcefrom", "");
            int    agentqrcodeid = Utility.IO.Context.GetRequestInt("agentqrcodeid", 0);
            int    opentype      = Utility.IO.Context.GetRequestInt("opentype", 0);
            string username      = Utility.IO.Context.GetRequest("username", "");

            _msg.isok = false;
            //if (agentqrcodeid>0 && string.IsNullOrEmpty(username))
            //{
            //    _msg.Msg = "请输入姓名";
            //    return Json(_msg, JsonRequestBehavior.AllowGet);
            //}
            if (string.IsNullOrEmpty(phone))
            {
                _msg.Msg = "请输入手机号";
                return(Json(_msg, JsonRequestBehavior.AllowGet));
            }
            if (string.IsNullOrEmpty(code))
            {
                _msg.Msg = "请输入验证码";
                return(Json(_msg, JsonRequestBehavior.AllowGet));
            }
            if (string.IsNullOrEmpty(password))
            {
                _msg.Msg = "请输入密码";
                return(Json(_msg, JsonRequestBehavior.AllowGet));
            }

            if (sourcefrom.Length > 20)
            {
                _msg.Msg = "无效来源";
                return(Json(_msg, JsonRequestBehavior.AllowGet));
            }
            if (!string.IsNullOrEmpty(phone))
            {
                Account tempaccout = AccountBLL.SingleModel.GetModelByPhone(phone);
                if (tempaccout != null)
                {
                    _msg.Msg = "该手机号已被注册";
                    return(Json(_msg, JsonRequestBehavior.AllowGet));
                }
            }


            //是否校验手机号,0检验,1不校验
            //校验验证码
            _msg = CommondHelper.CheckVaildCode(phone, code);
            if (!_msg.isok)
            {
                return(Json(_msg, JsonRequestBehavior.AllowGet));
            }
            Account account = null;

            //如果是代理分销扫描注册,测判断绑定的手机号是否已经注册过账号,如果没有则注册一个账号
            if (agentqrcodeid > 0)
            {
                sourcefrom = "代理分销推广";
                account    = AccountBLL.SingleModel.GetModelByPhone(phone);
            }
            if (account == null)
            {
                account = AccountBLL.SingleModel.WeiXinRegister("", 0, "", true, address, phone, sourcefrom, password);
            }
            else
            {
                //修改已经注册过的用户信息
                AccountBLL.SingleModel.UpdateUserInfo(account.Id.ToString(), phone, password, address);
            }

            if (account != null)
            {
                //用户已绑定手机号,判断是否有单页版
                XcxAppAccountRelation usertemplate = XcxAppAccountRelationBLL.SingleModel.GetModelByaccound(account.Id.ToString());
                if (usertemplate == null)
                {
                    //免费开通单页版
                    XcxAppAccountRelationBLL.SingleModel.AddFreeTemplate(account);
                }

                //如果是扫分销代理码注册,则开通代理,
                if (agentqrcodeid > 0)
                {
                    //判断是否是代理商
                    Agentinfo agentinfo = AgentinfoBLL.SingleModel.GetModelByAccoundId(account.Id.ToString(), -1);
                    if (agentinfo != null)
                    {
                        _msg.isok = true;
                        _msg.Msg  = "注册失败,该号码已绑定了代理商账号";
                        return(Json(_msg, JsonRequestBehavior.AllowGet));
                    }

                    _msg.Msg = _agentDistributionRelationBLL.CreateDistributionAgent(account.Id.ToString(), agentqrcodeid, opentype, username);
                    if (_msg.Msg != "")
                    {
                        return(Json(_msg, JsonRequestBehavior.AllowGet));
                    }
                }

                _msg.isok = true;
                _msg.Msg  = "注册成功";
            }
            else
            {
                _msg.isok = false;
                _msg.Msg  = "注册失败";
            }
            string key = string.Format(_resetPasswordkey, phone);

            RedisUtil.Remove(key);

            return(Json(_msg, JsonRequestBehavior.AllowGet));
        }
Esempio n. 29
0
        void TCBSearchKey_TextChanged(object obj)
        {
            var key = (string)LJC.FrameWork.Comm.ReflectionHelper.Eval(obj, "key");

            this.TCBSearchKey.Text = key;

            if (RedisServer == null)
            {
                return;
            }
            DateTime time = DateTime.Now;

            RedisUtil.Execute(RedisServer.ConnStr, (client) =>
            {
                tabControl1.SelectedTab = TabPageData;
                TBMsg.Text     = "";
                var keytype    = client.KeyType(key);
                this.RedisKey  = key;
                this.RedisType = keytype;
                switch (keytype)
                {
                case RedisType.Unknown:
                case RedisType.None:
                    {
                        tabControl1.SelectedTab = TabPageInfo;
                        TBMsg.Text = string.Format("键 {0} 不存在", key);
                        break;
                    }

                case RedisType.String:
                    {
                        var str      = (string)client.StringGet(key);
                        DataTable dt = new DataTable();
                        dt.Columns.Add("key");
                        dt.Columns.Add("value");
                        dt.Rows.Add(key, str);
                        this.DGVData.DataSource = dt;

                        break;
                    }

                case RedisType.Hash:
                    {
                        var hashs    = client.HashGetAll(key);
                        DataTable dt = new DataTable();
                        dt.Columns.Add("name");
                        dt.Columns.Add("value");
                        foreach (var hash in hashs)
                        {
                            dt.Rows.Add(hash.Name, hash.Value);
                        }
                        this.DGVData.DataSource = dt;
                        break;
                    }

                case RedisType.Set:
                    {
                        var sets     = client.SetMembers(key);
                        DataTable dt = new DataTable();
                        dt.Columns.Add("members");
                        foreach (var set in sets)
                        {
                            dt.Rows.Add(set);
                        }
                        this.DGVData.DataSource = dt;
                        break;
                    }

                case RedisType.List:
                    {
                        var list     = client.ListRange(key, 0, 2000);
                        DataTable dt = new DataTable();
                        dt.Columns.Add("item");
                        foreach (var item in list)
                        {
                            dt.Rows.Add(item);
                        }
                        this.DGVData.DataSource = dt;
                        break;
                    }

                case RedisType.SortedSet:
                    {
                        var ssets    = client.SortedSetRangeByRankWithScores(key, 0, 2000);
                        DataTable dt = new DataTable();
                        dt.Columns.Add("Element");
                        dt.Columns.Add("Score");
                        foreach (var set in ssets)
                        {
                            dt.Rows.Add(set.Element, set.Score);
                        }
                        this.DGVData.DataSource = dt;
                        break;
                    }
                }

                TBMsg.Text += string.Format("\r\n查询用时{0}ms", DateTime.Now.Subtract(time).TotalMilliseconds);
            }, (ex) =>
            {
                tabControl1.SelectedTab = TabPageInfo;
                TBMsg.Text = ex.ToString();
                //TBMsg.Text = string.Format("查询用时{0}ms", DateTime.Now.Subtract(time).TotalMilliseconds);
            });
        }