You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
In our system, we have a C# program that uses the harmonycore API to fetch and update data from VMS. Occasionally we found record lock error on ISM file when the C# program updates ISM files on VMS. When that happened, the file is locked for all apps including DIBOL programs in VMS. The only way to unlock the file is to stop the C# program or restart xfserver in VMS.
I debug the module in API that updates VMS data and found some issues:
after -DBContext.SaveChanges(), it doesn't matter if the data got updated successfully or not, it always goes to the @ValidationException where e = null. But it skips the first line and goes straight to the 2nd line in that catch section mreturn.ValidationHelper.ReturnValidationError(ModelState)
catch (e, @ValidationException)
begin
ModelState.AddModelError("RelationValidation",e.Message)
mreturn ValidationHelper.ReturnValidationError(ModelState)
end
endtry
mreturn NoContent()
But it does not return the validation error but goes to the statement outside the try-catch section and mreturn NoContent()
Here're some questions:
When the record got updated successfully, the method does not return the proper status showing update process.
It looks like _DBContext.SaveChanges() updates VMS data. When a record lock happens, is this the method that might be locking the file?
DBContext class extends Microsoft.EntityFrameworkCore.DbContext. How can I catch exceptions when it failed to update data due to record lock/time out?
SalesorderDetialsControoler.dbl
{HttpPatch("SalesorderDetails(Salesorderlineid={aSalesorderlineid})")}
{Consumes(MediaTypeNames.Application.Json)}
{Produces("application/json")}
{ProducesResponseType(StatusCodes.Status204NoContent)}
{ProducesResponseType(StatusCodes.Status400BadRequest)}
{ProducesResponseType(StatusCodes.Status401Unauthorized)}
{ProducesResponseType(StatusCodes.Status404NotFound)}
;;; <summary>
;;; Patch (partial update) an existing record
;;; </summary>
;;; <remarks>
;;;
;;; </remarks>
;;; <param name="aSalesorderlineid" example="ABC">Key segment overlay</param>
;;; <returns>Returns an IActionResult indicating the status of the operation and containing any data that was returned.</returns>
;;; <response code="204"><HTTP_204_MESSAGE></response>
;;; <response code="400"><HTTP_400_MESSAGE></response>
;;; <response code="401"><HTTP_401_MESSAGE></response>
;;; <response code="404"><HTTP_404_MESSAGE></response>
;;; <response code="500"><HTTP_500_MESSAGE></response>
public method PatchSalesorderDetail, @IActionResult
required in aSalesorderlineid, String
{FromBody}
required in aSalesorderDetail, @JsonPatchDocument<SalesorderDetail>
proc
;; Validate inbound data
if (!ModelState.IsValid)
mreturn ValidationHelper.ReturnValidationError(ModelState)
;;Patch the existing salesorderDetail
try
begin
;;Get the salesorderDetail to be updated
data salesorderDetailToUpdate = _DbContext.SalesorderDetails.Find(aSalesorderlineid.PadRight(11))
data patchError, @JsonPatchError, ^null
;;Did we find it?
if(salesorderDetailToUpdate == ^null)
mreturn NotFound()
;;Apply the changes to the salesorderDetail we read
aSalesorderDetail.ApplyTo(salesorderDetailToUpdate, lambda(error) { patchError = error })
;;if the patchdoc was bad return the error info
if(patchError != ^null)
mreturn BadRequest(string.Format("Error applying patch document: error message {0}, caused by {1}", patchError.ErrorMessage, JsonConvert.SerializeObject(patchError.Operation)))
;;Update and commit
_DbContext.SalesorderDetails.Update(salesorderDetailToUpdate)
_DbContext.SaveChanges()
end
catch (e, @InvalidOperationException)
begin
mreturn BadRequest(e)
end
catch (e, @ValidationException)
begin
ModelState.AddModelError("RelationValidation",e.Message)
mreturn ValidationHelper.ReturnValidationError(ModelState)
end
endtry
mreturn NoContent()
endmethod
The text was updated successfully, but these errors were encountered:
Do you have a crash dump of the program when it's hung? It would be pretty easy to figure out whats going on if we could look around at the state of things when it happens.
In our system, we have a C# program that uses the harmonycore API to fetch and update data from VMS. Occasionally we found record lock error on ISM file when the C# program updates ISM files on VMS. When that happened, the file is locked for all apps including DIBOL programs in VMS. The only way to unlock the file is to stop the C# program or restart xfserver in VMS.
I debug the module in API that updates VMS data and found some issues:
after -DBContext.SaveChanges(), it doesn't matter if the data got updated successfully or not, it always goes to the @ValidationException where e = null. But it skips the first line and goes straight to the 2nd line in that catch section mreturn.ValidationHelper.ReturnValidationError(ModelState)
But it does not return the validation error but goes to the statement outside the try-catch section and mreturn NoContent()
Here're some questions:
SalesorderDetialsControoler.dbl
The text was updated successfully, but these errors were encountered: