1

WCF RIA Services RTM을 사용하는 Silverlight 4 프로젝트가 있습니다. 대부분의 RIA 기능이 작동하지만 동시성 검사에 문제가 있습니다. 서버가 동시성을 올바르게 확인하고 DomainOperationException을 DomainDataSource.SubmittedChanges 이벤트로 전달합니다. 나는 이것을 처리하고 EntitiesInError를 열거한다. 그런 다음 EntityConflict에 대한 Resolve를 호출합니다. 이것은 엔터티에 대한 "이전 값"을 업데이트하는 것으로 보이므로 다시 제출할 수 있지만 클라이언트의 변경 사항은 엔터티에 보존됩니다. 차라리 고객의 변경 사항을 없애고 다시 변경하거나 결국 변경된 내용을 표시하고 유지할 항목을 선택하도록 할 것입니다. 아래는 내가 지금까지 가지고있는 코드 샘플이다. 나는이 게시물을 발견 : http://sklementiev.blogspot.com/2010/03/wcf-ria-and-concurrency.html하지만 그것은 RIA 서비스 RTM과 함께 작동하지 않는 것. 감사.WCF RIA 서비스가있는 Silverlight 클라이언트에서 동시성 오류 해결

코드 샘플 :

Private Sub dds_SubmittedChanges(ByVal sender As Object, ByVal e As System.Windows.Controls.SubmittedChangesEventArgs) 
    If e.HasError Then 
     If TypeOf e.Error Is DomainOperationException Then 
      handleDomainOperationException(sender, e, "myType") 

     End If 
    End If 
End Sub 

Private Sub handleDomainOperationException(ByVal sender As Object, ByVal e As SubmittedChangesEventArgs, ByVal entityType As String) 
    Dim dds As DomainDataSource = DirectCast(sender, DomainDataSource) 
    Select Case DirectCast(e.Error, DomainOperationException).Status 
     Case OperationErrorStatus.Conflicts 
      ErrorWindow.CreateNew(String.Format("Another user updated this {0} between the time that you viewed it and when you submitted your changes. Your changes have been reverted. Please make your changes again and re-submit.", entityType)) 

      For Each ent In e.EntitiesInError 
       If Not ent.EntityConflict.IsDeleted Then 
        'tried this, doesn't overwrite changes, just updates old fields 
        ent.EntityConflict.Resolve() 

       Else 
        Throw New Exception("This entity has already been deleted.") 
       End If 
      Next 
      e.MarkErrorAsHandled() 
     Case OperationErrorStatus.ValidationFailed 
      ErrorWindow.CreateNew("Data validation failed") 
    End Select 
End Sub 

답변

1

내가보기 엔 당신은 해상도 here (페이 월의 환상적인 데모를 가지고 동시성 충돌 처리에 야신 Khammal의 인 Pluralsight 훈련을보고 추천하지만, $ 29 달 가치가 많은 배). "데모 : 유효성 검사 및 동시성 오류 처리"라는 비디오를 참조하십시오. 나는 제시된 것 이외의 샘플에서 구현 된 이것에 대한 문서를 찾을 수 없었다. 이 솔루션을 이상적으로 만드는 것은 변경 집합을 통해 EF 계층에서 작동하고 세분성을 통해 변경된 사항을 식별 할 수있게 해주는 것입니다. 사용자에게로드 및 편집 된 내용이 서버에있는 내용과 다른 것을 사용자에게 알리고 가장 최근에 덮어 쓰거나 되돌릴 것인지 결정할 수 있도록 할 수 있습니다.

관련 문제