Exemple #1
0
        static async Task AddSubscriptionAsync(string transactionId, DateTime transactionDate, PatronSubscriptionPrice p)
        {
            var sub = new PatronSubscription();

            sub.TransactionId = transactionId;
            sub.PurchaseDate  = transactionDate;
            sub.ProductId     = p.Id;
            sub.NumMonths     = p.NumMonths;

            var db = CKContainer.DefaultContainer.PrivateCloudDatabase;
            await db.SaveRecordAsync(sub.Record);

            var v = visibleForm;

            if (v != null)
            {
                NSTimer.CreateScheduledTimer(1.0, nst => {
                    v.BeginInvokeOnMainThread(async() => {
                        for (var i = 0; i < 3; i++)
                        {
                            try {
                                await v.RefreshPatronDataAsync();
                            } catch (Exception ex) {
                                Log.Error(ex);
                            }
                            try {
                                await DocumentAppDelegate.Shared.CurrentDocumentListController.LoadDocs();
                            } catch (Exception ex) {
                                Log.Error(ex);
                            }
                            await Task.Delay(TimeSpan.FromSeconds(2.0));
                        }
                    });
                });
            }
        }
Exemple #2
0
		static async Task AddSubscriptionAsync (string transactionId, DateTime transactionDate, PatronSubscriptionPrice p)
		{
			var sub = new PatronSubscription ();
			sub.TransactionId = transactionId;
			sub.PurchaseDate = transactionDate;
			sub.ProductId = p.Id;
			sub.NumMonths = p.NumMonths;

			var db = CKContainer.DefaultContainer.PrivateCloudDatabase;
			await db.SaveRecordAsync (sub.Record);

			var v = visibleForm;
			if (v != null) {
				NSTimer.CreateScheduledTimer (1.0, nst => {
					v.BeginInvokeOnMainThread (async () => {
						for (var i = 0; i < 3; i++) {
							try {
								await v.RefreshPatronDataAsync ();
							} catch (Exception ex) {
								Log.Error (ex);
							}
							try {
								await DocumentAppDelegate.Shared.CurrentDocumentListController.LoadDocs ();
							} catch (Exception ex) {
								Log.Error (ex);
							}
							await Task.Delay (TimeSpan.FromSeconds (2.0));
						}
					});
				});
			}
		}