21 Replies Latest reply on Jan 20, 2015 3:57 PM by Ed Blair

    Accessing the design xml in Workflow Manager

    dale avery

      I am developing a subtask and I need to access the GIS
      features created in a design so I can export a spatial attribute from them to
      support a third party application.  If I
      run the subtask from an open design in ArcMap I can access the design xml to
      get the required data.  But I cannot find
      a way to access the design xml or the GIS data when I execute the subtask from
      Workflow Manager.  Does anyone know of a
      way to accomplish this?  Thanks

        • Re: Accessing the design xml in Workflow Manager

          If the information you're capturing is directly related to the design, you can access the design XML by making use of the package manager.  You'll need to use the IMMPackageManager/MMPackageManagerClass, the workspace the design is saved in, and the IMMPackageName/MMPackageNameClass to get this information.  You get at it by creating a package name object with the category of design xml, type of hidden, and the name is equal to the designs ID.  Pass that package name into the package manager and you should get the package back out.  That package will have the design tree as its contents (in id8listitem form).  From there you should be able to access all design related information.  If you need specific feature/gis information, it may not be available via the design xml.  In that case you would need to access the version associated with the design and make your queries from there.

          1 of 1 people found this helpful
            • Re: Accessing the design xml in Workflow Manager
              dale avery

              Thanks for the reply.

               

              I do need to get GIS specific feature data for my application.  When you say I need to access the design’s version to do my queries, are you talking about something like a difference cursor to see what is in the version?  Is there a way to use the version to find a GIS feature and then find the CU from
              the WFM database which was used to create it?  In ArcMap I can access the design xml (using  IMMListTreeAsXML2  get_ListTreeAsDOM) and navigate the xml document to get the GIS table and subtype for the associated CU.  Is there a way to find the same data when the running a subtask from WFM.  Is this data something I need to cache when the design is in ArcMap so it is available when the design is not open in ArcMap and the subtask is run from WFM?

               

              Thanks again

                • Re: Accessing the design xml in Workflow Manager

                  A difference cursor would likely add unncessecary complexity.  What you can do is get the design xml from the hidden package, get the version name from the process framework (IMMPxSdeVersion is your friend here), get a reference to the login workspace (which should be the workspace that you created the design in, right?), then you can parse the design tree using all of the tablename/objectid information in the design tree to access the features themselves.

                  1 of 1 people found this helpful
                    • Re: Accessing the design xml in Workflow Manager
                      dale avery

                      I am still having trouble getting the hidden package.  All I get back is a null object.  I tried a couple ways to acquire the hidden package but both returned null.  Here is the code I have tried:

                       

                      IMMPxApplicationEx2 pEX = (IMMPxApplicationEx2)mpPXApp;
                      IMMPxSDEVersion pSDEVersion = pEX.GetSDEVersion(pPxNode.Id, pPxNode.NodeType, false);
                      string sVersionName = pSDEVersion.get_Name();
                      IVersionedWorkspace pVWSpace = (IVersionedWorkspace)pEX.Workspace;
                      IVersion pVersion = pVWSpace.FindVersion(sVersionName);
                      IWorkspace pWS = (IWorkspace)pVersion;

                       

                      IMMPackageName pPackName = new MMPackageNameClass();
                      pPackName.Category = mmPackageCategory.mmPCDesignXML;
                      pPackName.Type = mmPackageType.mmPTHidden;
                      pPackName.Name = Convert.ToString(pPxNode.Id);

                       

                      IMMPackageManager pPackMgr = new MMPackageManagerClass();
                      IMMPackage pPackage = new MMPackageClass();
                      pPackage = pPackMgr.GetPackage(pPackName);

                       

                      IMMPackageByWS pPackWS = new MMPackageManagerClass();
                      string sUser = pSDEVersion.get_UserName();
                      IMMPackageName pPackName2 = (IMMPackageName)pPackWS.GetPackageByWS(pPackName, pWS, sUser);

                       

                      Thanks Robert

                        • Re: Accessing the design xml in Workflow Manager

                          It may seem weird, by once you create your package name, pass it into the "GetPackageName" method and use the resulting package name to get the actual package.  That's always worked for me in the past.  It's worth noting that you'll only be able to retrieve the design xml that has been opened and saved in designer (the package of design xml is created / updated every time the design is saved in designer).

                          1 of 1 people found this helpful
                          • Re: Accessing the design xml in Workflow Manager
                            James Wright

                            Dale,

                             

                            This is a complete method for retrieving the Design XML Package as a String with the Design XML. Based on this method, it appears you are doing things a little different. Try and replicate what I am doing here and you should be good to go.

                             

                            Based on your code, it appears your providing the "UserName' to the GetPackageByWS while you should be providing the 'DesignID'. If you go to the MM_HIDDEN_PACKAGES table you will see what I mean. I think thats all your missing.

                             

                            public string getDesignXML(string designID, IWorkspace workspace)

                                    {

                                        IMMPackageName packageName = new MMPackageNameClass();

                                        packageName.Category = mmPackageCategory.mmPCDesignXML;

                                        packageName.Type = mmPackageType.mmPTHidden;

                                        packageName.Name = designID;

                                        IMMPackageByWS pPM = new MMPackageManagerClass();

                                        IMMPackage pPackage = pPM.GetPackageByWS(packageName, workspace, designID);

                             

                             

                                        if (pPackage == null)

                                        {

                                            MMSupportHelper.SetStatusBar("Invalid Design ID or Pacakge Name Provided.");

                                            return "";

                                        }

                             

                             

                                        XMLStreamClass xmlStream = new XMLStreamClass();

                                        MMXMLPackage pXMLPackage = pPackage.Contents as MMXMLPackage;

                                        pXMLPackage.SaveToStream(xmlStream);

                                        string output = "";

                                        try

                                        {

                                            output = xmlStream.SaveToString();

                                        }

                                        catch (Exception e)

                                        {

                                            MMSupportHelper.SetStatusBar("Error saving file: " + e.Message);

                                        }

                             

                                        return output;

                            }

                             

                            Let me know if this works, or if you need any assistance.

                             

                            - James

                    • Re: Accessing the design xml in Workflow Manager

                      Hi Dale,

                       

                      I wanted to follow-up with you on this thread and see if any of Robert's answers above provide what you were looking for.  If so, please find the one that does and and mark it as the "Correct Answer".  If not let us know and if possible, clarify-in-advance what additional details you might be looking for.

                       

                      Note that as it mentions here, only one answer can be marked the 'Correct Answer', but several answers can be marked as helpful, so feel free to mark other contribution as a 'Helpful Answer' if applicable.

                       

                      Thanks!

                      1 of 1 people found this helpful
                      • Re: Accessing the design xml in Workflow Manager
                        dale avery

                        Hi James,

                         

                        I was pulled off from this for a more pressing issue.  I should be able to get back to it the beginning of next week.  I'll let you know how it goes.

                         

                        Thanks,

                         

                        Dale

                        1 of 1 people found this helpful
                        • Re: Accessing the design xml in Workflow Manager
                          dale avery

                          Sorry for the delay in getting to this.  I've been off on another issue.  I tried the code and was able to get it to work successfully.  Many thanks to Robert, Matthew and James for their help.  I will post the code I used when I have a chance.  Thanks again!