예제 #1
0
        public virtual void PrimaryDriver_FieldUpdated_Handler(PXCache cache, FSAppointmentEmployee fsAppointmentEmployeeRow)
        {
            PXResultset <FSAppointmentEmployee> employeeRows = AppointmentServiceEmployees.Select();

            foreach (FSAppointmentEmployee row in employeeRows.RowCast <FSAppointmentEmployee>()
                     .Where(_ => _.EmployeeID == fsAppointmentEmployeeRow.EmployeeID))
            {
                row.PrimaryDriver = fsAppointmentEmployeeRow.PrimaryDriver;
                if (cache.GetStatus(row) == PXEntryStatus.Notchanged)
                {
                    cache.SetStatus(row, PXEntryStatus.Updated);
                }
            }

            if (fsAppointmentEmployeeRow.PrimaryDriver == true)
            {
                foreach (FSAppointmentEmployee row in employeeRows.RowCast <FSAppointmentEmployee>()
                         .Where(_ => _.EmployeeID != fsAppointmentEmployeeRow.EmployeeID &&
                                _.PrimaryDriver == true))
                {
                    row.PrimaryDriver = false;
                    if (cache.GetStatus(row) == PXEntryStatus.Notchanged)
                    {
                        cache.SetStatus(row, PXEntryStatus.Updated);
                    }
                }
            }

            AppointmentServiceEmployees.View.RequestRefresh();
        }
예제 #2
0
        public virtual void ValidatePrimaryDriver()
        {
            PXResultset <FSAppointmentEmployee> fsAppointmentEmployeeRow = AppointmentServiceEmployees.Select();

            if (fsAppointmentEmployeeRow.Count > 0 &&
                fsAppointmentEmployeeRow.RowCast <FSAppointmentEmployee>().Where(_ => _.PrimaryDriver == true).Any() == false)
            {
                throw new PXException(TX.Messages.MISSING_PRIMARY_DRIVER);
            }
        }
예제 #3
0
        public virtual void StartServiceBasedOnAssignmentAction(IEnumerable <FSDetailFSLogAction> createLogItems = null)
        {
            IEnumerable <FSDetailFSLogAction> createLogItemsLocal = null;
            FSAppointmentLog fsAppointmentLogRow;

            if (createLogItems == null)
            {
                createLogItemsLocal = ServicesLogAction.Select().RowCast <FSDetailFSLogAction>().Where(x => x.Selected == true);
            }
            else
            {
                createLogItemsLocal = createLogItems;
            }

            if (createLogItemsLocal != null)
            {
                foreach (FSDetailFSLogAction fsDetailLogActionRow in createLogItemsLocal)
                {
                    var employeesRelatedToService = AppointmentServiceEmployees.Select().RowCast <FSAppointmentEmployee>()
                                                    .Where(x => x.ServiceLineRef == fsDetailLogActionRow.LineRef);

                    if (employeesRelatedToService.Count() > 0)
                    {
                        foreach (FSAppointmentEmployee employeeRow in employeesRelatedToService)
                        {
                            int?timeDuration = employeeRow != null && fsDetailLogActionRow.EstimatedDuration != null ? fsDetailLogActionRow.EstimatedDuration : 0;

                            fsAppointmentLogRow = new FSAppointmentLog()
                            {
                                Type          = ID.Type_Log.STAFF_ASSIGMENT,
                                BAccountID    = employeeRow.EmployeeID,
                                DetLineRef    = employeeRow.ServiceLineRef,
                                DateTimeBegin = LogActionFilter.Current.LogTime,
                                TimeDuration  = fsDetailLogActionRow.EstimatedDuration
                            };

                            LogRecords.Cache.Insert(fsAppointmentLogRow);
                        }
                    }
                    else
                    {
                        fsAppointmentLogRow = new FSAppointmentLog()
                        {
                            Type          = ID.Type_Log.SERVICE,
                            BAccountID    = null,
                            DetLineRef    = fsDetailLogActionRow.LineRef,
                            DateTimeBegin = LogActionFilter.Current.LogTime,
                            TimeDuration  = fsDetailLogActionRow.EstimatedDuration
                        };

                        LogRecords.Cache.Insert(fsAppointmentLogRow);
                    }
                }
            }
        }
예제 #4
0
        public virtual void PrimaryDriver_RowDeleting_Handler(PXCache cache, FSAppointmentEmployee fsAppointmentEmployeeRow)
        {
            if (fsAppointmentEmployeeRow.PrimaryDriver == true)
            {
                PXResultset <FSAppointmentEmployee> fsAppointmentEmployeeRows = AppointmentServiceEmployees.Select();

                if (fsAppointmentEmployeeRows.RowCast <FSAppointmentEmployee>()
                    .Where(_ => _.EmployeeID == fsAppointmentEmployeeRow.EmployeeID).Any() == false)
                {
                    IEnumerable <FSAppointmentEmployee> firstAppointmentEmployeeRow = fsAppointmentEmployeeRows.RowCast <FSAppointmentEmployee>()
                                                                                      .OrderBy(_ => _.LineNbr);
                    if (firstAppointmentEmployeeRow.Any() == true)
                    {
                        cache.SetValueExt <FSAppointmentEmployee.primaryDriver>(firstAppointmentEmployeeRow.First(), true);
                    }

                    AppointmentRecords.Current.PrimaryDriver = firstAppointmentEmployeeRow.FirstOrDefault()?.EmployeeID;
                }
            }
        }
예제 #5
0
        public virtual void StartStaffAction(IEnumerable <FSStaffLogActionDetail> createLogItems = null)
        {
            IEnumerable <FSStaffLogActionDetail> createLogItemsLocal = null;

            if (createLogItems == null)
            {
                if (LogActionFilter.Current.Me == true)
                {
                    EPEmployee employeeByUserID = PXSelect <EPEmployee,
                                                            Where <
                                                                EPEmployee.userID, Equal <Current <AccessInfo.userID> > > >
                                                  .Select(this);

                    if (employeeByUserID != null)
                    {
                        bool isEmployeeInGrid = AppointmentServiceEmployees.Select().RowCast <FSAppointmentEmployee>()
                                                .Where(x => x.EmployeeID == employeeByUserID.BAccountID)
                                                .Count() > 0;

                        bool isTherePrimaryDriver = AppointmentServiceEmployees.Select().RowCast <FSAppointmentEmployee>()
                                                    .Where(x => x.PrimaryDriver == true)
                                                    .Count() > 0;

                        if (isEmployeeInGrid == false)
                        {
                            FSAppointmentEmployee fsAppointmentEmployeeRow = new FSAppointmentEmployee()
                            {
                                EmployeeID = employeeByUserID.BAccountID
                            };

                            if (isTherePrimaryDriver == false)
                            {
                                fsAppointmentEmployeeRow.PrimaryDriver = true;
                            }

                            AppointmentServiceEmployees.Cache.Insert(fsAppointmentEmployeeRow);

                            FSAppointmentLog fsAppointmentLogRow = new FSAppointmentLog()
                            {
                                Type          = ID.Type_Log.STAFF_ASSIGMENT,
                                BAccountID    = employeeByUserID.BAccountID,
                                DetLineRef    = null,
                                DateTimeBegin = LogActionFilter.Current.LogTime
                            };

                            LogRecords.Cache.Insert(fsAppointmentLogRow);
                        }
                        else
                        {
                            createLogItemsLocal = LogStaffActionDetails.Select().RowCast <FSStaffLogActionDetail>()
                                                  .Where(x => x.Selected == true);
                        }
                    }
                }
                else
                {
                    createLogItemsLocal = LogStaffActionDetails.Select().RowCast <FSStaffLogActionDetail>()
                                          .Where(x => x.Selected == true);
                }
            }
            else
            {
                createLogItemsLocal = createLogItems;
            }

            if (createLogItemsLocal != null)
            {
                foreach (FSStaffLogActionDetail fsStaffLogActionDetailRow in createLogItemsLocal)
                {
                    int?timeDuration = fsStaffLogActionDetailRow != null && fsStaffLogActionDetailRow.EstimatedDuration != null ? fsStaffLogActionDetailRow.EstimatedDuration : 0;

                    FSAppointmentLog fsAppointmentLogRow = new FSAppointmentLog()
                    {
                        Type          = ID.Type_Log.STAFF_ASSIGMENT,
                        BAccountID    = fsStaffLogActionDetailRow.BAccountID,
                        DetLineRef    = fsStaffLogActionDetailRow.DetLineRef,
                        DateTimeBegin = LogActionFilter.Current.LogTime,
                        TimeDuration  = timeDuration
                    };

                    LogRecords.Cache.Insert(fsAppointmentLogRow);
                }
            }
        }
예제 #6
0
        public virtual void StartServiceAction(IEnumerable <FSAppointmentEmployeeFSLogStart> createLogItems = null)
        {
            IEnumerable <FSAppointmentEmployeeFSLogStart> createLogItemsLocal = null;
            FSAppointmentLog fsAppointmentLogRow;
            FSAppointmentDet fsAppointmentDetRow = null;
            string           detLineRef          = null;
            DateTime?        dateTimeBegin       = null;
            int timeDuration = 0;

            if (LogActionFilter.Current?.DetLineRef == null)
            {
                return;
            }

            if (createLogItems == null)
            {
                detLineRef    = LogActionFilter.Current?.DetLineRef;
                dateTimeBegin = LogActionFilter.Current?.LogTime;

                if (LogActionFilter.Current.DetLineRef != null)
                {
                    fsAppointmentDetRow = PXSelect <FSAppointmentDet,
                                                    Where <
                                                        FSAppointmentDet.appointmentID, Equal <Required <FSAppointmentDet.appointmentID> >,
                                                        And <FSAppointmentDet.lineRef, Equal <Required <FSAppointmentDet.lineRef> > > > >
                                          .Select(this, AppointmentRecords.Current.AppointmentID, LogActionFilter.Current.DetLineRef);

                    if (fsAppointmentDetRow != null)
                    {
                        timeDuration = fsAppointmentDetRow.EstimatedDuration ?? 0;
                    }
                }

                if (LogActionFilter.Current.Me == true)
                {
                    EPEmployee employeeByUserID = PXSelect <EPEmployee,
                                                            Where <
                                                                EPEmployee.userID, Equal <Current <AccessInfo.userID> > > >
                                                  .Select(this);

                    if (employeeByUserID != null)
                    {
                        bool isEmployeeInGrid = AppointmentServiceEmployees.Select().RowCast <FSAppointmentEmployee>()
                                                .Where(x => x.EmployeeID == employeeByUserID.BAccountID)
                                                .Count() > 0;

                        bool isTherePrimaryDriver = AppointmentServiceEmployees.Select().RowCast <FSAppointmentEmployee>()
                                                    .Where(x => x.PrimaryDriver == true)
                                                    .Count() > 0;

                        if (isEmployeeInGrid == false)
                        {
                            FSAppointmentEmployee fsAppointmentEmployeeRow = new FSAppointmentEmployee()
                            {
                                EmployeeID = employeeByUserID.BAccountID,
                            };

                            if (isTherePrimaryDriver == false)
                            {
                                fsAppointmentEmployeeRow.PrimaryDriver = true;
                            }

                            AppointmentServiceEmployees.Cache.Insert(fsAppointmentEmployeeRow);
                        }

                        fsAppointmentLogRow = new FSAppointmentLog()
                        {
                            Type          = ID.Type_Log.SERVICE,
                            BAccountID    = employeeByUserID.BAccountID,
                            DetLineRef    = detLineRef,
                            DateTimeBegin = dateTimeBegin,
                            TimeDuration  = timeDuration
                        };

                        LogRecords.Cache.Insert(fsAppointmentLogRow);
                    }
                }
                else
                {
                    createLogItemsLocal = StaffMemberLogStartAction.Select().RowCast <FSAppointmentEmployeeFSLogStart>()
                                          .Where(x => x.Selected == true);
                }
            }
            else
            {
                detLineRef          = null;
                dateTimeBegin       = PXDBDateAndTimeAttribute.CombineDateTime(AppointmentRecords.Current.ExecutionDate, PXTimeZoneInfo.Now);
                createLogItemsLocal = createLogItems;
            }

            if (createLogItemsLocal != null)
            {
                foreach (FSAppointmentEmployeeFSLogStart row in createLogItemsLocal)
                {
                    fsAppointmentLogRow = new FSAppointmentLog()
                    {
                        Type          = ID.Type_Log.SERVICE,
                        BAccountID    = row.BAccountID,
                        DetLineRef    = detLineRef,
                        DateTimeBegin = dateTimeBegin,
                        TimeDuration  = timeDuration
                    };

                    LogRecords.Cache.Insert(fsAppointmentLogRow);
                }
            }
        }