/// <summary> /// Creates a new operation. /// </summary> /// <param name="operationName">The name of the operation to create.</param> /// <param name="parentContext">Create an operation using another context for the duration of the operation.</param> /// <returns>A correlated Operation.</returns> public IOperation CreateOperation(string operationName, byte[] parentContext) { try { byte[] capturedCorrelationContext = this.CorrelationContext.Capture(); CorrelationContext localCorrelationcontext = new CorrelationContext(parentContext); long newOperationId = localCorrelationcontext.AddOperation(); string newOperationIdString = newOperationId.GetBase64String(); if (string.IsNullOrWhiteSpace(operationName)) { Diag("Attempting to create operation with null name. Resetting to randomized value. m7x/mk3e30M"); operationName = "ERR_NO_OPERATION_NAME " + newOperationIdString; } string cc = localCorrelationcontext.ToString(); this.CorrelationContext = localCorrelationcontext; IOperation createdOperation = new ConsoleOperation(this, operationName, newOperationIdString, cc, capturedCorrelationContext); return(createdOperation); } catch (Exception ex) { DiagnosticTrace.Instance.Error("An unexpected error occurred when attempting to create an operation", ex, "cd11de1d-c4b6-406c-937e-37bc85eb4370"); return(new NullOperation()); } }
/// <summary> /// Creates a new operation. /// </summary> /// <param name="operationName">The name of the operation to create.</param> /// <returns>A correlated Operation.</returns> public IOperation CreateOperation(string operationName) { try { ICorrelationContext localCorrelationcontext = this.CorrelationContext; long newOperationId = localCorrelationcontext.AddOperation(); string newOperationIdString = newOperationId.GetBase64String(); if (string.IsNullOrWhiteSpace(operationName)) { Diag("Attempting to create operation with null name. Resetting to randomized value. FTOsTooZ1kM"); operationName = "ERR_NO_OPERATION_NAME " + newOperationIdString; } string cc = localCorrelationcontext.ToString(); this.CorrelationContext = localCorrelationcontext; IOperation createdOperation = new ConsoleOperation(this, operationName, newOperationIdString, cc); return(createdOperation); } catch (Exception ex) { DiagnosticTrace.Instance.Error("An unexpected error occurred when attempting to create an operation", ex, "1f3803c8-5a8c-4562-a96b-7069520d8e32"); return(new NullOperation()); } }