示例#1
0
        public async Task LoadNotificationsAsync()
        {
            if (IsBusy)
            {
                return;
            }

            IsBusy = true;

            try
            {
                if (await ConnectivityService.IsConnected())
                {
                    //Notifications.Clear();

                    var thanks = await AmazonWebService.Instance.GetUserThanksAsync();

                    Notifications.AddRange(thanks);

                    //await AmazonWebService.Instance.DeleteThanksAsync(thanks);
                }
                else
                {
                    DialogService.ShowError("No internet connection");
                }
            }
            catch (Exception ex)
            {
                //Xamarin.Insights.Report(ex);
            }

            IsBusy = false;
        }
示例#2
0
 public void Include(EntityData otherData)
 {
     Alerts.AddRange(otherData.Alerts);
     EmailAlertRecipients.AddRange(otherData.EmailAlertRecipients);
     SmsAlertRecipients.AddRange(otherData.SmsAlertRecipients);
     AlertReports.AddRange(otherData.AlertReports);
     AlertRules.AddRange(otherData.AlertRules);
     ApplicationLanguages.AddRange(otherData.ApplicationLanguages);
     ContentLanguages.AddRange(otherData.ContentLanguages);
     Countries.AddRange(otherData.Countries);
     DataCollectors.AddRange(otherData.DataCollectors);
     Districts.AddRange(otherData.Districts);
     GatewaySettings.AddRange(otherData.GatewaySettings);
     HeadManagerConsents.AddRange(otherData.HeadManagerConsents);
     HealthRisks.AddRange(otherData.HealthRisks);
     HealthRiskLanguageContents.AddRange(otherData.HealthRiskLanguageContents);
     Localizations.AddRange(otherData.Localizations);
     LocalizedTemplates.AddRange(otherData.LocalizedTemplates);
     NationalSocieties.AddRange(otherData.NationalSocieties);
     Notifications.AddRange(otherData.Notifications);
     Projects.AddRange(otherData.Projects);
     SupervisorUserProjects.AddRange(otherData.SupervisorUserProjects);
     ProjectHealthRisks.AddRange(otherData.ProjectHealthRisks);
     RawReports.AddRange(otherData.RawReports);
     Regions.AddRange(otherData.Regions);
     Reports.AddRange(otherData.Reports);
     Users.AddRange(otherData.Users);
     UserNationalSocieties.AddRange(otherData.UserNationalSocieties);
     Villages.AddRange(otherData.Villages);
     Zones.AddRange(otherData.Zones);
 }
 public void AddNotifications(IEnumerable <Notification> messages)
 {
     if (messages != null)
     {
         Notifications.AddRange(messages);
     }
 }
示例#4
0
        public void AddNotification(Notifiable object1, Notifiable object2 = null, Notifiable object3 = null)
        {
            Notifications.AddRange(object1.Notifications);

            if (object2 != null)
            {
                Notifications.AddRange(object2.Notifications);
            }
            if (object3 != null)
            {
                Notifications.AddRange(object3.Notifications);
            }
        }
示例#5
0
        public override void AddNotifications(IEnumerable <Notification> notifications, bool overwrite = false)
        {
            try
            {
                if (overwrite)
                {
                    Notifications.Clear();
                }

                Notifications.AddRange(notifications);
            }
            catch (ArgumentNullException)
            {
                throw new NotificationIsNullException();
            }
        }
示例#6
0
        private async void NotificationHandler(object sender, UserNotificationChangedEventArgs e)
        {
            if (!IsListenerActive)
            {
                return;
            }
            if (e.ChangeKind != UserNotificationChangedKind.Added)
            {
                return;
            }
            try
            {
                var notifs = await Listener.GetNotificationsAsync(NotificationKinds.Toast);

                var newlyAdded = notifs.Except(Notifications, new NotificationComparer()).ToList();
                Conf.Log($"received {newlyAdded.Count} notification(s) from listener");
                NewNotificationPool.AddRange(newlyAdded);
                Notifications.AddRange(newlyAdded);
                foreach (var item in newlyAdded)
                {
                    Conf.CurrentConf.AddApp(new AppInfo(item.AppInfo)
                    {
                        ForwardingEnabled = !Conf.CurrentConf.MuteNewApps
                    });
                    var appIndex = Conf.CurrentConf.FindAppIndex(new AppInfo(item.AppInfo));
                    if (appIndex == -1 && !Conf.CurrentConf.MuteNewApps)
                    {
                        continue;
                    }
                    if (!Conf.CurrentConf.AppsToForward[appIndex].ForwardingEnabled)
                    {
                        continue;
                    }
                    Conf.Log($"marked notification #{item.Id} as pending, app: {item.AppInfo.AppUserModelId}");
                    UnsentNotificationPool.Add(new Protocol.Notification(item));
                }
                Conf.CurrentConf.NotificationsReceived += newlyAdded.Count;
            }
            catch (Exception ex)
            {
                Conf.Log($"notification listener failed: {ex.Message}, HRESULT {ex.HResult:x}", LogLevel.Error);
                if (ex.HResult == -2147024891)
                {
                    await Dispatcher.RunAsync(Windows.UI.Core.CoreDispatcherPriority.Normal, async() => { await NoPermissionDialog(); });
                }
            }
        }
示例#7
0
        public void LoadUserProfile()
        {
            if (!File.Exists(PROFILE))
            {
                return;
            }

            var jo = JObject.Parse(File.ReadAllText(PROFILE));

            string temp = jo.Value <string>(nameof(Notifications));

            Notifications.AddRange(JsonConvert.DeserializeObject <NotificationModel[]>(temp));

            temp = jo.Value <string>(nameof(Notes));
            if (temp != null)
            {
                Notes.AddRange(JsonConvert.DeserializeObject <NoteModel[]>(temp));
            }
        }
 internal void AddNotifications()
 {
     Notifications.AddRange(logger.StartupNotifications);
     logger.ClearStartupNotifications();
 }
示例#9
0
 public void AddNotifications(List <KeyValuePair <NotificationType, string> > notifications)
 {
     Notifications.AddRange(notifications);
 }
示例#10
0
 public void AddNotification(Contract contract)
 {
     Notifications.Clear();
     Notifications.AddRange(contract.Notifications);
 }