示例#1
0
        private async Task RemoveTableAsync <T>(int count) where T : class, ITable, new()
        {
            try
            {
                var list = await DataBaseConnection.Table <T>().Where(p => p.IsEnabled).Take(count).ToListAsync();

                foreach (var table in list)
                {
                    table.IsEnabled = false;
                    var taskTable = table as TaskTable;
                    if (taskTable != null)
                    {
                        taskTable.Position = 0;
                    }
                }
                await DataBaseConnection.UpdateAllAsync(list);
                await RefreshTableAsync <T>();
            }
            catch (Exception exception)
            {
                GaService.TrackAppException(this.Class, "RemoveBonusAsync", exception, false);
            }
        }
示例#2
0
        private async Task CorrectingPurchaseAsync(int currentPurchase, int realPurchase, Func <int, Task> addFunc, Func <int, Task> removeFunc)
        {
            try
            {
                if (currentPurchase == realPurchase)
                {
                    return;
                }
                var difference = Math.Abs(currentPurchase - realPurchase);

                if (currentPurchase > realPurchase)
                {
                    await removeFunc(difference);
                }
                else if (currentPurchase < realPurchase)
                {
                    await addFunc(difference);
                }
            }
            catch (Exception exception)
            {
                GaService.TrackAppException(this.Class, "CorrectingPurchaseAsync", exception, false);
            }
        }
示例#3
0
        //Refresh and check if
        public async Task CheckAndRefreshPurshases(IList <ErshPurchase> ershPurchases, bool isConnected)
        {
            try
            {
                _taskPurchases  = ershPurchases.Where(purchase => purchase.ProductType == StringConst.Task).ToList();
                _bonusPurchases = ershPurchases.Where(purchase => purchase.ProductType == StringConst.Bonus).ToList();
                if (!isConnected)
                {
                    return;
                }

                var currentPurchaseTaskCount = Tasks.Count - IntConst.DefaultTaskCount;
                var purchaseTaskCount        = GetPurchaseCount(_taskPurchases, IntConst.AllTaskCount, IntConst.DefaultTaskCount);
                await CorrectingPurchaseAsync(currentPurchaseTaskCount, purchaseTaskCount, AddProductAsync <TaskTable>, RemoveTableAsync <TaskTable>);

                var currentPurchaseBonusCount = Bonuses.Count - IntConst.DefaultBonusCount;
                var purchaseBonusCount        = GetPurchaseCount(_bonusPurchases, IntConst.AllBonusCount, IntConst.DefaultBonusCount);
                await CorrectingPurchaseAsync(currentPurchaseBonusCount, purchaseBonusCount, AddProductAsync <BonusTable>, RemoveTableAsync <BonusTable>);
            }
            catch (Exception exception)
            {
                GaService.TrackAppException(this.Class, "CheckAndRefreshPurshases", exception, false);
            }
        }
示例#4
0
        private IEnumerable <T> GetTable <T>() where T : ITable, new()
        {
            try
            {
                switch (new T().TableName)
                {
                case StringConst.BonusTable:
                    return((IEnumerable <T>)GetTable(Parser.ParseBonus, i => i < IntConst.DefaultBonusCount, _context.Assets.Open("Bonus.csv")));

                case StringConst.TaskTable:
                    return((IEnumerable <T>)GetTable(Parser.ParseTask, i => i < IntConst.DefaultTaskCount, _context.Assets.Open("Task.csv")));

                case StringConst.CategoryTable:
                    return((IEnumerable <T>)GetTable(Parser.ParseCategory, i => true, _context.Assets.Open("Category.csv")));

                default: throw new NotImplementedException();
                }
            }
            catch (Exception exception)
            {
                GaService.TrackAppException(this.Class, string.Format("GetTable<{0}>", new T().TableName), exception, false);
                throw;
            }
        }
 private static void ConnectionOnOnInAppBillingError(InAppBillingErrorType error, string message)
 {
     GaService.TrackAppException("Extensions", "ConnectionOnOnInAppBillingError", error.ToString(), message, false);
 }
 private static void HandlerOnInAppBillingProcesingError(string message)
 {
     GaService.TrackAppException("Extensions", "HandlerOnInAppBillingProcesingError", string.Empty, message, false);
 }
 private static void HandlerOnOnInvalidOwnedItemsBundleReturned(Bundle ownedItems)
 {
     GaService.TrackAppException("Extensions", "HandlerOnOnInvalidOwnedItemsBundleReturned", string.Empty, "Get owned items in bundle", false);
 }