protected virtual void _(Events.RowPersisting <FSGPSTrackingLocation> e) { if (e.Row == null) { return; } FSGPSTrackingLocation fsGPSTrackingLocationRow = e.Row as FSGPSTrackingLocation; if (e.Operation == PXDBOperation.Insert || e.Operation == PXDBOperation.Update) { SetWeeklyOnDayFlag(fsGPSTrackingLocationRow); UpdateIntervalAndDistance(fsGPSTrackingLocationRow); // @TODO: This must be a configuring setting? if (e.Operation == PXDBOperation.Insert) { fsGPSTrackingLocationRow.StartDate = Base.Accessinfo.BusinessDate; fsGPSTrackingLocationRow.EndDate = fsGPSTrackingLocationRow.StartDate.Value.AddYears(1000); } if (fsGPSTrackingLocationRow.TimeZoneID == null) { Base.UserPrefs.Cache.RaiseExceptionHandling <UserPreferences.timeZone>( Base.UserPrefs.Current, Base.UserPrefs.Current.TimeZone, new PXSetPropertyException(TX.Error.TIME_ZONE_REQUIRED_LOCATION_TRACKING_ENABLED, PXErrorLevel.Error)); e.Cache.RaiseExceptionHandling <FSGPSTrackingLocation.weekDay>( fsGPSTrackingLocationRow, fsGPSTrackingLocationRow.WeekDay, new PXSetPropertyException(TX.Error.TIME_ZONE_REQUIRED_LOCATION_TRACKING_ENABLED, PXErrorLevel.RowError)); } } }
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; } }
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; } }
protected virtual void _(Events.RowSelecting <FSGPSTrackingLocation> e) { if (e.Row == null) { return; } FSGPSTrackingLocation fsGPSTrackingLocationRow = e.Row as FSGPSTrackingLocation; if (fsGPSTrackingLocationRow.WeeklyOnDay1 == true) { fsGPSTrackingLocationRow.WeekDay = (int?)DayOfWeek.Sunday; } else if (fsGPSTrackingLocationRow.WeeklyOnDay2 == true) { fsGPSTrackingLocationRow.WeekDay = (int?)DayOfWeek.Monday; } else if (fsGPSTrackingLocationRow.WeeklyOnDay3 == true) { fsGPSTrackingLocationRow.WeekDay = (int?)DayOfWeek.Tuesday; } else if (fsGPSTrackingLocationRow.WeeklyOnDay4 == true) { fsGPSTrackingLocationRow.WeekDay = (int?)DayOfWeek.Wednesday; } else if (fsGPSTrackingLocationRow.WeeklyOnDay5 == true) { fsGPSTrackingLocationRow.WeekDay = (int?)DayOfWeek.Thursday; } else if (fsGPSTrackingLocationRow.WeeklyOnDay6 == true) { fsGPSTrackingLocationRow.WeekDay = (int?)DayOfWeek.Friday; } else if (fsGPSTrackingLocationRow.WeeklyOnDay7 == true) { fsGPSTrackingLocationRow.WeekDay = (int?)DayOfWeek.Saturday; } }
public virtual void SetWeeklyOnDayFlag(FSGPSTrackingLocation fsGPSTrackingLocationRow) { switch (fsGPSTrackingLocationRow.WeekDay) { case (int?)DayOfWeek.Monday: fsGPSTrackingLocationRow.WeeklyOnDay1 = false; fsGPSTrackingLocationRow.WeeklyOnDay2 = true; fsGPSTrackingLocationRow.WeeklyOnDay3 = false; fsGPSTrackingLocationRow.WeeklyOnDay4 = false; fsGPSTrackingLocationRow.WeeklyOnDay5 = false; fsGPSTrackingLocationRow.WeeklyOnDay6 = false; fsGPSTrackingLocationRow.WeeklyOnDay7 = false; break; case (int?)DayOfWeek.Tuesday: fsGPSTrackingLocationRow.WeeklyOnDay1 = false; fsGPSTrackingLocationRow.WeeklyOnDay2 = false; fsGPSTrackingLocationRow.WeeklyOnDay3 = true; fsGPSTrackingLocationRow.WeeklyOnDay4 = false; fsGPSTrackingLocationRow.WeeklyOnDay5 = false; fsGPSTrackingLocationRow.WeeklyOnDay6 = false; fsGPSTrackingLocationRow.WeeklyOnDay7 = false; break; case (int?)DayOfWeek.Wednesday: fsGPSTrackingLocationRow.WeeklyOnDay1 = false; fsGPSTrackingLocationRow.WeeklyOnDay2 = false; fsGPSTrackingLocationRow.WeeklyOnDay3 = false; fsGPSTrackingLocationRow.WeeklyOnDay4 = true; fsGPSTrackingLocationRow.WeeklyOnDay5 = false; fsGPSTrackingLocationRow.WeeklyOnDay6 = false; fsGPSTrackingLocationRow.WeeklyOnDay7 = false; break; case (int?)DayOfWeek.Thursday: fsGPSTrackingLocationRow.WeeklyOnDay1 = false; fsGPSTrackingLocationRow.WeeklyOnDay2 = false; fsGPSTrackingLocationRow.WeeklyOnDay3 = false; fsGPSTrackingLocationRow.WeeklyOnDay4 = false; fsGPSTrackingLocationRow.WeeklyOnDay5 = true; fsGPSTrackingLocationRow.WeeklyOnDay6 = false; fsGPSTrackingLocationRow.WeeklyOnDay7 = false; break; case (int?)DayOfWeek.Friday: fsGPSTrackingLocationRow.WeeklyOnDay1 = false; fsGPSTrackingLocationRow.WeeklyOnDay2 = false; fsGPSTrackingLocationRow.WeeklyOnDay3 = false; fsGPSTrackingLocationRow.WeeklyOnDay4 = false; fsGPSTrackingLocationRow.WeeklyOnDay5 = false; fsGPSTrackingLocationRow.WeeklyOnDay6 = true; fsGPSTrackingLocationRow.WeeklyOnDay7 = false; break; case (int?)DayOfWeek.Saturday: fsGPSTrackingLocationRow.WeeklyOnDay1 = false; fsGPSTrackingLocationRow.WeeklyOnDay2 = false; fsGPSTrackingLocationRow.WeeklyOnDay3 = false; fsGPSTrackingLocationRow.WeeklyOnDay4 = false; fsGPSTrackingLocationRow.WeeklyOnDay5 = false; fsGPSTrackingLocationRow.WeeklyOnDay6 = false; fsGPSTrackingLocationRow.WeeklyOnDay7 = true; break; default: fsGPSTrackingLocationRow.WeeklyOnDay1 = true; fsGPSTrackingLocationRow.WeeklyOnDay2 = false; fsGPSTrackingLocationRow.WeeklyOnDay3 = false; fsGPSTrackingLocationRow.WeeklyOnDay4 = false; fsGPSTrackingLocationRow.WeeklyOnDay5 = false; fsGPSTrackingLocationRow.WeeklyOnDay6 = false; fsGPSTrackingLocationRow.WeeklyOnDay7 = false; break; } }