public ConsumerInfo GetConsumerInfo(string consumerId)
        {
            var          key    = "ConsumerInfo_" + consumerId;
            ConsumerInfo result = null;

            if (RedisCacheHelper.Exists(key))
            {
                result = RedisCacheHelper.GetCache <ConsumerInfo>(key);
            }
            if (result == null)
            {
                var doc           = dataOp.FindOneByQuery(MQConsumerInfo, Query.EQ("consumerId", consumerId));
                var ip            = doc.String("ip");
                var queueType     = doc.String("queueType");
                var id            = doc.String("consumerId");
                var isStart       = doc.Int("isStart");
                var lastStartTime = doc.Date("lastStartTime");
                var lastEndTime   = doc.Date("lastEndTime");
                var lastExecTime  = doc.Date("lastExecTime");
                result = new ConsumerInfo()
                {
                    consumerId    = id,
                    ip            = ip,
                    isStart       = isStart,
                    lastEndTime   = lastEndTime,
                    lastExecTime  = lastExecTime,
                    lastStartTime = lastStartTime,
                    queueType     = queueType
                };
                RedisCacheHelper.SetCache(key, result, DateTime.Now.AddDays(30));
            }
            return(result);
        }
        public string GetCustomerNameByJobId(string jobId)
        {
            var    key    = "JobIdCustomerName_" + jobId;
            string result = null;

            if (RedisCacheHelper.Exists(key))
            {
                result = RedisCacheHelper.GetCache <string>(key);
            }
            if (string.IsNullOrEmpty(result))
            {
                var doc  = dataOp.FindOneByQuery("BackgroundJob", Query.EQ("jobId", jobId));
                var code = doc.String("customerCode");
                doc    = dataOp.FindOneByQuery("CustomerInfo", Query.EQ("customerCode", code));
                result = doc.String("name");
                RedisCacheHelper.SetCache(key, result, DateTime.Now.AddDays(1));
            }
            return(result);
        }
Ejemplo n.º 3
0
        public ActionResult Index()
        {
            //var count = SQLHelper.ExecuteScalar("select COUNT(*) from Student");

            //var data = SQLHelper.ExecuteDataTable("select * from Student");

            //var countStudent = int.Parse(SQLHelper.ExecuteScalar("select COUNT(*) from Student where S#='10' ").ToString());
            //if (countStudent > 0)
            //{
            //    var temp = SQLHelper.ExecuteNonQuery("delete from Student where S#='10' ");
            //}

            //var insert = SQLHelper.ExecuteNonQuery("insert into student (s#,Sname,Sage,Ssex) values('10','aaaa','1990-04-01 00:00:00.000','男')");

            ViewData["message"] = "这是ViewData(string)" + IPHepler.GetLocalIP();



            Student stu = new Student {
                Age = 320, Name = "潘守军3", NO = "NO003"
            };

            //Student stu = new Student { Age = 10, Name = "潘守军", NO = "NO001" }//;
            ViewBag.ViewBagStu      = stu;
            ViewData["ViewDataStu"] = stu;
            TempData["TempDataStu"] = stu;

            if (!RedisCacheHelper.Exists(stu.NO))
            {
                RedisCacheHelper.Add <Student>(stu.NO, stu, DateTime.Now.AddMinutes(15));
            }
            else
            {
                var student = RedisCacheHelper.Get <Student>("NO001");
            }

            return(View());
        }