public override UITableViewCell GetCell(UITableView tableView, Foundation.NSIndexPath indexPath)
        {
            var cell = tableView.DequeueReusableCell(_cellIdentifier, indexPath) as CustomCellModeZoneView;

            if (cell == null)
            {
                cell = (CustomCellModeZoneView) new UITableViewCell(UITableViewCellStyle.Default, _cellIdentifier);
            }

            _currentIndex            = indexPath.Row;
            _currentAlert            = App.Locator.ModeZone.LsAlertsModeZone[_currentIndex];
            tableView.SeparatorStyle = UITableViewCellSeparatorStyle.None;

            // rounded alert type
            CALayer profileImageCircle = cell.TypeView.Layer;

            profileImageCircle.CornerRadius = cell.TypeView.Frame.Size.Width / 2;
            cell.TypeView.ClipsToBounds     = true;

            // title and body
            cell.TitleLabel.Text   = _currentAlert.Title;
            cell.MessageLabel.Text = _currentAlert.Content;

            // number of recipient
            CALayer profileImageCircle1 = cell.RecipientLabel.Layer;

            profileImageCircle1.CornerRadius  = cell.RecipientLabel.Frame.Size.Width / 2;
            cell.RecipientLabel.ClipsToBounds = true;
            cell.RecipientLabel.Text          = _currentAlert.LsRecipients.Count.ToString();

            return(cell);
        }
Exemple #2
0
 public AlertWithRecipientDTO ConvertClassMemberToAlertWithRecipientDTO()
 {
     var source = new AlertWithRecipientDTO();
     if (ModeDefinition == ModeDefinitionEnum.ModeZone)
     {
         source.IdAlert = App.Locator.ModeZone.LsAlertsModeZone.Count();
     }
     else if (ModeDefinition == ModeDefinitionEnum.ModeDontMove)
     {
         source.IdAlert = App.Locator.ModeDontMove.LsAlertsModeDontMove.Count();
     }
     source.IdMode = IdMode;
     source.IdAlertType = (int)AlertDefinitionEnum.Email;
     source.Content = ContentAlert.ToUpperCaseFirst();
     source.Title = TitleAlert.ToUpperCaseFirst();
     source.LsRecipients = new List<AlertRecipientDTO>();
     foreach (AlertRecipientDTO recipient in LsRecipients)
     {
         source.LsRecipients.Add(recipient);
     }
     return source;
 }
 /// <summary>
 /// Go to the alert detail page
 /// </summary>
 public void GoToAlertDetail(AlertWithRecipientDTO item, int position)
 {
     if (_navigationService.CurrentPageKey != App.ALERT_PAGE)
     {
         if (item == null)
         {
             App.Locator.Alert.IsNew            = true;
             App.Locator.ModeZone.EditingAlerts = false;
         }
         else
         {
             App.Locator.Alert.IsNew            = false;
             App.Locator.Alert.IdAlert          = item.IdAlert;
             App.Locator.Alert.ContentAlert     = item.Content;
             App.Locator.Alert.TitleAlert       = item.Title;
             App.Locator.Alert.LsRecipients     = item.LsRecipients;
             App.Locator.ModeZone.EditingAlerts = true;
             App.Locator.Alert.ConvertAlertDTOToClassMember(item);
         }
         App.Locator.ModeZone.WaitingForAlerts = true;
         _navigationService.NavigateTo(App.ALERT_PAGE);
     }
 }
Exemple #4
0
 public async Task<bool> UpdateAlert(string title, string content)
 {
     TitleAlert = title;
     ContentAlert = content;
     if (await CheckIfRecipients() && !await CheckIfEmptyField())
     {
         var alertToUpdate = ConvertClassMemberToAlertWithRecipientDTO();
         AlertWithRecipientDTO alertOld = null;
         if (ModeDefinition == ModeDefinitionEnum.ModeZone)
         {
             alertOld = App.Locator.ModeZone.LsAlertsModeZone.FirstOrDefault(el => el.IdAlert == IdAlert);
         }
         else if (ModeDefinition == ModeDefinitionEnum.ModeDontMove)
         {
             alertOld = App.Locator.ModeDontMove.LsAlertsModeDontMove.FirstOrDefault(el => el.IdAlert == IdAlert);
         }
         alertOld.Title = alertToUpdate.Title;
         alertOld.Content = alertToUpdate.Content;
         alertOld.LsRecipients.Clear();
         alertOld.LsRecipients.AddRange(alertToUpdate.LsRecipients);
         return true;
     }
     else return false;
 }
 /// <summary>
 /// Updates the content of one holder
 /// </summary>
 private void UpdateHolderContents(ListAlertModeZoneViewHolder holder, AlertWithRecipientDTO contents)
 {
     holder.titre.Text         = contents.Title;
     holder.description.Text   = contents.Content;
     holder.nbrRecipients.Text = contents.LsRecipients != null?contents.LsRecipients.Count.ToString() : "0";
 }
Exemple #6
0
        /// <summary>
        /// Modify SOS alert, depending of the SOSAlert variable
        /// </summary>
        public async Task <bool> InsertOrUpdateAlertSOS(string title, string content)
        {
            try
            {
                // Adding alert sos
                if (CurrentAlertSOS == null)
                {
                    // Create a new alert with recipient to add
                    var alertWithRecipientToAdd = new AlertWithRecipientDTO
                    {
                        IdAlertType  = (int)AlertDefinitionEnum.Email,
                        IdMode       = null,
                        Title        = title,
                        Content      = content,
                        LsRecipients = LsRecipients,
                    };
                    // Add the alert with recipient in the database
                    var alertId = await _dataService.InsertAlertSOSWithRecipient(App.Locator.DetailSeekios.SeekiosSelected.Idseekios, alertWithRecipientToAdd);

                    // Something wrong
                    if (alertId <= 0)
                    {
                        return(false);
                    }
                    else
                    {
                        // Update the local values
                        App.Locator.AddSeekios.UpdatingSeekios.AlertSOS_idalert = alertId;
                        alertWithRecipientToAdd.IdAlert = alertId;
                        App.CurrentUserEnvironment.LsAlert.Add(alertWithRecipientToAdd);
                        App.CurrentUserEnvironment.LsSeekios[App.CurrentUserEnvironment.LsSeekios.IndexOf(App.Locator.AddSeekios.UpdatingSeekios)].AlertSOS_idalert = alertId;
                        foreach (var recipient in LsRecipients)
                        {
                            recipient.IdAlert = alertId;
                        }
                        App.CurrentUserEnvironment.LsAlertRecipient.AddRange(LsRecipients);
                        CurrentAlertSOS = alertWithRecipientToAdd;
                        return(true);
                    }
                }
                // Modify alert sos
                else
                {
                    // Create a new alert with recipient to update
                    var alertWithRecipientToUpdate = new AlertWithRecipientDTO
                    {
                        IdAlert      = CurrentAlertSOS.IdAlert,
                        IdAlertType  = (int)AlertDefinitionEnum.Email,
                        IdMode       = null,
                        Title        = title,
                        Content      = content,
                        LsRecipients = LsRecipients,
                    };
                    foreach (var recipient in alertWithRecipientToUpdate.LsRecipients)
                    {
                        recipient.IdAlert = alertWithRecipientToUpdate.IdAlert;
                    }
                    // Update the alert with recipient in the database
                    if (await _dataService.UpdateAlertSOSWithRecipient(App.Locator.DetailSeekios.SeekiosSelected.Idseekios, alertWithRecipientToUpdate) > 0)
                    {
                        CurrentAlertSOS.Title   = title;
                        CurrentAlertSOS.Content = content;
                        App.CurrentUserEnvironment.LsAlert.RemoveAll(r => r.IdAlert == CurrentAlertSOS.IdAlert);
                        App.CurrentUserEnvironment.LsAlert.Add(alertWithRecipientToUpdate);
                        App.CurrentUserEnvironment.LsAlertRecipient.RemoveAll(r => r.IdAlert == CurrentAlertSOS.IdAlert);
                        App.CurrentUserEnvironment.LsAlertRecipient.AddRange(LsRecipients);
                    }
                    return(true);
                }
            }
            catch (TimeoutException)
            {
                await _dialogService.ShowError(
                    Resources.TimeoutError
                    , Resources.TimeoutErrorTitle
                    , Resources.Close, null);
            }
            catch (WebException)
            {
                await _dialogService.ShowError(
                    Resources.TimeoutError
                    , Resources.TimeoutErrorTitle
                    , Resources.Close, null);
            }
            catch (Exception)
            {
                await _dialogService.ShowError(
                    Resources.UnexpectedError
                    , Resources.UnexpectedErrorTitle
                    , Resources.Close, null);
            }
            return(false);
        }
        private void SetData()
        {
            _user = new UserDTO()
            {
                DateLastConnection = DateTime.Now,
                DateLocation       = DateTime.Now,
                DefaultTheme       = 0,
                Email                = "*****@*****.**",
                FirstName            = "TestFirstName",
                GCMRegistrationToken = "noToken",
                IsValidate           = true,
                LastName             = "TestLastName",
                LocationLatitude     = 0,
                LocationLongitude    = 0,
                NumberView           = 1,
                Password             = "******",
                PhoneNumber          = "33|64564866",
                RemainingRequest     = 1000,
                SocialNetworkType    = 0,
                SocialNetworkUserId  = null,
                UserPicture          = null
            };

            DataService.Email = _user.Email;
            DataService.Pass  = _user.Password;

            _seekios = new SeekiosDTO()
            {
                Idseekios                              = _idseekios,
                SeekiosName                            = "UnitTestSeekios",
                SeekiosPicture                         = null,
                SeekiosDateCreation                    = DateTime.Now,
                BatteryLife                            = 99,
                SignalQuality                          = 50,
                DateLastCommunication                  = DateTime.Now,
                LastKnownLocation_longitude            = 0.0,
                LastKnownLocation_latitude             = 0.0,
                LastKnownLocation_altitude             = 0.0,
                LastKnownLocation_accuracy             = 0.0,
                LastKnownLocation_dateLocationCreation = DateTime.Now,
                Subscription_idsubscription            = 2,
                Category_idcategory                    = 1,
                User_iduser                            = _iduser,
                HasGetLastInstruction                  = true,
                IsAlertLowBattery                      = true,
                IsInPowerSaving                        = false,
                PowerSaving_hourStart                  = 0,
                PowerSaving_hourEnd                    = 0,
                AlertSOS_idalert                       = null,
                IsRefreshingBattery                    = false,
                FreeCredit                             = 100000000
            };

            _mode = new ModeDTO()
            {
                DateModeCreation                    = DateTime.Now,
                Trame                               = "1",
                NotificationPush                    = 0,
                CountOfTriggeredAlert               = 0,
                LastTriggeredAlertDate              = DateTime.Now,
                Seekios_idseekios                   = _idseekios,
                ModeDefinition_idmodeDefinition     = (int)SeekiosApp.Enum.ModeDefinitionEnum.ModeTracking,
                StatusDefinition_idstatusDefinition = 1
            };

            alertes.Add(new AlertWithRecipientDTO()
            {
                IdAlertType = 1,
                Title       = "Test",
                Content     = "Test"
            });

            _alert = new AlertDTO()
            {
                IdAlertType = 1,
                IdMode      = _idmode,
                Title       = "Test",
                Content     = "Test"
            };

            var recipients = new List <AlertRecipientDTO>();

            recipients.Add(new AlertRecipientDTO()
            {
                Email       = "*****@*****.**",
                DisplayName = "TestDisplayname",
            });

            _alertwithrecipient = new AlertWithRecipientDTO()
            {
                IdAlert      = _idalert,
                IdAlertType  = 3,
                IdMode       = _idmode,
                Title        = "Test",
                Content      = "Test",
                LsRecipients = recipients
            };

            _listAlertWithRecipient.Add(_alertwithrecipient);
        }