public override async Task <IOperationStatus> CreateOperationStatusAsync(IOperationDescription operationDescription, IOperationContext context) { context.ThrowIfNull(nameof(context)); ClusterOperationDescription description = operationDescription == null ? null : operationDescription as ClusterOperationDescription; Trace.WriteInfo(TraceType, "CreateOperationStatusAsync: begin"); IOperationStatus status = null; try { Trace.WriteInfo(TraceType, "CreateOperationStatusAsync: performing operation"); var errorDetails = await DoOperation(description, context); Trace.WriteInfo(TraceType, "CreateOperationStatusAsync: building status"); status = await BuildStatusAsync(description, context, errorDetails); } catch (Exception ex) { Trace.WriteError(this.TraceType, $"CreateOperationStatusAsync: Exception encountered: {ex}"); } Trace.WriteInfo(TraceType, "CreateOperationStatusAsync: end"); return(status); }
public MigrationContext( MigrationSettings settings, OrmPackage package, PortalApplication portal, BundleManifest manifest, IVSProject vsProject, CodeDomProvider codeProvider, StrongNameKeyPair keyPair, IExtendedLog log, IOperationStatus status, ICollection<Plugin> plugins) { _settings = settings; _package = package; _portal = portal; _manifest = manifest; _vsProject = vsProject; _codeProvider = codeProvider; _keyPair = keyPair; _log = log; _status = status; _plugins = plugins; _forms = new Dictionary<string, FormInfo>(StringComparer.InvariantCultureIgnoreCase); _mainViews = new Dictionary<string, MainViewInfo>(StringComparer.InvariantCultureIgnoreCase); _navigation = new List<NavigationInfo>(); _scripts = new Dictionary<string, ScriptInfo>(StringComparer.InvariantCultureIgnoreCase); _tables = new Dictionary<string, TableInfo>(StringComparer.InvariantCultureIgnoreCase); _entities = new Dictionary<string, OrmEntity>(StringComparer.InvariantCultureIgnoreCase); _relationships = new Dictionary<DataPathJoin, RelationshipInfo>(); _linkedFiles = new List<LinkedFile>(); _localizedStrings = new Dictionary<string, string>(StringComparer.InvariantCultureIgnoreCase); _references = new Dictionary<string, string>(StringComparer.InvariantCultureIgnoreCase); _smartParts = new List<SmartPartMapping>(); _secondaryJoins = new Dictionary<DataPathJoin, DataPathJoin>(); }
/// <summary> /// Get the Operation Status. /// </summary> /// <param name='operations'> /// Reference to the /// Microsoft.Azure.Management.BackupServices.IOperationStatus. /// </param> /// <param name='resourceGroupName'> /// Required. /// </param> /// <param name='resourceName'> /// Required. /// </param> /// <param name='operationId'> /// Required. OperationId. /// </param> /// <param name='customRequestHeaders'> /// Optional. Request header parameters. /// </param> /// <returns> /// The definition of a CSMOperationResult. /// </returns> public static CSMOperationResult CSMGet(this IOperationStatus operations, string resourceGroupName, string resourceName, string operationId, CustomRequestHeaders customRequestHeaders) { return(Task.Factory.StartNew((object s) => { return ((IOperationStatus)s).CSMGetAsync(resourceGroupName, resourceName, operationId, customRequestHeaders); } , operations, CancellationToken.None, TaskCreationOptions.None, TaskScheduler.Default).Unwrap().GetAwaiter().GetResult()); }
public bool TryRemove(IOperationStatus status) { var operationId = Int64.MinValue; return(this.Operations.TryRemove( status.ResourceId, out operationId)); }
/// <summary> /// Instance new HttpOperationStatusResult object for checking code error of the first unsuccesful operation /// </summary> /// <param name="operations">List of operation that will be checked for http status codes errors</param> public HttpOperationStatusResult(params IOperationStatus[] operations) { if (operations == null) { throw new ArgumentNullException(nameof(operations)); } _unsuccessfulOperation = operations.FirstOrDefault(x => x.Code != HttpStatusCode.OK); }
/// <summary> /// Initializes a new instance of the BackupServicesManagementClient /// class. /// </summary> /// <param name='httpClient'> /// The Http client /// </param> public BackupServicesManagementClient(HttpClient httpClient) : base(httpClient) { this._backUp = new BackUpOperations(this); this._container = new ContainerOperations(this); this._cSMProtectionPolicy = new CSMProtectionPolicyOperations(this); this._dataSource = new DataSourceOperations(this); this._job = new JobOperations(this); this._operationStatus = new OperationStatus(this); this._protectableObject = new ProtectableObjectOperations(this); this._recoveryPoint = new RecoveryPointOperations(this); this._restore = new RestoreOperations(this); this._apiVersion = "2013-03-01"; this._longRunningOperationInitialTimeout = -1; this._longRunningOperationRetryTimeout = -1; this.HttpClient.Timeout = TimeSpan.FromSeconds(300); }
public static string ToFormattedString(this IOperationStatus status) { var formattedString = string.Empty; if (status != null) { formattedString = $@" OperationSequenceNumber: {status.OperationSequenceNumber} OperationType: {status.OperationType} ResourceId: {status.ResourceId} Status: {status.Status} Progress: {status.Progress} ErrorDetails: {status.ErrorDetails} "; } return(formattedString); }
public override async Task <IOperationStatus> CreateOperationStatusAsync( IOperationDescription description, IOperationContext context) { description.ThrowIfNull(nameof(description)); context.ThrowIfNull(nameof(context)); Trace.WriteInfo(TraceType, "CreateOperationStatusAsync called"); IOperationStatus status = null; try { IFabricOperationResult result = null; if (!this.Operations.OperationExists(description)) { result = await this.fabricClient.GetAsync(description, context); status = result?.OperationStatus; var operationContext = new OperationContext( context.CancellationToken, Constants.MaxOperationTimeout, context.ContinuationToken); switch (description.OperationType) { case OperationType.CreateOrUpdate: if (null == status) { try { await this.fabricClient.CreateAsync( description, operationContext); } catch (Exception e) { return(this.HandleOperationFailedStatus( description, nameof(this.fabricClient.CreateAsync), e)); } } break; case OperationType.Delete: try { await this.fabricClient.DeleteAsync( description, operationContext); } catch (Exception e) { return(this.HandleOperationFailedStatus( description, nameof(this.fabricClient.DeleteAsync), e)); } break; default: Trace.WriteError(this.TraceType, "Unhandled operation type: {0}", description.OperationType); break; } Trace.WriteInfo( this.TraceType, this.Operations.TryAdd(description) ? "CreateOperationStatusAsync: Operation started for resource. OperationId: {0}. ResourceId: {1}." : "CreateOperationStatusAsync: Failed to track operation for resource. OperationId: {0}. ResourceId: {1}.", description.OperationSequenceNumber, description.ResourceId); } result = await this.fabricClient.GetAsync(description, context); status = result?.OperationStatus; } catch (Exception e) { ResourceCommandProcessor.HandleException("CreateOperationStatusAsync", e, this.TraceType); } Trace.WriteInfo( TraceType, "CreateOperationStatusAsync: completed {0}", status.ToFormattedString()); return(status); }
/// <summary> /// Get the Operation Status. /// </summary> /// <param name='operations'> /// Reference to the /// Microsoft.Azure.Management.BackupServices.IOperationStatus. /// </param> /// <param name='resourceGroupName'> /// Required. /// </param> /// <param name='resourceName'> /// Required. /// </param> /// <param name='operationId'> /// Required. OperationId. /// </param> /// <param name='customRequestHeaders'> /// Optional. Request header parameters. /// </param> /// <returns> /// The definition of a CSMOperationResult. /// </returns> public static Task <CSMOperationResult> CSMGetAsync(this IOperationStatus operations, string resourceGroupName, string resourceName, string operationId, CustomRequestHeaders customRequestHeaders) { return(operations.CSMGetAsync(resourceGroupName, resourceName, operationId, customRequestHeaders, CancellationToken.None)); }
public void Execute(MigrationSettings settings, IOperationStatus status) { Guard.ArgumentNotNull(settings, "settings"); Guard.ArgumentNotNull(status, "status"); _settings = settings; _status = status; int stepCount = _steps.Length; if (_settings.ProcessScripts) { stepCount += (_migrators.Length - 1)*3; } else { stepCount += (_migrators.Length - 1)*2; } _status.Reset(stepCount); foreach (StepHandler step in _steps) { step(); if (_status.IsCancelled) { break; } } if (!_status.IsCancelled && MigrationComplete != null) { MigrationComplete(this, new MigrationCompleteEventArgs(_report)); } _settings = null; _status = null; }
public OperationFatalErrorException(IOperationStatus status, string message, Exception innerException) : base(message, innerException) { this.Status = status; }
private void backgroundWorker_DoWork(object sender, DoWorkEventArgs e) { if (_workItem == null) { throw new MigrationException("WorkItem not set"); } if (_status == null) { _status = new BackgroundWorkerStatus(backgroundWorker, _workItem.Log); } _workItem.Execute(_settings, _status); e.Cancel = _cancelled; }