public MaintenanceHelper(int level, Token token, MaintenanceHelper[] helpers, KeyValuePair<FullKey, Branch> kv, int index)
 {
     Level = level;
     Token = token;
     Helpers = helpers;
     Index = index;
     Task = Task.Factory.StartNew(Do, kv, TaskCreationOptions.AttachedToParent);
 }
예제 #2
0
            public void Maintenance(int level, Token token)
            {
                if (HaveChildrenForMaintenance)
                {
                    MaintenanceHelper[] helpers = new MaintenanceHelper[Branches.Count];
                    for (int index = Branches.Count - 1; index >= 0; index--)
                    {
                        helpers[index] = new MaintenanceHelper(level, token, helpers, Branches[index], index);
                    }

                    Branches.Clear();
                    for (int index = 0; index < helpers.Length; index++)
                    {
                        var helper = helpers[index];
                        helper.Task.Wait();
                        Branches.AddRange(helper.List);
                    }

                    RebuildOptimizator();

                    HaveChildrenForMaintenance = false;

                    IsModified = true;
                }

                //sink branches
                int operationCount = Branches.Sum(x => x.Value.Cache.OperationCount);

                if (operationCount > Branch.Tree.MAX_OPERATIONS)
                {
                    //Debug.WriteLine(string.Format("{0}: {1} = {2}", level, Branch.NodeHandle, operationCount));
                    foreach (var kv in Branches.Where(x => x.Value.Cache.OperationCount > 0).OrderByDescending(x => x.Value.Cache.OperationCount))
                    {
                        Branch branch = kv.Value;

                        operationCount -= branch.Cache.OperationCount;
                        if (branch.Fall(level, token, new Params(WalkMethod.Current, WalkAction.None, null, true)))
                        {
                            IsModified = true;
                        }

                        if (operationCount <= Branch.Tree.MIN_OPERATIONS)
                        {
                            break;
                        }

                        //branch.WaitFall();
                    }
                }
            }
예제 #3
0
    private void CheckMaintenanceSettings()
    {
        var pageLocation = HttpContext.Current.Request.Url.AbsoluteUri;

        var info = new MaintenanceInfo();

        if (pageLocation.Contains("/Deposit"))
        {
            info.CurrentPage = MaintenanceModules.DPM;
        }
        else if (pageLocation.Contains("/Withdrawal"))
        {
            info.CurrentPage = MaintenanceModules.WPM;
        }
        else if (pageLocation.Contains("/Profile/Rebates.aspx"))
        {
            info.CurrentPage = MaintenanceModules.RS;
        }
        else if (pageLocation.Contains("/FundTransfer"))
        {
            info.CurrentPage = MaintenanceModules.FTM;
        }
        else
        {
            info.CurrentPage = MaintenanceModules.NonPage;
        }

        info.MainSite     = Convert.ToBoolean(_opsettings.Values.Get("MaintenanceAllPages"));
        info.Deposit      = Convert.ToBoolean(_opsettings.Values.Get("MaintenanceDeposit"));
        info.Widrawal     = Convert.ToBoolean(_opsettings.Values.Get("MaintenanceWidrawal"));
        info.FundTransfer = Convert.ToBoolean(_opsettings.Values.Get("MaintenanceFundTransfer"));
        info.Rebates      = Convert.ToBoolean(_opsettings.Values.Get("MaintenanceRebates"));

        var maintenanceHelper = new MaintenanceHelper(info).CheckStatus();

        if (maintenanceHelper.AllSite)
        {
            Response.Clear();
            Response.Redirect(_opsettings.Values.Get("MaintenanceAllPage"), true);
        }
        else if (maintenanceHelper.PerModule)
        {
            Response.Clear();
            Response.Redirect(_opsettings.Values.Get("MaintenancePage"), true);
        }
    }
            public void Maintenance(int level, Token token)
            {
                if (HaveChildrenForMaintenance)
                {
                    MaintenanceHelper[] helpers = new MaintenanceHelper[Branches.Count];
                    for (int index = Branches.Count - 1; index >= 0; index--)
                        helpers[index] = new MaintenanceHelper(level, token, helpers, Branches[index], index);

                    Branches.Clear();
                    for (int index = 0; index < helpers.Length; index++)
                    {
                        var helper = helpers[index];
                        helper.Task.Wait();
                        Branches.AddRange(helper.List);
                    }

                    RebuildOptimizator();

                    HaveChildrenForMaintenance = false;

                    IsModified = true;
                }

                //sink branches
                int operationCount = Branches.Sum(x => x.Value.Cache.OperationCount);
                if (operationCount > Branch.Tree.INTERNAL_NODE_MAX_OPERATIONS)
                {
                    //Debug.WriteLine(string.Format("{0}: {1} = {2}", level, Branch.NodeHandle, operationCount));
                    foreach (var kv in Branches.Where(x => x.Value.Cache.OperationCount > 0).OrderByDescending(x => x.Value.Cache.OperationCount))
                    {
                        Branch branch = kv.Value;

                        operationCount -= branch.Cache.OperationCount;
                        if (branch.Fall(level, token, new Params(WalkMethod.Current, WalkAction.None, null, true)))
                            IsModified = true;

                        if (operationCount <= Branch.Tree.INTERNAL_NODE_MIN_OPERATIONS)
                            break;

                        //branch.WaitFall();
                    }
                }
            }
예제 #5
0
 public static Thread _maintenanceThread(this MaintenanceHelper maintenanceHelper) => (Thread)Reflector.GetFieldValue(maintenanceHelper, nameof(_maintenanceThread));
예제 #6
0
 public static MaintenanceExecutingContext _maintenanceExecutingContext(this MaintenanceHelper maintenanceHelper) => (MaintenanceExecutingContext)Reflector.GetFieldValue(maintenanceHelper, nameof(_maintenanceExecutingContext));