Ejemplo n.º 1
0
        public virtual void VerifyBeforeTransaction(string action, string type)
        {
            int  itemsSelectedCount = 0;
            bool canPerformAction   = false;

            if (action == ID.LogActions.START)
            {
                if (type == ID.Type_Log.TRAVEL || type == ID.Type_Log.SERVICE)
                {
                    itemsSelectedCount = StaffMemberLogStartAction.Select().RowCast <FSAppointmentEmployeeFSLogStart>().Where(x => x.Selected == true).Count();
                    canPerformAction   = LogActionFilter.Current.Me == true || itemsSelectedCount > 0;

                    if (type == ID.Type_Log.SERVICE && LogActionFilter.Current.DetLineRef == null)
                    {
                        LogActionFilter.Cache.RaiseExceptionHandling <FSLogActionFilter.detLineRef>(LogActionFilter.Current,
                                                                                                    LogActionFilter.Current.DetLineRef,
                                                                                                    new PXSetPropertyException(PXMessages.LocalizeFormatNoPrefix(TX.Error.FIELD_MAY_NOT_BE_EMPTY,
                                                                                                                                                                 PXUIFieldAttribute.GetDisplayName <FSLogActionFilter.detLineRef>(LogActionFilter.Cache))));

                        canPerformAction = false;
                    }
                }
                else if (type == ID.Type_Log.STAFF_ASSIGMENT)
                {
                    itemsSelectedCount = LogStaffActionDetails.Select().RowCast <FSStaffLogActionDetail>().Where(x => x.Selected == true).Count();
                    canPerformAction   = itemsSelectedCount > 0;
                }
                else if (type == ID.Type_Log.SERV_BASED_ASSIGMENT)
                {
                    itemsSelectedCount = ServicesLogAction.Select().RowCast <FSDetailFSLogAction>().Where(x => x.Selected == true).Count();
                    canPerformAction   = itemsSelectedCount > 0;
                }
            }
            else if (action == ID.LogActions.COMPLETE)
            {
                if (type == ID.Type_Log.TRAVEL)
                {
                    itemsSelectedCount = LogActionTravelDetails.Select().RowCast <FSLogActionTravelDetail>().Where(x => x.Selected == true).Count();
                }
                else if (type == ID.Type_Log.SERVICE || type == ID.Type_Log.STAFF_ASSIGMENT)
                {
                    itemsSelectedCount = LogActionServiceDetails.Select().RowCast <NoTravelLogInProcess>().Where(x => x.Selected == true).Count();
                }

                canPerformAction = itemsSelectedCount > 0;
            }

            if (canPerformAction == false)
            {
                LogActionFilter.Cache.RaiseExceptionHandling <FSLogActionFilter.action>(LogActionFilter.Current,
                                                                                        LogActionFilter.Current.Action,
                                                                                        new PXSetPropertyException(TX.Error.CANNOT_PERFORM_LOG_ACTION_RECORD_NOT_SELECTED));

                throw new PXRowPersistingException(null, null, TX.Error.CANNOT_PERFORM_LOG_ACTION_RECORD_NOT_SELECTED);
            }
        }
Ejemplo n.º 2
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);
                    }
                }
            }
        }