public override int Persist(Type cacheType, PXDBOperation operation) { try { return(base.Persist(cacheType, operation)); } catch (PXDatabaseException e) { if (cacheType == typeof(PaymentMethodAccount) && (operation == PXDBOperation.Delete || operation == PXDBOperation.Command) && (e.ErrorCode == PXDbExceptions.DeleteForeignKeyConstraintViolation || e.ErrorCode == PXDbExceptions.DeleteReferenceConstraintViolation)) { CashAccount ca = PXSelect <CashAccount, Where <CashAccount.cashAccountID, Equal <Required <CashAccount.cashAccountID> > > > . Select(this, e.Keys[1]); string CashAccountCD = ca.CashAccountCD; throw new PXException(Messages.CannotDeletePaymentMethodAccount, e.Keys[0], CashAccountCD); } else { throw; } } }
public PXCommandPreparingEventArgs(object row, object value, PXDBOperation operation, Type table) { _Row = row; _Value = value; _Operation = operation; _Table = table; }
private void CacheEventHandler(PXCache sender, object row, PXDBOperation operation, bool externalCall) { if (row == null) { return; } CSAttributeGroup cSAttributeGroup = (CSAttributeGroup)sender.CreateCopy(row); if (externalCall == true) { if (cSAttributeGroup.EntityType == typeof(TEntity1).FullName) { cSAttributeGroup.EntityType = typeof(TEntity2).FullName; UpdateCacheRecord(sender, cSAttributeGroup, operation); } } else { if (cSAttributeGroup.EntityType == typeof(TEntity2).FullName) { cSAttributeGroup.EntityType = typeof(TEntity3).FullName; UpdateCacheRecord(sender, cSAttributeGroup, operation); } } }
public PXRowPersistedEventArgs(object row, PXDBOperation operation, PXTranStatus tranStatus, Exception exception) { _Row = row; _Operation = operation; _TranStatus = tranStatus; _Exception = exception; }
public PXLockViolationException(Type table, PXDBOperation operation, object[] keys) : base("") { _Table = table; _Operation = operation; _Keys = keys; }
public PXLockViolationException(Type table, PXDBOperation operation, object[] keys, bool deletedDatabaseRecord) : base("") { _Table = table; _Operation = operation; _Keys = keys; _deletedDatabaseRecord = deletedDatabaseRecord; }
public override int Persist(Type cacheType, PXDBOperation operation) { if (cacheType == typeof(INUnit) && operation == PXDBOperation.Update) { base.Persist(cacheType, PXDBOperation.Insert); } return(base.Persist(cacheType, operation)); }
/// <summary> /// Initializes an instance of the <tt>PXCommandPreparingEventArgs</tt> class. /// </summary> /// <param name="row">The data record.</param> /// <param name="value">The field value.</param> /// <param name="operation">The type of the database operation</param> /// <param name="table">The DAC type of the data record.</param> public PXCommandPreparingEventArgs(object row, object value, PXDBOperation operation, Type table, ISqlDialect dialect = null) { _Row = row; _Value = value; _Operation = operation; _Table = table; SqlDialect = dialect; }
public int Persist(Type cacheType, PXDBOperation operation, Func <Type, PXDBOperation, int> basePersist) { if (operation.IsIn(PXDBOperation.Insert, PXDBOperation.Update) && cacheType == typeof(TLineSplit)) { using (new NotDecimalUnitErrorRedirectorScope <TLineSplit, TLineSplitQty, TLine, TLineQty>(Base.Caches <TLine>(), LocateLine)) return(basePersist(cacheType, operation)); } return(basePersist(cacheType, operation)); }
public virtual void CommandPreparing(PXCache sender, PXCommandPreparingEventArgs e) { PXDBOperation command = e.Operation.Command(); if (command == PXDBOperation.Update || command == PXDBOperation.Insert && this.NoInsert) { e.ExcludeFromInsertUpdate(); } }
public override void CommandPreparing(PXCache sender, PXCommandPreparingEventArgs e) { base.CommandPreparing(sender, e); e.BqlTable = _BqlTable; var table = e.Table == null ? _BqlTable : e.Table; e.Expr = new Data.SQLTree.Column(_databaseField, new Data.SQLTree.SimpleTable(table), e.DataType); PXDBOperation command = e.Operation.Command(); if (command == PXDBOperation.Update || command == PXDBOperation.Insert) { object currentValue = sender.GetValue(e.Row, _valueField.Name); if (!Equals(currentValue, _expectedValue)) { e.ExcludeFromInsertUpdate(); } } }
public override int Persist(Type cacheType, PXDBOperation operation) { int res = base.Persist(cacheType, operation); if (cacheType == typeof(BranchBAccount) && operation == PXDBOperation.Update) { foreach (PXResult <NoteDoc, UploadFile> rec in PXSelectJoin <NoteDoc, InnerJoin <UploadFile, On <NoteDoc.fileID, Equal <UploadFile.fileID> > >, Where <NoteDoc.noteID, Equal <Current <BranchBAccount.noteID> > > > .Select(this)) { UploadFile file = (UploadFile)rec; if (file.IsPublic != true) { this.SelectTimeStamp(); file.IsPublic = true; file = (UploadFile)this.Caches[typeof(UploadFile)].Update(file); this.Caches[typeof(UploadFile)].PersistUpdated(file); } } } return(res); }
public static void ValidatePostBatchStatus(PXGraph graph, PXDBOperation dbOperation, string postTo, string createdDocType, string createdRefNbr) { if (dbOperation == PXDBOperation.Update && graph.Accessinfo.ScreenID != SharedFunctions.SetScreenIDToDotFormat(ID.ScreenID.INVOICE_BY_APPOINTMENT) && graph.Accessinfo.ScreenID != SharedFunctions.SetScreenIDToDotFormat(ID.ScreenID.INVOICE_BY_SERVICE_ORDER) ) { FSCreatedDoc fsCreatedDocRow = PXSelectJoin <FSCreatedDoc, InnerJoin <FSPostBatch, On <FSCreatedDoc.batchID, Equal <FSPostBatch.batchID> > >, Where < FSPostBatch.status, Equal <FSPostBatch.status.temporary>, And <FSCreatedDoc.postTo, Equal <Required <FSCreatedDoc.postTo> >, And <FSCreatedDoc.createdDocType, Equal <Required <FSCreatedDoc.createdDocType> >, And <FSCreatedDoc.createdRefNbr, Equal <Required <FSCreatedDoc.createdRefNbr> > > > > > > .Select(graph, postTo, createdDocType, createdRefNbr); if (fsCreatedDocRow != null) { throw new PXException(TX.Error.CANNOT_UPDATE_DOCUMENT_BECAUSE_BATCH_STATUS_IS_TEMPORARY); } } }
private void InsertUpdateDeleteSODet( ServiceOrderEntry graphServiceOrder, PMTimeActivity pmTimeActivityRow, FSxPMTimeActivity fsxPMTimeActivityRow, PXDBOperation operation) { FSSODetService fsSODetServiceRow; graphServiceOrder.ServiceOrderDetServices.Current = graphServiceOrder.ServiceOrderDetServices .Search <FSSODet.sourceNoteID>(pmTimeActivityRow.NoteID); if (graphServiceOrder.ServiceOrderDetServices.Current != null) { if (operation == PXDBOperation.Delete || fsxPMTimeActivityRow.ServiceID == null) { graphServiceOrder.ServiceOrderDetServices.Delete(graphServiceOrder.ServiceOrderDetServices.Current); return; } } else { //This line does not require appointment if (fsxPMTimeActivityRow.ServiceID == null) { return; } //Insert a new SODet line fsSODetServiceRow = new FSSODetService(); //Assign the PMTimeActivity reference to the new FSSODet line fsSODetServiceRow.SourceNoteID = pmTimeActivityRow.NoteID; graphServiceOrder.ServiceOrderDetServices.Current = graphServiceOrder.ServiceOrderDetServices.Insert(fsSODetServiceRow); } //Update the SODet line UpdateSODetServiceRow(graphServiceOrder, graphServiceOrder.ServiceOrderDetServices.Current, pmTimeActivityRow, fsxPMTimeActivityRow); }
public virtual void ValidatePostBatchStatus(PXDBOperation dbOperation, string postTo, string createdDocType, string createdRefNbr) { DocGenerationHelper.ValidatePostBatchStatus(Base, dbOperation, postTo, createdDocType, createdRefNbr); }
private void UpdateCacheRecord(PXCache sender, CSAttributeGroup cSAttributeGroup, PXDBOperation operation) { if (operation == PXDBOperation.Insert) { sender.Insert(cSAttributeGroup); } else if (operation == PXDBOperation.Update) { sender.Update(cSAttributeGroup); } else if (operation == PXDBOperation.Delete) { sender.Delete(cSAttributeGroup); } }
public PXRowPersistingEventArgs(PXDBOperation operation, object row) { _Row = row; _Operation = operation; }
public PXLockViolationException(Type table, PXDBOperation operation, object[] keys) : base("") { _Table = table; _Operation = operation; _Keys = keys; }
public override void CommandPreparing(PXCache sender, PXCommandPreparingEventArgs e) { if (!_IsActive || _Fields == null || !e.IsSelect()) { return; } PXDBOperation eOp = e.Operation & PXDBOperation.Option; bool operationAllowsSelectForXml = eOp == PXDBOperation.External || eOp == PXDBOperation.Internal || eOp == PXDBOperation.Normal && e.Value == null || eOp == PXDBOperation.GroupBy && sender.BqlSelect != null; // it's ok because the subselect will be used inside FROM (...) part without any aggregation Type tableToUse = eOp == PXDBOperation.External ? sender.GetItemType() : e.Table ?? _BqlTable; if (!_BqlTable.IsAssignableFrom(sender.BqlTable)) { if (sender.Graph.Caches[_BqlTable].BqlSelect != null && operationAllowsSelectForXml) { e.BqlTable = _BqlTable; e.Expr = new Column(_DatabaseFieldName, (e.Operation & PXDBOperation.Option) == PXDBOperation.External ? sender.GetItemType() : _BqlTable); } else { PXCommandPreparingEventArgs.FieldDescription description; sender.Graph.Caches[_BqlTable].RaiseCommandPreparing(_DatabaseFieldName, e.Row, e.Value, e.Operation, e.Table, out description); if (description != null) { e.DataType = description.DataType; e.DataValue = description.DataValue; e.BqlTable = _BqlTable; e.Expr = description.Expr; } } } else { var dialect = e.SqlDialect; if (operationAllowsSelectForXml) { if (aggregateAttributes && (e.Operation & PXDBOperation.Option) != PXDBOperation.External) { List <Type> init = new List <Type>() { tableToUse }; e.BqlTable = tableToUse; e.DataType = PXDbType.NVarChar; e.Expr = new SQLTree.SubQuery(GetAttributesJoinedQuery(sender.Graph, init, ((IBqlSearch)_SingleSelect).GetField(), _PureWhere)); return; } else { e.BqlTable = _BqlTable; Query q = new Query().Field(new SQLConst(_Fields.Length)); e.Expr = new SubQuery(q); } } else { e.Expr = SQLExpression.Null(); } } e.DataType = PXDbType.Int; e.DataLength = 4; }
public PXRowPersistedEventArgs(object row, PXDBOperation operation, PXTranStatus tranStatus, Exception exception) { _Row = row; _Operation = operation; _TranStatus = tranStatus; _Exception = exception; }
public PXCommandPreparingEventArgs(object row, object value, PXDBOperation operation, Type table) { _Row = row; _Value = value; _Operation = operation; _Table = table; }
public PXRowPersistingEventArgs(PXDBOperation operation, object row) { _Row = row; _Operation = operation; }
private void UpdateServiceOrderDetail(PXCache cache, CRActivity crActivityRow, PXDBOperation operation) { FSServiceOrder fsServiceOrderRow = GetServiceOrderRecord(cache.Graph, crActivityRow); if (fsServiceOrderRow != null) { PMTimeActivity pmTimeActivityRow = PXSelect <PMTimeActivity, Where < PMTimeActivity.refNoteID, Equal <Required <PMTimeActivity.refNoteID> > > > .Select(Base, crActivityRow.NoteID); if (pmTimeActivityRow == null) { return; } FSxPMTimeActivity fsxPMTimeActivityRow = PXCache <PMTimeActivity> .GetExtension <FSxPMTimeActivity>(pmTimeActivityRow); //Show note if AutoShowNote is true if (fsxPMTimeActivityRow != null) { SharedFunctions.ShowServiceOrderNote(operation, Base.BaseBAccount.View, fsxPMTimeActivityRow.ServiceID); } ServiceOrderEntry graphServiceOrder = PXGraph.CreateInstance <ServiceOrderEntry>(); //Load existing ServiceOrder graphServiceOrder.ServiceOrderRecords.Current = graphServiceOrder.ServiceOrderRecords .Search <FSServiceOrder.refNbr>(fsServiceOrderRow.RefNbr, fsServiceOrderRow.SrvOrdType); //Update ServiceOrder detail InsertUpdateDeleteSODet(graphServiceOrder, pmTimeActivityRow, fsxPMTimeActivityRow, operation); if (graphServiceOrder.IsDirty) { graphServiceOrder.Save.Press(); } } }
public override void CommandPreparing(PXCache sender, PXCommandPreparingEventArgs e) { if (!_IsActive || _Fields == null || !e.IsSelect()) { return; } PXDBOperation eOp = e.Operation & PXDBOperation.Option; bool operationAllowsSelectForXml = eOp == PXDBOperation.External || eOp == PXDBOperation.Internal || eOp == PXDBOperation.Normal && e.Value == null || eOp == PXDBOperation.GroupBy && sender.BqlSelect != null; // it's ok because the subselect will be used inside FROM (...) part without any aggregation Type tableToUse = eOp == PXDBOperation.External ? sender.GetItemType() : e.Table ?? _BqlTable; if (!_BqlTable.IsAssignableFrom(sender.BqlTable)) { if (sender.Graph.Caches[_BqlTable].BqlSelect != null && operationAllowsSelectForXml) { e.BqlTable = _BqlTable; e.FieldName = ((e.Operation & PXDBOperation.Option) == PXDBOperation.External ? sender.GetItemType().Name : _BqlTable.Name) + '.' + _DatabaseFieldName; } else { PXCommandPreparingEventArgs.FieldDescription description; sender.Graph.Caches[_BqlTable].RaiseCommandPreparing(_DatabaseFieldName, e.Row, e.Value, e.Operation, e.Table, out description); if (description != null) { e.DataType = description.DataType; e.DataValue = description.DataValue; e.BqlTable = _BqlTable; e.FieldName = description.FieldName; } } } else { var dialect = e.SqlDialect; if (operationAllowsSelectForXml) { if (aggregateAttributes && (e.Operation & PXDBOperation.Option) != PXDBOperation.External) { List <Type> init = new List <Type>() { tableToUse }; StringBuilder bld = new StringBuilder(); dialect.prepareAttributesJoined(sender.Graph, bld, init, ((IBqlSearch)_SingleSelect).GetField(), _PureWhere); e.FieldName = bld.ToString(); e.DataType = PXDbType.NVarChar; return; } else { e.BqlTable = _BqlTable; e.FieldName = BqlCommand.SubSelect + _Fields.Length + ')'; } } else { e.FieldName = BqlCommand.Null; } } e.DataType = PXDbType.Int; e.DataLength = 4; }
public override int Persist(Type cacheType, PXDBOperation operation) { //this graph should not be persisted. its an emulation.base.Persist(); return(1); }
public PXLockViolationException(Type table, PXDBOperation operation, object[] keys) : this(table, operation, keys, false) { }
public static PXDBOperation Place(this PXDBOperation self) => self & PXDBOperation.Place;
public static PXDBOperation Command(this PXDBOperation self) => self & PXDBOperation.Command;
public static PXDBOperation Option(this PXDBOperation self) => self & PXDBOperation.Option;