Пример #1
0
        /// <summary>
        /// update the order modify time, but dont save it. this will be used as a message to
        /// re-process the order
        /// </summary>
        /// <param name="utcModTime"></param>
        /// <param name="workingOrderId"></param>
        private static void UpdateOrderModifyTime(DateTime utcModTime, Guid workingOrderId)
        {
            using (TransactionScope transactionScope = new TransactionScope())
            {
                // This provides a context for any transactions.
                DataModelTransaction dataModelTransaction = DataModelTransaction.Current;
                WorkingOrderRow      workingOrderRow      = DataModel.WorkingOrder.WorkingOrderKey.Find(workingOrderId);
                if (workingOrderRow == null)
                {
                    return;
                }

                DataModel dataModel = new DataModel();
                workingOrderRow.AcquireWriterLock(dataModelTransaction.TransactionId, DataModel.LockTimeout);
                try
                {
                    if (workingOrderRow.RowState == System.Data.DataRowState.Deleted ||
                        workingOrderRow.RowState == System.Data.DataRowState.Detached)
                    {
                        return;
                    }

                    DataModel.DataLock.EnterWriteLock();
                    try
                    {
                        workingOrderRow.BeginEdit();
                        workingOrderRow[DataModel.WorkingOrder.ModifiedTimeColumn] = utcModTime;
                    }
                    finally
                    {
                        workingOrderRow.EndEdit();
                        workingOrderRow.RejectChanges();
                        DataModel.DataLock.ExitWriteLock();
                    }
                }
                finally
                {
                    workingOrderRow.ReleaseWriterLock(dataModelTransaction.TransactionId);
                }
            }
        }