Beispiel #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);
            }
        }
Beispiel #2
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);
                }
            }
        }
Beispiel #3
0
        public virtual void UpdateLogActionViews(string type, bool fromStaffTab)
        {
            if (type == ID.Type_Log.TRAVEL)
            {
                if (AppointmentDetails.Current?.IsTravelItem == true)
                {
                    LogActionFilter.Current.DetLineRef = AppointmentDetails.Current.LineRef;
                }
                else
                {
                    LogActionFilter.Current.DetLineRef = SharedFunctions.GetItemLineRef(this, AppointmentRecords.Current.AppointmentID, true);
                }

                if (LogActionFilter.Current.DetLineRef != null)
                {
                    foreach (FSLogActionTravelDetail row in LogActionTravelDetails.Select())
                    {
                        row.Selected = row.DetLineRef == LogActionFilter.Current.DetLineRef;

                        if (LogActionTravelDetails.Cache.GetStatus(row) == PXEntryStatus.Notchanged)
                        {
                            LogActionTravelDetails.Cache.SetStatus(row, PXEntryStatus.Updated);
                        }
                    }
                }
            }
            else if (type == ID.Type_Log.SERVICE)
            {
                LogActionFilter.Current.DetLineRef = AppointmentDetails.Current?.LineType == ID.LineType_ALL.SERVICE ? AppointmentDetails.Current.LineRef : null;

                foreach (NoTravelLogInProcess row in LogActionServiceDetails.Select())
                {
                    if (fromStaffTab == false)
                    {
                        row.Selected = row.DetLineRef == LogActionFilter.Current.DetLineRef;
                    }
                    else
                    {
                        row.Selected = row.BAccountID == AppointmentServiceEmployees.Current?.EmployeeID;
                    }

                    if (LogActionServiceDetails.Cache.GetStatus(row) == PXEntryStatus.Notchanged)
                    {
                        LogActionServiceDetails.Cache.SetStatus(row, PXEntryStatus.Updated);
                    }
                }
            }
            else if (type == ID.Type_Log.STAFF_ASSIGMENT)
            {
                FSStaffLogActionDetail row = LogStaffActionDetails.Select()
                                             .RowCast <FSStaffLogActionDetail>()
                                             .Where(_ => _.LineRef == AppointmentServiceEmployees.Current.LineRef)
                                             .FirstOrDefault();

                if (row != null)
                {
                    foreach (FSStaffLogActionDetail selectedRow in LogStaffActionDetails.Select()
                             .RowCast <FSStaffLogActionDetail>()
                             .Where(_ => _.Selected == true))
                    {
                        selectedRow.Selected = false;

                        if (LogStaffActionDetails.Cache.GetStatus(selectedRow) == PXEntryStatus.Notchanged)
                        {
                            LogStaffActionDetails.Cache.SetStatus(selectedRow, PXEntryStatus.Updated);
                        }
                    }

                    row.Selected = row.BAccountID == AppointmentServiceEmployees.Current.EmployeeID;

                    if (LogStaffActionDetails.Cache.GetStatus(row) == PXEntryStatus.Notchanged)
                    {
                        LogStaffActionDetails.Cache.SetStatus(row, PXEntryStatus.Updated);
                    }
                }
            }
        }