コード例 #1
0
        public override void Persist()
        {
            bool requestRelogin = Accessinfo.BranchID == null;

            using (PXTransactionScope ts = new PXTransactionScope())
            {
                foreach (BranchBAccount item in BAccount.Cache.Deleted)
                {
                    Branch branch = PXSelect <Branch, Where <Branch.branchCD, Equal <Required <Branch.branchCD> > > > .Select(this, item.BranchBranchCD);

                    if (branch != null)
                    {
                        if (Accessinfo.BranchID == branch.BranchID)
                        {
                            requestRelogin = true;
                        }
                        PXDatabase.Update <Ledger>(
                            new PXDataFieldAssign <Ledger.defBranchID>(null),
                            new PXDataFieldRestrict <Ledger.defBranchID>(branch.BranchID));
                    }
                }
                base.Persist();
                ts.Complete();
            }
            using (PXTransactionScope tran = new PXTransactionScope())
            {
                PXResultset <Branch> activeBranches = PXSelect <Branch> .Select(this);

                bool clearRoleNames = true;
                foreach (Branch branch in PXSelect <Branch> .Select(this))
                {
                    if (branch.RoleName != null)
                    {
                        clearRoleNames = false;
                    }
                }
                using (PXReadDeletedScope rds = new PXReadDeletedScope())
                {
                    if (clearRoleNames)
                    {
                        PXDatabase.Update <Branch>(new PXDataFieldAssign <Branch.roleName>(null));
                    }
                }
                tran.Complete();
            }
            if (requestRelogin)
            {
                PXAccess.ResetBranchSlot();
                PXLogin.SetBranchID(CreateInstance <PX.SM.SMAccessPersonalMaint>().GetDefaultBranchId());
            }
        }
コード例 #2
0
        public void RunStepGroup()
        {
            Guid?longOperationKey = null;

            if (this._longOperationKey != null)
            {
                longOperationKey = (Guid)this._longOperationKey;
            }

            if (_singleThread == false)
            {
                using (var ls = new PXLoginScope(CurrentStepGroup.MainContext.UserNameForLoginScope))
                {
                    PXSessionContextFactory.AuthenticateRequest();
                    PXLogin.SetBranchID(CurrentStepGroup.MainContext.BranchID);

                    CurrentStepGroup.MainContext.SetContextValues();
                    ls.Keep();
                }

                lock (CurrentStepGroup.MainContext.childLongOperations)
                {
                    if (longOperationKey != null)
                    {
                        CurrentStepGroup.MainContext.childLongOperations.Add((Guid)longOperationKey);
                    }
                }

                PXLongOperation.StartOperation(
                    longOperationKey,
                    () =>
                {
                    if (Thread.CurrentThread.Name == null)
                    {
                        Thread.CurrentThread.Name = "Child - " + longOperationKey.ToString();
                    }

                    CurrentStepGroup.RunAllSteps(longOperationKey);
                });
            }
            else
            {
                CurrentStepGroup.RunAllSteps(longOperationKey);
            }
        }