private static async Task <bool> CheckIsThereUpdate() { IMarketplaceInformationService mis = new MarketplaceInformationService(); var data = await mis.GetAppInformationAsync(); var currentVersion = new Version(WPUtils.GetAppAttributeValue("Version")); return(new Version(data.Entry.Version) > currentVersion); }
private async void agent_enabledisable(object sender, EventArgs e) { string message = String.Empty; if (!CurrentApp.LicenseInformation.ProductLicenses.ContainsKey(IAPs.IAP_PushNotification)) { var agent = ScheduledActionService.Find(UpdateCreditAgent.AgentName); if (agent != null) { WPUtils.RemoveAgent(UpdateCreditAgent.AgentName); message = AppResources.BADisabled; } else { WPUtils.StartPeriodicAgent(UpdateCreditAgent.AgentName); message = AppResources.BAEnabled; } } else { var hub = WPUtils.NotificationGet(); var channel = HttpNotificationChannel.Find(Constants.CnName); if (channel != null && channel.ConnectionStatus == ChannelConnectionStatus.Connected) { channel.Close(); await hub.UnregisterNativeAsync(); message = AppResources.BADisabled; } else { await WPUtils.PushNotificationSetUp(this); return; } } new ToastPrompt { Message = message }.Show(); }
private void TaskDownloadData(ProgressIndicator progress, string usr, string pwd, string Type) { Task.Factory.StartNew( () => { try { if ((App.Current as App).currentInfo.NumberInfos == null) { (App.Current as App).currentInfo = CreateWindInformations(usr, pwd, Type); } else { var tslot = Storage.LoadAsync <byte[]>(IAPs.IAP_AdditionalLogin); tslot.Wait(); var res = tslot.Result; if (res != null && !CanAddNumber(res)) { SafeDispatcher.Run(() => { progress.IsVisible = false; SystemTray.SetProgressIndicator(this, progress); notworking.IsEnabled = LLS.IsEnabled = loginButton.IsEnabled = usrtxt.IsEnabled = pwdtxt.IsEnabled = true; var msg = new MessagePrompt { Title = AppResources.NoAviableNumbersTitle, Message = AppResources.NoAviableNumbersMessage, IsCancelVisible = true }; msg.Completed += addin_buy; msg.Show(); return; }); return; } else { var itm = CreateWindInformations(usr, pwd, Type); (App.Current as App).currentInfoArray.Add(itm); Utils.SaveCreditState((App.Current as App).currentInfoArray); foreach (var item in itm.NumberInfos) { Utils.RenderTiles(item.Number, item); } goto ok; } } if ((App.Current as App).currentInfo.NumberInfos.Count == 0) { throw new Exception(AppResources.ErrorConnection); } Utils.SaveCreditState((App.Current as App).currentInfo); foreach (var item in (App.Current as App).currentInfo.NumberInfos) { Utils.RenderTiles(item.Number, item); } ok: SafeDispatcher.Run(() => NavigationService.Navigate(new Uri("/DataPage.xaml?paymentCheck=1", UriKind.Relative))); WPUtils.StartPeriodicAgent(UpdateCreditAgent.AgentName); return; } catch (Exception ex) { var msg = ex.InnerException != null ? ex.InnerException.Message : ex.Message; SafeDispatcher.Run(() => { progress.IsVisible = false; SystemTray.SetProgressIndicator(this, progress); notworking.IsEnabled = LLS.IsEnabled = loginButton.IsEnabled = usrtxt.IsEnabled = pwdtxt.IsEnabled = true; new MessagePrompt { Message = msg, Title = "SimInfo" }.Show(); }); return; } }); }
private async void ApplicationBarIconButton_Click(object sender, EventArgs e) { if ((sender as CimbalinoBeh.ApplicationBarIconButton).Text.ToLower() == "about") { NavigationService.Navigate(new Uri("/About.xaml", UriKind.Relative)); } else if ((sender as CimbalinoBeh.ApplicationBarIconButton).Text.ToLower() == "refresh") { (sender as CimbalinoBeh.ApplicationBarIconButton).IsEnabled = false; ShakeDetected(null, new ShakeDetectedEventArgs(true)); (sender as CimbalinoBeh.ApplicationBarIconButton).IsEnabled = true; } else if ((sender as CimbalinoBeh.ApplicationBarIconButton).Text.ToLower() == "save") { Task task = null; if (CurrentApp.LicenseInformation.ProductLicenses.ContainsKey(IAPs.IAP_PushNotification)) { task = WPUtils.UploadCurrentData(); } var c = (App.Current as App).currentInfo; var c2 = (App.Current as App).currentInfoArray; Utils.SaveCreditState(c); Utils.SaveCreditState(c2); foreach (var model in pivotNumbers.ItemsSource.Cast <NumberInfo>()) { Utils.RenderTiles(model.Number, model); var tile = ShellTile.ActiveTiles.Where(t => t.NavigationUri.OriginalString.Contains(model.Number)); var smallpath = System.IO.Path.Combine(WPUtils.baseDir, string.Format("{0}_{1}_{2}.jpg", 159, 159, model.Number)); var normalpath = System.IO.Path.Combine(WPUtils.baseDir, string.Format("{0}_{1}_{2}.jpg", 336, 336, model.Number)); //var widepath = System.IO.Path.Combine(WPUtils.baseDir, string.Format("{0}_{1}_{2}.jpg", 691, 336, model.Number)); foreach (var item in tile) { item.Update(new FlipTileData { Title = " ", //WideBackgroundImage = new Uri("isostore:" + widepath, UriKind.Absolute), BackgroundImage = new Uri("isostore:" + normalpath, UriKind.Absolute), SmallBackgroundImage = new Uri("isostore:" + smallpath, UriKind.Absolute), BackBackgroundImage = new Uri("isostore:" + normalpath, UriKind.Absolute), //WideBackBackgroundImage = new Uri("isostore:" + widepath, UriKind.Absolute), }); } } var Img = new ImageConverter(); SafeDispatcher.Run(() => { foreach (var str in new[] { "336", "159" }) { for (int i = 0; i < pivotNumbers.Items.Count; i++) { var hubtile = FindControl <HubTile>(this.pivotNumbers.ItemContainerGenerator.ContainerFromIndex(i), str); if (hubtile != null) { hubtile.Source = Img.Convert(new[] { str, str, (pivotNumbers.Items[i] as NumberInfo).Number }, null, null, null) as BitmapImage; hubtile.Source = Img.Convert(new[] { str, str, (pivotNumbers.Items[i] as NumberInfo).Number }, null, null, null) as BitmapImage; } } } (new ToastPrompt { Message = AppResources.Saved, IsTimerEnabled = true, UseLayoutRounding = true, MillisecondsUntilHidden = 2500 }).Show(); }); if (task != null) { await task; } } }
protected async override void OnNavigatedTo(System.Windows.Navigation.NavigationEventArgs e) { if (e.NavigationMode == System.Windows.Navigation.NavigationMode.New || NavigationContext.QueryString.ContainsKey("Reload")) { if ((App.Current as App).currentInfo == null) { (App.Current as App).currentInfo = Utils.GetSavedState(); } (App.Current as App).currentInfoArray = Utils.GetArraySavedState(); if (IsolatedStorageSettings.ApplicationSettings.Contains("AddinPub") == false) { var p = new MessagePrompt { Body = new addinbanner(), Title = string.Empty, Tag = "AddinPub" }; p.Completed += prt_Completed; p.Show(); } if (IsolatedStorageSettings.ApplicationSettings.Contains("PushNotificationPub") == false) { var p = new MessagePrompt { Body = new pushnotificationbanner(), Title = string.Empty, Tag = "PushNotificationPub" }; p.Completed += prt_Completed; p.Show(); } DataContext = new CreditInfo(); (DataContext as CreditInfo).NumberInfos = new System.Collections.ObjectModel.ObservableCollection <NumberInfo>(); if ((App.Current as App).currentInfo != null) { foreach (var n in (App.Current as App).currentInfo.NumberInfos) { if (n != (object)null) { (DataContext as CreditInfo).NumberInfos.Add(n); } } BugSenseHandler.Instance.UserIdentifier = (App.Current as App).currentInfo.Username; } else { NavigationService.Navigate(new Uri("/MainPage.xaml?FromData=1", UriKind.Relative)); } if ((App.Current as App).currentInfoArray != null) { foreach (var n in (App.Current as App).currentInfoArray.SelectMany(x => x.NumberInfos)) { if (n != (object)null) { (DataContext as CreditInfo).NumberInfos.Add(n); } } } if (NavigationContext.QueryString.ContainsKey("number")) { var number = NavigationContext.QueryString["number"]; if (pivotNumbers.Items != null && pivotNumbers.Items.Cast <NumberInfo>().Any(ni => ni.Number == number)) { pivotNumbers.SelectedItem = pivotNumbers.Items.Cast <NumberInfo>().Single(ni => ni.Number == number); } else { NavigationService.Navigate(new Uri("/MainPage.xaml?FromData=1", UriKind.Relative)); } } NavigationService.RemoveBackEntry(); if (NetworkInterface.GetIsNetworkAvailable() && NavigationContext.QueryString.ContainsKey("paymentCheck")) { using (var http = new HttpClient()) { var data = App.mobileClient.InvokeApiAsync("checkpayment", JToken.FromObject(new { username = (App.Current as App).currentInfo.Username }), HttpMethod.Post, null); if (CurrentApp.LicenseInformation.ProductLicenses.ContainsKey(IAPs.IAP_PushNotification)) { await WPUtils.UpdateFromCloud(); await WPUtils.PushNotificationSetUp(this).ContinueWith(q => WPUtils.RemoveAgent(UpdateCreditAgent.AgentName), TaskContinuationOptions.OnlyOnRanToCompletion); Update(false); } var value = (await data).First()["Cnt"].Value <int>(); Addins.Save(1 + value); } } } }
private async void Fulfill(string item, string receipt) { var t = CurrentApp.LoadListingInformationAsync(); int v; switch (item) { case IAPs.IAP_AdditionalLogin: products.ItemsSource = null; progressRing.IsActive = true; var prevData = await Storage.LoadAsync <byte[]>(IAPs.IAP_AdditionalLogin); if (prevData == null) { v = 2; } else { var dData = ProtectedData.Unprotect(prevData, null); int value = BitConverter.ToInt32(dData, 0); v = value + 1; } Save(v); using (var c = new HttpClient()) { var result = await c.PostAsync("https://wauth.apphb.com/api/AddPayment", new StringContent(JsonConvert.SerializeObject(new PayingUser { Username = (App.Current as App).currentInfo.Username, Count = v }), Encoding.UTF8, "application/json")); } progressRing.IsActive = false; products.ItemsSource = prods.ProductListings.Values.Select(x => new { x.Name, Status = CurrentApp.LicenseInformation.ProductLicenses[x.ProductId].IsActive ? "Purchased" : x.FormattedPrice, x.ImageUri, x.ProductId, BuyNowButtonVisible = CurrentApp.LicenseInformation.ProductLicenses[x.ProductId].IsActive ? System.Windows.Visibility.Collapsed : System.Windows.Visibility.Visible }); break; case IAPs.IAP_PushNotification: products.ItemsSource = null; progressRing.IsActive = true; var ch = WPUtils.ChannelStartup(); SystemTray.SetProgressIndicator(this, new ProgressIndicator { IsVisible = true, Text = AppResources.PushConnect, IsIndeterminate = true }); var tsk = WPUtils.UploadCurrentData(); while (ch.ConnectionStatus != ChannelConnectionStatus.Connected && ch.ChannelUri == null) { await Task.Delay(1000); } await WPUtils.PushNotificationSetUp(this); SystemTray.SetProgressIndicator(this, null); progressRing.IsActive = false; products.ItemsSource = prods.ProductListings.Values.Select(x => new { x.Name, Status = CurrentApp.LicenseInformation.ProductLicenses[x.ProductId].IsActive ? "Purchased" : x.FormattedPrice, x.ImageUri, x.ProductId, BuyNowButtonVisible = CurrentApp.LicenseInformation.ProductLicenses[x.ProductId].IsActive ? System.Windows.Visibility.Collapsed : System.Windows.Visibility.Visible }); await tsk; break; default: break; } prods = await t; var prod = prods.ProductListings.Single(x => x.Value.ProductId == item); if (prod.Value.ProductType == ProductType.Consumable) { CurrentApp.ReportProductFulfillment(item); } }