public void ExecuteJobs(int?branchID, string companyName, object parentLongOperationKey) { this.MainContext.SaveCurrentContextValues(companyName, parentLongOperationKey); //Changing context branch id before launching long run operations PXContext.SetBranchID(branchID); try { this.ExecuteJobs_MaximizeJobsInParallel(); } catch (ThreadAbortException) { foreach (Guid childLongOperation in this.MainContext.childLongOperations) { var r = PXLongOperation.GetTaskList().FirstOrDefault(_ => _.Key == childLongOperation.ToString()); if (r != null) { PXLongOperation.AsyncAbort(r.NativeKey); } } } finally { //Restoring default branch id PXContext.SetBranchID(this.MainContext.BranchID); } }
/// <summary> /// The branch menu item click event handler. /// </summary> private void Branch_ItemClick(object sender, PXListItemEventArgs e) { var targetBranch = int.Parse(e.Item.Value); if (targetBranch < 1) { return; } PXDropDown dropDown = this.GetBranchCombo(); foreach (PXAccess.BranchCollection.Info item in GetBranches()) { if (targetBranch.Equals(item.Id)) { PXContext.SetBranchID(targetBranch); HttpCookie branchCooky = HttpContext.Current.Response.Cookies["UserBranch"]; if (dropDown != null) { dropDown.Value = item.Id; } //if (this.Page is PXPage) ((PXPage)this.Page).ResetCurrentUser(HttpContext.Current); string branchObj = targetBranch.ToString(); if (branchCooky == null) { HttpContext.Current.Response.Cookies.Add(new HttpCookie("UserBranch", branchObj)); } else { branchCooky.Value = branchObj; } break; } } }
public void SetContextValues() { PXContext.SetBranchID(this.BranchID); PXContext.SetBusinessDate(this.BusinessDate); PXContext.SetScreenID(this.ScreenID); }