Closed NguyenBentley closed 3 years ago
Here is an overview of how channels work. This error typically indicates you are trying to modify data in a channel that is owned by the connector that produced that data.
@swwilson-bsi this article is inaccessible from the iTwin.js Learning docs - is that an oversight?
Thank We implement a iModelJs bridge that means we do have not so much freedom such as said the the doc "overview of how channels work": create a channel, enter it, ... The orchestrator created the channel and give us so the orchestrator is the owner and we are not
What i do not understand is while i can call toModelDb.elements.insertElement(...) without any problem but LineStyleDefinition.Utils.getOrCreateLinePixelsStyle() throws an exception the 2 calls change the Db ?
Please tell us how should we fix it ? That is my question
Posting some recent correspondence that took place outside of this issue discussion to close the loops.
We are working on a more complete, in-depth sample, but unfortunately it is not ready yet. We are in the process of migrating some updated documentation along with examples to Documentation Overview - iTwin.js We will add a link to overview of channels as well.
Shared resources are stored inside a DictionaryModel model. The Dictionary model is a definition model, which is the child of the root subject of an iModel (0x1). This model typically holds resources that are common across multiple applications. select%20*%20from%20bis.DictionaryModel
In the importDefinitions phase, you could create the necessary linestyles by calling create linestyles in a loop for the ones you may need.
While calling LineStyleDefinition.Utils.getOrCreateLinePixelsStyle(model, IModel.dictionaryId, strokeDasharray) where strokeDasharray is of the type LinePixels defined as
const lsCodes: LinePixels[] = [LinePixels.Solid, LinePixels.Code1, LinePixels.Code2, LinePixels.Code3, LinePixels.Code4, LinePixels.Code5, LinePixels.Code6, LinePixels.Code7];
i get the error "Error |imodeljs-backend.ConcurrencyControl| ChannelConstraintViolation: cannot write to the repository channel while in the channel owned by {"Bridge":"...","Properties":{"BridgeVersion":"1.13.0"}} {"channel":"...","element":{"classFullName":"BisCore:LineStyle","model":"0x10","code":{"spec":"0xf","scope":"0x10","value":"LinePixelsCodeNumber-2"},...}
i then go to "https://dev-imodelconsole.bentley.com" and do select * from BisCore:LineStyle and get the result "-- Total Results: 0"
That means that iModelDb has no BisCore:LineStyle defined and i can not create a new style how can i fix it ? Apply for more rights on the Db or tell the admin of the Db to fix it ?