Topic
  • 14 replies
  • Latest Post - ‏2013-03-11T19:26:20Z by Richard_Good
Richard_Good
Richard_Good
61 Posts

Pinned topic communicating between doors processes

‏2013-03-04T16:47:17Z |
Hello DXL’ers,
Some kind soul has seen fit to give me a thorny problem. A databases have been split into two. the two new parts are only loosely connected, but some sort of traceability between them is required. You may reasonably state that the split should never have happend, however it was unavoidable and I simply need to deal with it.
The loose connection is now achieved using external links, though in some cases a key attribute can also be used to match the a module in one database with another in the other database.
I want to use the external link relationship to return attribute information from one end of the external link to the other. I would prefer to do this entirely in dxl assuming it is not too clunky.
I could do fairly simply in two parts (one would produce an xml file from the remote database, the other would consume the xml file in the local database, but the powers that be want the interface to be a simple form similar to existing applications, if not too difficult….
It would be nice to communicate between two dxl processes and not to simply fire a dxl in batch mode synchronously that produces a file close the dxl process, then process my file in the other dxl , then fire another process up etc etc. I guess It would be nice to use skip lists populated in one process in the other, however I can’t see an obvious mechanism for doing this.

Things I want to do are as follows: -
1) On firing new utility from local Database in a module that contains the external links, create a skip list/ file that maps module names to unique ids for the remote database
2) Create a list of target modules by matching the external links urls to the unique ids in the returned skip list/ file, return to a listbox in the utility and allow the user to choose a target module in the remote database
3) On the user choosing a target module load all the attributes from the target module in the remote database into another list box
4) Allow the user to specify what attributes they want and how to display them (I wil port this stuff from an existing utility)
5) Run a dxl on the remote database to return the information specified (will port from existing utilty) in the remote databse into a skip list or file for processing in the local database.
6) Put information into the attribute in the local database.

Any advice on how best to achieve this (other than don’t split connected databases ;-))?

Regards,
Richard
Updated on 2013-03-11T19:26:20Z at 2013-03-11T19:26:20Z by Richard_Good
  • Richard_Good
    Richard_Good
    61 Posts

    Re: communicating between doors processes

    ‏2013-03-04T18:53:36Z  
    I think I might use java and jacob to control the system, maybe simply fire the java app from the doors menu item then throw dxl at two processes from there. Not sure why jacob is not mentioned more as a way to connect DOORS and other items, especially as IBM's other offerrings are mostly written in java.
    https://www.ibm.com/developerworks/forums/thread.jspa?threadID=388530&start=0&tstart=0

    It would probably be more direct to generate my own dll using something like c#, but I can remember having horrible trouble inadvertantly shutting down DOORS when the process finished (see thread below), you would think it would be a better way to go for DOORS 9.X than java though, certainly neater.
    https://www.ibm.com/developerworks/forums/thread.jspa?messageID=14462778&#14462778

    Seems as though there should be a better way of communicating between two DOORS databases.
  • Mathias Mamsch
    Mathias Mamsch
    2259 Posts

    Re: communicating between doors processes

    ‏2013-03-05T19:40:46Z  
    I think I might use java and jacob to control the system, maybe simply fire the java app from the doors menu item then throw dxl at two processes from there. Not sure why jacob is not mentioned more as a way to connect DOORS and other items, especially as IBM's other offerrings are mostly written in java.
    https://www.ibm.com/developerworks/forums/thread.jspa?threadID=388530&start=0&tstart=0

    It would probably be more direct to generate my own dll using something like c#, but I can remember having horrible trouble inadvertantly shutting down DOORS when the process finished (see thread below), you would think it would be a better way to go for DOORS 9.X than java though, certainly neater.
    https://www.ibm.com/developerworks/forums/thread.jspa?messageID=14462778&#14462778

    Seems as though there should be a better way of communicating between two DOORS databases.
    I would not employ a COM connection to DOORS. The fastest and most stable way to go, is to use batch mode. I heard a lot of requests for a general DOORS data interface. I think I might start an open source one on gitgub:

    https://github.com/domoran/DriveDOORS

    The idea would be to have a stable DXL Interface for marshalling data into DOORS and out from DOORS and implement language interfaces for java, python, etc. to talk to that interface. Additionally I envision a server component, that will allow to expose this interface over network.

    If you are interested to join, things will certainly make faster progress when more people work at this. I will try to sketch the idea in a basic design and keep this post up to date with progress.

    Regards, Mathias

    Mathias Mamsch, IT-QBase GmbH, Consultant for Requirement Engineering and D00RS
  • SystemAdmin
    SystemAdmin
    3180 Posts

    Re: communicating between doors processes

    ‏2013-03-06T15:48:08Z  
    I would not employ a COM connection to DOORS. The fastest and most stable way to go, is to use batch mode. I heard a lot of requests for a general DOORS data interface. I think I might start an open source one on gitgub:

    https://github.com/domoran/DriveDOORS

    The idea would be to have a stable DXL Interface for marshalling data into DOORS and out from DOORS and implement language interfaces for java, python, etc. to talk to that interface. Additionally I envision a server component, that will allow to expose this interface over network.

    If you are interested to join, things will certainly make faster progress when more people work at this. I will try to sketch the idea in a basic design and keep this post up to date with progress.

    Regards, Mathias

    Mathias Mamsch, IT-QBase GmbH, Consultant for Requirement Engineering and D00RS
    Hello Mathias

    > https://github.com/domoran/DriveDOORS

    The file design.uml, which program did you have used?

    Thanks
    Wolfgang
  • Richard_Good
    Richard_Good
    61 Posts

    Re: communicating between doors processes

    ‏2013-03-06T15:49:56Z  
    I would not employ a COM connection to DOORS. The fastest and most stable way to go, is to use batch mode. I heard a lot of requests for a general DOORS data interface. I think I might start an open source one on gitgub:

    https://github.com/domoran/DriveDOORS

    The idea would be to have a stable DXL Interface for marshalling data into DOORS and out from DOORS and implement language interfaces for java, python, etc. to talk to that interface. Additionally I envision a server component, that will allow to expose this interface over network.

    If you are interested to join, things will certainly make faster progress when more people work at this. I will try to sketch the idea in a basic design and keep this post up to date with progress.

    Regards, Mathias

    Mathias Mamsch, IT-QBase GmbH, Consultant for Requirement Engineering and D00RS
    Batch mode is certainly the fastest for me to understand, learn't a lot about COM servers and type libraries and assemblies yesterday, but spent a lot of time getting it wrong!

    By batch mode I expect you mean more than simply firing dxls using system commands from one doors session to open another. I imagine various dlls could be loaded and utilised to get running processes, but this did seem laborious and time consuming to think through

    I find writing C# applications much quicker and easier than utilising dlls in DOORS so I tried writing a .net dll and converting it into a type library that can be called from DOORS - this worked, only got as far as doing a hello world and getting the parent DOORS process, then I stopped to reflect. The trouble is it required me to put the generated type library next to the door exe and required access to the registry that users do not usually have. Ideally any system I/we create will not require the user to have access to the registry and to the doors install directories. More than happy to share any of this in your project area/ here. I think you are much more used to working at the DOORS sharp end than I am, your posts certainly suggest that, writing a server component sounds like a good idea, willing to admit I might have taken a wrong turn with the .net dll! Still it is an interesting aside.

    Can't wait to see your plan!

    Richard
  • Richard_Good
    Richard_Good
    61 Posts

    Re: communicating between doors processes

    ‏2013-03-06T15:50:51Z  
    I would not employ a COM connection to DOORS. The fastest and most stable way to go, is to use batch mode. I heard a lot of requests for a general DOORS data interface. I think I might start an open source one on gitgub:

    https://github.com/domoran/DriveDOORS

    The idea would be to have a stable DXL Interface for marshalling data into DOORS and out from DOORS and implement language interfaces for java, python, etc. to talk to that interface. Additionally I envision a server component, that will allow to expose this interface over network.

    If you are interested to join, things will certainly make faster progress when more people work at this. I will try to sketch the idea in a basic design and keep this post up to date with progress.

    Regards, Mathias

    Mathias Mamsch, IT-QBase GmbH, Consultant for Requirement Engineering and D00RS
    Batch mode is certainly the fastest for me to understand, learn't a lot about COM servers and type libraries and assemblies yesterday, but spent a lot of time getting it wrong!

    By batch mode I expect you mean more than simply firing dxls using system commands from one doors session to open another. I imagine various dlls could be loaded and utilised to get running processes, but this did seem laborious and time consuming to think through

    I find writing C# applications much quicker and easier than utilising dlls in DOORS so I tried writing a .net dll and converting it into a type library that can be called from DOORS - this worked, only got as far as doing a hello world and getting the parent DOORS process, then I stopped to reflect. The trouble is it required me to put the generated type library next to the door exe and required access to the registry that users do not usually have. Ideally any system I/we create will not require the user to have access to the registry and to the doors install directories. More than happy to share any of this in your project area/ here. I think you are much more used to working at the DOORS sharp end than I am, your posts certainly suggest that, writing a server component sounds like a good idea, willing to admit I might have taken a wrong turn with the .net dll! Still it is an interesting aside.

    Can't wait to see your plan!

    Richard
  • Mathias Mamsch
    Mathias Mamsch
    2259 Posts

    Re: communicating between doors processes

    ‏2013-03-06T19:40:52Z  
    Batch mode is certainly the fastest for me to understand, learn't a lot about COM servers and type libraries and assemblies yesterday, but spent a lot of time getting it wrong!

    By batch mode I expect you mean more than simply firing dxls using system commands from one doors session to open another. I imagine various dlls could be loaded and utilised to get running processes, but this did seem laborious and time consuming to think through

    I find writing C# applications much quicker and easier than utilising dlls in DOORS so I tried writing a .net dll and converting it into a type library that can be called from DOORS - this worked, only got as far as doing a hello world and getting the parent DOORS process, then I stopped to reflect. The trouble is it required me to put the generated type library next to the door exe and required access to the registry that users do not usually have. Ideally any system I/we create will not require the user to have access to the registry and to the doors install directories. More than happy to share any of this in your project area/ here. I think you are much more used to working at the DOORS sharp end than I am, your posts certainly suggest that, writing a server component sounds like a good idea, willing to admit I might have taken a wrong turn with the .net dll! Still it is an interesting aside.

    Can't wait to see your plan!

    Richard
    Well the plan is, to have an efficient language interface for getting data in and out of DOORS. For this one needs to solve the problem of getting large amounts of data into a DXL script and also return large amounts of data efficiently.

    For this I envision a 'DataMapper' library, that allows deserializing different data structures from files, at the moment I envision:
    • Simple types (string, integer, etc) -> e.g. for passing parameters to the DXL
    • Spreadsheet data -> for returning/receiving tabular data
    • An Hierarchical Object Mapper -> for returning/receiving hierarchical data/class instances.

    So this library allows transforming data from and to strings.

    Then I envision language APIs for C#, java, python, etc.: These have to implement the data mappers themselfes to write data structures that the DXL can understand. The language API basically should have functions to run what I call 'Datalet' (like servelet). A datalet receives data, decodes it using the data mapper and can then process it and return data to the calling program.

    The communication between the language API will be done by a 'Runner' component. This component is responsible for being able to call rapidly many small datalets and get a quick response. Additionally we need a server component for being able to interact with a remote DOORS.

    Nice features, that I also see are, that Datalets contain their own test code and are runnable on its own. Running them directly in the DOORS interpreter execute the test code (for ease of development). The DOORS runner will run the production code. The datalets are separated from the framework, so a new datalet can be deployed by deploying a new file and a non-working datalet will not disturb other files.

    So far for this large scope. The stuff I checked in has nothing of that and the design does not really contain a lot of info yet (it was created with StarUML by the way). But with time this will grow, I will try to work on it here and there, of course it will be more motivating and quicker if you guys want to chime in ;-) But in that case, we should get together outside of the forum. You can reach me under mmamsch at google mail dot com.

    Regards, Mathias

    Mathias Mamsch, IT-QBase GmbH, Consultant for Requirement Engineering and D00RS


    Mathias Mamsch, IT-QBase GmbH, Consultant for Requirement Engineering and D00RS
  • Richard_Good
    Richard_Good
    61 Posts

    Re: communicating between doors processes

    ‏2013-03-08T09:15:26Z  
    Well the plan is, to have an efficient language interface for getting data in and out of DOORS. For this one needs to solve the problem of getting large amounts of data into a DXL script and also return large amounts of data efficiently.

    For this I envision a 'DataMapper' library, that allows deserializing different data structures from files, at the moment I envision:
    • Simple types (string, integer, etc) -> e.g. for passing parameters to the DXL
    • Spreadsheet data -> for returning/receiving tabular data
    • An Hierarchical Object Mapper -> for returning/receiving hierarchical data/class instances.

    So this library allows transforming data from and to strings.

    Then I envision language APIs for C#, java, python, etc.: These have to implement the data mappers themselfes to write data structures that the DXL can understand. The language API basically should have functions to run what I call 'Datalet' (like servelet). A datalet receives data, decodes it using the data mapper and can then process it and return data to the calling program.

    The communication between the language API will be done by a 'Runner' component. This component is responsible for being able to call rapidly many small datalets and get a quick response. Additionally we need a server component for being able to interact with a remote DOORS.

    Nice features, that I also see are, that Datalets contain their own test code and are runnable on its own. Running them directly in the DOORS interpreter execute the test code (for ease of development). The DOORS runner will run the production code. The datalets are separated from the framework, so a new datalet can be deployed by deploying a new file and a non-working datalet will not disturb other files.

    So far for this large scope. The stuff I checked in has nothing of that and the design does not really contain a lot of info yet (it was created with StarUML by the way). But with time this will grow, I will try to work on it here and there, of course it will be more motivating and quicker if you guys want to chime in ;-) But in that case, we should get together outside of the forum. You can reach me under mmamsch at google mail dot com.

    Regards, Mathias

    Mathias Mamsch, IT-QBase GmbH, Consultant for Requirement Engineering and D00RS


    Mathias Mamsch, IT-QBase GmbH, Consultant for Requirement Engineering and D00RS

    Hi Mathias and any other interested parties,
    Had a look at your site and your strategy is probably the best way to go. Couldn't view the uml, even when I downloaded the staruml tool or whatever it was, said it was corrupt. Got something incredibly tedious to do so will have to drop this until next week. Can't upload to your site so dropping my experiment in here. The code for the C# dll project written using visual studio 2008 is attached below
    To use the class in DOORS you need to generate a type library from this dll and put it next to the door.exe, probably some other way of doing it via GAC if you can be bothered
    I have a post build event that runs the following line, this creates a type library registers it and gives it a GUID
    regasm "D:\Visual Studio 2008\Projects\ConnectDoorsServers\ConnectDoorsServers\bin\Release\ConnectDoorsServers.dll" /tlb:"C:\Program Files\IBM\Rational\DOORS\9.2\bin\ConnectDoorsServers.tlb"
     

    using System;
    using System.Collections.Generic;
    using System.Text;
    using System.Diagnostics;
    using DOORSCOMLib;
    using System.Runtime.InteropServices;
    using System.ComponentModel;
    using System.Security.Permissions;
    namespace ConnectDoorsServers
    {
     
        
        /// To use the class in DOORS you need to generate a type library from this dll and put it next to the door.exe, probably some other way of doing it via GAC
        /// I have a post build event that runs the following line, this also registers the dll and gives it a GUID
        /// regasm "D:\Visual Studio 2008\Projects\ConnectDoorsServers\ConnectDoorsServers\bin\Release\ConnectDoorsServers.dll" /tlb:"C:\Program Files\IBM\Rational\DOORS\9.2\bin\ConnectDoorsServers.tlb"
        /// 
        ///You can use the following DXL to test its working
        /////initiate my dll - note that type library has to be registered and installed next to doors.exe
        /////might want to use this as an executable if possible to get around the issue
        ///OleAutoObj conDoorsServerTool = oleCreateAutoObject("ConnectDoorsServers.ControlDoors")
        ///string testStr 
        ///oleGet(conDoorsServerTool, "test", testStr)
        ///print testStr
        ///oleCloseAutoObject(conDoorsServerTool)
        /// </summary>
     
     
        /// <summary>
        /// This needs to have an interface and a delegate we can subscribe to in dxl ideally we want to raise and recieve events from the 
        /// .net system we are building - doubt this will work, worth a little experiment though 
        /// may have to poll the results in dxl using oleSetResult command and poll it here by looking at the DoorClass.Result property or standardout of process
        /// </summary>
        //[InterfaceType(ComInterfaceType.InterfaceIsIDispatch)]
        //public interface IFinishedProcessing 
        //{
        // void OnFinishing(string finishMessage)
        //}
        /// <summary>
        /// Methods exposed to doors here
        /// </summary>
        public interface IControlDoors
        {
            string test { get; }
            void firstConnect();
        }
     
     
     
        //public delegate void FinishingDelegate(string finishMessage);
     
     
        /// <summary>
        /// Need to be able to establish one or more connections and sendxl between them, we also need to be able to connect to already running instances
        /// Need to be able to wait for dxls to be ran and accept back statuses, standard outs, data structures etc
        /// not sure dll referenced by doors is best way forward
        /// </summary>
        [ClassInterface(ClassInterfaceType.None)]//,ComSourceInterfaces("IFinishedProcessing")]
        public class ControlDoors : IControlDoors
        {
            /// <summary>
            /// Constructor need to do something
            /// </summary>
            private Process firstDatabase;
            public ControlDoors()
            {
                System.Windows.Forms.MessageBox.Show("I am Working");
                //firstConnect();
            }
            
            public string test
            {
                get { return "just a test"; }
            }
     
            
            public void firstConnect()
            {
     
     
                // Get all instances of doors running on the local computer. this works when debugged from another project but not when
                //compiled into a dll and not from DOORS! Why?
                Process[] doorsProcArray = Process.GetProcessesByName("doors");
                
                if (doorsProcArray.Length.Equals(0))
                {
                    System.Windows.Forms.MessageBox.Show("This dll should only be loaded from doors");
                }
                else if (doorsProcArray.Length.Equals(1))
                {
                    firstDatabase = doorsProcArray[0];
                    System.Windows.Forms.MessageBox.Show("Working correctly in debug mode");
                }
                else {
                    System.Windows.Forms.MessageBox.Show("More than one doors process running, don't know how to get right one");
                }
     
                //get the correct doors process
                //Fire the event out
                //push the dxl to the process
                //wait for the event to occur
                //trouble is we are firing the event from here the way I have done it, need to fire the event from DOORS and handle it here
                //try again with brain inserted.
     
     
               
                //need to cast the process into doors com lib class or get it off the process somehow
    //dlls can't be static, not what they do can only poll the other DOORS processes, this is not a dll task I guess.
                //DOORSClass d = (DOORSCOMLib.DOORSClass);
                
                //d.runStr("print \"Have we found the parent process\"");
               
            }
     
     
     
         }
        /// <summary>
        /// Pinched from internet should be in seperate class, could consider using ntdll from inside DOORS
        /// </summary>
        [StructLayout(LayoutKind.Sequential)]
        public struct ParentProcessUtilities
        {
            // These members must match PROCESS_BASIC_INFORMATION
            internal IntPtr Reserved1;
            internal IntPtr PebBaseAddress;
            internal IntPtr Reserved2_0;
            internal IntPtr Reserved2_1;
            internal IntPtr UniqueProcessId;
            internal IntPtr InheritedFromUniqueProcessId;
     
            [DllImport("ntdll.dll")]
            private static extern int NtQueryInformationProcess(IntPtr processHandle, int processInformationClass, ref ParentProcessUtilities processInformation, int processInformationLength, out int returnLength);
     
            /// <summary>
            /// Gets the parent process of the current process.
            /// </summary>
            /// <returns>An instance of the Process class.</returns>
            public static Process GetParentProcess()
            {
                return GetParentProcess(Process.GetCurrentProcess().Handle);
            }
     
            /// <summary>
            /// Gets the parent process of specified process.
            /// </summary>
            /// <param name="id">The process id.</param>
            /// <returns>An instance of the Process class.</returns>
            public static Process GetParentProcess(int id)
            {
                Process process = Process.GetProcessById(id);
                return GetParentProcess(process.Handle);
            }
     
            /// <summary>
            /// Gets the parent process of a specified process.
            /// </summary>
            /// <param name="handle">The process handle.</param>
            /// <returns>An instance of the Process class.</returns>
            public static Process GetParentProcess(IntPtr handle)
            {
                ParentProcessUtilities pbi = new ParentProcessUtilities();
                int returnLength;
                int status = NtQueryInformationProcess(handle, 0, ref pbi, Marshal.SizeOf(pbi), out returnLength);
                if (status != 0)
                    throw new Win32Exception(status);
     
                try
                {
                    return Process.GetProcessById(pbi.InheritedFromUniqueProcessId.ToInt32());
                }
                catch (ArgumentException)
                {
                    // not found
                    return null;
                }
            }
        }
    }
    

     


    To test the dll, you can use the following code. Note this will only work if you have registered your type library as detailed in earlier steps: All this just gives a flavour of .net and doors, doesn't really do a lot!

     

     

    //You can use the following DXL to test its working
        //initiate my dll - note that type library has to be registered and installed next to doors.exe
      
        OleAutoObj conDoorsServerTool = oleCreateAutoObject("ConnectDoorsServers.ControlDoors")
        string testStr 
        oleGet(conDoorsServerTool, "test", testStr)
        print testStr
        oleCloseAutoObject(conDoorsServerTool)
    



    This technique is not quite right here, but may well be useful for other things, interesting aside if nothing else.

    Richard



     

    Updated on 2014-01-09T00:10:54Z at 2014-01-09T00:10:54Z by iron-man
  • SystemAdmin
    SystemAdmin
    3180 Posts

    Re: communicating between doors processes

    ‏2013-03-08T09:21:25Z  

    Hi Mathias and any other interested parties,
    Had a look at your site and your strategy is probably the best way to go. Couldn't view the uml, even when I downloaded the staruml tool or whatever it was, said it was corrupt. Got something incredibly tedious to do so will have to drop this until next week. Can't upload to your site so dropping my experiment in here. The code for the C# dll project written using visual studio 2008 is attached below
    To use the class in DOORS you need to generate a type library from this dll and put it next to the door.exe, probably some other way of doing it via GAC if you can be bothered
    I have a post build event that runs the following line, this creates a type library registers it and gives it a GUID
    regasm "D:\Visual Studio 2008\Projects\ConnectDoorsServers\ConnectDoorsServers\bin\Release\ConnectDoorsServers.dll" /tlb:"C:\Program Files\IBM\Rational\DOORS\9.2\bin\ConnectDoorsServers.tlb"
     

    <pre class="javascript dw" data-editor-lang="js" data-pbcklang="javascript" dir="ltr">using System; using System.Collections.Generic; using System.Text; using System.Diagnostics; using DOORSCOMLib; using System.Runtime.InteropServices; using System.ComponentModel; using System.Security.Permissions; namespace ConnectDoorsServers { /// To use the class in DOORS you need to generate a type library from this dll and put it next to the door.exe, probably some other way of doing it via GAC /// I have a post build event that runs the following line, this also registers the dll and gives it a GUID /// regasm "D:\Visual Studio 2008\Projects\ConnectDoorsServers\ConnectDoorsServers\bin\Release\ConnectDoorsServers.dll" /tlb:"C:\Program Files\IBM\Rational\DOORS\9.2\bin\ConnectDoorsServers.tlb" /// ///You can use the following DXL to test its working /////initiate my dll - note that type library has to be registered and installed next to doors.exe /////might want to use this as an executable if possible to get around the issue ///OleAutoObj conDoorsServerTool = oleCreateAutoObject("ConnectDoorsServers.ControlDoors") ///string testStr ///oleGet(conDoorsServerTool, "test", testStr) ///print testStr ///oleCloseAutoObject(conDoorsServerTool) /// </summary> /// <summary> /// This needs to have an interface and a delegate we can subscribe to in dxl ideally we want to raise and recieve events from the /// .net system we are building - doubt this will work, worth a little experiment though /// may have to poll the results in dxl using oleSetResult command and poll it here by looking at the DoorClass.Result property or standardout of process /// </summary> //[InterfaceType(ComInterfaceType.InterfaceIsIDispatch)] //public interface IFinishedProcessing //{ // void OnFinishing(string finishMessage) //} /// <summary> /// Methods exposed to doors here /// </summary> public interface IControlDoors { string test { get; } void firstConnect(); } //public delegate void FinishingDelegate(string finishMessage); /// <summary> /// Need to be able to establish one or more connections and sendxl between them, we also need to be able to connect to already running instances /// Need to be able to wait for dxls to be ran and accept back statuses, standard outs, data structures etc /// not sure dll referenced by doors is best way forward /// </summary> [ClassInterface(ClassInterfaceType.None)]//,ComSourceInterfaces("IFinishedProcessing")] public class ControlDoors : IControlDoors { /// <summary> /// Constructor need to do something /// </summary> private Process firstDatabase; public ControlDoors() { System.Windows.Forms.MessageBox.Show("I am Working"); //firstConnect(); } public string test { get { return "just a test"; } } public void firstConnect() { // Get all instances of doors running on the local computer. this works when debugged from another project but not when //compiled into a dll and not from DOORS! Why? Process[] doorsProcArray = Process.GetProcessesByName("doors"); if (doorsProcArray.Length.Equals(0)) { System.Windows.Forms.MessageBox.Show("This dll should only be loaded from doors"); } else if (doorsProcArray.Length.Equals(1)) { firstDatabase = doorsProcArray[0]; System.Windows.Forms.MessageBox.Show("Working correctly in debug mode"); } else { System.Windows.Forms.MessageBox.Show("More than one doors process running, don't know how to get right one"); } //get the correct doors process //Fire the event out //push the dxl to the process //wait for the event to occur //trouble is we are firing the event from here the way I have done it, need to fire the event from DOORS and handle it here //try again with brain inserted. //need to cast the process into doors com lib class or get it off the process somehow //dlls can't be static, not what they do can only poll the other DOORS processes, this is not a dll task I guess. //DOORSClass d = (DOORSCOMLib.DOORSClass); //d.runStr("print \"Have we found the parent process\""); } } /// <summary> /// Pinched from internet should be in seperate class, could consider using ntdll from inside DOORS /// </summary> [StructLayout(LayoutKind.Sequential)] public struct ParentProcessUtilities { // These members must match PROCESS_BASIC_INFORMATION internal IntPtr Reserved1; internal IntPtr PebBaseAddress; internal IntPtr Reserved2_0; internal IntPtr Reserved2_1; internal IntPtr UniqueProcessId; internal IntPtr InheritedFromUniqueProcessId; [DllImport("ntdll.dll")] private static extern int NtQueryInformationProcess(IntPtr processHandle, int processInformationClass, ref ParentProcessUtilities processInformation, int processInformationLength, out int returnLength); /// <summary> /// Gets the parent process of the current process. /// </summary> /// <returns>An instance of the Process class.</returns> public static Process GetParentProcess() { return GetParentProcess(Process.GetCurrentProcess().Handle); } /// <summary> /// Gets the parent process of specified process. /// </summary> /// <param name="id">The process id.</param> /// <returns>An instance of the Process class.</returns> public static Process GetParentProcess(int id) { Process process = Process.GetProcessById(id); return GetParentProcess(process.Handle); } /// <summary> /// Gets the parent process of a specified process. /// </summary> /// <param name="handle">The process handle.</param> /// <returns>An instance of the Process class.</returns> public static Process GetParentProcess(IntPtr handle) { ParentProcessUtilities pbi = new ParentProcessUtilities(); int returnLength; int status = NtQueryInformationProcess(handle, 0, ref pbi, Marshal.SizeOf(pbi), out returnLength); if (status != 0) throw new Win32Exception(status); try { return Process.GetProcessById(pbi.InheritedFromUniqueProcessId.ToInt32()); } catch (ArgumentException) { // not found return null; } } } } </pre>

     


    To test the dll, you can use the following code. Note this will only work if you have registered your type library as detailed in earlier steps: All this just gives a flavour of .net and doors, doesn't really do a lot!

     

     

    <pre class="javascript dw" data-editor-lang="js" data-pbcklang="javascript" dir="ltr">//You can use the following DXL to test its working //initiate my dll - note that type library has to be registered and installed next to doors.exe OleAutoObj conDoorsServerTool = oleCreateAutoObject("ConnectDoorsServers.ControlDoors") string testStr oleGet(conDoorsServerTool, "test", testStr) print testStr oleCloseAutoObject(conDoorsServerTool) </pre>



    This technique is not quite right here, but may well be useful for other things, interesting aside if nothing else.

    Richard



     

    > Couldn't view the uml, even when I downloaded the staruml tool or whatever it was, said it was corrupt.

    You mustn't believe all error messages of a program. The atachment should work.

    Attachments

  • Richard_Good
    Richard_Good
    61 Posts

    Re: communicating between doors processes

    ‏2013-03-08T09:48:46Z  
    > Couldn't view the uml, even when I downloaded the staruml tool or whatever it was, said it was corrupt.

    You mustn't believe all error messages of a program. The atachment should work.
    I'm pretty sure I downloaded the file ok, just downloaded your version. I open the file or import it and it says its corrupt and I get no useful error message and the file doesn't appear, therefore I tend to believe the error message!
  • SystemAdmin
    SystemAdmin
    3180 Posts

    Re: communicating between doors processes

    ‏2013-03-08T12:19:02Z  
    I'm pretty sure I downloaded the file ok, just downloaded your version. I open the file or import it and it says its corrupt and I get no useful error message and the file doesn't appear, therefore I tend to believe the error message!
    I'm not shure about the problem. I'll test it in detail at home. But I think that the Explorer does not know the extension ".uml" and then he damages the file. At this PC I'm using the IE and if I do not download the file but click on the link the IE shows the svg-content of the file. This data I've copied to the notepad and saved as Design.uml.
  • SystemAdmin
    SystemAdmin
    3180 Posts

    Re: communicating between doors processes

    ‏2013-03-09T13:00:53Z  
    I'm not shure about the problem. I'll test it in detail at home. But I think that the Explorer does not know the extension ".uml" and then he damages the file. At this PC I'm using the IE and if I do not download the file but click on the link the IE shows the svg-content of the file. This data I've copied to the notepad and saved as Design.uml.
    Hi

    At Home I've the same situation in IE and FF. Before I've installed StarUml, the browser show the content of the file and after it, they download it.

    No Damaging.

    Best regards
    Wolfgang
  • SystemAdmin
    SystemAdmin
    3180 Posts

    Re: communicating between doors processes

    ‏2013-03-10T12:27:59Z  
    I'm pretty sure I downloaded the file ok, just downloaded your version. I open the file or import it and it says its corrupt and I get no useful error message and the file doesn't appear, therefore I tend to believe the error message!
    1. When you download the file from the git page, make sure that you load the "Raw" version.
    2. When downloading the attachment from Wolfgang's post, make sure the file is saved as "Design.uml" and not as "Design.uml.xml" as some browsers tend to do.
    3. If in doubt, open the file in notepad.exe and check if it begins with "<?xml version="1.0" encoding="UTF-8"?><XPD:PROJECT " and ends with "</XPD:OBJ></XPD:OBJ></XPD:BODY></XPD:PROJECT>"
    4. I use the version 5.0.2.1570 of StarUml, have no problem when opening the file.
    5. see the png imghttp://up.picr.de/13716734bz.png[/img] which shows you diagram Mathias drew (for whatever reasons, ibm does not allow me to attach this picture, "file contains virus" ???.)

    HTH
    Mike
  • Richard_Good
    Richard_Good
    61 Posts

    Re: communicating between doors processes

    ‏2013-03-11T11:42:06Z  
    1. When you download the file from the git page, make sure that you load the "Raw" version.
    2. When downloading the attachment from Wolfgang's post, make sure the file is saved as "Design.uml" and not as "Design.uml.xml" as some browsers tend to do.
    3. If in doubt, open the file in notepad.exe and check if it begins with "<?xml version="1.0" encoding="UTF-8"?><XPD:PROJECT " and ends with "</XPD:OBJ></XPD:OBJ></XPD:BODY></XPD:PROJECT>"
    4. I use the version 5.0.2.1570 of StarUml, have no problem when opening the file.
    5. see the png imghttp://up.picr.de/13716734bz.png[/img] which shows you diagram Mathias drew (for whatever reasons, ibm does not allow me to attach this picture, "file contains virus" ???.)

    HTH
    Mike
    Whoops! I appear to have installed something other than star uml on the machine in question. It worked a lot better when I actually installed Star UML! I take this as a sign that I was not born to write vast amounts of UML!! Looks like a nice basic tool for this sort of activity.
  • Richard_Good
    Richard_Good
    61 Posts

    Re: communicating between doors processes

    ‏2013-03-11T19:26:20Z  
    Whoops! I appear to have installed something other than star uml on the machine in question. It worked a lot better when I actually installed Star UML! I take this as a sign that I was not born to write vast amounts of UML!! Looks like a nice basic tool for this sort of activity.
    Not a python expert, but I think I got the general idea of your prototype. The one issue I have with this is it seems to fire up a DOORS instance for every query you run. Using standard out is perhaps the best method to get information back from a DOORS process, but ideally I would like to use DOORSCOMLib to fire runStr or runFile at each process and use either SetResult or GetResult and tags in standard out to indicate that processing had finished.
    I find it impossible to get a connection to the DOORSCOMLib type library for the required doors process, I can create one or use an existing one, but I cannot get a connection to a particular one, I only ever get a reference to which ever database I loaded first. Maybe the second processes could be made current or first in the running object table forcing the DOORSCOMLib to be reference in the required DOORS process, massive guess work here. Tried a lot of hacks, nothing wanted to work today, not been this stuck in a long while.
    I would like if possible to have fewer moving parts than in your example, I imagined that I could add a DOORSCOMLIB reference to each doors process, maybe using a moniker. I also hoped it may be possible to hack the doors process to force a particular one to come to the front, this does not seem to work, I can only ever get a reference to the first database I fired up, possibly because there can be only one. Obviously not understanding some key part of this as I have been getting it wrong for the last 5 hours!! I think its possible otherwise I would already have given up.
    Maybe need to create the reference at DOORS startup time, by using a oleCreateObject(“DOORSCOMLIB.DOORSClass”) trouble is I expect that would point to the first database fired as well ;-) and I don’t want to add dependencies that only a few users need