public virtual void SetBranchLocationID(PXGraph graph, CROpportunity crOpportunityRow, FSxCROpportunity fsxCROpportunityRow)
        {
            if (crOpportunityRow.BranchID != null)
            {
                UserPreferences userPreferencesRow =
                    PXSelect <UserPreferences,
                              Where <
                                  UserPreferences.userID, Equal <CurrentValue <AccessInfo.userID> > > > .Select(graph);

                if (userPreferencesRow != null &&
                    userPreferencesRow.DefBranchID == crOpportunityRow.BranchID)
                {
                    FSxUserPreferences fsxUserPreferencesRow = PXCache <UserPreferences> .GetExtension <FSxUserPreferences>(userPreferencesRow);

                    if (fsxUserPreferencesRow != null)
                    {
                        fsxCROpportunityRow.BranchLocationID = fsxUserPreferencesRow.DfltBranchLocationID;
                    }
                }
                else
                {
                    fsxCROpportunityRow.BranchLocationID = null;
                }
            }
            else
            {
                fsxCROpportunityRow.BranchLocationID = null;
            }
        }
Пример #2
0
        public virtual void UpdateIntervalAndDistance(FSGPSTrackingLocation fsGPSTrackingLocationRow)
        {
            UserPreferences userPreferencesRow = Base.UserPrefs.Current;

            if (userPreferencesRow != null)
            {
                FSxUserPreferences fsxUserPreferencesRow = PXCache <UserPreferences> .GetExtension <FSxUserPreferences>(userPreferencesRow);

                fsGPSTrackingLocationRow.Interval = fsxUserPreferencesRow.Interval ?? 5;
                fsGPSTrackingLocationRow.Distance = fsxUserPreferencesRow.Distance ?? 250;
            }
        }
Пример #3
0
        protected virtual void _(Events.RowSelected <UserPreferences> e)
        {
            if (e.Row == null)
            {
                return;
            }

            UserPreferences userPreferencesRow = e.Row as UserPreferences;
            PXCache         cache = e.Cache;

            FSxUserPreferences fsxUserPreferencesRow = cache.GetExtension <FSxUserPreferences>(userPreferencesRow);

            EnableDisableLocationTracking(cache, userPreferencesRow, fsxUserPreferencesRow);
        }
Пример #4
0
        /// <summary>
        /// Try to get the appropriate ServiceOrderType from this sources:
        /// a. <c>FSServiceOrder</c>
        /// b. <c>FSWrkProcessRow</c>
        /// c. <c>FSSetup</c>
        /// </summary>
        /// <param name="fsWrkProcessRow"><c>FSWrkProcess</c> row.</param>
        /// <param name="fsServiceOrderRow">FSServiceOrder row.</param>
        private static string GetSrvOrdType(PXGraph graph, FSWrkProcess fsWrkProcessRow, FSServiceOrder fsServiceOrderRow)
        {
            // a) Try to retrieve the ServiceOrderType from the ServiceOrder row
            if (fsWrkProcessRow.SOID != null &&
                fsServiceOrderRow != null &&
                !string.IsNullOrEmpty(fsServiceOrderRow.SrvOrdType))
            {
                return(fsServiceOrderRow.SrvOrdType);
            }

            // b) Try to retrieve the ServiceOrderType from the WrkProcess row
            if (!string.IsNullOrEmpty(fsWrkProcessRow.SrvOrdType) &&
                !string.IsNullOrWhiteSpace(fsWrkProcessRow.SrvOrdType))
            {
                return(fsWrkProcessRow.SrvOrdType);
            }

            // c) Try to retrieve the ServiceOrderType from the users preferences
            PX.SM.UserPreferences userPreferencesRow = PXSelect <PX.SM.UserPreferences,
                                                                 Where <
                                                                     PX.SM.UserPreferences.userID, Equal <CurrentValue <AccessInfo.userID> > > >
                                                       .Select(graph);

            if (userPreferencesRow != null)
            {
                FSxUserPreferences fsxUserPreferencesRow = PXCache <PX.SM.UserPreferences> .GetExtension <FSxUserPreferences>(userPreferencesRow);

                if (!string.IsNullOrEmpty(fsxUserPreferencesRow.DfltSrvOrdType))
                {
                    return(fsxUserPreferencesRow.DfltSrvOrdType);
                }
            }


            // d) Try to retrieve the Default ServiceOrderType from the Setup row
            FSSetup fsSetupRow = PXSetup <FSSetup> .Select(graph);

            if (fsSetupRow != null &&
                !string.IsNullOrEmpty(fsSetupRow.DfltSrvOrdType))
            {
                return(fsSetupRow.DfltSrvOrdType);
            }

            return(null);
        }
Пример #5
0
        protected virtual void _(Events.RowInserted <FSGPSTrackingLocation> e)
        {
            if (e.Row == null)
            {
                return;
            }

            FSGPSTrackingLocation fsGPSTrackingLocationRow = e.Row as FSGPSTrackingLocation;
            UserPreferences       userPreferencesRow       = Base.UserPrefs.Current;

            if (userPreferencesRow != null)
            {
                FSxUserPreferences fsxUserPreferencesRow = PXCache <UserPreferences> .GetExtension <FSxUserPreferences>(userPreferencesRow);

                fsGPSTrackingLocationRow.Interval = fsxUserPreferencesRow.Interval;
                fsGPSTrackingLocationRow.Distance = fsxUserPreferencesRow.Distance;
            }
        }
Пример #6
0
        protected virtual void _(Events.FieldUpdated <UserPreferences, FSxUserPreferences.distance> e)
        {
            if (e.Row == null)
            {
                return;
            }

            UserPreferences    userPreferencesRow    = e.Row as UserPreferences;
            FSxUserPreferences fsxUserPreferencesRow = PXCache <UserPreferences> .GetExtension <FSxUserPreferences>(userPreferencesRow);

            if (fsxUserPreferencesRow.Distance != (short)e.OldValue)
            {
                foreach (FSGPSTrackingLocation fsGPSLocationTrackingRow in LocationTracking.Select())
                {
                    fsGPSLocationTrackingRow.Interval = fsxUserPreferencesRow.Distance;
                    LocationTracking.Update(fsGPSLocationTrackingRow);
                }
            }
        }
Пример #7
0
        protected virtual void _(Events.RowPersisting <Users> e)
        {
            if (e.Row == null)
            {
                return;
            }

            Users           usersRow    = e.Row as Users;
            UserPreferences userPrefRow = Base.UserPrefs.Current;

            if (userPrefRow != null)
            {
                FSxUserPreferences fsxUserPreferencesRow = PXCache <UserPreferences> .GetExtension <FSxUserPreferences>(userPrefRow);

                if (fsxUserPreferencesRow != null &&
                    fsxUserPreferencesRow.TrackLocation == true &&
                    (e.Operation == PXDBOperation.Insert || e.Operation == PXDBOperation.Update))
                {
                    if (userPrefRow.TimeZone == null)
                    {
                        Base.UserPrefs.Cache.RaiseExceptionHandling <UserPreferences.timeZone>(
                            userPrefRow,
                            userPrefRow.TimeZone,
                            new PXSetPropertyException(TX.Error.TIME_ZONE_REQUIRED_LOCATION_TRACKING_ENABLED, PXErrorLevel.Error));
                    }
                    else
                    {
                        string timeZone = (string)Base.UserPrefs.Cache.GetValueOriginal <UserPreferences.timeZone>(userPrefRow);

                        if (timeZone != userPrefRow.TimeZone)
                        {
                            foreach (FSGPSTrackingLocation fsGPSTrackingLocationRow in LocationTracking.Select())
                            {
                                fsGPSTrackingLocationRow.TimeZoneID = userPrefRow.TimeZone;
                                LocationTracking.Cache.Update(fsGPSTrackingLocationRow);
                            }
                        }
                    }
                }
            }
        }
Пример #8
0
        private void SetBranchLocationID(PXGraph graph, FSxCRCase fsxCaseRow)
        {
            UserPreferences userPreferencesRow =
                PXSelect <UserPreferences,
                          Where <
                              UserPreferences.userID, Equal <CurrentValue <AccessInfo.userID> > > > .Select(graph);

            if (userPreferencesRow != null)
            {
                FSxUserPreferences fsxUserPreferencesRow = PXCache <UserPreferences> .GetExtension <FSxUserPreferences>(userPreferencesRow);

                if (fsxUserPreferencesRow != null)
                {
                    fsxCaseRow.BranchLocationID = fsxUserPreferencesRow.DfltBranchLocationID;
                }
            }
            else
            {
                fsxCaseRow.BranchLocationID = null;
            }
        }
Пример #9
0
 public virtual void EnableDisableLocationTracking(PXCache cache, UserPreferences userPreferencesRow, FSxUserPreferences fsxUserPreferencesRow)
 {
     PXUIFieldAttribute.SetEnabled <FSxUserPreferences.interval>(cache, userPreferencesRow, fsxUserPreferencesRow.TrackLocation == true);
     PXUIFieldAttribute.SetEnabled <FSxUserPreferences.distance>(cache, userPreferencesRow, fsxUserPreferencesRow.TrackLocation == true);
     LocationTracking.Cache.AllowInsert = fsxUserPreferencesRow.TrackLocation == true;
     LocationTracking.Cache.AllowDelete = fsxUserPreferencesRow.TrackLocation == true;
     LocationTracking.Cache.AllowUpdate = fsxUserPreferencesRow.TrackLocation == true;
 }
Пример #10
0
        protected virtual void _(Events.FieldUpdated <UserPreferences, FSxUserPreferences.trackLocation> e)
        {
            if (e.Row == null)
            {
                return;
            }

            UserPreferences    userPreferencesRow    = e.Row as UserPreferences;
            FSxUserPreferences fsxUserPreferencesRow = e.Cache.GetExtension <FSxUserPreferences>(userPreferencesRow);

            if (fsxUserPreferencesRow != null &&
                fsxUserPreferencesRow.TrackLocation != (bool)e.OldValue)
            {
                if (fsxUserPreferencesRow.TrackLocation == true && LocationTracking.Select().Count == 0)
                {
                    List <FSGPSTrackingLocation> trackingLocations = new List <FSGPSTrackingLocation>();
                    CSCalendar csCalendarRow = UserCalendar.SelectSingle();

                    if (csCalendarRow?.SunWorkDay == true)
                    {
                        trackingLocations.Add(new FSGPSTrackingLocation
                        {
                            WeeklyOnDay1 = true,
                            WeekDay      = 0,
                            StartTime    = csCalendarRow.SunStartTime,
                            EndTime      = csCalendarRow.SunEndTime
                        });
                    }

                    if (csCalendarRow?.MonWorkDay == true)
                    {
                        trackingLocations.Add(new FSGPSTrackingLocation
                        {
                            WeeklyOnDay2 = true,
                            WeekDay      = 1,
                            StartTime    = csCalendarRow.MonStartTime,
                            EndTime      = csCalendarRow.MonEndTime
                        });
                    }

                    if (csCalendarRow?.TueWorkDay == true)
                    {
                        trackingLocations.Add(new FSGPSTrackingLocation
                        {
                            WeeklyOnDay3 = true,
                            WeekDay      = 2,
                            StartTime    = csCalendarRow.TueStartTime,
                            EndTime      = csCalendarRow.TueEndTime
                        });
                    }

                    if (csCalendarRow?.WedWorkDay == true)
                    {
                        trackingLocations.Add(new FSGPSTrackingLocation
                        {
                            WeeklyOnDay4 = true,
                            WeekDay      = 3,
                            StartTime    = csCalendarRow.WedStartTime,
                            EndTime      = csCalendarRow.WedEndTime
                        });
                    }

                    if (csCalendarRow?.ThuWorkDay == true)
                    {
                        trackingLocations.Add(new FSGPSTrackingLocation
                        {
                            WeeklyOnDay5 = true,
                            WeekDay      = 4,
                            StartTime    = csCalendarRow.ThuStartTime,
                            EndTime      = csCalendarRow.ThuEndTime
                        });
                    }

                    if (csCalendarRow?.FriWorkDay == true)
                    {
                        trackingLocations.Add(new FSGPSTrackingLocation
                        {
                            WeeklyOnDay6 = true,
                            WeekDay      = 5,
                            StartTime    = csCalendarRow.FriStartTime,
                            EndTime      = csCalendarRow.FriEndTime
                        });
                    }

                    if (csCalendarRow?.SatWorkDay == true)
                    {
                        trackingLocations.Add(new FSGPSTrackingLocation
                        {
                            WeeklyOnDay7 = true,
                            WeekDay      = 6,
                            StartTime    = csCalendarRow.SatStartTime,
                            EndTime      = csCalendarRow.SatEndTime
                        });
                    }

                    foreach (FSGPSTrackingLocation fsGPSTrackingLocationRow in trackingLocations)
                    {
                        fsGPSTrackingLocationRow.StartDate = Base.Accessinfo.BusinessDate;
                        fsGPSTrackingLocationRow.EndDate   = fsGPSTrackingLocationRow.StartDate.Value.AddYears(1000);
                        fsGPSTrackingLocationRow.Interval  = fsxUserPreferencesRow.Interval;
                        fsGPSTrackingLocationRow.Distance  = fsxUserPreferencesRow.Distance;
                        LocationTracking.Insert(fsGPSTrackingLocationRow);
                    }
                }
                else
                {
                    foreach (FSGPSTrackingLocation fsGPSTrackingLocationRow in LocationTracking.Select())
                    {
                        fsGPSTrackingLocationRow.IsActive = fsxUserPreferencesRow.TrackLocation;
                        LocationTracking.Cache.Update(fsGPSTrackingLocationRow);
                    }
                }

                PXPersistingCheck persistingCheck = fsxUserPreferencesRow.TrackLocation == true ? PXPersistingCheck.NullOrBlank : PXPersistingCheck.Nothing;
                PXDefaultAttribute.SetPersistingCheck <UserPreferences.timeZone>(e.Cache, userPreferencesRow, persistingCheck);
            }
        }