private void GetMobileServiceOnline(Subscription subscription) { MobileDbContext ctx = new MobileDbContext(); var subscriptionDb = ctx.Subscriptions.Where(s => s.Id == subscription.Id).First(); try { var service = Data.Helper.GetMobileServiceInSubscription(subscription.Id.ToString("d")); if (service == null) { return; } service.ForEach(u => { if (!MobileServiceList.Contains(u.Name)) { Application.Current.Dispatcher.Invoke(() => MobileServiceList.Add(u.Name)); subscriptionDb.MobileServices.Add(new MobileService() { Name = u.Name }); try { ctx.SaveChanges(); Message = String.Format("Inserted New Mobile Service Reference : {0}", u.Name); } catch (Exception e) { Message = String.Format("Error during Mobile Service List Update : {0}", e.Message); } } }); } catch (Exception e) { Message = e.Message; } }
internal void SubscriptionsChanged(Subscription subscription) { LoadingRingMessage = true; Message = String.Format("Get Mobile Service From Subscription : {0} ", subscription.Name); Application.Current.Dispatcher.Invoke(() => MobileServiceList.Clear()); //Update list of mobile service MobileDbContext ctx = new MobileDbContext(); var mobileService = ctx.MobileServices.Where(u => u.subscription.Id == subscription.Id).ToList(); foreach (var item in mobileService) { Application.Current.Dispatcher.Invoke(() => MobileServiceList.Add(item.Name)); } if (AutoRefresh) { GetMobileServiceOnline(subscription); } Message = String.Empty; LoadingRingMessage = false; }