Beispiel #1
0
        public static void AddPaymentAccount(PaymentAccountDetails account)
        {
            Statistics stat = new Statistics();

            stat.Data1        = StatisticsManager.GetPaymentAccountName(account);
            stat.data2        = "0.000#0.000#0.000#0.000#0.000#0.000#0.000#0.000#0.000#0.000#0.000#0.000#0.000#0.000";
            stat.Type         = StatisticsType.AvailableFunds;
            stat.NumberOfDays = 14;
            stat.Save();
        }
Beispiel #2
0
        public static void UpdatePaymentAccount(string oldUserName, PaymentAccountDetails account)
        {
            if (oldUserName == account.Username)
            {
                return;
            }

            var        id   = TableHelper.SelectScalar(string.Format("SELECT Id FROM [Statistics] WHERE Data1 LIKE '{0}:{1}'", account.AccountType, oldUserName));
            Statistics stat = new Statistics((int)id);

            stat.Data1 = StatisticsManager.GetPaymentAccountName(account);
            stat.Save();
        }
Beispiel #3
0
        public static void CheckAndUpdateStatistics(StatisticsType Type)
        {
            Statistics Stat;

            switch (Type)
            {
            case StatisticsType.TotalMembersCount:
                Stat = new Statistics(Type);
                var where1 = new Dictionary <string, object>();

                where1.Add("AccountStatusInt", (int)MemberStatus.Active);
                int totalmember = TableHelper.CountOf <Member>(where1);

                where1.Add(Member.Columns.MembershipName, Memberships.Membership.Standard.Name);
                int upgradedmember = TableHelper.CountOf <Member>(where1);
                upgradedmember = totalmember - upgradedmember;

                //Now update
                var list1 = TableHelper.GetIntListFromString(Stat.Data1);
                list1[0]   = totalmember;
                Stat.Data1 = TableHelper.GetStringFromIntList(list1);

                var list2 = TableHelper.GetIntListFromString(Stat.Data2);
                list2[0]   = upgradedmember;
                Stat.Data2 = TableHelper.GetStringFromIntList(list2);

                Stat.Save();
                break;

            case StatisticsType.PointsInSystem:
                Stat = new Statistics(Type);

                //Now update
                var list888 = TableHelper.GetIntListFromString(Stat.Data1);
                list888[0] = AppSettings.Points.TotalInSystem;
                Stat.Data1 = TableHelper.GetStringFromIntList(list888);

                Stat.Save();
                break;

            case StatisticsType.PointsGenerated:
                Stat = new Statistics(Type);

                //Now update
                var list999        = TableHelper.GetIntListFromString(Stat.Data1);
                int totalNow       = AppSettings.Points.TotalGenerated;
                int totalYesterday = AppSettings.Points.TotalGeneratedUpToYesterday;
                int totalToday     = totalNow - totalYesterday;

                list999[0] = totalToday;
                Stat.Data1 = TableHelper.GetStringFromIntList(list999);

                Stat.Save();
                break;

            case StatisticsType.AvailableReferrals:
                Stat = new Statistics(Type);
                //Now update
                var list3 = TableHelper.GetIntListFromString(Stat.Data1);
                list3[0]   = RentReferralsSystem.GetAvailableNormalReferralsCount();
                Stat.Data1 = TableHelper.GetStringFromIntList(list3);

                Stat.Save();
                break;

            case StatisticsType.NormalRentedReferrals:
                Stat = new Statistics(Type);
                //Now update
                var list4 = TableHelper.GetIntListFromString(Stat.Data1);
                list4[0]   = RentReferralsSystem.GetRentedNormalReferralsCount();
                Stat.Data1 = TableHelper.GetStringFromIntList(list4);

                Stat.Save();
                break;

            case StatisticsType.BotRentedReferrals:
                Stat = new Statistics(Type);
                //Now update
                var list5 = TableHelper.GetIntListFromString(Stat.Data1);
                list5[0]   = RentReferralsSystem.GetRentedBotReferralsCount();
                Stat.Data1 = TableHelper.GetStringFromIntList(list5);

                Stat.Save();
                break;

            case StatisticsType.MoneyDistributedPerAdPack:
                Stat = new Statistics(Type);
                //Now update
                //TO DO: review
                var        list6 = TableHelper.GetMoneyListFromString(Stat.Data1);
                AdPackType type  = AdPackType.Standard;
                list6[0]   = new Money(type.Price.ToDecimal() * (type.FixedDistributionValuePercent / (Decimal)100));
                Stat.Data1 = TableHelper.GetStringFromMoneyList(list6);

                Stat.Save();
                break;

            case StatisticsType.AvailableFunds:

                //Handle
                var list = PaymentAccountDetails.AllGateways;

                foreach (var account in list)
                {
                    var where = TableHelper.MakeDictionary("Type", (int)StatisticsType.AvailableFunds);
                    where.Add("Data1", StatisticsManager.GetPaymentAccountName(account));

                    var TempStatList = TableHelper.SelectRows <Statistics>(where);
                    if (TempStatList.Count > 0)
                    {
                        Statistics stat = TempStatList[0];
                        if (stat != null)
                        {
                            stat.SetData2(account.Account.Balance);
                            stat.Save();
                        }
                    }
                }

                //var where2 = TableHelper.MakeDictionary("Type", (int)StatisticsType.AvailableFunds);
                //where2.Add("Data1", AppSettings.Cryptocurrencies.APIProvider.ToString());

                //var tempStatList2 = TableHelper.SelectRows<Statistics>(where2);
                //if (tempStatList2.Count > 0)
                //{
                //    var stat = tempStatList2[0];
                //    if (stat != null)
                //    {
                //        stat.SetData2(BitcoinAPIFacotry.Get().GetAccountBalance());
                //        stat.Save();
                //    }
                //}

                break;
            }
        }
Beispiel #4
0
 public static void DeletePaymentAccount(PaymentAccountDetails account)
 {
     TableHelper.DeleteRows <Statistics>(TableHelper.MakeDictionary("Data1", StatisticsManager.GetPaymentAccountName(account)));
 }
Beispiel #5
0
        private static void GetChartProperties(StatisticsType Type, List <int> dataIntList = null, List <Money> dataMoneyList = null)
        {
            var        sb = new StringBuilder();
            Statistics stat;

            switch (Type)
            {
            case StatisticsType.PTCClicks:                          //ADMIN
            case StatisticsType.FacebookClicks:                     //ADMIN
            case StatisticsType.BannerClicks:                       //ADMIN
            case StatisticsType.NewMembers:                         //ADMIN
            case StatisticsType.AvailableReferrals:                 //ADMIN
            case StatisticsType.NormalRentedReferrals:              //ADMIN
            case StatisticsType.BotRentedReferrals:                 //ADMIN
            case StatisticsType.PointsExchanged:                    //ADMIN
            case StatisticsType.PointsGenerated:                    //ADMIN
            case StatisticsType.PointsInSystem:                     //ADMIN
            case StatisticsType.SearchesMade:                       //ADMIN
            case StatisticsType.VideosWatched:                      //ADMIN

                StatisticsManager.CheckAndUpdateStatistics(Type);

                switch (Type)
                {
                case StatisticsType.NewMembers:
                    YName = "New Members";
                    break;

                case StatisticsType.AvailableReferrals:
                    YName = "Available referrals";
                    break;

                case StatisticsType.NormalRentedReferrals:
                    YName = "Normal referrals";
                    break;

                case StatisticsType.BotRentedReferrals:
                    YName = "Bots";
                    break;

                case StatisticsType.PointsExchanged:
                case StatisticsType.PointsInSystem:
                case StatisticsType.PointsGenerated:
                    YName = AppSettings.PointsName;
                    break;

                case StatisticsType.VideosWatched:
                    YName = "Videos";
                    break;

                case StatisticsType.SearchesMade:
                    YName = "Searches";
                    break;
                }

                stat = new Statistics(Type);
                AddValuesToArray(TableHelper.GetIntListFromString(stat.Data1), JsonArray);
                break;

            case StatisticsType.User_AllCreditedMoney:              //USER
            case StatisticsType.Referrals_AllCreditedMoney:         //USER
            case StatisticsType.Referrals_AdPacks:                  //USER
            case StatisticsType.User_CashLinksMoney:                //USER
            case StatisticsType.Referrals_CashLinksMoney:           //USER
            case StatisticsType.User_ArticleSharesMoney:            //USER

                YName = L1.AMOUNT;
                AddValuesToArray(dataMoneyList, JsonArray);

                break;

            //3000
            case StatisticsType.User_AllClicks:
            case StatisticsType.User_Clicks:                        //USER
            case StatisticsType.User_PointsEarned:
            case StatisticsType.User_AllPointsCredited:             //USER
            case StatisticsType.DRClicks:                           //USER
            case StatisticsType.RRClicks:
            case StatisticsType.Referrals_AllCreditedPoints:        //USER
            case StatisticsType.User_ArticleSharesReads:            //USER

                //Check if Points instead of Clicks
                if (Type == StatisticsType.User_AllPointsCredited || Type == StatisticsType.User_PointsEarned)
                {
                    YName = AppSettings.PointsName;
                }

                if (Type == StatisticsType.User_ArticleSharesReads)
                {
                    YName = U6012.READS;
                }

                AddValuesToArray(dataIntList, JsonArray);

                break;

            case StatisticsType.PopularUpgrades:

                XName = "Upgrade packs";
                YName = "Copies bought";

                AddValuesToArray(StatisticsManager.GetPopularUpgradesData(), JsonArray);

                break;

            case StatisticsType.TotalMembersCount:                  //ADMIN

                YName = "Members";

                StatisticsManager.CheckAndUpdateStatistics(Type);
                stat = new Statistics(Type);

                var list1 = TableHelper.GetIntListFromString(stat.Data1);
                var list2 = TableHelper.GetIntListFromString(stat.Data2);

                //Data1
                AddValuesToArray(list1, JsonArray, true);
                Data1Def = "All active members";
                //Data2
                AddValuesToArray(list2, JsonArray2, true);
                Data2Def = "Upgraded members";

                break;

            case StatisticsType.Cashflow:                           //ADMIN

                YName = "Cashflow";

                StatisticsManager.CheckAndUpdateStatistics(Type);
                stat = new Statistics(Type);

                var list3 = TableHelper.GetMoneyListFromString(stat.Data1);
                var list4 = TableHelper.GetMoneyListFromString(stat.Data2);

                //Data1
                AddValuesToArray(list3, JsonArray, true);
                Data1Def = "Income";
                //Data2
                AddValuesToArray(list4, JsonArray2, true);
                Data2Def = "Outcome";

                break;

            case StatisticsType.MembersPerCountry:                  //ADMIN

                AddValuesToArray(StatisticsManager.GetMembersPerCountryData(), JsonArray);
                break;

            case StatisticsType.AvailableFunds:                     //ADMIN

                StatisticsManager.CheckAndUpdateStatistics(Type);
                YName = "Available funds";

                var gatlist = TableHelper.SelectRows <Statistics>(TableHelper.MakeDictionary("Type", (int)Type));

                if (gatlist.Count > 0)
                {
                    //Generate gateways list
                    int    index;
                    string name;

                    foreach (var elem in gatlist)
                    {
                        var thelist = TableHelper.GetMoneyListFromString(elem.Data2);
                        var array   = new JArray();
                        AddValuesToArray(thelist, array, true);
                        var jObject = new JObject();

                        name  = elem.Data1;
                        index = name.IndexOf(":", StringComparison.Ordinal);
                        if (index > 0)
                        {
                            name = name.Substring(0, index);
                        }

                        jObject["key"]    = name;
                        jObject["values"] = array;
                        jContainer.Add(jObject);
                    }
                }
                break;

            case StatisticsType.Null:
                break;

            case StatisticsType.AdPackClicks:
                break;

            case StatisticsType.MoneyDistributedPerAdPack:
                break;
            }
        }