本文整理汇总了C#中EntitySpaces.Interfaces.esDataRequest.FireOnError方法的典型用法代码示例。如果您正苦于以下问题:C# esDataRequest.FireOnError方法的具体用法?C# esDataRequest.FireOnError怎么用?C# esDataRequest.FireOnError使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类EntitySpaces.Interfaces.esDataRequest
的用法示例。
在下文中一共展示了esDataRequest.FireOnError方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: SaveDynamicCollection_InsertsUpdates
private static DataTable SaveDynamicCollection_InsertsUpdates(esDataRequest request)
{
DataTable dataTable = CreateDataTable(request);
using (esTransactionScope scope = new esTransactionScope())
{
using (SADataAdapter da = new SADataAdapter())
{
da.AcceptChangesDuringUpdate = false;
da.ContinueUpdateOnError = request.ContinueUpdateOnError;
SACommand cmd = null;
if (!request.IgnoreComputedColumns)
{
da.RowUpdated += new SARowUpdatedEventHandler(OnRowUpdated);
}
foreach (esEntitySavePacket packet in request.CollectionSavePacket)
{
if (packet.RowState != esDataRowState.Added && packet.RowState != esDataRowState.Modified) continue;
DataRow row = dataTable.NewRow();
dataTable.Rows.Add(row);
switch (packet.RowState)
{
case esDataRowState.Added:
cmd = da.InsertCommand = Shared.BuildDynamicInsertCommand(request, packet.ModifiedColumns);
SetModifiedValues(request, packet, row);
break;
case esDataRowState.Modified:
cmd = da.UpdateCommand = Shared.BuildDynamicUpdateCommand(request, packet.ModifiedColumns);
SetOriginalValues(request, packet, row, false);
SetModifiedValues(request, packet, row);
row.AcceptChanges();
row.SetModified();
break;
}
request.Properties["esDataRequest"] = request;
request.Properties["esEntityData"] = packet;
dataTable.ExtendedProperties["props"] = request.Properties;
DataRow[] singleRow = new DataRow[1];
singleRow[0] = row;
try
{
esTransactionScope.Enlist(cmd, request.ConnectionString, CreateIDbConnectionDelegate);
#region Profiling
if (sTraceHandler != null)
{
using (esTraceArguments esTrace = new esTraceArguments(request, cmd, packet, "SaveCollectionDynamic", System.Environment.StackTrace))
{
try
{
da.Update(singleRow);
}
catch (Exception ex)
{
esTrace.Exception = ex.Message;
throw;
}
}
}
else
#endregion Profiling
{
da.Update(singleRow);
}
if (row.HasErrors)
{
request.FireOnError(packet, row.RowError);
}
}
finally
{
esTransactionScope.DeEnlist(cmd);
dataTable.Rows.Clear();
}
}
}
scope.Complete();
}
return dataTable;
}
示例2: SaveStoredProcCollection
//.........这里部分代码省略.........
{
DataRow row = dataTable.NewRow();
switch (request.EntitySavePacket.RowState)
{
case esDataRowState.Added:
SetModifiedValues(request, packet, row);
dataTable.Rows.Add(row);
if (request.ContinueUpdateOnError) rowMapping[row] = packet;
break;
case esDataRowState.Modified:
SetOriginalValues(request, packet, row, false);
SetModifiedValues(request, packet, row);
dataTable.Rows.Add(row);
row.AcceptChanges();
row.SetModified();
if (request.ContinueUpdateOnError) rowMapping[row] = packet;
break;
case esDataRowState.Deleted:
SetOriginalValues(request, packet, row, true);
dataTable.Rows.Add(row);
row.AcceptChanges();
row.Delete();
if (request.ContinueUpdateOnError) rowMapping[row] = packet;
break;
}
}
if (Shared.HasUpdates(dataTable.Rows, out needToInsert, out needToUpdate, out needToDelete))
{
using (SADataAdapter da = new SADataAdapter())
{
da.AcceptChangesDuringUpdate = false;
da.ContinueUpdateOnError = request.ContinueUpdateOnError;
SACommand cmd = null;
if (needToInsert) da.InsertCommand = cmd = Shared.BuildStoredProcInsertCommand(request);
if (needToUpdate) da.UpdateCommand = cmd = Shared.BuildStoredProcUpdateCommand(request);
if (needToDelete) da.DeleteCommand = cmd = Shared.BuildStoredProcDeleteCommand(request);
using (esTransactionScope scope = new esTransactionScope())
{
if (needToInsert) esTransactionScope.Enlist(da.InsertCommand, request.ConnectionString, CreateIDbConnectionDelegate);
if (needToUpdate) esTransactionScope.Enlist(da.UpdateCommand, request.ConnectionString, CreateIDbConnectionDelegate);
if (needToDelete) esTransactionScope.Enlist(da.DeleteCommand, request.ConnectionString, CreateIDbConnectionDelegate);
try
{
#region Profiling
if (sTraceHandler != null)
{
using (esTraceArguments esTrace = new esTraceArguments(request, cmd, "SaveCollectionStoredProcedure", System.Environment.StackTrace))
{
try
{
da.Update(dataTable);
}
catch (Exception ex)
{
esTrace.Exception = ex.Message;
throw;
}
}
}
else
#endregion Profiling
{
da.Update(dataTable);
}
}
finally
{
if (needToInsert) esTransactionScope.DeEnlist(da.InsertCommand);
if (needToUpdate) esTransactionScope.DeEnlist(da.UpdateCommand);
if (needToDelete) esTransactionScope.DeEnlist(da.DeleteCommand);
}
scope.Complete();
}
}
if (request.ContinueUpdateOnError && dataTable.HasErrors)
{
DataRow[] errors = dataTable.GetErrors();
foreach (DataRow rowWithError in errors)
{
request.FireOnError(rowMapping[rowWithError], rowWithError.RowError);
}
}
}
return request.Table;
}
示例3: SaveDynamicCollection_Deletes
private static DataTable SaveDynamicCollection_Deletes(esDataRequest request)
{
SACommand cmd = null;
DataTable dataTable = CreateDataTable(request);
using (esTransactionScope scope = new esTransactionScope())
{
using (SADataAdapter da = new SADataAdapter())
{
da.AcceptChangesDuringUpdate = false;
da.ContinueUpdateOnError = request.ContinueUpdateOnError;
try
{
da.ContinueUpdateOnError = request.ContinueUpdateOnError;
cmd = da.DeleteCommand = Shared.BuildDynamicDeleteCommand(request, request.CollectionSavePacket[0]);
esTransactionScope.Enlist(cmd, request.ConnectionString, CreateIDbConnectionDelegate);
DataRow[] singleRow = new DataRow[1];
// Delete each record
foreach (esEntitySavePacket packet in request.CollectionSavePacket)
{
DataRow row = dataTable.NewRow();
dataTable.Rows.Add(row);
SetOriginalValues(request, packet, row, true);
row.AcceptChanges();
row.Delete();
singleRow[0] = row;
#region Profiling
if (sTraceHandler != null)
{
using (esTraceArguments esTrace = new esTraceArguments(request, cmd, packet, "SaveCollectionDynamic", System.Environment.StackTrace))
{
try
{
da.Update(singleRow);
}
catch (Exception ex)
{
esTrace.Exception = ex.Message;
throw;
}
}
}
else
#endregion Profiling
{
da.Update(singleRow);
}
if (row.HasErrors)
{
request.FireOnError(packet, row.RowError);
}
dataTable.Rows.Clear(); // ADO.NET won't let us reuse the same DataRow
}
}
finally
{
esTransactionScope.DeEnlist(cmd);
}
}
scope.Complete();
}
return request.Table;
}
示例4: SaveDynamicCollection_Deletes
static private DataTable SaveDynamicCollection_Deletes(esDataRequest request)
{
SACommand cmd = null;
DataTable dataTable = CreateDataTable(request);
using (esTransactionScope scope = new esTransactionScope())
{
using (SADataAdapter da = new SADataAdapter())
{
da.AcceptChangesDuringUpdate = false;
da.ContinueUpdateOnError = request.ContinueUpdateOnError;
try
{
da.ContinueUpdateOnError = request.ContinueUpdateOnError;
cmd = da.DeleteCommand = Shared.BuildDynamicDeleteCommand(request, request.CollectionSavePacket[0]);
esTransactionScope.Enlist(cmd, request.ConnectionString, CreateIDbConnectionDelegate);
DataRow[] singleRow = new DataRow[1];
// Delete each record
foreach (esEntitySavePacket packet in request.CollectionSavePacket)
{
DataRow row = dataTable.NewRow();
dataTable.Rows.Add(row);
SetOriginalValues(request, packet, row, true);
row.AcceptChanges();
row.Delete();
singleRow[0] = row;
da.Update(singleRow);
if (row.HasErrors)
{
request.FireOnError(packet, row.RowError);
}
dataTable.Rows.Clear(); // ADO.NET won't let us reuse the same DataRow
}
}
finally
{
esTransactionScope.DeEnlist(cmd);
}
}
scope.Complete();
}
return request.Table;
}
示例5: SaveDynamicCollection_InsertsUpdates
static private DataTable SaveDynamicCollection_InsertsUpdates(esDataRequest request)
{
DataTable dataTable = CreateDataTable(request);
using (esTransactionScope scope = new esTransactionScope())
{
using (VistaDBDataAdapter da = new VistaDBDataAdapter())
{
da.AcceptChangesDuringUpdate = false;
da.ContinueUpdateOnError = request.ContinueUpdateOnError;
VistaDBCommand cmd = null;
if (!request.IgnoreComputedColumns)
{
da.RowUpdated += new VistaDBRowUpdatedEventHandler(OnRowUpdated);
}
foreach (esEntitySavePacket packet in request.CollectionSavePacket)
{
if (packet.RowState != esDataRowState.Added && packet.RowState != esDataRowState.Modified) continue;
DataRow row = dataTable.NewRow();
dataTable.Rows.Add(row);
switch (packet.RowState)
{
case esDataRowState.Added:
cmd = da.InsertCommand = Shared.BuildDynamicInsertCommand(request, packet.ModifiedColumns);
SetModifiedValues(request, packet, row);
break;
case esDataRowState.Modified:
cmd = da.UpdateCommand = Shared.BuildDynamicUpdateCommand(request, packet.ModifiedColumns);
SetOriginalValues(request, packet, row, false);
SetModifiedValues(request, packet, row);
row.AcceptChanges();
row.SetModified();
break;
}
request.Properties["esDataRequest"] = request;
request.Properties["esEntityData"] = packet;
dataTable.ExtendedProperties["props"] = request.Properties;
DataRow[] singleRow = new DataRow[1];
singleRow[0] = row;
try
{
esTransactionScope.Enlist(cmd, request.ConnectionString, CreateIDbConnectionDelegate);
da.Update(singleRow);
if (row.HasErrors)
{
request.FireOnError(packet, row.RowError);
}
}
finally
{
esTransactionScope.DeEnlist(cmd);
dataTable.Rows.Clear();
}
if (!row.HasErrors && cmd.Parameters != null)
{
foreach (VistaDBParameter param in cmd.Parameters)
{
switch (param.Direction)
{
case ParameterDirection.Output:
case ParameterDirection.InputOutput:
packet.CurrentValues[param.SourceColumn] = param.Value;
break;
}
}
}
cmd.Dispose();
}
}
scope.Complete();
}
return dataTable;
}
示例6: SaveDynamicCollection
private static DataTable SaveDynamicCollection(esDataRequest request)
{
if (request.CollectionSavePacket == null) return null;
using (esTransactionScope scope = new esTransactionScope())
{
SqlCommand cmd = null;
bool exception = false;
foreach (esEntitySavePacket packet in request.CollectionSavePacket)
{
exception = false;
cmd = null;
switch (packet.RowState)
{
case esDataRowState.Added:
cmd = Shared.BuildDynamicInsertCommand(request, packet);
break;
case esDataRowState.Modified:
cmd = Shared.BuildDynamicUpdateCommand(request, packet);
break;
case esDataRowState.Deleted:
cmd = Shared.BuildDynamicDeleteCommand(request, packet);
break;
case esDataRowState.Unchanged:
continue;
}
try
{
esTransactionScope.Enlist(cmd, request.ConnectionString, CreateIDbConnectionDelegate);
int count;
#region Profiling
if (sTraceHandler != null)
{
using (esTraceArguments esTrace = new esTraceArguments(request, cmd, "SaveCollectionDynamic", System.Environment.StackTrace))
{
try
{
count = cmd.ExecuteNonQuery(); ;
}
catch (Exception ex)
{
esTrace.Exception = ex.Message;
throw;
}
}
}
else
#endregion Profiling
{
count = cmd.ExecuteNonQuery();
}
if (count < 1)
{
throw new esConcurrencyException("Update failed to update any records for Table " + Shared.CreateFullName(request));
}
}
catch (Exception ex)
{
exception = true;
request.FireOnError(packet, ex.Message);
if (!request.ContinueUpdateOnError)
{
throw;
}
}
finally
{
esTransactionScope.DeEnlist(cmd);
cmd.Dispose();
}
if (!exception && packet.RowState != esDataRowState.Deleted && cmd.Parameters != null)
{
foreach (SqlParameter param in cmd.Parameters)
{
switch (param.Direction)
{
case ParameterDirection.Output:
case ParameterDirection.InputOutput:
packet.CurrentValues[param.SourceColumn] = param.Value;
break;
}
}
}
}
//.........这里部分代码省略.........