public static void Process(EMailAccountSyncFilter filter, List <EMailSyncAccount> accounts, Object uid, string screenid)
        {
            //Check that process is singleton
            foreach (RowTaskInfo info in PXLongOperation.GetTaskList())
            {
                if (Object.Equals(uid, info.NativeKey))
                {
                    continue;
                }

                PXLongRunStatus status = PXLongOperation.GetStatus(info.NativeKey);
                if (status != PXLongRunStatus.InProcess)
                {
                    continue;
                }

                string company = PXLogin.ExtractCompany(info.User);
                string screen  = (info.Screen ?? String.Empty).Replace(".", "");
                if (screen == screenid && company == PXAccess.GetCompanyName())
                {
                    throw new PXException(ErrorMessages.PrevOperationNotCompleteYet);
                }
            }

            EmailsSyncMaint graph = CreateInstance <EmailsSyncMaint>();

            using (new PXUTCTimeZoneScope())
            {
                graph.ProcessInternal(new ProcessingContext(filter, accounts, graph.GetPolicies()));
            }
        }
예제 #2
0
        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);
            }
        }
예제 #3
0
        private void SetProcessDelegate()
        {
            BalanceFilter filter     = Filter.Current;
            bool          depriciate = filter.Action == BalanceFilter.action.Depreciate;

            Balances.SetProcessDelegate(delegate(List <FABookBalance> list)
            {
                if (PXLongOperation.GetTaskList().Where(_ => _.Screen == "FA.50.20.00").ToArray().Length > 1)
                {
                    throw new PXException(Messages.AnotherDeprRunning);
                }

                List <FABookBalance> balances = GetProcessableRecords(list);

                if (depriciate)
                {
                    AssetProcess.DepreciateAsset(balances, null, filter.PeriodID, true);
                }
                else
                {
                    AssetProcess.CalculateAsset(balances, filter.PeriodID);
                }
            });

            bool canDepreciate = !string.IsNullOrEmpty(filter.PeriodID) && fasetup.Current.UpdateGL == true;

            PXUIFieldAttribute.SetEnabled <BalanceFilter.action>(Filter.Cache, filter, canDepreciate);
            if (!canDepreciate)
            {
                filter.Action = BalanceFilter.action.Calculate;
            }
        }
예제 #4
0
        protected virtual void BalanceFilter_RowSelected(PXCache sender, PXRowSelectedEventArgs e)
        {
            if (e.Row != null)
            {
                BalanceFilter filter = Filter.Current;

                if (Depreciate)
                {
                    Balances.SetProcessDelegate(delegate(List <FABookBalance> list)
                    {
                        if (PXLongOperation.GetTaskList().Where(_ => _.Screen == "FA.50.20.00").ToArray().Count() > 1)
                        {
                            throw new PXException(Messages.AnotherDeprRunning);
                        }
                        AssetProcess.DepreciateAsset(list, null, filter.PeriodID, true);
                    });
                }
                else
                {
                    Balances.SetProcessDelegate(delegate(List <FABookBalance> list)
                    {
                        if (PXLongOperation.GetTaskList().Where(_ => _.Screen == "FA.50.20.00").ToArray().Count() > 1)
                        {
                            throw new PXException(Messages.AnotherDeprRunning);
                        }
                        AssetProcess.CalculateAsset(list, filter.PeriodID);
                    });
                }

                Balances.SetProcessVisible(false);
                Balances.SetProcessAllVisible(false);

                PXButtonState pstate    = Actions["Process"].GetState(e.Row) as PXButtonState;
                PXButtonState pastate   = Actions["ProcessAll"].GetState(e.Row) as PXButtonState;
                bool          penabled  = pstate == null || pstate.Enabled;
                bool          paenabled = pastate == null || pastate.Enabled;

                Calculate.SetEnabled(penabled);
                CalculateAll.SetEnabled(paenabled);

                CalcDepr.SetEnabled(!string.IsNullOrEmpty(filter.PeriodID) && fasetup.Current.UpdateGL == true && penabled);
                CalcDeprAll.SetEnabled(!string.IsNullOrEmpty(filter.PeriodID) && fasetup.Current.UpdateGL == true && paenabled);
            }
        }