Exemplo n.º 1
0
        public static void SetProcessDelegate <ProcessGraph>(PXGraph graph, ScheduleRun.Parameters filter, PXProcessing <Schedule> view)
            where ProcessGraph : PXGraph <ProcessGraph>, IScheduleProcessing, new()
        {
            if (filter == null)
            {
                return;
            }

            short times = filter.LimitTypeSel == ScheduleRunLimitType.StopAfterNumberOfExecutions
                                ? filter.RunLimit ?? 1
                                : short.MaxValue;

            DateTime executionDate = filter.LimitTypeSel == ScheduleRunLimitType.StopOnExecutionDate
                                ? filter.ExecutionDate ?? graph.Accessinfo.BusinessDate.Value
                                : DateTime.MaxValue;

            Dictionary <string, string> parametersErrors = PXUIFieldAttribute.GetErrors(
                graph.Caches[typeof(ScheduleRun.Parameters)],
                filter);

            view.SetProcessDelegate(schedules =>
            {
                if (parametersErrors.Any())
                {
                    throw new PXException(parametersErrors.First().Value);
                }

                ProcessGraph processGraph = PXGraph.CreateInstance <ProcessGraph>();
                bool failed = false;
                foreach (Schedule schedule in schedules)
                {
                    try
                    {
                        PXProcessing <Schedule> .SetCurrentItem(schedule);
                        processGraph.Clear();
                        processGraph.GenerateProc(schedule, times, executionDate);
                        PXProcessing <Schedule> .SetInfo(ActionsMessages.RecordProcessed);
                    }
                    catch (Exception e)
                    {
                        failed = true;
                        PXProcessing <Schedule> .SetError(e);
                    }
                }
                if (failed)
                {
                    //Clean current to prevent set exception to the last item
                    PXProcessing <Schedule> .SetCurrentItem(null);
                    throw new PXException(AR.Messages.OneOrMoreItemsAreNotProcessed);
                }
            });
        }
        public static void SetProcessDelegate <ProcessGraph>(PXGraph graph, ScheduleRun.Parameters filter, PXProcessing <Schedule> view)
            where ProcessGraph : PXGraph <ProcessGraph>, IScheduleProcessing, new()
        {
            if (filter == null)
            {
                return;
            }

            short times = filter.LimitTypeSel == ScheduleRunLimitType.StopAfterNumberOfExecutions
                                ? filter.RunLimit ?? 1
                                : short.MaxValue;

            DateTime executionDate = filter.LimitTypeSel == ScheduleRunLimitType.StopOnExecutionDate
                                ? filter.ExecutionDate ?? graph.Accessinfo.BusinessDate.Value
                                : DateTime.MaxValue;

            Dictionary <string, string> parametersErrors = PXUIFieldAttribute.GetErrors(
                graph.Caches[typeof(ScheduleRun.Parameters)],
                filter);

            view.SetProcessDelegate(schedules =>
            {
                if (parametersErrors.Any())
                {
                    throw new PXException(parametersErrors.First().Value);
                }

                ProcessGraph processGraph = PXGraph.CreateInstance <ProcessGraph>();

                foreach (Schedule schedule in schedules)
                {
                    processGraph.Clear();
                    processGraph.GenerateProc(schedule, times, executionDate);
                }
            });
        }
Exemplo n.º 3
0
 public static void SetProcessDelegate <ProcessGraph>(PXGraph graph, ScheduleRun.Parameters filter, PXProcessing <Schedule> view)
     where ProcessGraph : PXGraph <ProcessGraph>, IScheduleProcessing, new()
 => ScheduleRunBase.SetProcessDelegate <ProcessGraph>(graph, filter, view);