public static NotificationMobileJson SendNotificationId(NotificationMobileJson notification)
 {
     var response = Network.SendPackage(Network.ConvertObjectToStream(notification), MobileConfig.SEND_NOTIFICATION_CREATE_DEBUG_ANDROID);
     var stream = response.GetResponseStream();
     StreamReader read = new StreamReader(stream);
     string json = read.ReadToEnd();
     return Json.DeserializeObject<NotificationMobileJson>(json);
 }
        public static void SendNotificationId(string memberId, string notificationId,Context context)
        {
            Task<bool>.Factory.StartNew(
                                   () =>
                                   {
                                       try
                                       {
                                           var connectivityManager = (ConnectivityManager)context.GetSystemService(Context.ConnectivityService);
                                           var activeConnection = connectivityManager.ActiveNetworkInfo;
                                           if ((activeConnection != null) && activeConnection.IsConnected)
                                           {
                                               try
                                               {
                                                   NotificationMobileJson not = new NotificationMobileJson();
                                                   not.CanSendGameNotifications = true;
                                                   not.MemberId = memberId;
                                                   not.MobileTypeEnum = MobileTypeEnum.Android;
                                                   not.NotificationId = notificationId;
                                                   NotificationMobileJsonMb.SendNotificationId(not);
                                               }
                                               catch (Exception ex)
                                               {
                                                   ErrorHandler.Save(ex, MobileTypeEnum.Android, context);
                                               }
                                           }


                                       }
                                       catch (Exception exception)
                                       {
                                           ErrorHandler.Save(exception, MobileTypeEnum.Android, context);
                                       }
                                       return true;
                                   });

        }
 public static bool DeleteMobileNotification(NotificationMobileJson notification)
 {
     var dc = new ManagementContext();
     var n = dc.MobileSettings.Where(x => x.NotificationId == notification.NotificationId).FirstOrDefault();
     if (n != null)
     {
         dc.MobileSettings.Remove(n);
     }
     int c = dc.SaveChanges();
     return c > 0;
 }
        public static bool AddMobileNotification(NotificationMobileJson notification)
        {

            var dc = new ManagementContext();

            MobileNotificationSettings s = new MobileNotificationSettings();
            s.AllowGameNotifications = notification.CanSendGameNotifications;
            //s.CanSendForumNotifications = notification.CanSendForumNotifications;
            if (!String.IsNullOrEmpty(notification.MemberId))
                s.Member = dc.Members.Where(x => x.MemberId == new Guid(notification.MemberId)).FirstOrDefault();
            s.MobileTypeEnum = (byte)notification.MobileTypeEnum;
            s.NotificationId = notification.NotificationId;
            dc.MobileSettings.Add(s);
            int c = dc.SaveChanges();
            return true;
        }
 public static List<NotificationMobileJson> GetAllMobileNotificationSettings()
 {
     List<NotificationMobileJson> nots = new List<NotificationMobileJson>();
     var dc = new ManagementContext();
     var settings = dc.MobileSettings.Include("Member");
     foreach (var m in settings)
     {
         NotificationMobileJson n = new NotificationMobileJson();
         n.CanSendGameNotifications = m.AllowGameNotifications;
         //n.CanSendForumNotifications = m.CanSendForumNotifications;
         n.Id = m.Id;
         if (m.Member != null)
         {
             n.MemberId = m.Member.MemberId.ToString();
         }
         n.NotificationId = m.NotificationId;
         n.MobileTypeEnum = (MobileTypeEnum)m.MobileTypeEnum;
         nots.Add(n);
     }
     return nots;
 }
Ejemplo n.º 6
0
 private static void UpdateChannelForRDNation(string channelUri)
 {
     Task.Run(() =>
     {
         NotificationMobileJson json = new NotificationMobileJson();
         json.CanSendGameNotifications = true;
         json.CanSendForumNotifications = true;
         json.MobileTypeEnum = MobileTypeEnum.WP8;
         json.NotificationId = channelUri;
         
         if (SettingsMobile.Instance.User != null)
         {
             json.MemberId = SettingsMobile.Instance.User.MemberId.ToString();
             NotificationMobileJsonWP.SendNotificationId(json);
         }
         SqlFactory fact = new SqlFactory();
         fact.InsertNotificationSettings(json);
     });
 }
Ejemplo n.º 7
0
 public SqlFactory InsertNotificationSettings(NotificationMobileJson profile)
 {
     database.Insert(profile);
     return this;
 }