public void Test() { using (var ctx = new SimulationContext()) { ctx.Addresses.Add(new Address("Test", "Test", "Test", "Test")); ctx.SaveChanges(); } }
public void CreateTracker() { using (var ctx = new SimulationContext()) { Tracker t = new Tracker(0, 0, DateTime.Now); ctx.Trackers.Add(t); ctx.SaveChanges(); } }
public void Post() { using (var ctx = new SimulationContext()) { Tracker tracker = ctx.Trackers.Where(t => t.ID == 1).SingleOrDefault(); tracker.Routes.Add(mapRepo.generateRoute(tracker)); ctx.SaveChanges(); } }
public Models.Route generateRoute(Tracker tracker) { using (var ctx = new SimulationContext()) { Address start; Address end; getRouteAddres(tracker, out start, out end); Route route = new Route(start, end, getPolyline(mapResponse(start, end))); route.Markers = (ICollection <Marker>)GooglePoints.Decode(route.Polyline.points).ToList(); ctx.SaveChanges(); return(route); } }
public void Save(MeasureValueHolder holder) { SimulationContext context = new SimulationContext(); Func <TrialResult, bool> selecTionFunction = x => x.Size == ((int)holder.SimulationSize) && x.StartUtil == holder.StartUtilization.ToString() && x.Change == holder.ChangeAction.ToString() && x.Algorithm == holder.Strategy.ToString() && x.PushAuctionType == holder.Configuration.PushAuctionType.ToString() && x.PullAuctionType == holder.Configuration.PullAuctionType.ToString() && x.TestedPercent == (int)holder.TestedPercent && x.SchedulingAlgorithm == holder.Scheduling.ToString() && x.NetworkDelay == holder.NetworkDelay && x.ContainerType == holder.ContainerType.ToString() && x.TrialId == holder.TrialId; TrialResult t = context.TrialResults.SingleOrDefault(selecTionFunction) ?? new TrialResult(); t.Size = ((int)holder.SimulationSize); t.StartUtil = holder.StartUtilization.ToString(); t.Change = holder.ChangeAction.ToString(); t.Algorithm = holder.Strategy.ToString(); t.PushAuctionType = holder.Configuration.PushAuctionType.ToString(); t.PullAuctionType = holder.Configuration.PullAuctionType.ToString(); t.TestedPercent = (int)holder.TestedPercent; t.SchedulingAlgorithm = holder.Scheduling.ToString(); t.ContainerType = holder.ContainerType.ToString(); t.NetworkDelay = holder.NetworkDelay; t.TrialId = holder.TrialId; t.PredictionAlg = holder.Prediction.ToString(); t.AverageEntropy = holder.AverageEntropy; t.Power = holder.PowerConsumption; t.StdDev = holder.AverageStdDeviation; t.Hosts = holder.AverageHosts; t.RMSE = holder.RMSE; t.TotalMessages = holder.TotalMessages; t.TotalCommunicatedData = holder.TotalCommunicatedSize; t.Migrations = holder.TotalMigrations; t.SlaViolations = holder.TotalSlaViolationsCount; t.SlaViolationsPercent = holder.AverageSlaViolationsPercent; t.ImagePullsTotal = holder.ImagePulls; t.ImagePullsRatio = holder.AveragePullPerImage; t.FinalEntropy = holder.FinalEntropy; t.ContainersAverage = holder.AverageContainers; t.AverageContainerPerHost = holder.AverageContainersPerHost; t.TotalContainers = holder.TotalContainers; t.AverageDownTime = holder.AverageDownTime; context.TrialResults.AddOrUpdate(t); context.SaveChanges(); }