private IDictionary <string, string> CreateAnonymMessageDictionary(
            Ekreta.Mobile.Core.Models.PushNotification.PushMessage pushMessage)
        {
            IDictionary <string, string> dictionary = pushMessage.AsStringDictionary(BindingFlags.Instance | BindingFlags.Public);

            dictionary.Remove("Message");
            dictionary.Remove("NotificationType");
            dictionary.Remove("ItemId");
            return(dictionary);
        }
        public async Task <bool> DownloadPostaladaElem(Profile profile, Ekreta.Mobile.Core.Models.PushNotification.PushMessage pushMessage)
        {
            try
            {
                PostaladaElem uzenet = await this._uzenetDataService.FetchPostaladaElem(profile, (long)pushMessage.ItemId);

                if (uzenet != null)
                {
                    this._uzenetDataService.OverridePostaladaElem(profile, uzenet);
                    return(true);
                }
            }
            catch (Exception ex)
            {
                ErrorHandler.Current.HandleError(ex);
            }
            return(false);
        }
        public bool IsPushMessageDownloaded(Ekreta.Mobile.Core.Models.PushNotification.PushMessage pushMessage)
        {
            NotificationMessageType notificationType = pushMessage.NotificationType;
            int    itemId = pushMessage.ItemId;
            object obj;

            switch (notificationType)
            {
            case NotificationMessageType.Evaluation:
                obj = (object)this._evaluationDataService.GetEvaluations(this._profileDataService.GetActiveProfile()).Where <Evaluation>((Func <Evaluation, bool>)(x => x.EvaluationId == itemId)).FirstOrDefault <Evaluation>();
                break;

            case NotificationMessageType.Absence:
                obj = (object)this._absenceDataService.Get(itemId);
                break;

            case NotificationMessageType.Note:
                obj = (object)this._noteDataService.Get(this._profileDataService.GetActiveProfile(), itemId);
                break;

            case NotificationMessageType.Message:
                obj = (object)this._uzenetDataService.GetPostaladaElem(itemId);
                break;

            case NotificationMessageType.Homework:
                obj = (object)this._lessonDataService.GetByTeacherHomeworkId(itemId);
                break;

            case NotificationMessageType.Exam:
                obj = (object)this._examDataService.GetByUid(itemId);
                break;

            default:
                return(false);
            }
            return(obj != null);
        }
        public async Task <bool> HandleNotification(Ekreta.Mobile.Core.Models.PushNotification.PushMessage pushMessage)
        {
            object obj;
            int    num;

            try
            {
                this.CheckMessageIsProcessed(pushMessage.MessageId);
                CrossMobileAnalytics.Current.TrackEvent("Push Notification", this.CreateAnonymMessageDictionary(pushMessage));
                this._parsedMessageDataService.AddMessageId(pushMessage.MessageId);
                return(await Task.FromResult <bool>(true));
            }
            catch (DuplicatedPushMessageException ex)
            {
                obj = (object)ex;
                num = 1;
            }
            catch (Exception ex)
            {
                obj = (object)ex;
                num = 2;
            }
            switch (num)
            {
            case 1:
                CrossMobileAnalytics.Current.TrackEvent("Push Notification || Duplicated Message", this.CreateAnonymMessageDictionary(pushMessage));
                return(await Task.FromResult <bool>(false));

            case 2:
                CrossMobileAnalytics.Current.TrackException((Exception)obj, this.CreateAnonymMessageDictionary(pushMessage), nameof(HandleNotification), "/Users/admin/myagent/macMiniBlack3/_work/2/s/eKreta.Mobile/eKreta.Mobile.Core.Standard/Services/PushNotificationService.cs", 169);
                return(await Task.FromResult <bool>(false));

            default:
                bool flag;
                return(flag);
            }
        }
        public Ekreta.Mobile.Core.Models.PushNotification.PushMessage CreatePushMessage(
            IDictionary <string, string> properties)
        {
            Ekreta.Mobile.Core.Models.PushNotification.PushMessage pushMessage = (Ekreta.Mobile.Core.Models.PushNotification.PushMessage)null;
            bool flag = false;

            try
            {
                string str1;
                if (!properties.TryGetValue("Version", out str1))
                {
                    return((Ekreta.Mobile.Core.Models.PushNotification.PushMessage)null);
                }
                string str2;
                properties.TryGetValue("InstituteCode", out str2);
                string s1;
                properties.TryGetValue("UserId", out s1);
                string s2;
                properties.TryGetValue("InstituteUserId", out s2);
                string s3;
                properties.TryGetValue("ItemId", out s3);
                string str3;
                properties.TryGetValue("Message", out str3);
                string str4;
                properties.TryGetValue("MessageId", out str4);
                string str5;
                properties.TryGetValue("NotificationType", out str5);
                string s4;
                properties.TryGetValue("NotificationRole", out s4);
                pushMessage = new Ekreta.Mobile.Core.Models.PushNotification.PushMessage()
                {
                    Message          = str3,
                    MessageId        = str4,
                    NotificationRole = int.Parse(s4)
                };
                --pushMessage.NotificationRole;
                pushMessage.Version = str1;
                if (string.IsNullOrEmpty(str2))
                {
                    throw new InvalidPushNotificationException(properties, "InstituteCode", str2).SetErrorCode <InvalidPushNotificationException>("/Users/admin/myagent/macMiniBlack3/_work/2/s/eKreta.Mobile/eKreta.Mobile.Core.Standard/Services/PushNotificationService.cs", 95);
                }
                pushMessage.InstituteCode = str2;
                int result1;
                if (!string.IsNullOrEmpty(s1) && int.TryParse(s1, out result1))
                {
                    pushMessage.UserId = result1;
                }
                else
                {
                    int result2;
                    if (string.IsNullOrEmpty(s2) || !int.TryParse(s2, out result2))
                    {
                        throw new InvalidPushNotificationException(properties, "InstituteUserId", s2).SetErrorCode <InvalidPushNotificationException>("/Users/admin/myagent/macMiniBlack3/_work/2/s/eKreta.Mobile/eKreta.Mobile.Core.Standard/Services/PushNotificationService.cs", 115);
                    }
                    pushMessage.UserId = result2;
                    CrossMobileAnalytics.Current.TrackException((Exception) new InvalidPushNotificationException(properties, "UserId", s1).SetErrorCode <InvalidPushNotificationException>("/Users/admin/myagent/macMiniBlack3/_work/2/s/eKreta.Mobile/eKreta.Mobile.Core.Standard/Services/PushNotificationService.cs", 106), (IDictionary <string, string>)null, nameof(CreatePushMessage), "/Users/admin/myagent/macMiniBlack3/_work/2/s/eKreta.Mobile/eKreta.Mobile.Core.Standard/Services/PushNotificationService.cs", 109);
                    flag = true;
                }
                int result3;
                if (string.IsNullOrEmpty(s3) || !int.TryParse(s3, out result3))
                {
                    throw new InvalidPushNotificationException(properties, "ItemId", s3).SetErrorCode <InvalidPushNotificationException>("/Users/admin/myagent/macMiniBlack3/_work/2/s/eKreta.Mobile/eKreta.Mobile.Core.Standard/Services/PushNotificationService.cs", 124);
                }
                pushMessage.ItemId = result3;
                NotificationMessageType result4;
                if (string.IsNullOrEmpty(str5) || !Enum.TryParse <NotificationMessageType>(str5, out result4))
                {
                    throw new InvalidPushNotificationException(properties, "NotificationType", str5).SetErrorCode <InvalidPushNotificationException>("/Users/admin/myagent/macMiniBlack3/_work/2/s/eKreta.Mobile/eKreta.Mobile.Core.Standard/Services/PushNotificationService.cs", 133);
                }
                pushMessage.NotificationType = result4;
            }
            catch (Exception ex)
            {
                CrossMobileAnalytics.Current.TrackException(ex, (IDictionary <string, string>)null, nameof(CreatePushMessage), "/Users/admin/myagent/macMiniBlack3/_work/2/s/eKreta.Mobile/eKreta.Mobile.Core.Standard/Services/PushNotificationService.cs", 138);
            }
            if (flag)
            {
                this.UpdateRegistrationsAsync(this._pushNotificationHandler.Token).Wait();
            }
            return(pushMessage);
        }