private void actionWorker_RunWorkerCompleted(object sender, RunWorkerCompletedEventArgs e)
{
if (TaskCancelled)
{
Log.WriteWarning(new SourceInfo(), _statusControl, "Query cancelled successfully.");
return;
}
if (ActionTask.IsFaulted)
{
if (ActionTask.Exception != null)
foreach (
Exception ex in
ActionTask.Exception.InnerExceptions.Where(
ex => !(ex is ThreadAbortException) && !TaskCancelled))
{
if (ex is ServerException)
{
ServerException se = (ServerException)ex;
Log.WriteError(new SourceInfo(), _statusControl,
"Error Code:{0}, ErrorDetail:{1}, CorrelationId:{2}, ErrorType:{3}, ErrorValue:{4}.",
se.ServerErrorCode, se.ServerErrorDetails, se.ServerErrorTraceCorrelationId,
se.ServerErrorTypeName, se.ServerErrorValue);
}
else
{
Log.WriteError(new SourceInfo(), _statusControl, "Exception:{0}, Message:{1}",
ex.GetType().Name, ex.Message);
}
}
Log.WriteWarning(new SourceInfo(), _statusControl, "Query executed with errors.");
}
else
{
Log.WriteVerbose(new SourceInfo(), _statusControl, "Query executed successfully.");
}
}