Skip to content

Commit

Permalink
change event type
Browse files Browse the repository at this point in the history
  • Loading branch information
aelmendorf committed Jul 9, 2024
1 parent 70d829c commit 4ab4289
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 65 deletions.
62 changes: 6 additions & 56 deletions QuickTest.Api/Endpoints/PutEndpoint/InsertMeasurementEndpoint.cs
Original file line number Diff line number Diff line change
Expand Up @@ -55,69 +55,19 @@ await SendAsync(new InsertMeasurementResponse() {
Errors =result.FirstError.Description
},cancellation:ct);
} else {
await SendAsync(new InsertMeasurementResponse() {
Success = true,
Errors = ""
},cancellation:ct);
await PublishAsync(
new MeasurementInsertedEvent() {
SpectrumMeasurements = req.SpectrumMeasurements,
WaferId = req.WaferId,
MeasurementType = req.MeasurementType,
ActualPad = req.ActualPad,
PadLocation = req.PadLocation
},Mode.WaitForNone, cancellation: ct);
await SendAsync(new InsertMeasurementResponse() {
Success = true,
Errors = ""
},cancellation:ct);
},Mode.WaitForAll, cancellation: ct);
}
}
}
}

/*public class InsertMeasurementEndpoint:Endpoint<InsertMeasurementRequest, InsertMeasurementResponse> {
private readonly QuickTestDataService _qtDataService;
public InsertMeasurementEndpoint(QuickTestDataService qtDataService) {
this._qtDataService = qtDataService;
}
public override void Configure() {
Put(QtApiPaths.InsertMeasurementPath);
AllowAnonymous();
}
public override async Task HandleAsync(InsertMeasurementRequest req, CancellationToken ct) {
StringBuilder builder = new StringBuilder();
bool error = false;
if(string.IsNullOrWhiteSpace(req.WaferId)) {
error = true;
builder.AppendLine("WaferId cannot be null or empty");
}
if (string.IsNullOrEmpty(req.PadLocation)) {
error = true;
builder.AppendLine("PadLocation cannot be null or empty");
}
if (string.IsNullOrWhiteSpace(req.ActualPad)) {
error = true;
builder.AppendLine("ActualPad cannot be null or empty");
}
if (error) {
await SendAsync(new InsertMeasurementResponse() {
Success = false,
Errors=builder.ToString()
},cancellation:ct);
} else {
var result = await this._qtDataService.InsertMeasurement(req);
if (result.IsError) {
await SendAsync(new InsertMeasurementResponse() {
Success = false,
Errors =result.FirstError.Description
},cancellation:ct);
} else {
await SendAsync(new InsertMeasurementResponse() {
Success = true,
Errors = ""
},cancellation:ct);
}
}
}
}*/
}
3 changes: 2 additions & 1 deletion QuickTest.Api/Event/MeasurementInsertedEventHandler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@ public MeasurementInsertedEventHandler(QuickTestDataService qtDataService,ILogge
}
public async Task HandleAsync(MeasurementInsertedEvent eventModel, CancellationToken ct) {
foreach (var measurement in eventModel.SpectrumMeasurements) {
await this._qtDataService.InsertSpectrumMeasurement(measurement,(MeasurementType)eventModel.MeasurementType,eventModel.WaferId, eventModel.PadLocation, eventModel.ActualPad);
await this._qtDataService.InsertSpectrumMeasurement(measurement,(MeasurementType)eventModel.MeasurementType,
eventModel.WaferId, eventModel.PadLocation, eventModel.ActualPad);
this._logger.LogInformation("Inserted Spectrum Measurement for {WaferId}",eventModel.WaferId);
}
}
Expand Down
12 changes: 4 additions & 8 deletions QuickTest.Infrastructure/Services/QuickTestDataService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -101,19 +101,15 @@ public async Task<ErrorOr<bool>> CreateQuickTest(string waferId,int stationId) {

public async Task<ErrorOr<Success>> InsertAllMeasurements(InsertMeasurementRequest request) {
List<Error> errors = [];

foreach (var measurement in request.Measurements) {
var result=await this.InsertMeasurement(measurement,(MeasurementType)request.MeasurementType,request.WaferId!,request.PadLocation!,request.ActualPad!);
var result=await this.InsertMeasurement(measurement,
(MeasurementType)request.MeasurementType,
request.WaferId!,request.PadLocation!,request.ActualPad!);
if (result.IsError) {
errors.Add(result.FirstError);
}
}

/*foreach (var measurement in request.SpectrumMeasurements) {
var result=await this.InsertSpectrumMeasurement(measurement,(MeasurementType)request.MeasurementType,request.WaferId!,request.PadLocation!,request.ActualPad!);
if (result.IsError) {
errors.Add(result.FirstError);
}
}*/
return errors.Any() ? errors : Result.Success;
}

Expand Down

0 comments on commit 4ab4289

Please sign in to comment.