public async Task <IHttpActionResult> GetStatus(int auftragsid) { Log.Information("Received GetStatus call for order with id {auftragsid}.", auftragsid); if (!ApiKeyChecker.IsCorrect(Request)) { return(Unauthorized()); } try { var orderItems = await messageBusCallHelper.FindOrderItems(new[] { auftragsid }); if (orderItems.Length == 0) { return(StatusCode(HttpStatusCode.NotFound)); } Log.Information("Returned status for order with id {auftragsid}.", auftragsid); return(Ok(orderItems[0].Status.ToString())); } catch (Exception e) { Log.Error(e, "Unexpected error while getting status for order with id {auftragsid}", auftragsid); return(InternalServerError(e)); } }
public async Task <IHttpActionResult> SetStatusDigitalisierungExtern(int auftragsid) { if (!ApiKeyChecker.IsCorrect(Request)) { return(Unauthorized()); } await vecteurActionsClient.SetStatusDigitalisierungExtern(auftragsid); return(Ok("OK")); }
public async Task <IHttpActionResult> SetStatusZumReponierenBereit(int auftragsid) { if (!ApiKeyChecker.IsCorrect(Request)) { return(Unauthorized()); } await vecteurActionsClient.SetStatusZumReponierenBereit(auftragsid); return(Ok("OK")); }
public async Task <IHttpActionResult> SetStatusDigitalisierungExtern(int auftragsid) { Log.Information("Received SetStatusDigitalisierungExtern call for order with id {auftragsid}.", auftragsid); if (!ApiKeyChecker.IsCorrect(Request)) { return(Unauthorized()); } await vecteurActionsClient.SetStatusDigitalisierungExtern(auftragsid); Log.Information("Successfully updated status to StatusDigitalisierungExtern for order with id {auftragsid}.", auftragsid); return(Ok("OK")); }
public async Task <IHttpActionResult> GetStatus(int auftragsid) { if (!ApiKeyChecker.IsCorrect(Request)) { return(Unauthorized()); } try { var orderItems = await messageBusCallHelper.FindOrderItems(new[] { auftragsid }); if (orderItems.Length == 0) { return(StatusCode(HttpStatusCode.NotFound)); } return(Ok(orderItems[0].Status.ToString())); } catch (Exception e) { return(InternalServerError(e)); } }
public async Task <IHttpActionResult> GetNextDigitalisierungsauftrag() { DigipoolEntry digipoolEntry = null; if (!ApiKeyChecker.IsCorrect(Request)) { return(Unauthorized()); } try { Log.Verbose("Getting next order from digipool"); DigitalisierungsAuftrag auftrag; var digipoolEntryArray = await orderManagerClient.GetDigipool(1); if (digipoolEntryArray.Length == 0) { return(StatusCode(HttpStatusCode.NoContent)); } digipoolEntry = digipoolEntryArray[0]; // Hat der zurückgelieferte Eintrag einen Aufbereitungsfehler, so bedeutet dies, // dass nur noch Aufträge mit Aufbereitungsfehlern im Digipool liegen. // Wir liefern einen spezifischen HTTP Code zurück um dies anzuzeigen if (digipoolEntry.HasAufbereitungsfehler) { return(Content(HttpStatusCode.Forbidden, onlyFaultedItemsInDigipoolExceptionMessage)); } if (digipoolEntry.VeId.HasValue) { // Hat die Bestellung eine VE-ID, so holen wir die Details zum Record aus Elastic und // bereiten die Bestellung über den Dienst auf. Log.Verbose($"Fetching ve {digipoolEntry.VeId} from elastic index"); var orderedItemRecord = await messageBusCallHelper.GetElasticArchiveRecord(digipoolEntry.VeId.ToString()); if (orderedItemRecord == null) { throw new Exception(veNotFoundMessage); } Log.Verbose($"Fetching full digitization order from AIS for {orderedItemRecord.GetAuszuhebendeArchiveRecordId()}"); auftrag = await digitizationHelper.GetDigitalisierungsAuftrag(orderedItemRecord.GetAuszuhebendeArchiveRecordId()); // Lade Dossier, falls bestellte Einheit nicht das Dossier ist ElasticArchiveRecord dossierRecord; dossierRecord = auftrag.Dossier.VerzEinheitId.ToString() != orderedItemRecord.ArchiveRecordId ? await messageBusCallHelper.GetElasticArchiveRecord(auftrag.Dossier.VerzEinheitId.ToString()) : orderedItemRecord; if (dossierRecord.ProtectionEndDate?.Date == null) { throw new Exception(veHasNoProtectionEndDateMessage); } // Schutzfrist für Bestellungen hängen vom Schutzfrist-Enddatum des Dossiers und dem Freigabestatus ab. // Der Freigabestatus ist immer derjenige der bestellten Einheit. if (dossierRecord.ProtectionEndDate.Date > DateTime.Today) { auftrag.Dossier.InSchutzfrist = digipoolEntry.ApproveStatus != ApproveStatus.FreigegebenAusserhalbSchutzfrist; } else { auftrag.Dossier.InSchutzfrist = digipoolEntry.ApproveStatus == ApproveStatus.FreigegebenInSchutzfrist; } // Übertrage den Wert des Schutzfristproperties des Dossiers, auf alle enthaltenen VE (rekursiv) UpdateInSchutzfrist(auftrag.Dossier.UntergeordneteVerzEinheiten, auftrag.Dossier.InSchutzfrist); } else { // Hat die Bestellung KEINE VE-ID, so handelt es sich um ein manuell hinzugefügtes Dossier. // Wir erstellen manuell ein DigitalisierungsAuftrag mit den Angaben des Benutzers. auftrag = await digitizationHelper.GetManualDigitalisierungsAuftrag(digipoolEntry); // Schutzfrist für manuelle Bestellungen hängen nur vom Freigabestatus des Auftrags ab. auftrag.Dossier.InSchutzfrist = digipoolEntry.ApproveStatus != ApproveStatus.FreigegebenAusserhalbSchutzfrist; } // Gemeinsame Daten auftrag.Auftragsdaten.AuftragsId = digipoolEntry.OrderItemId.ToString(); auftrag.Auftragsdaten.BemerkungenBar = digipoolEntry.InternalComment + ""; auftrag.Auftragsdaten.BemerkungenKunde = GetBemerkungKunde(digipoolEntry) + ""; auftrag.Auftragsdaten.Bestelldatum = digipoolEntry.OrderDate; Log.Verbose("Update Benutzungskopie flag for order"); await orderManagerClient.UpdateBenutzungskopie(digipoolEntry.OrderItemId, auftrag.Auftragsdaten.Benutzungskopie); var errorList = ValidateAuftrag(auftrag); if (errorList.Any()) { throw new XmlSchemaValidationException("The data is not valid according to the Auftragsdaten.xsd schema. " + $"{Environment.NewLine}The errors found are:{Environment.NewLine}" + $"{string.Join(Environment.NewLine, errorList)}"); } return(Ok(auftrag)); } // Request timeout --> Manager, Index or External Content Service is not running catch (RequestTimeoutException e) { Log.Error(e, "RequestTimeout Exception"); return(Content(HttpStatusCode.ServiceUnavailable, serviceNotAvailableExceptionMessage)); } // Something in the remote call failed. catch (RequestFaultException e) { Log.Error(e, "Remote call faulted"); // if we have a remote sql db problem, then return a service unavailable if (e.Fault.Exceptions[0].ExceptionType == typeof(OrderDatabaseNotFoundOrNotRunningException).FullName) { return(Content(HttpStatusCode.ServiceUnavailable, $"{serviceNotAvailableExceptionMessage} (SQL Server not running.)")); } // if we have a remote ais db problem, then return a service unavailable if (e.Fault.Exceptions[0].ExceptionType == typeof(AISDatabaseNotFoundOrNotRunningException).FullName) { return(Content(HttpStatusCode.ServiceUnavailable, $"{serviceNotAvailableExceptionMessage} (AIS database not running.")); } // Any other problem, mark the order as faulted. if (digipoolEntry != null) { return(await ProcessFaultedItem(digipoolEntry, $"{e.Fault.Exceptions[0].Message}{Environment.NewLine + Environment.NewLine}{e.Fault.Exceptions[0].StackTrace}")); } // If there is an error, and we do not have a digipool entry, then return internal server error // This should not happen return(InternalServerError(e)); } catch (XmlSchemaValidationException e) { Log.Error(e, "Schema validation failed"); return(await ProcessNormalError(digipoolEntry, e)); } catch (Exception e) { Log.Error(e, "Unexpected error while getting next order from digipool."); return(await ProcessNormalError(digipoolEntry, e)); } }