Пример #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 EF.WeekActivePeriod UpdateWeekActivePeriod(EF.WeekActivePeriod weekActivePeriod)
        {
            try
            {
                EF.WeekActivePeriod periodToSave = (from wap in EF.DataContext.Current.WeekActivePeriodSet
                                                    where wap.WeekActivePeriodID == weekActivePeriod.WeekActivePeriodID
                                                    select wap).FirstOrDefault();

                periodToSave.Monday     = weekActivePeriod.Monday;
                periodToSave.Monday2    = weekActivePeriod.Monday2;
                periodToSave.Tuesday    = weekActivePeriod.Tuesday;
                periodToSave.Tuesday2   = weekActivePeriod.Tuesday2;
                periodToSave.Wednesday  = weekActivePeriod.Wednesday;
                periodToSave.Wednesday2 = weekActivePeriod.Wednesday2;
                periodToSave.Thursday   = weekActivePeriod.Thursday;
                periodToSave.Thursday2  = weekActivePeriod.Thursday2;
                periodToSave.Friday     = weekActivePeriod.Friday;
                periodToSave.Friday2    = weekActivePeriod.Friday2;
                periodToSave.Saturday   = weekActivePeriod.Saturday;
                periodToSave.Saturday2  = weekActivePeriod.Saturday2;
                periodToSave.Sunday     = weekActivePeriod.Sunday;
                periodToSave.Sunday2    = weekActivePeriod.Sunday2;

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

            EF.WeekActivePeriod weekActivePeriodToReturn = null;

            try
            {
                weekActivePeriodToReturn = (from wap in EF.DataContext.Current.WeekActivePeriodSet
                                            where wap.WeekActivePeriodID == weekActivePeriod.WeekActivePeriodID
                                            select wap).FirstOrDefault();
            }
            catch (Exception ex)
            {
            }

            return(weekActivePeriodToReturn);
        }
Пример #3
0
        private void AddNotification()
        {
            GeoManagement client = new GeoManagement();

            EF.PointGeofenceNotification notification = new EF.PointGeofenceNotification();
            notification.Description = txtNotificationTitle.Text;
            notification.Incoming    = chkIncoming.Checked;
            notification.Outgoing    = chkOutgoing.Checked;
            notification.IsEnabled   = chkNotificationEnabled.Checked;

            #region Convert to an EF Week Active Period
            if (this.WeekActivePeriod.WeekActivePeriodId == Guid.Empty)
            {
                EF.WeekActivePeriod period = new EF.WeekActivePeriod();
                period.WeekActivePeriodID     = Guid.NewGuid();
                period.Monday                 = this.WeekActivePeriod.Monday;
                period.Monday2                = this.WeekActivePeriod.MondaySecond;
                period.Tuesday                = this.WeekActivePeriod.Tuesday;
                period.Tuesday2               = this.WeekActivePeriod.TuesdaySecond;
                period.Wednesday              = this.WeekActivePeriod.Wednesday;
                period.Wednesday2             = this.WeekActivePeriod.WednesdaySecond;
                period.Thursday               = this.WeekActivePeriod.Thursday;
                period.Thursday2              = this.WeekActivePeriod.ThursdaySecond;
                period.Friday                 = this.WeekActivePeriod.Friday;
                period.Friday2                = this.WeekActivePeriod.FridaySecond;
                period.Saturday               = this.WeekActivePeriod.Saturday;
                period.Saturday2              = this.WeekActivePeriod.SaturdaySecond;
                period.Sunday                 = this.WeekActivePeriod.Sunday;
                period.Sunday2                = this.WeekActivePeriod.SundaySecond;
                notification.WeekActivePeriod = new EF.WeekActivePeriod();
                notification.WeekActivePeriod.WeekActivePeriodID = client.AddWeekActivePeriod(period).WeekActivePeriodID;
            }

            #endregion

            client.AddPointGeofenceNotification(notification, PointID, CurrentRecipients);

            rgNotifications.Rebind();
        }
Пример #4
0
        public EF.WeekActivePeriod AddWeekActivePeriod(EF.WeekActivePeriod weekActivePeriod)
        {
            try
            {
                EF.WeekActivePeriod periodToSave = new EF.WeekActivePeriod();
                periodToSave.WeekActivePeriodID = weekActivePeriod.WeekActivePeriodID;
                periodToSave.Monday             = weekActivePeriod.Monday;
                periodToSave.Monday2            = weekActivePeriod.Monday2;
                periodToSave.Tuesday            = weekActivePeriod.Tuesday;
                periodToSave.Tuesday2           = weekActivePeriod.Tuesday2;
                periodToSave.Wednesday          = weekActivePeriod.Wednesday;
                periodToSave.Wednesday2         = weekActivePeriod.Wednesday2;
                periodToSave.Thursday           = weekActivePeriod.Thursday;
                periodToSave.Thursday2          = weekActivePeriod.Thursday2;
                periodToSave.Friday             = weekActivePeriod.Friday;
                periodToSave.Friday2            = weekActivePeriod.Friday2;
                periodToSave.Saturday           = weekActivePeriod.Saturday;
                periodToSave.Saturday2          = weekActivePeriod.Saturday2;
                periodToSave.Sunday             = weekActivePeriod.Sunday;
                periodToSave.Sunday2            = weekActivePeriod.Sunday2;

                EF.DataContext.Current.AddToWeekActivePeriodSet(periodToSave);
                EF.DataContext.Current.SaveChanges();
            }
            catch (Exception ex)
            {
            }
            EF.WeekActivePeriod weekPeriod = null;
            try
            {
                weekPeriod = EF.DataContext.Current.WeekActivePeriodSet.FirstOrDefault(w => w.WeekActivePeriodID == weekActivePeriod.WeekActivePeriodID);
            }
            catch (Exception ex)
            {
            }

            return(weekPeriod);
        }