コード例 #1
0
        public EF.PointGeofenceNotification AddPointGeofenceNotification(EF.PointGeofenceNotification pointGeofenceNotification, int pointId, List <UserLight> notificationUsers)
        {
            try
            {
                //EF.DataContext.Current.AttachTo("PointGeofenceNotificationSet", pointGeofenceNotification);
                Guid weekActivePeriodId  = pointGeofenceNotification.WeekActivePeriod.WeekActivePeriodID;
                EF.WeekActivePeriod week = EF.DataContext.Current.WeekActivePeriodSet.First(w => w.WeekActivePeriodID == weekActivePeriodId);
                pointGeofenceNotification.WeekActivePeriod = week;

                EF.DataContext.Current.AddToPointGeofenceNotificationSet(pointGeofenceNotification);

                //dataContext1.AttachTo("PointGeofenceNotificationSet", pointGeofenceNotification);

                foreach (UserLight user in notificationUsers)
                {
                    pointGeofenceNotification.PointGeofenceNotificationUsers.Add(new EF.PointGeofenceNotificationUser()
                    {
                        Recipient = user.Recipient, UserName = user.UserName, TypeId = user.TypeId
                    });
                }

                EF.PointGeofence geofence = EF.DataContext.Current.PointGeofenceSet.FirstOrDefault(pg => pg.PointId == pointId);
                pointGeofenceNotification.PointGeofence = geofence;

                EF.DataContext.Current.SaveChanges();
            }
            catch (Exception ex)
            {
            }

            return(this.GetPointGeofenceNotificationForWebService(pointId));
        }
コード例 #2
0
        public List <Orchestrator.WebUI.Services.FleetViewTreeViewNode> UpdatePointGeofenceVehicles(int pointId, List <Orchestrator.WebUI.Services.FleetViewTreeViewNode> pointGeofenceVehicles)
        {
            List <FleetViewTreeViewNode> returnCollection = new List <FleetViewTreeViewNode>();

            try
            {
                EF.PointGeofence geofence = (from pg in EF.DataContext.Current.PointGeofenceSet.Include("PointGeofenceVehicles")
                                             where pg.PointId == pointId
                                             select pg).FirstOrDefault();

                for (int i = geofence.PointGeofenceVehicles.Count - 1; i >= 0; i--)
                {
                    EF.DataContext.Current.DeleteObject(geofence.PointGeofenceVehicles.ElementAt(i));
                }

                foreach (Orchestrator.WebUI.Services.FleetViewTreeViewNode pointGeofenceVehicle in pointGeofenceVehicles)
                {
                    EF.PointGeofenceVehicle vehicle = new PointGeofenceVehicle()
                    {
                        GPSUnitId = pointGeofenceVehicle.GpsUnitId
                    };
                    vehicle.Resource      = EF.DataContext.Current.Resources.FirstOrDefault(r => r.ResourceId == pointGeofenceVehicle.Id);
                    vehicle.PointGeofence = geofence;
                }

                EF.DataContext.Current.SaveChanges();
            }
            catch (Exception ex)
            {
                throw;
            }

            return(returnCollection);
        }