Add Trigger to Transition

被刻印的时光 ゝ 提交于 2019-12-05 18:38:19

This particular relation (from Transition to Trigger) is probably not supported by the API as such. In that case you'll have to use a workaround.

First you'll need to figure out where exactly EA stores this information. The easiest to figure this out is to start from an empty model, create only the elements you need (state machine, two states, a transition and a trigger) and create the link using the EA GUI.

Then inspect the database. Since you only have these few elements in there it should be quite easy to find where EA has stored the relationship.

If I had to guess I would say that it will probably be stored in the t_xref table, or else somewhere in a style or styleEx column (or the Pdata column as you indicated yourself). Then you'll need to add this info directly into the database using an SQL update or insert query and the undocumented Repository.Execute operation. You can find an example of such a thing on github:

        /// <summary>
        /// copy the workingset tot the given user
        /// </summary>
        /// <param name="user">the user to copy the working set to</param>
        /// <param name="overwrite">if true then the first workingset found with the same name
        /// for the given user will be overwritten</param>
        public void copyToUser(User user, bool overwrite)
        {
            if (overwrite)
            {
                //check if a workingset with the same name already exists
                WorkingSet workingSetToOverwrite = this.model.workingSets.Find(w => 
                                                                    w.user != null
                                                                    && w.user.login == user.login 
                                                                    && w.name == this.name);
                if (workingSetToOverwrite != null)
                {
                    workingSetToOverwrite.delete();
                }
            }
            string insertQuery = @"insert into t_document (DocID,DocName, Notes, Style,ElementID, ElementType,StrContent,BinContent,DocType,Author,DocDate )
                                select '"+Guid.NewGuid().ToString("B")+@"',d.DocName, d.Notes, d.Style,
                                d.ElementID, d.ElementType,d.StrContent,d.BinContent,d.DocType,'" + user.fullName + @"',d.DocDate from t_document d
                                where d.DocID like '"+this.ID+"'";
            this.model.executeSQL(insertQuery);

        }
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!