示例#1
0
        public void DoTheJob()
        {
            var _timeToSleepMS = 1000 * 60;

            //TODO: use IoC http://docs.hangfire.io/en/latest/background-methods/using-ioc-containers.html
            Thread.Sleep(_timeToSleepMS);
            using (var context = new DockerContext())
            {
                var jobResult = new JobResult()
                {
                    CreateDate  = DateTime.UtcNow,
                    MachineName = System.Environment.MachineName,
                    Result      = $"I've Slept for {_timeToSleepMS} ms"
                };
                context.JobResults.Add(jobResult);
                context.SaveChanges();
            }
        }
示例#2
0
        public ActionResult Index()
        {
            ViewBag.VisitCount = 1;
            string ipAddress = Request.ServerVariables["HTTP_X_FORWARDED_FOR"];

            if (string.IsNullOrEmpty(ipAddress))
            {
                ipAddress = Request.ServerVariables["REMOTE_ADDR"];
            }
            using (var context = new DockerContext())
            {
                var visit = new DockerData.Entities.Visit()
                {
                    IPAddress  = ipAddress,
                    CreateDate = DateTime.UtcNow
                };
                context.Visits.Add(visit);
                context.SaveChanges();
                ViewBag.VisitCount = context.Visits.Count();
            }
            return(View());
        }
示例#3
0
 public virtual void Store(T entity)
 {
     DbSet.Add(entity);
     Context.SaveChanges();
 }