コード例 #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
        void rgNotifications_ItemCommand(object sender, GridCommandEventArgs e)
        {
            if (e.CommandName == "Select")
            {
                this.CurrentRecipients.Clear();

                // Load the selected Notification
                EF.PointGeofenceNotification notification = _ds.GetPointGeofenceNotification((int)e.Item.OwnerTableView.DataKeyValues[e.Item.ItemIndex]["NotificationId"]);

                this.NotificationID = notification.NotificationId;

                var notifictionUsers = _ds.GetPointGeofenceNotificationUsers(this.NotificationID);
                // Load the Notification Users
                foreach (var u in notifictionUsers)
                {
                    this.CurrentRecipients.Add(new UserLight()
                    {
                        UserName  = u.UserName,
                        Recipient = u.Recipient,
                        TypeId    = u.TypeId
                    });
                }

                // Set the WAP
                this.WeekActivePeriod                 = new WeekActivePeriod();
                this.WeekActivePeriod.Monday          = notification.WeekActivePeriod.Monday;
                this.WeekActivePeriod.MondaySecond    = notification.WeekActivePeriod.Monday2;
                this.WeekActivePeriod.Tuesday         = notification.WeekActivePeriod.Tuesday;
                this.WeekActivePeriod.TuesdaySecond   = notification.WeekActivePeriod.Tuesday2;
                this.WeekActivePeriod.Wednesday       = notification.WeekActivePeriod.Wednesday;
                this.WeekActivePeriod.WednesdaySecond = notification.WeekActivePeriod.Wednesday2;
                this.WeekActivePeriod.Thursday        = notification.WeekActivePeriod.Thursday;
                this.WeekActivePeriod.ThursdaySecond  = notification.WeekActivePeriod.Thursday2;
                this.WeekActivePeriod.Friday          = notification.WeekActivePeriod.Friday;
                this.WeekActivePeriod.FridaySecond    = notification.WeekActivePeriod.Friday2;
                this.WeekActivePeriod.Saturday        = notification.WeekActivePeriod.Saturday;
                this.WeekActivePeriod.SaturdaySecond  = notification.WeekActivePeriod.Saturday2;
                this.WeekActivePeriod.Sunday          = notification.WeekActivePeriod.Sunday;
                this.WeekActivePeriod.SundaySecond    = notification.WeekActivePeriod.Sunday2;

                UpdateUIToWAP();
                this.rgContacts.Rebind();

                this.txtNotificationTitle.Text      = notification.Description;
                this.chkNotificationEnabled.Checked = notification.IsEnabled;
                this.chkIncoming.Checked            = notification.Incoming;
                this.chkOutgoing.Checked            = notification.Outgoing;

                this.btnAddNotification.Text = "Update Notification";
            }

            if (e.CommandName == "Delete")
            {
                this.NotificationID = (int)e.Item.OwnerTableView.DataKeyValues[e.Item.ItemIndex]["NotificationId"];
                // need to prompt to ensure.

                _ds.DeletePointGeofenceNotification(this.NotificationID);
            }
        }
コード例 #3
0
        public void DeletePointGeofenceNotification(int notificationId)
        {
            try
            {
                //EF.DataContext.Current.AttachTo("PointGeofenceNotificationSet", pointGeofenceNotification);
                EF.PointGeofenceNotification pgn = EF.DataContext.Current.PointGeofenceNotificationSet.FirstOrDefault(p => p.NotificationId == notificationId);
                if (pgn != null)
                {
                    EF.DataContext.Current.DeleteObject(pgn);
                }

                EF.DataContext.Current.SaveChanges();
            }
            catch (Exception ex)
            {
            }
        }
コード例 #4
0
        void rgNotifications_ItemDataBound(object sender, GridItemEventArgs e)
        {
            // ned this to display the recipients as something sensible
            if (e.Item is GridDataItem)
            {
                EF.PointGeofenceNotification d     = (EF.PointGeofenceNotification)e.Item.DataItem;
                List <UserLight>             users = _ds.GetPointGeofenceNotificationUsers(d.NotificationId);
                Label lbl = e.Item.FindControl("lblRecipients") as Label;

                string userString = string.Empty;

                foreach (var u in users)
                {
                    userString += u.UserName + ", ";
                }

                lbl.Text = userString;
            }
        }
コード例 #5
0
        public EF.PointGeofenceNotification UpdatePointGeofenceNotification(int notificationID, string description, bool IsEnabled, bool IsIncoming, bool IsOutgoing, List <UserLight> notificationUsers)
        {
            EF.PointGeofenceNotification pn = null;
            try
            {
                pn = (from r in EF.DataContext.Current.PointGeofenceNotificationSet.Include("PointGeofence").Include("WeekActivePeriod")
                      where r.NotificationId == notificationID
                      select r).FirstOrDefault();

                pn.Description = description;
                pn.IsEnabled   = IsEnabled;
                pn.Incoming    = IsIncoming;
                pn.Outgoing    = IsOutgoing;


                Guid weekActivePeriodId = pn.WeekActivePeriod.WeekActivePeriodID;
                //EF.WeekActivePeriod week = dataContext1.WeekActivePeriodSet.First(w => w.WeekActivePeriodID == weekActivePeriodId);
                //pointGeofenceNotification.WeekActivePeriod = week;

                pn.PointGeofenceNotificationUsers.Load();

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

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

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

            return(pn);
        }
コード例 #6
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();
        }
コード例 #7
0
        private void UpdateNotification()
        {
            GeoManagement client = new GeoManagement();

            EF.PointGeofenceNotification notification = client.GetPointGeofenceNotification(this.NotificationID);

            notification.WeekActivePeriod.Monday     = this.WeekActivePeriod.Monday;
            notification.WeekActivePeriod.Monday2    = this.WeekActivePeriod.MondaySecond;
            notification.WeekActivePeriod.Tuesday    = this.WeekActivePeriod.Tuesday;
            notification.WeekActivePeriod.Tuesday2   = this.WeekActivePeriod.TuesdaySecond;
            notification.WeekActivePeriod.Wednesday  = this.WeekActivePeriod.Wednesday;
            notification.WeekActivePeriod.Wednesday2 = this.WeekActivePeriod.WednesdaySecond;
            notification.WeekActivePeriod.Thursday   = this.WeekActivePeriod.Thursday;
            notification.WeekActivePeriod.Thursday2  = this.WeekActivePeriod.ThursdaySecond;
            notification.WeekActivePeriod.Friday     = this.WeekActivePeriod.Friday;
            notification.WeekActivePeriod.Friday2    = this.WeekActivePeriod.FridaySecond;
            notification.WeekActivePeriod.Saturday   = this.WeekActivePeriod.Saturday;
            notification.WeekActivePeriod.Saturday2  = this.WeekActivePeriod.SaturdaySecond;
            notification.WeekActivePeriod.Sunday     = this.WeekActivePeriod.Sunday;
            notification.WeekActivePeriod.Sunday2    = this.WeekActivePeriod.SundaySecond;
            client.UpdateWeekActivePeriod(notification.WeekActivePeriod);

            client.UpdatePointGeofenceNotification(this.NotificationID, txtNotificationTitle.Text, chkNotificationEnabled.Checked, chkIncoming.Checked, chkOutgoing.Checked, CurrentRecipients);

            this.txtContactDetail.Text          = String.Empty;
            this.txtNotificationName.Text       = String.Empty;
            this.txtNotificationTitle.Text      = String.Empty;
            this.chkNotificationEnabled.Checked = false;
            this.chkOutgoing.Checked            = false;
            this.chkIncoming.Checked            = false;
            CurrentRecipients.Clear();
            rgContacts.Rebind();

            rgNotifications.Rebind();

            this.WeekActivePeriod = null;
            CLearWAP();
        }