Exemplo n.º 1
0
        public void Create(WorkplaceOrder workplaceOrder)
        {
            Workplace workplace = sheringDBContext.Workplace.FirstOrDefault(e => e.Id == workplaceOrder.WorkplaceId);

            sheringDBContext.WorkplaceOrder.Add(workplaceOrder);
            sheringDBContext.SaveChanges();
        }
Exemplo n.º 2
0
        public void GenerateMonitoring(int clientId)
        {
            DateTime        curDate = DateTime.Now;
            List <DateTime> dates   = (from p in sheringDBContext.Diastance

                                       select new DateTime(p.Date.Year, p.Date.Month, p.Date.Day)).Distinct().ToList();

            //IEnumerable<DateTime> dates = sheringDBContext.Diastance
            //    .Where(y => y.Date.Year != DateTime.Now.Year
            //                && y.Date.Month != DateTime.Now.Month
            //                && y.Date.Day != DateTime.Now.Day)
            //    .Select(d => new {d.Date.Year, d.Date.Month, d.Date.Day})
            //    .Distinct()
            //    .ToList()
            //    .Select(x => new DateTime(x.Year, x.Month, x.Day));

            foreach (var date in dates)
            {
                var mon = sheringDBContext.Monitoring
                          .FirstOrDefault(x => x.Date.Year == date.Year && x.Date.Month == date.Month && x.Date.Day == date.Day);

                if (mon == null)
                {
                    int rightCount = sheringDBContext.Diastance
                                     .Count(x => x.DistanceValue >= 50 && x.DistanceValue <= 90);

                    int count = sheringDBContext.Diastance.Count();

                    double rightValues = 0;

                    if (count != 0)
                    {
                        rightValues = (double)((double)rightCount / count);
                    }

                    Monitoring monitoring = new Monitoring
                    {
                        ClientId    = clientId,
                        Date        = date,
                        RightValues = rightValues
                    };

                    IEnumerable <Distance> distances = sheringDBContext.Diastance
                                                       .Where(x => x.Date.Year == date.Year && x.Date.Month == date.Month && x.Date.Day == date.Day);

                    sheringDBContext.Diastance.RemoveRange(distances);
                    sheringDBContext.SaveChanges();
                    sheringDBContext.Monitoring.Add(monitoring);
                    sheringDBContext.SaveChanges();
                }
            }
        }
Exemplo n.º 3
0
        public void Create(Client client)
        {
            sheringDBContext.Client.Add(client);

            int n = sheringDBContext.SaveChanges();

            if (n > 0)
            {
                cache.Set(client.Id, client, new MemoryCacheEntryOptions
                {
                    AbsoluteExpirationRelativeToNow = TimeSpan.FromMinutes(5)
                });
            }
        }
Exemplo n.º 4
0
        public ActionResult <string> Get(double id)
        {
            Distance distance = new Distance()
            {
                ClientId      = 1008,
                DistanceValue = id,
                Date          = DateTime.Now
            };

            sheringDBContext.Diastance.Add(distance);
            sheringDBContext.SaveChanges();
            return("value");
        }
Exemplo n.º 5
0
 public void Save()
 {
     sheringDBContext.SaveChanges();
 }
Exemplo n.º 6
0
 public void Create(SearchSetting searchSetting)
 {
     sheringDBContext.SearchSetting.Add(searchSetting);
     sheringDBContext.SaveChanges();
 }
Exemplo n.º 7
0
 public void Create(WorkplaceParameter workplace)
 {
     sheringDBContext.WorkplaceParameter.Add(workplace);
     sheringDBContext.SaveChanges();
 }
Exemplo n.º 8
0
 public void Create(Equipment equipment)
 {
     sheringDBContext.Equipment.Add(equipment);
     sheringDBContext.SaveChanges();
 }
Exemplo n.º 9
0
 public void Create(Landlord landlord)
 {
     sheringDBContext.Landlord.Add(landlord);
     sheringDBContext.SaveChanges();
 }
Exemplo n.º 10
0
 public void Create(Building building)
 {
     sheringDBContext.Building.Add(building);
     sheringDBContext.SaveChanges();
 }
Exemplo n.º 11
0
 public void Create(WorkplaceEquipment workplaceEquipment)
 {
     sheringDBContext.WorkplaceEquipment.Add(workplaceEquipment);
     sheringDBContext.SaveChanges();
 }