Hello!
I have created a custom SOE which receives some data in JSON format and should create new features in an Oracle DB. A service is published with sources pointing to "SDE.DEFAULT" version. There is another version, already created - "SOS.ORDER1" (with parent "SDE.DEFAULT"). My SOE logic should create those new features in version "SOS.ORDER1".
I'm using this topic - Editing with the geodatabase API (Connecting to one version and editing another) to develop my logic, but when trying to create new features in a table I'm getting following error: Objects in this class cannot be updated outside an edit session [GDO.O_LINKA].
This is my workflow:
IWorkspace workspace <SPAN class="operator token">=</SPAN> <SPAN class="punctuation token">.</SPAN><SPAN class="punctuation token">.</SPAN><SPAN class="punctuation token">.</SPAN> <SPAN class="comment token">// from SOE</SPAN>
<SPAN class="comment token">// workspace.ConnectionProperties.GetProperty("VERSION") => "SDE.DEFAULT"</SPAN>
<SPAN class="comment token">// get a reference to the desired geodatabase version</SPAN>
IVersion version <SPAN class="operator token">=</SPAN> <SPAN class="punctuation token">(</SPAN>workspace <SPAN class="keyword token">as</SPAN> IVersionedWorkspace<SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">.</SPAN><SPAN class="token function">FindVersion</SPAN><SPAN class="punctuation token">(</SPAN><SPAN class="string token">"SOS.ORDER1"</SPAN><SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">;</SPAN>
<SPAN class="comment token">// this should start an editing session in SOS.ORDER1 version</SPAN>
IMultiuserWorkspaceEdit multiuserWorkspaceEdit <SPAN class="operator token">=</SPAN> version <SPAN class="keyword token">as</SPAN> IMultiuserWorkspaceEdit<SPAN class="punctuation token">;</SPAN>
IWorkspaceEdit2 workspaceEdit <SPAN class="operator token">=</SPAN> version <SPAN class="keyword token">as</SPAN> IWorkspaceEdit2<SPAN class="punctuation token">;</SPAN>
multiuserWorkspaceEdit<SPAN class="punctuation token">.</SPAN><SPAN class="token function">StartMultiuserEditing</SPAN><SPAN class="punctuation token">(</SPAN>esriMultiuserEditSessionMode<SPAN class="punctuation token">.</SPAN>esriMESMVersioned<SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">;</SPAN>
<SPAN class="comment token">// start editing</SPAN>
workspaceEdit<SPAN class="punctuation token">.</SPAN><SPAN class="token function">StartEditing</SPAN><SPAN class="punctuation token">(</SPAN><SPAN class="keyword token">false</SPAN><SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">;</SPAN>
workspaceEdit<SPAN class="punctuation token">.</SPAN><SPAN class="token function">StartEditOperation</SPAN><SPAN class="punctuation token">(</SPAN><SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">;</SPAN>
<SPAN class="comment token">// this probably still points to SDE.DEFAULT instead of SOS.ORDER1</SPAN>
ITable table <SPAN class="operator token">=</SPAN> <SPAN class="punctuation token">(</SPAN>workspace <SPAN class="keyword token">as</SPAN> IFeatureWorkspace<SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">.</SPAN><SPAN class="token function">OpenTable</SPAN><SPAN class="punctuation token">(</SPAN><SPAN class="string token">"GDO.O_LINKA"</SPAN><SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">;</SPAN>
<SPAN class="comment token">// error is thrown here</SPAN>
IRow row <SPAN class="operator token">=</SPAN> table<SPAN class="punctuation token">.</SPAN><SPAN class="token function">CreateRow</SPAN><SPAN class="punctuation token">(</SPAN><SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">;</SPAN><SPAN class="line-numbers-rows"><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN></SPAN>Is there something wrong with this code? After finding the desired geodatabase version and casting it to IMultiuserWorkspaceEdit, workspace still points to "SDE.DEFAULT". How can I properly update the sources to the new version or get a reference to its workspace?
I cannot publish a map service with sources pointing to "SOS.ORDER1" and make the edits directly there as there will be many versions, similar to SOS.ORDER1, created programmatically.