Beispiel #1
0
        public static IEnumerable SkillFilterDelegate <ServiceDetType>(
            PXGraph graph,
            PXSelectBase <ServiceDetType> servicesView,
            PXFilter <StaffSelectionFilter> filter,
            PXSelectBase <SkillGridFilter> skillView)
            where ServiceDetType : class, IBqlTable, IFSSODetBase, new()
        {
            List <int?> serviceIDList      = new List <int?>();
            List <int?> serviceIDCheckList = new List <int?>();

            IEnumerable <SkillGridFilter> skillRecords = skillView.Cache.Cached.Cast <SkillGridFilter>();
            bool initSkillFilter = skillRecords.Count() == 0;

            if (initSkillFilter)
            {
                serviceIDList      = ServiceSelectionHelper.GetServicesInServiceTab <ServiceDetType>(servicesView, null);
                serviceIDCheckList = ServiceSelectionHelper.GetServicesInServiceTab <ServiceDetType>(servicesView, filter.Current.ServiceLineRef);
            }

            foreach (SkillGridFilter skillRow in PXSelect <SkillGridFilter> .Select(graph))
            {
                if (initSkillFilter)
                {
                    skillRow.Mem_ServicesList = SkillGridFilter.GetServiceListField(graph, serviceIDList, skillRow.SkillID);
                    string serviceList = SkillGridFilter.GetServiceListField(graph, serviceIDCheckList, skillRow.SkillID);

                    skillRow.Mem_Selected = string.IsNullOrEmpty(serviceList) == false;
                }

                skillView.Cache.SetStatus(skillRow, PXEntryStatus.Held);
                skillView.Cache.IsDirty = false;

                yield return(skillRow);
            }
        }
Beispiel #2
0
        public static IEnumerable LicenseTypeFilterDelegate <ServiceDetType>(
            PXGraph graph,
            PXSelectBase <ServiceDetType> servicesView,
            PXFilter <StaffSelectionFilter> filter,
            PXSelectBase <LicenseTypeGridFilter> licenseTypeView)
            where ServiceDetType : class, IBqlTable, IFSSODetBase, new()
        {
            List <int?> serviceIDList = new List <int?>();

            IEnumerable <LicenseTypeGridFilter> licenseTypeRecords = licenseTypeView.Cache.Cached.Cast <LicenseTypeGridFilter>();
            bool initLicenseTypeFilter = licenseTypeRecords.Count() == 0;

            if (initLicenseTypeFilter)
            {
                serviceIDList = ServiceSelectionHelper.GetServicesInServiceTab <ServiceDetType>(servicesView, filter.Current.ServiceLineRef);
            }

            foreach (LicenseTypeGridFilter licenseTypeRow in PXSelect <LicenseTypeGridFilter> .Select(graph))
            {
                if (initLicenseTypeFilter)
                {
                    licenseTypeRow.Mem_FromService = LicenseTypeGridFilter.IsThisLicenseTypeRequiredByAnyService(graph, licenseTypeRow.LicenseTypeID, serviceIDList);
                    licenseTypeRow.Mem_Selected    = licenseTypeRow.Mem_FromService == true;
                }

                licenseTypeView.Cache.SetStatus(licenseTypeRow, PXEntryStatus.Held);
                licenseTypeView.Cache.IsDirty = false;

                yield return(licenseTypeRow);
            }
        }
Beispiel #3
0
        /// <summary>
        /// Gets a list of Staff Members related to <c>filter.ServiceLineRef</c>.
        /// </summary>
        /// <param name="filter">Instance of the filter.</param>
        /// <param name="staffView">Current list of Staff Members in the grid.</param>
        /// <returns>A list of EPEmployee ready to be shown in the smartpanel.</returns>
        private static IEnumerable <BAccountStaffMember> GetStaffAvailableForSelect(PXFilter <StaffSelectionFilter> filter, object staffView)
        {
            PXResultset <BAccountStaffMember> bqlResultSet;

            List <int?> staffIDList = GetStaffByLineRefTab(staffView, filter.Current.ServiceLineRef);
            PXSelectBase <BAccountStaffMember> cmd = new StaffSelectionHelper.StaffRecords_View(filter.Cache.Graph);

            bqlResultSet = cmd.Select();

            var bAccountStaffMemberRowsGrouped = bqlResultSet.AsEnumerable().GroupBy(
                p => ((BAccountStaffMember)p).BAccountID,
                (key, group) => new
            {
                Group = (BAccountStaffMember)group.First()
            })
                                                 .Select(g => g.Group).ToList();

            foreach (BAccountStaffMember staffMemberRow in bAccountStaffMemberRowsGrouped)
            {
                if (staffIDList.Exists(delegate(int?staffMemberID) { return(staffMemberID == staffMemberRow.BAccountID); }) == true)
                {
                    staffMemberRow.Selected = true;
                }
                else
                {
                    staffMemberRow.Selected = false;
                }

                yield return(staffMemberRow);
            }
        }
Beispiel #4
0
        //@TODO SD-7694
        public static IEnumerable RouteRecordsDelegate(
            PXFilter <RouteAppointmentAssignmentFilter> filter,
            PXSelectBase <FSRouteDocument> cmd)
        {
            if (filter.Current == null)
            {
                yield break;
            }

            foreach (PXResult <FSRouteDocument, FSRoute> bqlResult in cmd.Select())
            {
                FSRouteDocument fsRouteDocumentRow = (FSRouteDocument)bqlResult;
                FSRoute         fsRouteRow         = (FSRoute)bqlResult;
                if (filter.Current.RouteDate.HasValue == true)
                {
                    if (!fsRouteDocumentRow.TimeBegin.HasValue)
                    {
                        fsRouteDocumentRow.TimeBegin = AppointmentCore.GetDateTimeEnd(fsRouteDocumentRow.Date, 0, 0, 0);
                    }

                    if (fsRouteDocumentRow.Date.Value.Date >= filter.Current.RouteDate.Value.Date &&
                        fsRouteDocumentRow.Date.Value.Date <= AppointmentCore.GetDateTimeEnd(filter.Current.RouteDate.Value.Date, 23, 59, 59))
                    {
                        yield return(bqlResult);
                    }
                }
                else
                {
                    yield return(bqlResult);
                }
            }
        }
Beispiel #5
0
        public static void OpenServiceSelector <DocDate>(PXCache documentCache,
                                                         PXFilter <ServiceSelectionFilter> serviceSelectorFilter,
                                                         PXSelect <EmployeeGridFilter> employeeGridFilter)
            where DocDate : class, IBqlField
        {
            if (documentCache.Current != null)
            {
                serviceSelectorFilter.Current.ScheduledDateTimeBegin = (DateTime?)documentCache.GetValue <DocDate>(documentCache.Current);
            }

            employeeGridFilter.Cache.Clear();
            serviceSelectorFilter.AskExt();
        }
Beispiel #6
0
        public void LaunchStaffSelector(PXGraph graph, PXFilter <StaffSelectionFilter> filter)
        {
            if (filter.Current.PostalCode != null && filter.Current.GeoZoneID == null)
            {
                FSGeoZonePostalCode fsGeoZoneRow = GetMatchingGeoZonePostalCode(graph, filter.Current.PostalCode);
                if (fsGeoZoneRow != null)
                {
                    filter.Current.GeoZoneID = fsGeoZoneRow.GeoZoneID;
                }
            }

            filter.Current.ExistContractEmployees = this.ExistContractEmployees(filter.Cache.Graph, filter.Current.ProjectID);
            filter.AskExt();
        }
Beispiel #7
0
        /// <summary>
        /// Gets a list of Staff Members related to <c>filter.ServiceLineRef</c>.
        /// </summary>
        /// <param name="filter">Instance of the filter.</param>
        /// <param name="staffView">Current list of Staff Members in the grid.</param>
        /// <returns>A list of EPEmployee ready to be shown in the smartpanel.</returns>
        private static IEnumerable <BAccountStaffMember> GetStaffAvailableForSelect(PXFilter <StaffSelectionFilter> filter, object staffView)
        {
            PXResultset <BAccountStaffMember> bqlResultSet;

            List <int?> staffIDList = GetStaffByLineRefTab(staffView, filter.Current.ServiceLineRef);
            PXSelectBase <BAccountStaffMember> cmd = new StaffSelectionHelper.StaffRecords_View(filter.Cache.Graph);

            if (filter.Current.ExistContractEmployees == true)
            {
                cmd.Join <LeftJoin <EPEmployeeContract, On <EPEmployeeContract.employeeID, Equal <EPEmployee.bAccountID> > > >();
                cmd.WhereAnd <Where <EPEmployeeContract.contractID, Equal <Required <StaffSelectionFilter.projectID> > > >();
                bqlResultSet = cmd.Select(filter.Current.ProjectID);
            }
            else
            {
                bqlResultSet = cmd.Select();
            }

            var bAccountStaffMemberRowsGrouped = bqlResultSet.GroupBy(
                p => ((BAccountStaffMember)p).BAccountID,
                (key, group) => new
            {
                Group = (BAccountStaffMember)group.First()
            })
                                                 .Select(g => g.Group).ToList();

            foreach (BAccountStaffMember staffMemberRow in bAccountStaffMemberRowsGrouped)
            {
                if (staffIDList.Exists(delegate(int?staffMemberID) { return(staffMemberID == staffMemberRow.BAccountID); }) == true)
                {
                    staffMemberRow.Selected = true;
                }
                else
                {
                    staffMemberRow.Selected = false;
                }

                yield return(staffMemberRow);
            }
        }
Beispiel #8
0
        public static IEnumerable StaffRecordsDelegate(
            object staffView,
            PXSelectBase <SkillGridFilter> skillView,
            PXSelectBase <LicenseTypeGridFilter> licenseTypeView,
            PXFilter <StaffSelectionFilter> filter)
        {
            if (filter.Current == null)
            {
                yield break;
            }

            PXGraph graphFilter = filter.Cache.Graph;
            IEnumerable <BAccountStaffMember> staffSet = GetStaffAvailableForSelect(filter, staffView);

            List <int?> skillsSelection = skillView.Select()
                                          .Where(y => ((SkillGridFilter)y).Mem_Selected == true)
                                          .Select(y => ((SkillGridFilter)y).SkillID)
                                          .ToList();

            List <int?> licenseTypesSelection = licenseTypeView.Select()
                                                .Where(y => ((LicenseTypeGridFilter)y).Mem_Selected == true)
                                                .Select(y => ((LicenseTypeGridFilter)y).LicenseTypeID)
                                                .ToList();

            if (skillsSelection.Count == 0 && licenseTypesSelection.Count == 0)
            {
                foreach (BAccountStaffMember staffRow in staffSet)
                {
                    yield return(staffRow);
                }
            }
            else
            {
                List <int?> employeeIDList = staffSet.Select(y => y.BAccountID).ToList();

                //Loading Skill list for each employee in employeeIDList
                List <SharedClasses.ItemList> allStaffSkillList = SharedFunctions.GetItemWithList <FSEmployeeSkill,
                                                                                                   FSEmployeeSkill.employeeID,
                                                                                                   FSEmployeeSkill.skillID>(graphFilter, employeeIDList);

                //NOTE: TIME info must be removed in order to catch licenses that expire the same day as ScheduledDateTimeBegin
                filter.Current.ScheduledDateTimeBegin = SharedFunctions.RemoveTimeInfo(filter.Current.ScheduledDateTimeBegin);

                //Loading LicenseType list for each employee in employeeIDList
                List <SharedClasses.ItemList> allStaffLicenseTypeList = SharedFunctions.GetItemWithList <FSLicense,
                                                                                                         FSLicense.employeeID,
                                                                                                         FSLicense.licenseTypeID,
                                                                                                         Where2 <
                                                                                                             Where <Current <StaffSelectionFilter.scheduledDateTimeBegin>, IsNull>,
                                                                                                             Or <Where <FSLicense.expirationDate, GreaterEqual <Current <StaffSelectionFilter.scheduledDateTimeBegin> >,
                                                                                                                        And <FSLicense.issueDate, LessEqual <Current <StaffSelectionFilter.scheduledDateTimeBegin> > > > > > >
                                                                            (graphFilter, employeeIDList);

                foreach (BAccountStaffMember staffRow in staffSet)
                {
                    SharedClasses.ItemList employeeSkillList = allStaffSkillList.FirstOrDefault(y => y.itemID == staffRow.BAccountID);
                    if (HasEmployeeItemsSelected(employeeSkillList, skillsSelection) == false && staffRow.Selected == false)
                    {
                        continue;
                    }

                    SharedClasses.ItemList employeeLicenseTypeList = allStaffLicenseTypeList.FirstOrDefault(y => y.itemID == staffRow.BAccountID);
                    if (HasEmployeeItemsSelected(employeeLicenseTypeList, licenseTypesSelection) == false && staffRow.Selected == false)
                    {
                        continue;
                    }

                    yield return(staffRow);
                }
            }
        }
        public static IEnumerable VehicleRecordsDelegate(PXGraph graph, SharedClasses.RouteSelected_view routeSelected, PXFilter <VehicleSelectionFilter> filter)
        {
            if (routeSelected.Current == null)
            {
                yield break;
            }

            List <object> args = new List <object>();

            PXSelectBase <FSVehicle> commandFilter = new PXSelectJoinGroupBy <FSVehicle,
                                                                              LeftJoin <FSRouteDocument,
                                                                                        On <
                                                                                            FSRouteDocument.vehicleID, Equal <FSVehicle.SMequipmentID>,
                                                                                            And <FSRouteDocument.date, Equal <Required <FSRouteDocument.date> > > > >,
                                                                              Where <
                                                                                  FSVehicle.isVehicle, Equal <True> >,
                                                                              Aggregate <
                                                                                  GroupBy <
                                                                                      FSVehicle.SMequipmentID> >,
                                                                              OrderBy <
                                                                                  Asc <FSServiceVehicleType.priorityPreference> > >(graph);

            args.Add(routeSelected.Current.Date);

            if (filter.Current.ShowUnassignedVehicles == true)
            {
                commandFilter.WhereAnd <Where <FSRouteDocument.routeID, IsNull> >();
            }

            var list = commandFilter.Select(args.ToArray());

            foreach (PXResult <FSVehicle, FSRouteDocument> bqlResult in list)
            {
                FSVehicle       fsEquipmentRow     = (FSVehicle)bqlResult;
                FSRouteDocument fsRouteDocumentRow = (FSRouteDocument)bqlResult;

                if (fsRouteDocumentRow != null && fsRouteDocumentRow.RouteID != null)
                {
                    fsEquipmentRow.Mem_UnassignedVehicle = true;
                }

                yield return(bqlResult);
            }
        }
Beispiel #10
0
        public static IEnumerable ServiceRecordsDelegate <ServiceDetType>(
            PXSelectBase <ServiceDetType> servicesView,
            PXSelectBase <EmployeeGridFilter> employeesView,
            PXFilter <ServiceSelectionFilter> filter)
            where ServiceDetType : class, IBqlTable, IFSSODetBase, new()
        {
            if (filter.Current == null)
            {
                yield break;
            }

            PXGraph graph = filter.Cache.Graph;
            PXSelectBase <InventoryItem> cmd = new ServiceRecords_View(graph);

            List <int?> serviceList       = GetServicesInServiceTab <ServiceDetType>(servicesView, null);
            List <int?> employeeSelection = employeesView.Select()
                                            .Where(y => y.GetItem <EmployeeGridFilter>().Mem_Selected == true)
                                            .Select(y => y.GetItem <EmployeeGridFilter>().EmployeeID)
                                            .ToList();

            IEnumerable <InventoryItem> inventoryRecords = GetListWithServicesOnly(cmd, serviceList);

            if (employeeSelection.Count == 0)
            {
                foreach (InventoryItem inventoryRow in inventoryRecords)
                {
                    yield return(inventoryRow);
                }
            }
            else
            {
                List <int?> serviceIDList = inventoryRecords.Select(y => y.InventoryID).ToList();

                //Loading Skill list for each service in inventoryIDList
                List <SharedClasses.ItemList> serviceSkillList = SharedFunctions.GetItemWithList <FSServiceSkill,
                                                                                                  FSServiceSkill.serviceID,
                                                                                                  FSServiceSkill.skillID>(graph, serviceIDList);

                //Loading Skill list for each employee in employeeSelection
                List <SharedClasses.ItemList> employeeSkillList = SharedFunctions.GetItemWithList <FSEmployeeSkill,
                                                                                                   FSEmployeeSkill.employeeID,
                                                                                                   FSEmployeeSkill.skillID>(graph, employeeSelection);

                //Loading License list for each service in inventoryIDList
                List <SharedClasses.ItemList> serviceLicenseList = SharedFunctions.GetItemWithList <FSServiceLicenseType,
                                                                                                    FSServiceLicenseType.serviceID,
                                                                                                    FSServiceLicenseType.licenseTypeID>(graph, serviceIDList);

                //NOTE: TIME info must be removed in order to catch licenses that expire the same day as ScheduledDateTimeBegin
                filter.Current.ScheduledDateTimeBegin = SharedFunctions.RemoveTimeInfo(filter.Current.ScheduledDateTimeBegin);

                //Loading License list for each employee in employeeSelection
                List <SharedClasses.ItemList> employeeLicenseList = SharedFunctions.GetItemWithList <FSLicense,
                                                                                                     FSLicense.employeeID,
                                                                                                     FSLicense.licenseTypeID,
                                                                                                     Where2 <
                                                                                                         Where <Current <ServiceSelectionFilter.scheduledDateTimeBegin>, IsNull>,
                                                                                                         Or <Where <FSLicense.expirationDate, GreaterEqual <Current <ServiceSelectionFilter.scheduledDateTimeBegin> >,
                                                                                                                    And <FSLicense.issueDate, LessEqual <Current <ServiceSelectionFilter.scheduledDateTimeBegin> > > > > > >(graph, employeeSelection);

                foreach (InventoryItem inventoryRow in inventoryRecords)
                {
                    SharedClasses.ItemList inventoryItemSkillList   = null;
                    SharedClasses.ItemList inventoryItemLicenseList = null;

                    if (serviceSkillList.Count != 0)
                    {
                        inventoryItemSkillList = serviceSkillList.FirstOrDefault(y => y.itemID == inventoryRow.InventoryID);
                    }

                    if (serviceLicenseList.Count != 0)
                    {
                        inventoryItemLicenseList = serviceLicenseList.FirstOrDefault(y => y.itemID == inventoryRow.InventoryID);
                    }

                    if ((inventoryItemSkillList == null ||
                         CanThisServiceBeCompleteByTheseEmployeesSkills(inventoryItemSkillList, employeeSkillList)) &&
                        (inventoryItemLicenseList == null ||
                         CanThisServiceBeCompleteByTheseEmployeesLicenses(inventoryItemLicenseList, employeeLicenseList)))
                    {
                        yield return(inventoryRow);
                    }

                    continue;
                }
            }
        }
        public static IEnumerable DriverRecordsDelegate(PXGraph graph, SharedClasses.RouteSelected_view routeSelected, PXFilter <DriverSelectionFilter> filter)
        {
            if (routeSelected.Current == null)
            {
                yield break;
            }

            List <object> args = new List <object>();

            PXSelectBase <EPEmployee> commandFilter = new PXSelectJoinGroupBy <EPEmployee,
                                                                               InnerJoin <FSRouteEmployee,
                                                                                          On <
                                                                                              FSRouteEmployee.employeeID, Equal <EPEmployee.bAccountID> >,
                                                                                          LeftJoin <FSRouteDocument,
                                                                                                    On <
                                                                                                        FSRouteDocument.driverID, Equal <FSRouteEmployee.employeeID>,
                                                                                                        And <FSRouteDocument.date, Equal <Required <FSRouteDocument.date> > > > > >,
                                                                               Where <
                                                                                   FSRouteEmployee.routeID, Equal <Required <FSRouteEmployee.routeID> >,
                                                                                   And <
                                                                                       FSxEPEmployee.sDEnabled, Equal <True>,
                                                                                       And <
                                                                                           FSxEPEmployee.isDriver, Equal <True> > > >,
                                                                               Aggregate <
                                                                                   GroupBy <EPEmployee.bAccountID> >,
                                                                               OrderBy <
                                                                                   Asc <FSRouteEmployee.priorityPreference> > >(graph);

            args.Add(routeSelected.Current.Date);
            args.Add(routeSelected.Current.RouteID);

            if (filter.Current.ShowUnassignedDrivers == true)
            {
                commandFilter.WhereAnd <Where <FSRouteDocument.routeID, IsNull> >();
            }

            var bqlResultSet = commandFilter.Select(args.ToArray());

            foreach (PXResult <EPEmployee, FSRouteEmployee, FSRouteDocument> bqlResult in bqlResultSet)
            {
                EPEmployee      epEmployeeRow      = (EPEmployee)bqlResult;
                FSRouteEmployee fsRouteEmployeeRow = (FSRouteEmployee)bqlResult;
                FSRouteDocument fsRouteDocumentRow = (FSRouteDocument)bqlResult;

                FSxEPEmployee fsxEPEmployeeRow = PXCache <EPEmployee> .GetExtension <FSxEPEmployee>(epEmployeeRow);

                if (fsRouteDocumentRow != null && fsRouteDocumentRow.RouteID != null)
                {
                    fsxEPEmployeeRow.Mem_UnassignedDriver = true;
                }

                yield return(bqlResult);
            }
        }