예제 #1
0
 public static void TryAddMemberAndCredit(Member user, Money servicePrice, AdvertType adType = AdvertType.Null)
 {
     if (AppSettings.TitanModules.HasModule(33) || AppSettings.TitanModules.HasModule(39))
     {
         MatrixBase matrix = MatrixFactory.GetMatrix();
         if (matrix != null)
         {
             matrix.TryAddMember(user, adType);
             matrix.Credit(user, servicePrice);
         }
     }
 }
예제 #2
0
        //public Matrix<double> GetMatrixData(int n, string Letter)
        //{
        //    var matrix = Matrix<double>.Build.Dense(n, n);
        //    string input = Letter;// @"C:\Users\PC\source\repos\Lab2_TRSPO_Paralel\Lab2_TRSPO_Paralel\bin\Debug\netcoreapp3.1\matrixA.txt";
        //    //StreamReader reader = new StreamReader(input);
        //    using (var reader = new StreamReader(input))
        //    {
        //        for (var i = 0; i < n; i++)
        //        {
        //            for (var j = 0; j < n; j++)
        //            {
        //                string line;
        //                //if ((line = reader.ReadAsync()) != null)
        //                //{
        //                    matrix[i, j] = reader.Read();
        //                    Console.WriteLine($"index {i}{j}, Line: {matrix[i, j]}");
        //                    //matrix[i, j] = Convert.ToDouble(line);
        //                //}
        //            }
        //            reader.ReadLine();
        //        }
        //    }
        //    using (TextWriter tw = new StreamWriter("matrixARew.txt"))
        //    {
        //        for (int i = 0; i < n; i++)
        //        {
        //            for (int j = 0; j < n; j++)
        //            {
        //                tw.Write(matrix[i, j]);
        //            }
        //            tw.WriteLine();
        //        }
        //    }
        //    return matrix;
        //}
        //public Vector<double> GetVectorData(int n, string Letter)
        //{
        //    var vector = Vector<double>.Build.Dense(n);
        //    string input = Letter;// @"C:\Users\PC\source\repos\Lab2_TRSPO_Paralel\Lab2_TRSPO_Paralel\bin\Debug\netcoreapp3.1\matrixA.txt";
        //    //StreamReader reader = new StreamReader(input);
        //    using (var reader = new StreamReader(input))
        //    {
        //        for (var i = 0; i < n; i++)
        //        {
        //            string line;
        //            if ((line = reader.ReadLine()) != null)
        //            {
        //                Console.WriteLine($"Loop index {i + n * i}, Line: {line}");
        //                vector[i] = Convert.ToDouble(line);
        //            }
        //        }
        //    }
        //    return vector;
        //}

        public ObjectObgortka GetMatrixData(int n, MatrixEnum Letter)
        {
            MatrixFactory matrixFactory = new MatrixFactory();

            ObjectObgortka obgortka = new ObjectObgortka();

            Console.WriteLine(n);
            obgortka.Matrix = matrixFactory.GetMatrix(Letter, n);
            //obgortka.Matrix = null;
            Console.WriteLine("obgortka");
            Console.WriteLine(obgortka.Matrix);
            return(obgortka);
        }
예제 #3
0
    protected void Page_Load(object sender, EventArgs e)
    {
        AccessManager.RedirectIfDisabled(AppSettings.TitanFeatures.ReferralMatrixEnabled);
        AccessManager.RedirectIfDisabled(AppSettings.Matrix.Type == MatrixType.Referral);

        MatrixBase matrix = MatrixFactory.GetMatrix();

        ShowPoints    = matrix != null ? matrix.Crediter is BinaryReferralMatrixCrediter : false;
        PointsOnEdges = !TitanFeatures.IsTrafficThunder;

        if (!Page.IsPostBack)
        {
            InitializeData();
        }

        //Listening for AJAX request "Assign the member"
        ListenForAJAX();
    }
예제 #4
0
    public static void Register(string InUsername, string InEmail, int InPIN, DateTime InBirthYear, string InPassword, string InReferer, Gender InGender, Panel CustomFields,
                                string FirstName, string SecondName, string Address, string City, string StateProvince, string ZipCode, bool isEarner, bool isAdvertiser, bool isPublisher, string FacebookId = null,
                                bool skipRedirection = false)
    {
        AppSettings.Email.Reload();

        bool IsFromFacebookOAuth = FacebookId != null ? true : false;

        // 0. Logged-in check
        if (Member.IsLogged)
        {
            throw new MsgException(U5009.LOGOUTTOREGISTER);
        }

        // 1. Validate if Username is not taken
        if (Member.Exists(InUsername))
        {
            throw new MsgException(L1.ER_INVALIDUSERNAME3);
        }

        // Or forbidden
        if (!SecurityManager.IsOkWithRules(SecurityRuleType.Username, InUsername) || InUsername.Contains("refback"))
        {
            throw new MsgException(L1.UNAMEFORBID);
        }

        // 2. Validate if Email is not taken
        if (Member.ExistsWithEmail(InEmail))
        {
            throw new MsgException(L1.ER_DUPLICATEEMAIL);
        }

        string             currentip = IP.Current;
        CountryInformation CIService = new CountryInformation(currentip);

        // 0. Validate if Country/IP is not forbidden
        if (!SecurityManager.IsOkWithRules(SecurityRuleType.IP, currentip))
        {
            throw new MsgException(L1.IPFORBID);
        }

        if (!SecurityManager.IsOkWithRules(SecurityRuleType.Country, CIService.CountryName))
        {
            throw new MsgException(L1.COUNTRYFORBID);
        }

        // Validate if IP is not a proxy
        if (AppSettings.Proxy.IPPolicy == IPVerificationPolicy.EveryRegistration && ProxyManager.IsProxy(currentip))
        {
            throw new MsgException(L1.IPAPROXY);
        }

        if (AppSettings.Site.AllowOnlyOneRegisteredIP)
        {
            int membersRegisteredWithThisIP = (int)TableHelper.SelectScalar(
                String.Format("SELECT COUNT(*) FROM Users WHERE RegisteredWithIP = '{0}'", currentip));

            if (membersRegisteredWithThisIP > 0)
            {
                throw new MsgException(U5005.IPALREADYREGISTERED);
            }
        }

        AppSettings.DemoCheck();

        //Validate if country is OK
        FeatureManager Manager = null;

        if (IsFromFacebookOAuth)
        {
            Manager = new FeatureManager(GeolocatedFeatureType.FacebookRegistration);
        }
        else
        {
            Manager = new FeatureManager(GeolocatedFeatureType.Registration);
        }

        if (!Manager.IsAllowed)
        {
            throw new MsgException(U4000.SORRYCOUNTRY);
        }

        // All data is OK. Now lets register
        Member NewMember = new Member();

        NewMember.Name            = InUsername;
        NewMember.Email           = InEmail;
        NewMember.PIN             = InPIN;
        NewMember.BirthYear       = InBirthYear;
        NewMember.PrimaryPassword = MemberAuthenticationService.ComputeHash(InPassword);
        NewMember.FacebookOAuthId = FacebookId;

        //Detailed info?
        if (AppSettings.Authentication.DetailedRegisterFields)
        {
            NewMember.FirstName     = FirstName;
            NewMember.SecondName    = SecondName;
            NewMember.Address       = Address;
            NewMember.City          = City;
            NewMember.StateProvince = StateProvince;
            NewMember.ZipCode       = ZipCode;
            NewMember.Gender        = InGender;
        }

        //Custom fields?
        RegistrationFieldCreator.Save(NewMember, CustomFields);

        NewMember.CameFromUrl                     = (HttpContext.Current.Session == null || HttpContext.Current.Session["ReferralFrom"] == null) ? "Unknown" : HttpContext.Current.Session["ReferralFrom"].ToString().Replace("www.", "");
        NewMember.Country                         = CIService.CountryName;
        NewMember.CountryCode                     = CIService.CountryCode;
        NewMember.MessageSystemTurnedOn           = true;
        NewMember.RevenueShareAdsWatchedYesterday = 1000; //No yesterday, that is why we assume that he watched all
        NewMember.PointsBalance                   = 0;

        //Slot Machine Modlue
        if (AppSettings.TitanFeatures.SlotMachineEnabled)
        {
            try
            {
                NewMember.PointsBalance = (int)HttpContext.Current.Session["anonymousSlotMachinePoints"];
            }
            catch (Exception slotError)
            {
                NewMember.SlotMachineChances = 1;
                ErrorLogger.Log(slotError);
            }
        }

        //Account type
        NewMember.IsEarner     = isEarner;
        NewMember.IsAdvertiser = isAdvertiser;
        NewMember.IsPublisher  = isPublisher;

        // Check if instant register or requires activation

        if (AppSettings.Authentication.IsInstantlyActivated || AppSettings.IsDemo || IsFromFacebookOAuth)
        {
            //Adding referer and points bonus
            NewMember.TryAddReferer(InReferer);

            //Add history entry
            History.AddRegistration(NewMember.Name);

            //Representatives policy
            TrySetRepresentativeAsReferer(NewMember, CIService);

            if (AppSettings.Proxy.SMSType == ProxySMSType.EveryRegistration)
            {
                NewMember.Register(MemberStatus.AwaitingSMSPIN);
            }
            else
            {
                if (NewMember.HasReferer)
                {
                    var list = new List <RestrictionKind>(new RestrictionKind[] { RestrictionKind.DirectReferralsCount });
                    LeadershipSystem.CheckSystem(list, new Member(NewMember.ReferrerId));
                }
                NewMember.Register(MemberStatus.Active);
            }

            //Registration Bonus
            TryApplyRegistrationBonus(Manager, NewMember);

            //Matrix
            MatrixBase matrix = MatrixFactory.GetMatrix();
            if (matrix != null)
            {
                matrix.TryAddMember(NewMember);
            }

            if (!skipRedirection)
            {
                HttpContext.Current.Response.Redirect("~/status.aspx?type=registerok&id=register1");
            }
        }
        else
        {
            try
            {
                Mailer.SendActivationLink(InUsername, InEmail);

                //Representatives policy
                TrySetRepresentativeAsReferer(NewMember, CIService);

                //Adding referer and points bonus
                NewMember.TryAddReferer(InReferer);

                NewMember.Register(MemberStatus.Inactive);

                //Add history entry
                History.AddRegistration(NewMember.Name);

                //Registration Bonus
                TryApplyRegistrationBonus(Manager, NewMember);

                //Matrix
                MatrixBase matrix = MatrixFactory.GetMatrix();
                if (matrix != null)
                {
                    matrix.TryAddMember(NewMember);
                }
            }
            catch (Exception ex)
            {
                ErrorLogger.Log(ex);
                throw new MsgException("The system was unable to send the activation e-mail. Contact the administrator.");
            }

            if (!skipRedirection)
            {
                HttpContext.Current.Response.Redirect("~/status.aspx?type=registerok&id=register2");
            }
        }
    }
예제 #5
0
    public static void ProceedDailyTasks()
    {
        log = new StringBuilder();

        var Entry = new CronEntry();

        Entry.Date = DateTime.Now;

        try
        {
            Log("Starting CRON procedure");

            //Make sure it runs only once
            if (CanRun())
            {
                AppSettings.IsOffline        = true;
                AppSettings.Misc.LastCRONRun = DateTime.Now;
                AppSettings.Misc.Save();
                stime = DateTime.Now;

                AntiCheatSystem.CRON();
                Log("OK [1] AntiCheatSystem. Elapsed time: " + GetTimeString(stime));

                RentReferralsSystem.CRON();
                Log("OK [2] RentedReferralsSystem. Elapsed time: " + GetTimeString(stime));

                StatisticsManager.CRON();
                Log("OK [3a] StatisticsManager. Elapsed time: " + GetTimeString(stime));

                //MUST BE RUN BEFORE MEMBERMANAGER.CRON() !!!
                CustomFeaturesManager.CRON();
                Log("OK [3b] CustomFeaturesManager. Elapsed time: " + GetTimeString(stime));

                MemberManager.CRON();
                Log("OK [4] Member. Elapsed time: " + GetTimeString(stime));

                SyncedNetworkFactory.SynchronizeAll();
                Log("OK [5] CPA Offers. Elapsed time: " + GetTimeString(stime));

                AppSettings.Payments.CRON();
                Log("OK [6] Payments. Elapsed time: " + GetTimeString(stime));

                ShoutboxManager.CRON();
                Log("OK [7] Shoutbox. Elapsed time: " + GetTimeString(stime));

                CLPManager.CRON();
                Log("OK [8] CLPManager. Elapsed time: " + GetTimeString(stime));

                BannerAuctionManager.CRON();
                Log("OK [10] BannerAuctionManager. Elapsed time: " + GetTimeString(stime));

                PointsLockingManager.CRON();
                Log("OK [11] PointsLockingManager. Elapsed time: " + GetTimeString(stime));

                DBArchiver.CRON();
                Log("OK [12] DBArchiver. Elapsed time: " + GetTimeString(stime));

                RevenueSharesDistributionManager.CRON();
                Log("OK [13] RevenueSharesDistributionManager. Elapsed time: " + GetTimeString(stime));

                CreditLineManager.CRON();
                Log("OK [14] CreditLineManager. Elapsed time: " + GetTimeString(stime));

                PoolRotatorManager.CRON();
                Log("OK [15] PoolRotatorManager. Elapsed time: " + GetTimeString(stime));

                JackpotManager.CRON();
                Log("OK [16] JackpotManager. Elapsed time: " + GetTimeString(stime));

                TrafficExchangeManager.CRON();
                Log("OK [17] TrafficExchangeManager. Elapsed time: " + GetTimeString(stime));

                DailyPoolManager.CRON();
                Log("OK [18] DailyPoolManager. Elapsed time: " + GetTimeString(stime));

                //Matrix
                MatrixBase matrix = MatrixFactory.GetMatrix();
                if (matrix != null)
                {
                    matrix.CRON();
                }
                Log("OK [19] MatrixBase. Elapsed time: " + GetTimeString(stime));

                ApiAccessToken.CRON();
                Log("OK [20] ApiAccessToken. Elapsed time: " + GetTimeString(stime));

                InvestmentPlatformManager.CRON();
                Log("OK [21] InvestmentPlatformManager. Elapsed time: " + GetTimeString(stime));

                MarketplaceBalanceLogManager.CRON();
                Log("OK [22] MarketplaceBalanceLogManager. Elapsed time: " + GetTimeString(stime));

                MiniVideoManager.CRON();
                Log("OK [23] MiniVideoManager. Elapsed time: " + GetTimeString(stime));

                PaidToPromoteManager.CRON();
                Log("OK [24] PaidToPromoteManager. Elapsed time: " + GetTimeString(stime));

                RollDiceLotteryManager.CRON();
                Log("OK [25] RollDiceLotteryManager. Elapsed time: " + GetTimeString(stime));

                WalletManager.CRON();
                Log("OK [26] WalletManager. Elapsed time: " + GetTimeString(stime));

                NewsManager.CRON();
                Log("OK [27] NewsManager. Elapsed time: " + GetTimeString(stime));


                Entry.Type = 1;
                Entry.Text = "Procedure completed successfully (27/27 100%) after " + GetTimeString(stime);
            }
            else
            {
                Entry.Type = 2;
                Entry.Text = "Procedure prevented from multiple run";
            }
        }
        catch (Exception ex)
        {
            ErrorLogger.Log(ex);
            Log("Fatal error (exception thrown)..");
            Entry.Type = 3;
            Entry.Text = "Fatal error during procedure execution. Check logs for more information";
            Mailer.SendCRONFailureMessage();
        }
        finally
        {
            ErrorLogger.Log(log.ToString(), LogType.CRON);
            AppSettings.IsOffline = false;
            Entry.Save();
            HttpContext.Current.Response.Write(Entry.Text);
        }
    }