public override void RowPersisting(PXCache sender, PXRowPersistingEventArgs e) { if (_IsIntegrityCheck == false) { if ((e.Operation & PXDBOperation.Command) != PXDBOperation.Delete) { object key = sender.GetValue(e.Row, _FieldOrdinal); PXCache cache = sender.Graph.Caches[typeof(CATran)]; CATran info = null; if (key != null) { info = PXSelect <CATran, Where <CATran.tranID, Equal <Required <CATran.tranID> > > > .Select(sender.Graph, key); if (info == null) { key = null; sender.SetValue(e.Row, _FieldOrdinal, null); } } if (info != null && !IsCreationNeeded((CADeposit)e.Row)) { cache.Delete(info); cache.PersistDeleted(info); } } base.RowPersisting(sender, e); } }
public override void RowPersisting(PXCache sender, PXRowPersistingEventArgs e) { object key; if (IsTopLevel && (key = sender.GetValue(e.Row, FieldName)) != null) { PXCache cache = sender.Graph.Caches[typeof(CurrencyInfo)]; CurrencyInfo info = (CurrencyInfo)cache.Locate(new CurrencyInfo { CuryInfoID = Convert.ToInt64(key) }); PXEntryStatus status = PXEntryStatus.Notchanged; if (info != null && ((status = cache.GetStatus(info)) == PXEntryStatus.Inserted)) { cache.PersistInserted(info); } else if (status == PXEntryStatus.Updated) { cache.PersistUpdated(info); } else if (status == PXEntryStatus.Deleted) { cache.PersistDeleted(info); } } base.RowPersisting(sender, e); }
protected virtual void ARInvoice_RowPersisting(PXCache sender, PXRowPersistingEventArgs e) { sender.Persist(e.Row, PXDBOperation.Normal); sender.PersistInserted(e.Row); sender.PersistUpdated(e.Row); sender.PersistDeleted(e.Row); }
public virtual IEnumerable GenerateProjection(PXAdapter adapter) { if (RouteAppointmentForecastingFilter.Current != null && RouteAppointmentForecastingFilter.Current.DateBegin != null && RouteAppointmentForecastingFilter.Current.DateEnd != null && RouteAppointmentForecastingFilter.Current.DateBegin < RouteAppointmentForecastingFilter.Current.DateEnd) { DateTime beginFromFilter = RouteAppointmentForecastingFilter.Current.DateBegin.Value; DateTime endToFilter = RouteAppointmentForecastingFilter.Current.DateEnd.Value; string recordType = ID.RecordType_ServiceContract.ROUTE_SERVICE_CONTRACT; int?serviceID = RouteAppointmentForecastingFilter.Current.ServiceID; int?customerID = RouteAppointmentForecastingFilter.Current.CustomerID; int?customerLocationID = RouteAppointmentForecastingFilter.Current.CustomerLocationID; int?routeID = RouteAppointmentForecastingFilter.Current.RouteID; PXLongOperation.StartOperation( this, delegate { using (PXTransactionScope ts = new PXTransactionScope()) { if (beginFromFilter != null && endToFilter != null) { DateHandler requestDate = new DateHandler(endToFilter); var period = new Period((DateTime)beginFromFilter, (DateTime)endToFilter); List <Scheduler.Schedule> scheduleListToProcess = new List <Scheduler.Schedule>(); var generator = new TimeSlotGenerator(); var fsRouteContractScheduleRecords = PXSelectJoinGroupBy <FSRouteContractSchedule, InnerJoin <FSServiceContract, On <FSServiceContract.serviceContractID, Equal <FSRouteContractSchedule.entityID> >, InnerJoin <FSScheduleRoute, On <FSScheduleRoute.scheduleID, Equal <FSRouteContractSchedule.scheduleID> >, InnerJoin <FSScheduleDet, On <FSScheduleDet.scheduleID, Equal <FSRouteContractSchedule.scheduleID> > > > >, Where < FSRouteContractSchedule.entityType, Equal <FSSchedule.entityType.Contract>, And <FSServiceContract.recordType, Equal <FSServiceContract.recordType.RouteServiceContract>, And <FSRouteContractSchedule.active, Equal <True>, And <FSServiceContract.status, Equal <FSServiceContract.status.Active>, And <FSRouteContractSchedule.startDate, LessEqual <Required <FSRouteContractSchedule.startDate> >, And2 < Where < Required <FSScheduleDet.inventoryID>, IsNull, Or <FSScheduleDet.inventoryID, Equal <Required <FSScheduleDet.inventoryID> > > >, And2 < Where < Required <FSRouteContractSchedule.customerID>, IsNull, Or <FSRouteContractSchedule.customerID, Equal <Required <FSRouteContractSchedule.customerID> > > >, And2 < Where < Required <FSRouteContractSchedule.customerLocationID>, IsNull, Or <FSRouteContractSchedule.customerLocationID, Equal <Required <FSRouteContractSchedule.customerLocationID> > > >, And2 < Where < Required <FSScheduleRoute.dfltRouteID>, IsNull, Or <FSScheduleRoute.dfltRouteID, Equal <Required <FSScheduleRoute.dfltRouteID> > > >, And < Where <FSRouteContractSchedule.endDate, IsNull, Or <FSRouteContractSchedule.endDate, GreaterEqual <Required <FSRouteContractSchedule.startDate> > > > > > > > > > > > > >, Aggregate < GroupBy <FSRouteContractSchedule.scheduleID> > > .Select(this, beginFromFilter, serviceID, serviceID, customerID, customerID, customerLocationID, customerLocationID, routeID, routeID, endToFilter); foreach (FSRouteContractSchedule fsRouteContractScheduleRecord in fsRouteContractScheduleRecords) { List <Scheduler.Schedule> mapScheduleResults = MapFSScheduleToSchedule.convertFSScheduleToSchedule(RouteAppointmentForecastingFilter.Cache, fsRouteContractScheduleRecord, endToFilter, recordType); foreach (Scheduler.Schedule mapSchedule in mapScheduleResults) { scheduleListToProcess.Add(mapSchedule); } } if (recordType == ID.RecordType_ServiceContract.ROUTE_SERVICE_CONTRACT) { foreach (Scheduler.Schedule schedule in scheduleListToProcess) { schedule.Priority = (int?)RouteScheduleProcess.SetSchedulePriority(schedule, this); schedule.RouteInfoList = RouteScheduleProcess.getRouteListFromSchedule(schedule, this); } } List <TimeSlot> timeSlots = generator.GenerateCalendar(period, scheduleListToProcess); var fsRouteAppointmentForecastingRecords = PXSelect <FSRouteAppointmentForecasting, Where < FSRouteAppointmentForecasting.startDate, GreaterEqual <Required <FSRouteAppointmentForecasting.startDate> >, And < FSRouteAppointmentForecasting.startDate, LessEqual <Required <FSRouteAppointmentForecasting.startDate> > > > > .Select(this, beginFromFilter, endToFilter); PXCache <FSRouteAppointmentForecasting> cacheRouteForecasting = new PXCache <FSRouteAppointmentForecasting>(this); foreach (FSRouteAppointmentForecasting fsRouteAppointmentDetailProjectionRecord in fsRouteAppointmentForecastingRecords) { cacheRouteForecasting.PersistDeleted(fsRouteAppointmentDetailProjectionRecord); } foreach (TimeSlot timeSlot in timeSlots) { requestDate.setDate(timeSlot.DateTimeBegin); FSSchedule fsScheduleRow = ScheduleSelected.Select(timeSlot.ScheduleID); FSScheduleRoute fsScheduleRouteRow = ScheduleRouteSelected.Select(fsScheduleRow.ScheduleID); FSServiceContract fsServiceContractRow = ServiceContractSelected.Select(fsScheduleRow.EntityID); FSRouteAppointmentForecasting fsRouteAppointmentForecastingRow = new FSRouteAppointmentForecasting(); fsRouteAppointmentForecastingRow.RouteID = fsScheduleRouteRow.DfltRouteID; fsRouteAppointmentForecastingRow.StartDate = requestDate.StartOfDay(); fsRouteAppointmentForecastingRow.ScheduleID = fsScheduleRow.ScheduleID; fsRouteAppointmentForecastingRow.ServiceContractID = fsServiceContractRow.ServiceContractID; fsRouteAppointmentForecastingRow.CustomerLocationID = fsServiceContractRow.CustomerLocationID; fsRouteAppointmentForecastingRow.CustomerID = fsServiceContractRow.CustomerID; fsRouteAppointmentForecastingRow.SequenceOrder = int.Parse(fsScheduleRouteRow.GlobalSequence); cacheRouteForecasting.PersistInserted(fsRouteAppointmentForecastingRow); } } ts.Complete(); } }); } return(adapter.Get()); }
public virtual void RowPersisting(PXCache sender, PXRowPersistingEventArgs e) { object key = sender.GetValue(e.Row, _FieldOrdinal); PXCache cache = sender.Graph.Caches[typeof(CATran)]; CATran info = null; if (key != null) { //do not read cached record in release processes if ((info = PXSelectReadonly <CATran, Where <CATran.tranID, Equal <Required <CATran.tranID> > > > .Select(sender.Graph, key)) != null) { CATran cached = (CATran)cache.Locate(info); if (cached != null) { if ((cached.OrigModule != null && info.OrigModule != null && cached.OrigModule != info.OrigModule) || (cached.OrigRefNbr != null && info.OrigRefNbr != null && cached.OrigRefNbr != info.OrigRefNbr) || (cached.OrigTranType != null && info.OrigTranType != null && cached.OrigTranType != info.OrigTranType)) { // TO Be removed after solving CATran issue (check JIRA item AC-57875 for details) throw new PXException(Messages.CouldNotInsertCATran); } if (cache.GetStatus(cached) == PXEntryStatus.Notchanged) { PXCache <CATran> .RestoreCopy(cached, info); } info = cached; } else { cache.SetStatus(info, PXEntryStatus.Notchanged); } } if ((long)key < 0L && info == null) { info = new CATran(); info.TranID = (long)key; info = (CATran)cache.Locate(info); } if (info == null) { key = null; sender.SetValue(e.Row, _FieldOrdinal, null); } } if ((e.Operation & PXDBOperation.Command) == PXDBOperation.Delete) { if (info != null) { cache.Delete(info); cache.PersistDeleted(info); } } else if (info == null) { if (!this.NeedPreventCashTransactionCreation(sender, e.Row)) { info = DefaultValues(sender, new CATran(), e.Row); if (info != null) { info = (CATran)cache.Insert(info); if (!(info.TranID < 0L)) { throw new PXException(Messages.CouldNotInsertCATran); } // TO Be removed after solving CATran issue (check JIRA item AC-57875 for details) sender.SetValue(e.Row, _FieldOrdinal, info.TranID); _KeyToAbort = info.TranID; cache.PersistInserted(info); long id = info.TranID ?? 0; if (id == 0 || id < 0) { throw new PXException(Messages.CATranNotSaved, sender.GetItemType().Name); } sender.SetValue(e.Row, _FieldOrdinal, id); info.TranID = id; cache.Normalize(); } } } else if (info.TranID < 0L) { info = DefaultValues(sender, PXCache <CATran> .CreateCopy(info), e.Row); if (info != null) { info = (CATran)cache.Update(info); sender.SetValue(e.Row, _FieldOrdinal, info.TranID); _KeyToAbort = info.TranID; cache.PersistInserted(info); long id = info.TranID ?? 0; if (id == 0 || id < 0) { throw new PXException(Messages.CATranNotSaved, sender.GetItemType().Name); } sender.SetValue(e.Row, _FieldOrdinal, id); info.TranID = id; cache.Normalize(); } } else { CATran copy = PXCache <CATran> .CreateCopy(info); copy = DefaultValues(sender, copy, e.Row); if (copy != null) { if ((copy.OrigModule != null && info.OrigModule != null && copy.OrigModule != info.OrigModule) || (copy.OrigRefNbr != null && info.OrigRefNbr != null && copy.OrigRefNbr != info.OrigRefNbr) || (copy.OrigTranType != null && info.OrigTranType != null && copy.OrigTranType != info.OrigTranType)) { // TO Be removed after solving CATran issue (check JIRA item AC-57875 for details) throw new PXException(Messages.CouldNotInsertCATran); } info = (CATran)cache.Update(copy); //to avoid another process updated DefaultValues will return null for Released docs, except for GLTran cache.PersistUpdated(info); } //JournalEntry is usually persisted prior to ReleaseGraph to obtain BatchNbr reference, read info should contain set Released flag else if (info.Released == false) { key = null; sender.SetValue(e.Row, _FieldOrdinal, null); cache.Delete(info); } } foreach (CATran toDelete in cache.Deleted) { cache.PersistDeleted(toDelete); } }
protected virtual void ARInvoice_RowDeleted(PXCache sender, PXRowDeletedEventArgs e) { sender.PersistDeleted(e.Row); }