/// <inheritdoc/> protected override void ProcessRecordInternal() { RepairTargetDescriptionBase repairTargetDescriptionBase = null; if (this.Node.IsPresent) { repairTargetDescriptionBase = new NodeRepairTargetDescription( nodeNames: this.NodeNames); } RepairImpactDescriptionBase repairImpactDescriptionBase = null; if (this.Node.IsPresent) { repairImpactDescriptionBase = new NodeRepairImpactDescription( nodeImpactList: this.NodeImpactList); } var repairTaskHistory = new RepairTaskHistory( createdUtcTimestamp: this.CreatedUtcTimestamp, claimedUtcTimestamp: this.ClaimedUtcTimestamp, preparingUtcTimestamp: this.PreparingUtcTimestamp, approvedUtcTimestamp: this.ApprovedUtcTimestamp, executingUtcTimestamp: this.ExecutingUtcTimestamp, restoringUtcTimestamp: this.RestoringUtcTimestamp, completedUtcTimestamp: this.CompletedUtcTimestamp, preparingHealthCheckStartUtcTimestamp: this.PreparingHealthCheckStartUtcTimestamp, preparingHealthCheckEndUtcTimestamp: this.PreparingHealthCheckEndUtcTimestamp, restoringHealthCheckStartUtcTimestamp: this.RestoringHealthCheckStartUtcTimestamp, restoringHealthCheckEndUtcTimestamp: this.RestoringHealthCheckEndUtcTimestamp); var repairTask = new RepairTask( taskId: this.TaskId, state: this.State, action: this.Action, version: this.Version, description: this.Description, flags: this.Flags, target: repairTargetDescriptionBase, executor: this.Executor, executorData: this.ExecutorData, impact: repairImpactDescriptionBase, resultStatus: this.ResultStatus, resultCode: this.ResultCode, resultDetails: this.ResultDetails, history: repairTaskHistory, preparingHealthCheckState: this.PreparingHealthCheckState, restoringHealthCheckState: this.RestoringHealthCheckState, performPreparingHealthCheck: this.PerformPreparingHealthCheck, performRestoringHealthCheck: this.PerformRestoringHealthCheck); var result = this.ServiceFabricClient.Repairs.UpdateRepairExecutionStateAsync( repairTask: repairTask, cancellationToken: this.CancellationToken).GetAwaiter().GetResult(); if (result != null) { this.WriteObject(this.FormatOutput(result)); } }
/// <summary> /// Serializes the object to JSON. /// </summary> /// <param name="writer">The <see cref="T: Newtonsoft.Json.JsonWriter" /> to write to.</param> /// <param name="obj">The object to serialize to JSON.</param> internal static void Serialize(JsonWriter writer, RepairTargetDescriptionBase obj) { var kind = obj.Kind; if (kind.Equals(RepairTargetKind.Node)) { NodeRepairTargetDescriptionConverter.Serialize(writer, (NodeRepairTargetDescription)obj); } else { throw new InvalidOperationException("Unknown Kind."); } }
/// <summary> /// Gets the object from Json properties. /// </summary> /// <param name="reader">The <see cref="T: Newtonsoft.Json.JsonReader" /> to read from.</param> /// <returns>The object Value.</returns> internal static RepairTargetDescriptionBase GetFromJsonProperties(JsonReader reader) { RepairTargetDescriptionBase obj = null; var propName = reader.ReadPropertyName(); if (!propName.Equals("Kind", StringComparison.OrdinalIgnoreCase)) { throw new JsonReaderException($"Incorrect discriminator property name {propName}, Expected discriminator property name is Kind."); } var propValue = reader.ReadValueAsString(); if (propValue.Equals("Node", StringComparison.OrdinalIgnoreCase)) { obj = NodeRepairTargetDescriptionConverter.GetFromJsonProperties(reader); } else { throw new InvalidOperationException("Unknown Kind."); } return(obj); }