private async Task ListPointsAsync()
        {

            // Request an instance of the default Wallet store.
            wallet = await WalletManager.RequestStoreAsync();

            // Find an existing wallet item.
            walletItem = await wallet.GetWalletItemAsync("CoffeeLoyalty123");

            if (walletItem == null)
            {
                rootPage.NotifyUser("Item does not exist. Add item using Scenario2", NotifyType.ErrorMessage);
                return;
            }

            if (walletItem.DisplayProperties.ContainsKey("PointsId"))
            {
                CoffePointsValue.Text = walletItem.DisplayProperties["PointsId"].Value;
            }
            else
            {
                rootPage.NotifyUser("Item does not have a PointsId property.", NotifyType.ErrorMessage);
                return;
            }

        }
        /// <summary>
        /// Adds a new membership card wallet item to Wallet.
        /// </summary>
        /// <returns></returns>
        private async Task AddItemAsync()
        {
            try
            {
                // Create the membership card.
                WalletItem card = new WalletItem(WalletItemKind.MembershipCard, "Contoso Loyalty Card");

                // Set colors, to give the card our distinct branding.
                card.BodyColor       = Windows.UI.Colors.Brown;
                card.BodyFontColor   = Windows.UI.Colors.White;
                card.HeaderColor     = Windows.UI.Colors.SaddleBrown;
                card.HeaderFontColor = Windows.UI.Colors.White;

                // Set basic properties.
                card.IssuerDisplayName = "Contoso Coffee";

                // Set some images.
                card.Logo336x336 = await StorageFile.GetFileFromApplicationUriAsync(new Uri("ms-appx:///assets/coffee336x336.png"));

                card.Logo99x99 = await StorageFile.GetFileFromApplicationUriAsync(new Uri("ms-appx:///assets/coffee99x99.png"));

                card.Logo159x159 = await StorageFile.GetFileFromApplicationUriAsync(new Uri("ms-appx:///assets/coffee159x159.png"));

                card.HeaderBackgroundImage = await StorageFile.GetFileFromApplicationUriAsync(new Uri("ms-appx:///assets/header640x130.png"));

                // Set the loyalty card points and show them on the detailed view of card and in the list view.
                WalletItemCustomProperty prop = new WalletItemCustomProperty("Coffee Points", "99");
                prop.DetailViewPosition            = WalletDetailViewPosition.FooterField1;
                prop.SummaryViewPosition           = WalletSummaryViewPosition.Field1;
                card.DisplayProperties["PointsId"] = prop;

                // Show the branch.
                prop = new WalletItemCustomProperty("Branch", "Contoso on 5th");
                prop.DetailViewPosition            = WalletDetailViewPosition.HeaderField1;
                card.DisplayProperties["BranchId"] = prop;

                // Add the customer account number.
                prop = new WalletItemCustomProperty("Account Number", "12345678");
                prop.DetailViewPosition = WalletDetailViewPosition.FooterField2;

                // We don't want this field entity extracted as it will be interpreted as a phone number.
                prop.AutoDetectLinks             = false;
                card.DisplayProperties["AcctId"] = prop;

                // Encode the user's account number as a Qr Code to be used in the store.
                card.Barcode = new WalletBarcode(WalletBarcodeSymbology.Qr, "12345678");

                // Add a promotional message to the card.
                card.DisplayMessage             = "Tap here for your 15% off coupon";
                card.IsDisplayMessageLaunchable = true;

                await wallet.AddAsync("CoffeeLoyalty123", card);

                rootPage.NotifyUser("Item has been added to Wallet. Tap \"View item in Wallet\" to see it in Wallet.", NotifyType.StatusMessage);
            }
            catch (Exception ex)
            {
                rootPage.NotifyUser(ex.Message, NotifyType.ErrorMessage);
            }
        }
        /// <summary>
        /// Adds a new membership card wallet item to Wallet.
        /// </summary>
        /// <returns></returns>
        private async Task AddItemAsync()
        {
            try
            {
                // Create the membership card.
                WalletItem card = new WalletItem(WalletItemKind.MembershipCard, "Contoso Loyalty Card");

                // Set colors, to give the card our distinct branding.
                card.BodyColor = Windows.UI.Colors.Brown;
                card.BodyFontColor = Windows.UI.Colors.White;
                card.HeaderColor = Windows.UI.Colors.SaddleBrown;
                card.HeaderFontColor = Windows.UI.Colors.White;

                // Set basic properties.
                card.IssuerDisplayName = "Contoso Coffee";

                // Set some images.
                card.Logo336x336 =  await StorageFile.GetFileFromApplicationUriAsync(new Uri("ms-appx:///assets/coffee336x336.png"));

                card.Logo99x99 =    await StorageFile.GetFileFromApplicationUriAsync(new Uri("ms-appx:///assets/coffee99x99.png"));

                card.Logo159x159 = await StorageFile.GetFileFromApplicationUriAsync(new Uri("ms-appx:///assets/coffee159x159.png"));

                card.HeaderBackgroundImage = await StorageFile.GetFileFromApplicationUriAsync(new Uri("ms-appx:///assets/header640x130.png"));

                // Set the loyalty card points and show them on the detailed view of card and in the list view.
                WalletItemCustomProperty prop = new WalletItemCustomProperty("Coffee Points", "99");
                prop.DetailViewPosition = WalletDetailViewPosition.FooterField1;
                prop.SummaryViewPosition = WalletSummaryViewPosition.Field1;
                card.DisplayProperties["PointsId"] = prop;

                // Show the branch.
                prop = new WalletItemCustomProperty("Branch", "Contoso on 5th");
                prop.DetailViewPosition = WalletDetailViewPosition.HeaderField1;
                card.DisplayProperties["BranchId"] = prop;

                // Add the customer account number.
                prop = new WalletItemCustomProperty("Account Number", "12345678");
                prop.DetailViewPosition = WalletDetailViewPosition.FooterField2;

                // We don't want this field entity extracted as it will be interpreted as a phone number.
                prop.AutoDetectLinks = false;
                card.DisplayProperties["AcctId"] = prop;

                // Encode the user's account number as a Qr Code to be used in the store.
                card.Barcode = new WalletBarcode(WalletBarcodeSymbology.Qr, "12345678");

                // Add a promotional message to the card.
                card.DisplayMessage = "Tap here for your 15% off coupon";
                card.IsDisplayMessageLaunchable = true;

                await wallet.AddAsync("CoffeeLoyalty123", card);

                rootPage.NotifyUser("Item has been added to Wallet. Tap \"View item in Wallet\" to see it in Wallet.", NotifyType.StatusMessage);
            }
            catch (Exception ex)
            {
                rootPage.NotifyUser(ex.Message, NotifyType.ErrorMessage);
            }
        }
        /// <summary>
        /// Imports a wallet item from a .mswallet file.
        /// </summary>
        /// <returns>An asynchronous action.</returns>
        public async Task ImportAsync()
        {
            try
            {
                // Import another membership card, represented by the .mswallet file located in the Assets folder of this sample.
                StorageFile file = await StorageFile.GetFileFromApplicationUriAsync(new Uri("ms-appx:///assets/ContosoCoffeePikePlace.mswallet"));

                if (file == null)
                {
                    this.rootPage.NotifyUser("Could not open file assets/ContosoCoffeePikePlace.mswallet", NotifyType.ErrorMessage);
                    return;
                }

                walletItem = await wallet.ImportItemAsync(file);

                this.rootPage.NotifyUser("Import succeeded. Tap \"view in wallet\" to see the imported item", NotifyType.StatusMessage);
            }
            catch (FileNotFoundException noFile)
            {
                this.rootPage.NotifyUser(noFile.Message, NotifyType.ErrorMessage);
            }
            catch (Exception ex)
            {
                var errorMessage = String.Format("Import failed {0}", ex.Message);
                this.rootPage.NotifyUser(errorMessage, NotifyType.ErrorMessage);
            }
        }
Ejemplo n.º 5
0
        async void OnSaveClickedAdd(object sender, EventArgs e)
        {
            var    text = Amount.Text;
            double num;
            bool   isNum = double.TryParse(text, out num);

            if (string.IsNullOrWhiteSpace(text))
            {
                await DisplayAlert("Clumsy...!", "Fill out the field", "Dismiss");
            }
            else if (!isNum)
            {
                await DisplayAlert("Oops", "Please enter a valid number", "Dismiss");
            }
            else if (this.intent.Equals(Intent.ADD))
            {
                WalletItem item = new WalletItem(currency.Code, num);
                new Database().AddItem(item);

                //Careful to remove the search Page also
                this.Navigation.RemovePage(this.Navigation.NavigationStack[this.Navigation.NavigationStack.Count - 2]);
                await Navigation.PopAsync();
            }
            else
            {
                item.amount          += num;
                item.formatted_amount = string.Format("{0:0.00}", item.amount);
                new Database().EditItem(this.item);

                await Navigation.PopAsync();
            }
        }
Ejemplo n.º 6
0
 private async void ContentDialogPrimaryButtonClick(ContentDialog sender, ContentDialogButtonClickEventArgs args)
 {
     if (string.IsNullOrWhiteSpace(tbxName.Text))
     {
         args.Cancel = true;
         await new MessageDialog("A new wallet item needs a name!", "Empty Name").ShowAsync();
         return;
     }
     if (string.IsNullOrWhiteSpace(tbxId.Text))
     {
         args.Cancel = true;
         await new MessageDialog("A new barcode item needs a id!", "Empty Id").ShowAsync();
         return;
     }
     Result = new WalletItem(WalletItemKind.General, tbxName.Text)
     {
         Barcode     = new WalletBarcode(boxType.SelectedItem as WalletBarcodeSymbology? ?? WalletBarcodeSymbology.Qr, tbxId.Text),
         HeaderColor = Colors.DarkBlue,
         LogoText    = tbxName.Text
     };
     if (!string.IsNullOrWhiteSpace(tbxId.Text))
     {
         Result.DisplayProperties.Add(
             "CardId",
             new WalletItemCustomProperty("Card Id", tbxId.Text)
         {
             DetailViewPosition  = WalletDetailViewPosition.PrimaryField1,
             SummaryViewPosition = WalletSummaryViewPosition.Field1
         });
     }
 }
        /// <summary>
        /// Imports a wallet item from a .mswallet file.
        /// </summary>
        /// <returns>An asynchronous action.</returns>
        public async Task ImportAsync()
        {
            try
            {
                // Import another membership card, represented by the .mswallet file located in the Assets folder of this sample. 
                StorageFile file = await StorageFile.GetFileFromApplicationUriAsync(new Uri("ms-appx:///assets/ContosoCoffeePikePlace.mswallet")); 

                if (file == null)
                {
                    this.rootPage.NotifyUser("Could not open file assets/ContosoCoffeePikePlace.mswallet", NotifyType.ErrorMessage);
                    return;
                }

                walletItem = await wallet.ImportItemAsync(file); 
                this.rootPage.NotifyUser("Import succeeded. Tap \"view in wallet\" to see the imported item", NotifyType.StatusMessage);
               
            }
            catch(FileNotFoundException noFile)
            {
                this.rootPage.NotifyUser(noFile.Message, NotifyType.ErrorMessage);
            }
            catch(Exception ex)
            {
                var errorMessage = String.Format("Import failed {0}", ex.Message);
                this.rootPage.NotifyUser(errorMessage, NotifyType.ErrorMessage);
            }
        }
Ejemplo n.º 8
0
 public void UpdateItem(WalletItem item)
 {
     if (_db.WalletItems.Any(i => i.Wallet.Id == item.Wallet.Id && i.Cryptocurrency.Id == item.Cryptocurrency.Id))
     {
         _db.Update(item);
         Save();
     }
 }
Ejemplo n.º 9
0
        /// <summary>
        /// transaction
        /// </summary>
        /// <param name="des">description</param>
        /// <param name="pay">paymet</param>
        public async void Transaction(string des, double pay)
        {
            try
            {
                SampleItem itemData = null;
                bool       isFind   = false;
                foreach (GroupInfoList group in Global.Current.SampleItems.Data)
                {
                    foreach (SampleItem item in group.ItemContent)
                    {
                        if (item.Title == des)
                        {
                            itemData       = item;
                            itemData.Price = "¥" + pay.ToString();
                            des            = des + "-付款";
                            isFind         = true;
                            break;
                        }
                    }
                    if (isFind)
                    {
                        break;
                    }
                }
                if (itemData != null)
                {
                    Global.Current.Serialization.SaveOrder(itemData);
                }
                WalletItem walletItem = await this.wallet.GetWalletItemAsync(conCardID);

                if (walletItem != null && walletItem.DisplayProperties.ContainsKey(conCardMoney))
                {
                    string money       = walletItem.DisplayProperties[conCardMoney].Value;
                    string updateMoney = (double.Parse(money) - pay).ToString();
                    walletItem.DisplayProperties[conCardMoney].Value = updateMoney;
                    await this.wallet.UpdateAsync(walletItem);

                    WalletTransaction walletTransaction = new WalletTransaction();
                    walletTransaction.Description     = des;
                    walletTransaction.DisplayAmount   = "¥" + pay.ToString();
                    walletTransaction.TransactionDate = DateTime.Now;
                    walletTransaction.IgnoreTimeOfDay = false;
                    walletTransaction.DisplayLocation = "Bank on 5th";
                    // Add the transaction to the TransactionHistory of this item.
                    walletItem.TransactionHistory.Add("transaction" + DateTime.Now.Ticks.ToString(), walletTransaction);
                    // Update the item in Wallet.
                    await this.wallet.UpdateAsync(walletItem);

                    Global.Current.Notifications.CreateToastNotifier("提示", "付款成功");
                    Global.Current.Notifications.CreateTileWide310x150Text09("付款成功", "恭喜您付款成功");
                }
            }
            catch (Exception ex)
            {
                Debug.WriteLine(ex.Message);
            }
        }
Ejemplo n.º 10
0
        public void SetDetailItem(object newDetailItem)
        {
            if (detailItem != newDetailItem) {
            detailItem = (WalletItem) newDetailItem;

            // Update the view
            ConfigureView ();
              }
        }
        protected override async void OnNavigatedTo(NavigationEventArgs e)
        {
            rootPage = MainPage.Current;

            // Request an instance of the default Wallet store.
            wallet = await WalletManager.RequestStoreAsync();

            // Get the wallet item to be used in this scenario.
            walletItem = await wallet.GetWalletItemAsync("CoffeeLoyalty123");
        }
        protected override async void OnNavigatedTo(NavigationEventArgs e)
        {
            rootPage = MainPage.Current;

            // Request an instance of the default Wallet store.
            wallet = await WalletManager.RequestStoreAsync();

            // Get the wallet item to be used in this scenario.
            walletItem = await wallet.GetWalletItemAsync("CoffeeLoyalty123");
        }
Ejemplo n.º 13
0
        public UseableWalletItem(BaseItem item)
        {
            //Generic copy
            UseableBaseItem.CopyItem(this, item);

            //Wallet copy
            WalletItem wallet = item as WalletItem;

            maxMoneyContained = wallet.maxMoneyContained;
            minMoneyContained = wallet.minMoneyContained;
        }
 private async void Delete_Click(object sender, RoutedEventArgs e)
 {
     if (walletItem == null)
     {
         rootPage.NotifyUser("Item does not exist. Add item using Scenario2", NotifyType.ErrorMessage);
     }
     else
     {
         await wallet.DeleteAsync(walletItem.Id);
         walletItem = null;
         rootPage.NotifyUser("Item deleted.", NotifyType.StatusMessage);
     }
 }
Ejemplo n.º 15
0
        /// <summary>
        /// delete wallet
        /// </summary>
        public async void DeleteWallet()
        {
            try
            {
                WalletItem walletItem = await this.wallet.GetWalletItemAsync(conCardID);

                await this.wallet.DeleteAsync(walletItem.Id);
            }
            catch (Exception ex)
            {
                Debug.WriteLine(ex.Message);
            }
        }
Ejemplo n.º 16
0
        public AddItemPage(WalletItem item, Intent intent)
        {
            this.item   = item;
            this.intent = intent;
            InitializeComponent();

            currencyCode.Text   = item.code;
            currencyName.Text   = item.name;
            currencyFlag.Source = item.flag;
            currencySymbol.Text = item.symbol;
            currencyAmount.Text = item.formatted_amount;

            //if(intent.Equals(Intent.EDIT)) saveButton2.Text = "Update";
        }
Ejemplo n.º 17
0
        private async void Delete_Click(object sender, RoutedEventArgs e)
        {
            if (walletItem == null)
            {
                rootPage.NotifyUser("Item does not exist. Add item using Scenario2", NotifyType.ErrorMessage);
            }
            else
            {
                await wallet.DeleteAsync(walletItem.Id);

                walletItem = null;
                rootPage.NotifyUser("Item deleted.", NotifyType.StatusMessage);
            }
        }
Ejemplo n.º 18
0
        /// <summary>
        /// create Wallet
        /// </summary>
        public async void CreateWallet()
        {
            try
            {
                // Create the membership card.
                WalletItem card = new WalletItem(WalletItemKind.MembershipCard, "My Card");
                // Set colors, to give the card our distinct branding.
                card.BodyColor       = Windows.UI.Colors.Brown;
                card.BodyFontColor   = Windows.UI.Colors.White;
                card.HeaderColor     = Windows.UI.Colors.SaddleBrown;
                card.HeaderFontColor = Windows.UI.Colors.White;
                // Set basic properties.
                card.IssuerDisplayName = "Bank";
                // Set some images.
                card.Logo336x336 = await StorageFile.GetFileFromApplicationUriAsync(new Uri("ms-appx:///assets/wallet/coffee336x336.png"));

                card.Logo99x99 = await StorageFile.GetFileFromApplicationUriAsync(new Uri("ms-appx:///assets/wallet/coffee99x99.png"));

                card.Logo159x159 = await StorageFile.GetFileFromApplicationUriAsync(new Uri("ms-appx:///assets/wallet/coffee159x159.png"));

                card.HeaderBackgroundImage = await StorageFile.GetFileFromApplicationUriAsync(new Uri("ms-appx:///assets/wallet/header640x130.png"));

                // Set the loyalty card points and show them on the detailed view of card and in the list view.
                WalletItemCustomProperty prop = new WalletItemCustomProperty("Money", "1000000");
                prop.DetailViewPosition              = WalletDetailViewPosition.FooterField1;
                prop.SummaryViewPosition             = WalletSummaryViewPosition.Field1;
                card.DisplayProperties[conCardMoney] = prop;
                // Show the branch.
                prop = new WalletItemCustomProperty("Branch", "Bank on 5th");
                prop.DetailViewPosition            = WalletDetailViewPosition.HeaderField1;
                card.DisplayProperties["BranchId"] = prop;
                // Add the customer account number.
                prop = new WalletItemCustomProperty("Account Number", "2014************3697");
                prop.DetailViewPosition = WalletDetailViewPosition.FooterField2;
                // We don't want this field entity extracted as it will be interpreted as a phone number.
                prop.AutoDetectLinks             = false;
                card.DisplayProperties["AcctId"] = prop;
                // Encode the user's account number as a Qr Code to be used in the store.
                card.Barcode = new WalletBarcode(WalletBarcodeSymbology.Qr, "20141212025641693697");
                // Add a promotional message to the card.
                card.DisplayMessage             = "Tap here for the fast payment";
                card.IsDisplayMessageLaunchable = true;
                await wallet.AddAsync(conCardID, card);
            }
            catch (Exception ex)
            {
                Debug.WriteLine(ex.Message);
            }
        }
Ejemplo n.º 19
0
        private async void ContentDialogPrimaryButtonClick(ContentDialog sender, ContentDialogButtonClickEventArgs args)
        {
            if (string.IsNullOrWhiteSpace(tbxName.Text))
            {
                args.Cancel = true;
                await new MessageDialog("A vCard needs a name!", "Empty Name").ShowAsync();
                return;
            }

            var vCard = new StringBuilder();

            vCard.AppendLine("BEGIN:VCARD");
            vCard.AppendLine("VERSION:2.1");
            vCard.AppendLine("FN:" + tbxName.Text);
            if (!string.IsNullOrWhiteSpace(tbxPhone.Text))
            {
                vCard.AppendLine("TEL;HOME;VOICE:" + tbxPhone.Text);
            }
            if (!string.IsNullOrWhiteSpace(tbxMail.Text))
            {
                vCard.AppendLine("EMAIL;HOME;INTERNET:" + tbxMail.Text);
            }
            if (!string.IsNullOrWhiteSpace(tbxOrganization.Text))
            {
                vCard.AppendLine("ORG:" + tbxOrganization.Text);
            }
            vCard.Append("END:VCARD");

            Result = new WalletItem(WalletItemKind.General, tbxName.Text)
            {
                Barcode     = new WalletBarcode(WalletBarcodeSymbology.Qr, vCard.ToString()),
                HeaderColor = Colors.DarkBlue,
                LogoText    = tbxName.Text
            };
            if (!string.IsNullOrWhiteSpace(tbxOrganization.Text))
            {
                Result.DisplayProperties.Add(
                    "Organization",
                    new WalletItemCustomProperty("Organization", tbxOrganization.Text)
                {
                    DetailViewPosition  = WalletDetailViewPosition.PrimaryField1,
                    SummaryViewPosition = WalletSummaryViewPosition.Field1
                });
            }
        }
        public async Task ShowWalletItemAsync()
        {
            WalletItem walletItem = await wallet.GetWalletItemAsync("CoffeeLoyalty123");

            // If the item exists, show it in Wallet
            if (walletItem != null)
            {
                // Launch Wallet and navigate to item
                await wallet.ShowAsync(walletItem.Id);
            }
            else
            {
                // Item does not exist, so just launch Wallet.
                // Alternatively, you could tell the user that the item they want to see does not exist
                // and stay in your app.
                await wallet.ShowAsync();
            }
        }
Ejemplo n.º 21
0
 public void InsertItem(WalletItem item, bool ok)
 {
     if (ok)
     {
         UpdateItem(item);
     }
     else
     {
         if (_db.Cryptos.Any(i => i.Id == item.CryptoId))
         {
             _db.WalletItems.Add(item);
         }
         else
         {
             throw new Exception("The specified cryptocurrency does not exist");
         }
     }
     Save();
 }
Ejemplo n.º 22
0
        /// <summary>
        /// show wallet
        /// </summary>
        /// <returns></returns>
        public async Task ShowWalletItemAsync()
        {
            try
            {
                WalletItem walletItem = await wallet.GetWalletItemAsync(conCardID);

                if (walletItem != null)
                {
                    await this.wallet.ShowAsync(walletItem.Id);
                }
                else
                {
                    await this.wallet.ShowAsync();
                }
            }
            catch (Exception ex)
            {
                Debug.WriteLine(ex.Message);
            }
        }
        private async Task ListPointsAsync()
        {
            // Request an instance of the default Wallet store.
            wallet = await WalletManager.RequestStoreAsync();

            // Find an existing wallet item.
            walletItem = await wallet.GetWalletItemAsync("CoffeeLoyalty123");

            if (walletItem == null)
            {
                rootPage.NotifyUser("Item does not exist. Add item using Scenario2", NotifyType.ErrorMessage);
                return;
            }

            if (walletItem.DisplayProperties.ContainsKey("PointsId"))
            {
                CoffePointsValue.Text = walletItem.DisplayProperties["PointsId"].Value;
            }
            else
            {
                rootPage.NotifyUser("Item does not have a PointsId property.", NotifyType.ErrorMessage);
                return;
            }
        }
Ejemplo n.º 24
0
        private async void AddExpiredDealPassButton_Click(object sender, RoutedEventArgs e)
        {
            WalletItemStore store = await WalletManager.RequestStoreAsync();

            //string itemId = string.IsNullOrEmpty(walletItemName.Text) ? walletItemName.Text : cardName;

            WalletItem card = new WalletItem(WalletItemKind.Deal, "Expired Deal");
            // Set colors, to give the card our distinct branding.
            card.BodyColor = Windows.UI.Colors.Brown;
            card.BodyFontColor = Windows.UI.Colors.White;
            card.HeaderColor = Windows.UI.Colors.SaddleBrown;
            card.HeaderFontColor = Windows.UI.Colors.White;


            card.Logo336x336 = await StorageFile.GetFileFromApplicationUriAsync(new Uri("ms-appx:///Assets/icons/CouponMedium.png"));
            card.Logo159x159 = await StorageFile.GetFileFromApplicationUriAsync(new Uri("ms-appx:///Assets/icons/CouponSmall.png"));
            card.Logo99x99 = await StorageFile.GetFileFromApplicationUriAsync(new Uri("ms-appx:///Assets/icons/CouponIcon.png"));

            card.LogoImage = await StorageFile.GetFileFromApplicationUriAsync(new Uri("ms-appx:///Assets/icons/CouponIcon.png"));
            card.LogoText = dealName;

            // Add the customer account number.
            WalletItemCustomProperty prop = new WalletItemCustomProperty("HOLD", "HOLD");
            prop.DetailViewPosition = WalletDetailViewPosition.HeaderField1;
            // We don't want this field entity extracted as it will be interpreted as a phone number.
            card.DisplayProperties["Holder1"] = prop;

            prop = new WalletItemCustomProperty("HOLD", "HOLD");
            prop.DetailViewPosition = WalletDetailViewPosition.HeaderField2;
            // We don't want this field entity extracted as it will be interpreted as a phone number.
            card.DisplayProperties["Holder2"] = prop;

            // Add the customer account number.
            prop = new WalletItemCustomProperty("Sale", "Christmas Couple");
            prop.DetailViewPosition = WalletDetailViewPosition.PrimaryField1;
            // We don't want this field entity extracted as it will be interpreted as a phone number.
            card.DisplayProperties["SaleTitle"] = prop;

            prop = new WalletItemCustomProperty("HOLD", "HOLD");
            prop.DetailViewPosition = WalletDetailViewPosition.PrimaryField2;
            // We don't want this field entity extracted as it will be interpreted as a phone number.
            card.DisplayProperties["Holder3"] = prop;

            // Add the customer account number.
            prop = new WalletItemCustomProperty("Coupon Code", "987654321");
            prop.DetailViewPosition = WalletDetailViewPosition.SecondaryField1;
            // We don't want this field entity extracted as it will be interpreted as a phone number.
            prop.AutoDetectLinks = false;
            card.DisplayProperties["Coupon Code"] = prop;

            prop = new WalletItemCustomProperty("HOLD", "HOLD");
            prop.DetailViewPosition = WalletDetailViewPosition.SecondaryField2;
            // We don't want this field entity extracted as it will be interpreted as a phone number.
            card.DisplayProperties["Holder4"] = prop;

            prop = new WalletItemCustomProperty("Valid Until", "2014-11-16");
            //prop.DetailViewPosition = WalletDetailViewPosition.FooterField1;
            prop.AutoDetectLinks = true;
            prop.SummaryViewPosition = WalletSummaryViewPosition.Field1;
            card.DisplayProperties["Website"] = prop;

            prop = new WalletItemCustomProperty("Website", "http://www.Contoso.com/");
            //prop.DetailViewPosition = WalletDetailViewPosition.FooterField2;
            prop.AutoDetectLinks = true;
            prop.SummaryViewPosition = WalletSummaryViewPosition.Field2;
            card.DisplayProperties["Website"] = prop;

            // Add the customer account number.
            prop = new WalletItemCustomProperty("Phone", "425-707-1234");
            //prop.DetailViewPosition = WalletDetailViewPosition.FooterField3;
            prop.AutoDetectLinks = true;
            card.DisplayProperties["phone"] = prop;

            prop = new WalletItemCustomProperty("Location", "1 Microsot Way, Redmond,  WA 98052");
            prop.AutoDetectLinks = true;
            //prop.DetailViewPosition = WalletDetailViewPosition.FooterField4;
            card.DisplayProperties["Address"] = prop;

            prop = new WalletItemCustomProperty("Email", "*****@*****.**");
            prop.AutoDetectLinks = true;
            card.DisplayProperties["Address"] = prop;

            // Encode the user's account number as a Qr Code to be used in the store.
            card.Barcode = new WalletBarcode(WalletBarcodeSymbology.Ean13, "9876543210123");

            //card.ExpirationDate = new DateTimeOffset(new DateTime(2015, 1, 1), new TimeSpan(10, 0, 0, 0));

            card.ExpirationDate = new DateTimeOffset(new DateTime(2014, 11, 16));
            //card.ExpirationDate = new DateTimeOffset(DateTime.UtcNow, new TimeSpan(0, 0, 0, 0));

            // NOTE: in the back of the card
            card.LastUpdated = new DateTimeOffset(new DateTime(2014, 10, 10));


            card.IsAcknowledged = true;
            card.IssuerDisplayName = "Contoso Ltd.";
            card.RelevantLocations.Add(
                "Store",
                new WalletRelevantLocation()
                {
                    DisplayMessage = "Store location",
                    Position = new Windows.Devices.Geolocation.BasicGeoposition()
                    {
                        Latitude = 47.640068,
                        Longitude = -122.129858
                    }
                });

            card.Verbs.Add("visit", new WalletVerb("Visit"));


            // Add a relevant date.
            card.RelevantDate = DateTime.Now;
            card.RelevantDateDisplayMessage = "Deal is available all the way in 2014!";

            // Add a promotional message to the card.
            card.DisplayMessage = "Tap here for your 15% off coupon";
            card.IsDisplayMessageLaunchable = true;

            ((Button)sender).IsEnabled = false;
            this.ExpiredDealPassInfoButton.IsEnabled = true;

            await store.AddAsync(expiredDealName, card);
        }
Ejemplo n.º 25
0
        private async void AddTicketButtonBarCode_Click(object sender, RoutedEventArgs e)
        {
            WalletItemStore store = await WalletManager.RequestStoreAsync();

            //string itemId = string.IsNullOrEmpty(walletItemName.Text) ? walletItemName.Text : cardName;

            WalletItem card = new WalletItem(WalletItemKind.Ticket, concertName);
            // Set colors, to give the card our distinct branding.
            card.BodyColor = Windows.UI.Colors.Brown;
            card.BodyFontColor = Windows.UI.Colors.White;
            card.HeaderColor = Windows.UI.Colors.SaddleBrown;
            card.HeaderFontColor = Windows.UI.Colors.White;

            card.Logo336x336 = await StorageFile.GetFileFromApplicationUriAsync(new Uri("ms-appx:///Assets/icons/wlr_concert_Medium.png"));
            card.Logo159x159 = await StorageFile.GetFileFromApplicationUriAsync(new Uri("ms-appx:///Assets/icons/wlr_concert_Small.png"));
            card.Logo99x99 = await StorageFile.GetFileFromApplicationUriAsync(new Uri("ms-appx:///Assets/icons/wlr_concert_Icon.png"));

            card.LogoImage = await StorageFile.GetFileFromApplicationUriAsync(new Uri("ms-appx:///Assets/icons/wlr_concert_Icon.png"));
            card.LogoText = concertName;

            // Add the customer account number.
            WalletItemCustomProperty prop = new WalletItemCustomProperty("Printed date", "2014-12-15");
            prop.DetailViewPosition = WalletDetailViewPosition.HeaderField1;
            card.DisplayProperties["PrintedDate"] = prop;

            // Add the customer account number.
            prop = new WalletItemCustomProperty("HOLD", "HOLD");
            prop.DetailViewPosition = WalletDetailViewPosition.HeaderField2;
            // We don't want this field entity extracted as it will be interpreted as a phone number.
            prop.AutoDetectLinks = false;
            card.DisplayProperties["Holder1"] = prop;


            prop = new WalletItemCustomProperty("Departing from", "Seattle-Tacoma (SEA)");
            prop.DetailViewPosition = WalletDetailViewPosition.PrimaryField1;
            card.DisplayProperties["Origin"] = prop;

            prop = new WalletItemCustomProperty("Destination", "New York (JFK)");
            prop.DetailViewPosition = WalletDetailViewPosition.PrimaryField2;
            prop.AutoDetectLinks = true;
            card.DisplayProperties["Destination"] = prop;

            prop = new WalletItemCustomProperty("Departure Time", "2014-12-19");
            prop.DetailViewPosition = WalletDetailViewPosition.SecondaryField1;
            prop.AutoDetectLinks = true;
            card.DisplayProperties["Departure"] = prop;

            prop = new WalletItemCustomProperty("Arrival Time ", "2014-12-20");
            prop.DetailViewPosition = WalletDetailViewPosition.SecondaryField2;
            prop.AutoDetectLinks = true;
            card.DisplayProperties["Arrival"] = prop;

            // Add the customer account number.
            prop = new WalletItemCustomProperty("HOLD", "HOLD");
            prop.DetailViewPosition = WalletDetailViewPosition.SecondaryField3;
            // We don't want this field entity extracted as it will be interpreted as a phone number.
            prop.AutoDetectLinks = false;
            card.DisplayProperties["Holder2"] = prop;

            // Add the customer account number.
            prop = new WalletItemCustomProperty("HOLD", "HOLD");
            prop.DetailViewPosition = WalletDetailViewPosition.SecondaryField4;
            // We don't want this field entity extracted as it will be interpreted as a phone number.
            prop.AutoDetectLinks = false;
            card.DisplayProperties["Holder3"] = prop;

            // Add the customer account number.
            prop = new WalletItemCustomProperty("HOLD", "HOLD");
            prop.DetailViewPosition = WalletDetailViewPosition.CenterField1;
            // We don't want this field entity extracted as it will be interpreted as a phone number.
            prop.AutoDetectLinks = false;
            card.DisplayProperties["Holder4"] = prop;

            // Add the customer account number.
            prop = new WalletItemCustomProperty("Name", "Joe Smith");
            prop.DetailViewPosition = WalletDetailViewPosition.FooterField1;
            // We don't want this field entity extracted as it will be interpreted as a phone number.
            prop.AutoDetectLinks = false;
            card.DisplayProperties["Name"] = prop;

            prop = new WalletItemCustomProperty("Seat", "12B");
            prop.DetailViewPosition = WalletDetailViewPosition.FooterField2;
            // We don't want this field entity extracted as it will be interpreted as a phone number.
            prop.AutoDetectLinks = false;
            card.DisplayProperties["Seat"] = prop;

            // Add the customer account number.
            prop = new WalletItemCustomProperty("TicketNumber", "9876543210123");
            prop.DetailViewPosition = WalletDetailViewPosition.FooterField3;
            // We don't want this field entity extracted as it will be interpreted as a phone number.
            prop.AutoDetectLinks = false;
            card.DisplayProperties["TicketNumber"] = prop;

            // Encode the user's account number as a Qr Code to be used in the store.
            card.Barcode = new WalletBarcode(WalletBarcodeSymbology.Ean13, "9876543210123");

            //card.ExpirationDate = new DateTimeOffset(new DateTime(2015, 1, 1), new TimeSpan(10, 0, 0, 0));

            card.IsAcknowledged = true;
            card.IssuerDisplayName = "WLR Concert";

            card.Verbs.Add("see", new WalletVerb("See"));

            // Add a relevant date.
            card.RelevantDate = DateTime.Now;
            card.RelevantDateDisplayMessage = "Once in a lifetime";

            // Add a promotional message to the card.
            card.DisplayMessage = "Concert ticket";
            card.IsDisplayMessageLaunchable = true;

            ((Button)sender).IsEnabled = false;
            this.TicketInfoButtonBarcode.IsEnabled = true;

            await store.AddAsync(concertName, card);
        }
Ejemplo n.º 26
0
        private async void AddMembershipButtonQR_Click(object sender, RoutedEventArgs e)
        {
            WalletItemStore store = await WalletManager.RequestStoreAsync();

            //string itemId = string.IsNullOrEmpty(walletItemName.Text) ? walletItemName.Text : cardName;

            WalletItem card = new WalletItem(WalletItemKind.MembershipCard, membershipCardQRName);
            // Set colors, to give the card our distinct branding.
            card.BodyColor = Windows.UI.Colors.Brown;
            card.BodyFontColor = Windows.UI.Colors.White;
            card.HeaderColor = Windows.UI.Colors.SaddleBrown;
            card.HeaderFontColor = Windows.UI.Colors.White;


            card.Logo336x336 = await StorageFile.GetFileFromApplicationUriAsync(new Uri("ms-appx:///Assets/icons/CaffeLuzzoMedium.png"));
            card.Logo159x159 = await StorageFile.GetFileFromApplicationUriAsync(new Uri("ms-appx:///Assets/icons/CaffeLuzzoSmall.png"));
            card.Logo99x99 = await StorageFile.GetFileFromApplicationUriAsync(new Uri("ms-appx:///Assets/icons/CaffeLuzzoIcon.png"));

            card.LogoImage = await StorageFile.GetFileFromApplicationUriAsync(new Uri("ms-appx:///Assets/icons/CaffeLuzzoIcon.png"));
            card.LogoText = membershipCardQRName;

            // Add the customer account number.
            WalletItemCustomProperty prop = new WalletItemCustomProperty("HOLD", "HOLD");
            prop.DetailViewPosition = WalletDetailViewPosition.HeaderField1;
            // We don't want this field entity extracted as it will be interpreted as a phone number.
            card.DisplayProperties["Holder1"] = prop;

            prop = new WalletItemCustomProperty("HOLD", "HOLD");
            prop.DetailViewPosition = WalletDetailViewPosition.HeaderField2;
            // We don't want this field entity extracted as it will be interpreted as a phone number.
            card.DisplayProperties["Holder2"] = prop;

            // Add the customer account number.
            prop = new WalletItemCustomProperty("Caffe Luzzo", "Membership Card");
            prop.DetailViewPosition = WalletDetailViewPosition.PrimaryField1;
            // We don't want this field entity extracted as it will be interpreted as a phone number.
            card.DisplayProperties["Title"] = prop;

            prop = new WalletItemCustomProperty("Website", "http://www.caffelusso.com/#!");
            prop.DetailViewPosition = WalletDetailViewPosition.PrimaryField2;
            card.DisplayProperties["Website"] = prop;

            prop = new WalletItemCustomProperty("Address", "17725 Ne 65th St Ste A150, Redmond, WA 98052 ");
            prop.DetailViewPosition = WalletDetailViewPosition.SecondaryField1;
            card.DisplayProperties["Address"] = prop;

            prop = new WalletItemCustomProperty("Rewards", "99");
            prop.DetailViewPosition = WalletDetailViewPosition.FooterField1;
            prop.SummaryViewPosition = WalletSummaryViewPosition.Field1;
            card.DisplayProperties["Points"] = prop;

            // Add the customer account number.
            prop = new WalletItemCustomProperty("Account Number", "12345678");
            prop.DetailViewPosition = WalletDetailViewPosition.FooterField2;
            // We don't want this field entity extracted as it will be interpreted as a phone number.
            prop.AutoDetectLinks = false;
            card.DisplayProperties["AcctId"] = prop;

            // Encode the user's account number as a Qr Code to be used in the store.
            card.Barcode = new WalletBarcode(WalletBarcodeSymbology.Qr, "12345678");

            // Add a promotional message to the card.
            card.DisplayMessage = "Tap here for your 15% off coupon";
            card.IsDisplayMessageLaunchable = true;
            
            card.Verbs.Add("visit", new WalletVerb("Visit Store"));

            ((Button)sender).IsEnabled = false;
            this.MembershipInfoButtonQR.IsEnabled = true;

            await store.AddAsync(membershipCardQRName, card);
        }
Ejemplo n.º 27
0
        private async void AddGeneralButtonQR_Click(object sender, RoutedEventArgs e)
        {
            WalletItemStore store = await WalletManager.RequestStoreAsync();

            //string itemId = string.IsNullOrEmpty(walletItemName.Text) ? walletItemName.Text : cardName;

            WalletItem card = new WalletItem(WalletItemKind.General, generalItemName);
            // Set colors, to give the card our distinct branding.
            card.BodyColor = Windows.UI.Colors.Brown;
            card.BodyFontColor = Windows.UI.Colors.White;
            card.HeaderColor = Windows.UI.Colors.SaddleBrown;
            card.HeaderFontColor = Windows.UI.Colors.White;


            card.Logo336x336 = await StorageFile.GetFileFromApplicationUriAsync(new Uri("ms-appx:///Assets/icons/stellarMedium.png"));
            card.Logo159x159 = await StorageFile.GetFileFromApplicationUriAsync(new Uri("ms-appx:///Assets/icons/stellarSmall.png"));
            card.Logo99x99 = await StorageFile.GetFileFromApplicationUriAsync(new Uri("ms-appx:///Assets/icons/stellarIcon.png"));

            card.LogoImage = await StorageFile.GetFileFromApplicationUriAsync(new Uri("ms-appx:///Assets/icons/stellarIcon.png"));
            card.LogoText = generalItemName;

            // Add the customer account number.
            WalletItemCustomProperty prop = new WalletItemCustomProperty("Litecoin", "Litecoin");
            prop.DetailViewPosition = WalletDetailViewPosition.HeaderField1;
            // We don't want this field entity extracted as it will be interpreted as a phone number.
            card.DisplayProperties["Title"] = prop;

            prop = new WalletItemCustomProperty("HOLD", "HOLD");
            prop.DetailViewPosition = WalletDetailViewPosition.HeaderField2;
            // We don't want this field entity extracted as it will be interpreted as a phone number.
            card.DisplayProperties["Holder2"] = prop;

            // Add the customer account number.
            prop = new WalletItemCustomProperty("HOLD", "Hold");
            prop.DetailViewPosition = WalletDetailViewPosition.PrimaryField1;
            // We don't want this field entity extracted as it will be interpreted as a phone number.
            card.DisplayProperties["Hold"] = prop;

            prop = new WalletItemCustomProperty("Website", "https://www.msn.com/");
            prop.DetailViewPosition = WalletDetailViewPosition.PrimaryField2;
            card.DisplayProperties["Website"] = prop;



            prop = new WalletItemCustomProperty("Balance", "0");
            prop.DetailViewPosition = WalletDetailViewPosition.FooterField1;
            prop.SummaryViewPosition = WalletSummaryViewPosition.Field1;
            card.DisplayProperties["Points"] = prop;

            // Add the customer account number.
            prop = new WalletItemCustomProperty("Account Number", "12345678");
            prop.DetailViewPosition = WalletDetailViewPosition.FooterField2;
            // We don't want this field entity extracted as it will be interpreted as a phone number.
            prop.AutoDetectLinks = false;
            card.DisplayProperties["AcctId"] = prop;

            // Encode the user's account number as a Qr Code to be used in the store.
            //card.Barcode = new WalletBarcode(WalletBarcodeSymbology.Qr, "12345678");

            // Add a promotional message to the card.
            card.DisplayMessage = "MSN!";
            card.IsDisplayMessageLaunchable = true;

            ((Button)sender).IsEnabled = false;
            this.GeneralInfoButtonQR.IsEnabled = true;

            await store.AddAsync(generalItemName, card);
        }
Ejemplo n.º 28
0
 public void AddItem(WalletItem item)
 {
     _connection.Insert(item);
 }
Ejemplo n.º 29
0
        pkPassConversionResult parsePkpassType(IReadOnlyList<Windows.Storage.StorageFile> files)
        {
            try
            {
                WalletItem item = null;
                CurrentInfo = "Opening pass.json...";
                JObject o = getJsonData(files.Where(x => x.Name == "pass.json").First());
                //Determine the type of the card and return it.
                if (o["boardingPass"] != null)
                {
                    pkPassType = "boardingPass";
                    item = new WalletItem(WalletItemKind.BoardingPass, o["description"].Value<string>());
                }
                else if (o["coupon"] != null)
                {
                    pkPassType = "coupon";
                    item = new WalletItem(WalletItemKind.Deal, o["description"].Value<string>());
                }
                else if (o["eventTicket"] != null)
                {
                    pkPassType = "eventTicket";
                    item = new WalletItem(WalletItemKind.Ticket, o["description"].Value<string>());
                }
                else if (o["storeCard"] != null)
                {
                    pkPassType = "storeCard";
                    item = new WalletItem(WalletItemKind.MembershipCard, o["description"].Value<string>());
                }
                else if (o["generic"] != null)
                {
                    pkPassType = "generic";
                    item = new WalletItem(WalletItemKind.General, o["description"].Value<string>());
                }
                else throw new Exception();

                //Get images
                CurrentInfo = "Fetching images...";
                item.Logo99x99 = item.Logo159x159 = item.Logo336x336 = getImageFromName("icon.png", contents);
                item.HeaderBackgroundImage = getImageFromName("logo.png", contents);
                item.BodyBackgroundImage = getImageFromName("background.png", contents);

                CurrentInfo = "Fetching colors...";
                item.BodyColor = HelperMethods.getColorFromRGBString(o["backgroundColor"].Value<string>());
                item.BodyFontColor = HelperMethods.getColorFromRGBString(o["foregroundColor"].Value<string>());
                item.HeaderColor = item.BodyColor;
                item.HeaderFontColor = HelperMethods.getColorFromRGBString(o["labelColor"].Value<string>());

                int i = 0;
                if (o[pkPassType]["primaryFields"] != null)
                {
                    foreach (JObject jo in o[pkPassType]["primaryFields"])
                    {
                        WalletItemCustomProperty prop = new WalletItemCustomProperty(jo["label"].Value<string>(), jo["value"].Value<string>());
                        if (i == 0) prop.DetailViewPosition = WalletDetailViewPosition.PrimaryField1;
                        else if (i == 1) prop.DetailViewPosition = WalletDetailViewPosition.PrimaryField2;
                        else throw new InvalidDataException();
                        item.DisplayProperties[jo["key"].Value<string>()] = prop;
                        i++;
                    }
                }

                //Secondary fields
                i = 0;
                if (o[pkPassType]["secondaryFields"] != null)
                {
                    foreach (JObject jo in o[pkPassType]["secondaryFields"])
                    {
                        WalletItemCustomProperty prop = new WalletItemCustomProperty(jo["label"].Value<string>(), jo["value"].Value<string>());
                        if (i == 0) prop.DetailViewPosition = WalletDetailViewPosition.SecondaryField1;
                        else if (i == 1) prop.DetailViewPosition = WalletDetailViewPosition.SecondaryField2;
                        else if (i == 2) prop.DetailViewPosition = WalletDetailViewPosition.SecondaryField3;
                        else if (i == 3) prop.DetailViewPosition = WalletDetailViewPosition.SecondaryField4;
                        else if (i == 4) prop.DetailViewPosition = WalletDetailViewPosition.SecondaryField5;
                        else throw new InvalidDataException();
                        item.DisplayProperties[jo["key"].Value<string>()] = prop;
                        i++;
                    }
                }

                //Auxiliary fields
                i = 0;
                if (o[pkPassType]["auxiliaryFields"] != null)
                {
                    foreach (JObject jo in o[pkPassType]["auxiliaryFields"])
                    {
                        WalletItemCustomProperty prop = new WalletItemCustomProperty(jo["label"].Value<string>(), jo["value"].Value<string>());
                        if (i == 0) prop.DetailViewPosition = WalletDetailViewPosition.FooterField1;
                        else if (i == 1) prop.DetailViewPosition = WalletDetailViewPosition.FooterField2;
                        else if (i == 2) prop.DetailViewPosition = WalletDetailViewPosition.FooterField3;
                        else if (i == 3) prop.DetailViewPosition = WalletDetailViewPosition.FooterField4;
                        else throw new InvalidDataException();
                        item.DisplayProperties[jo["key"].Value<string>()] = prop;
                        i++;
                    }
                }

                //Header fields
                i = 0;
                if (o[pkPassType]["headerFields"] != null)
                {
                    foreach (JObject jo in o[pkPassType]["headerFields"])
                    {
                        WalletItemCustomProperty prop = new WalletItemCustomProperty(jo["label"].Value<string>(), jo["value"].Value<string>());
                        if (i == 0) prop.DetailViewPosition = WalletDetailViewPosition.HeaderField1;
                        else if (i == 1) prop.DetailViewPosition = WalletDetailViewPosition.HeaderField2;
                        else throw new InvalidDataException();
                        item.DisplayProperties[jo["key"].Value<string>()] = prop;
                        i++;
                    }
                }

                //Header fields
                if (o[pkPassType]["backFields"] != null)
                {
                    foreach (JObject jo in o[pkPassType]["backFields"])
                    {
                        WalletItemCustomProperty prop = new WalletItemCustomProperty(jo["label"].Value<string>(), jo["value"].Value<string>());
                        prop.SummaryViewPosition = WalletSummaryViewPosition.Hidden;
                        item.DisplayProperties[jo["key"].Value<string>()] = prop;
                    }
                }

                if (o["barcode"] != null)
                {
                    WalletBarcodeSymbology sym = new WalletBarcodeSymbology();
                    switch (o["barcode"]["format"].Value<string>())
                    {
                        case "PKBarcodeFormatQR": sym = WalletBarcodeSymbology.Qr; break;
                        case "PKBarcodeFormatPDF417": sym = WalletBarcodeSymbology.Pdf417; break;
                        case "PKBarcodeFormatAztec": sym = WalletBarcodeSymbology.Aztec; break;
                        default: throw new InvalidDataException();
                    }
                    item.Barcode = new WalletBarcode(sym, o["barcode"]["message"].Value<string>());
                }

                if (o["locations"] != null)
                {
                    i = 0;
                    foreach (JObject jo in o["locations"])
                    {
                        WalletRelevantLocation location = new WalletRelevantLocation();
                        if (jo["relevantText"] != null)
                        {
                            location.DisplayMessage = jo["relevantText"].Value<string>();
                        }
                        var position = new Windows.Devices.Geolocation.BasicGeoposition();
                        position.Latitude = jo["latitude"].Value<double>();
                        position.Longitude = jo["longitude"].Value<double>();
                        try
                        {
                            position.Altitude = jo["altitude"].Value<double>();
                        }
                        catch (Exception)
                        {
                            System.Diagnostics.Debug.WriteLine("An altitude does not exist for location " + location.DisplayMessage);
                        }
                        location.Position = position;
                        //Check one doesn't already exist.
                        if (item.RelevantLocations.Where(x => x.Key == i.ToString()).Count() > 0)
                            i++;
                        else
                            item.RelevantLocations.Add(i.ToString(), location);
                        i++;
                    }
                }

                if (o["relevantDate"] != null)
                {
                    item.RelevantDate = DateTime.Parse(o["relevantDate"].Value<string>());
                }

                if (o["expirationDate"] != null)
                {
                    item.ExpirationDate = DateTime.Parse(o["expirationDate"].Value<string>());
                }

                string cardId = o["serialNumber"].Value<string>();

                pkPassConversionResult result = new pkPassConversionResult();
                result.item = item; result.cardId = cardId;
                return result;
            }
            catch (Exception ex)
            {
                CurrentInfo = "Exception: " + ex.Message;
                return null;
            }
        }
Ejemplo n.º 30
0
 public void EditItem(WalletItem item)
 {
     _connection.Update(item);
 }
Ejemplo n.º 31
0
 public void DeleteItem(WalletItem item)
 {
     _connection.Delete(item);
 }
Ejemplo n.º 32
0
 public Task CreateAsync(WalletItem wallet)
 {
     return(_wallets.InsertOneAsync(wallet));
 }
Ejemplo n.º 33
0
        /// <summary>
        /// Get information about all wallets in your account.
        /// </summary>
        /// <param name="user_id"></param>
        /// <param name="args">Add additional attributes for each exchange</param>
        /// <returns></returns>
        public override async Task <Wallets> FetchWallets(string user_id, Dictionary <string, object> args = null)
        {
            var _result = new Wallets();

            privateClient.ExchangeInfo.ApiCallWait(TradeType.Private);
            {
                var _params = new Dictionary <string, object>();
                {
                    _params.Add("userId", user_id);
                    _params.Add("page", 1);
                    _params.Add("perPage", 50);

                    privateClient.MergeParamsAndArgs(_params, args);
                }

                var _json_value = await privateClient.CallApiGet1Async("/wallets", _params);

#if DEBUG
                _result.rawJson = _json_value.Content;
#endif
                var _json_result = privateClient.GetResponseMessage(_json_value.Response);
                if (_json_result.success == true)
                {
                    var _json_data = privateClient.DeserializeObject <List <TWalletItem> >(_json_value.Content);
                    {
                        foreach (var _w in _json_data)
                        {
                            foreach (var _balance in _w.balances)
                            {
                                var _market = publicApi.publicClient.ExchangeInfo.Markets.GetMarketByQuoteId(_balance.currency);
                                if (_market != null)
                                {
                                    _balance.currency = _market.quoteName;
                                }

                                _balance.used = _balance.total - _balance.free;

                                var _wallet = new WalletItem
                                {
                                    userId = _w.userId,

                                    walletId   = _w.walletId,
                                    walletName = _w.walletName,

                                    timestamp = _w.timestamp,
                                    fee       = _w.fee,

                                    balance = _balance
                                };

                                _result.result.Add(_wallet);
                            }
                        }
                    }
                }

                _result.SetResult(_json_result);
            }

            return(_result);
        }
Ejemplo n.º 34
0
        private async Task SaveItemToWallet(WalletItem item,string cardId)
        {
            WalletItemStore wallet = await WalletManager.RequestStoreAsync();
            txtInfo.Text = "Saving to wallet...";
            if (await wallet.GetWalletItemAsync(cardId) != null)
            {
                MessageDialog msgbox = new MessageDialog("Would you like to overwrite this item?", "An item with the same ID exists!");
                UICommand uiYes = new UICommand("Yes");
                UICommand uiNo = new UICommand("No");
                msgbox.Commands.Add(uiYes);
                msgbox.Commands.Add(uiNo);
                msgbox.DefaultCommandIndex = 0;
                msgbox.CancelCommandIndex = 1;
                if (await msgbox.ShowAsync() == uiYes)
                {
                    try
                    {
                        await wallet.DeleteAsync(cardId);
                        await wallet.AddAsync(cardId, item);
                        txtInfo.Text = "Saved! Press the button below to return to the home screen.";
                        await wallet.ShowAsync(cardId);
                    }
                    catch (Exception)
                    {
                        txtInfo.Text = "There was a problem saving the card to the wallet.";
                    }
                }
                else
                {
                    txtInfo.Text = "You cancelled the creation.";
                }

            }
            else
            {
                await wallet.AddAsync(cardId, item);
                txtInfo.Text = "Saved! Press the button below to return to the home screen.";
                await wallet.ShowAsync(cardId);
            }
        }