Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Simphony POS Client Extension Application, subscribe to OpsTmedEvent method

Status
Not open for further replies.

JCCR

IS-IT--Management
Mar 20, 2016
71
0
0
CO
Hello everybody

The following code is a DLL in which I am trying to subscribe to the OpsTmedEvent event automatically, but I have not succeeded unless I call the MyExtensionTest method from a button. I appreciate if someone can help me by indicating how I can make the subscription be done without any button being used, that is, that the OpsTmedEvent method listens since Simphony loads. Thank you.



Code:
using System;
using System.Text;
using Micros.Ops;
using Micros.Ops.Extensibility;
using Micros.PosCore.Extensibility;
using Micros.PosCore.Extensibility.Ops;

namespace Test_Simphony
{
    public class TestSimphony : OpsExtensibilityApplication
    {
        
        public TestSimphony(IExecutionContext context) : base(context)
        {
            this.OpsTmedEvent += OnTmedEvent;
        }

        [ExtensibilityMethod]
        public void MyExtensionTest()
        {
            OpsContext.ShowMessage(string.Format("Hello World from {0}", this.ApplicationName));
        }


        private EventProcessingInstruction OnTmedEvent(object sender, OpsTmedEventArgs args)
        {
            try
            {
                OpsContext.ShowMessage("OnTmedEvent");
                return (EventProcessingInstruction)0;
            }
            catch
            {
                return (EventProcessingInstruction)1;
            }

        }

        
    }

    

    public class ApplicationFactory : IExtensibilityAssemblyFactory
    {
        public ExtensibilityAssemblyBase Create(IExecutionContext context)
        {
            return new TestSimphony(context);
        }

        public void Destroy(ExtensibilityAssemblyBase app)
        {
            app.Destroy();
        }
    }
}
 
Hello,
What you have should work just fine.
The only thing i can think of is that, you may have added the event subscription code after your created your Extension application in EMC and that the Service Host you are testing on still has the old version without the event subscription instantiated.

You got a remember that every time you build a new version of your dll, not only you have to uploaded to EMC as Ext app content, but that has to be downloaded to the Service Hosts and it has to be instantiated. you gotta repeat these steps for every new version:
1. Uploaded the new version as Ext App content in EMC: this saves the binary to central DB as a BLOB
2. Perform a Re-Load DB on the Service Host :This will download the the new BLOB from the central DB to local SQL Express DB
3. Restart the Service host: this will save the BLOB from the local DB onto the file system and instantiate it


This is the cycle you gotta keep repeating after each change you make. After a while it gets tedious. You have couple of options to make this process more efficient:
1. Install VS studio on SH, and for your Extension app use the file from bin/debug folder. than in your project Debug properties, use "start External Program" option to start the Service Host each time you build + debug. This is handy if you want to be able to put break points in your code
2. If your SH is a standard micros HW, you may notice that the performance of it is may not cut it for you. In that case you can build the new dll on your desktop, and copy the dll to SH manually(I use PS scripts for this ), and instruct it to use the .dll from a different folder than the default handlers folder


both of these above will eliminate the need for uploading the new version to EMC every time, and having to do "reload db"

Hope this help

 
Thank you very much for your help. I did what you told me but it didn't work for me, I always have to call some method to initialize the dll.
 
JCCR,
Hmmm. Not sure, what's happening. I took your class and built an EA out of it an it works for me. Here is the configuration screen shots from EMC:
Extension App:
EA2_bregc4.png
PAge_omvji5.png
Tmed_iejcwc.png
EA_cnxxt7.png


After i setup the above in EMC, on the Service Host I did:
1. "Reload DB"
2. Killed the Service Host
3. Restarted Service Host

I tried to delete the dll, and it didnt let me as expected, cause it's instentiated:
Delete_zw7mzo.png



1. Rang up an item
2. Rang up "Tektips" Tmed

And i get your message box as expected:
OPS_y4oxp0.png


Hope this helps
 
Is the option bit to disable the extension application enabled?

I think it still loads on a button press if the application is disabled and the DLL already exists on the disk.

Specialist in creating custom applications for the Micros POS range: 3700, 9700, Simphony FE, Simphony. SIM Scripts, Data Exports, Simphony extension applications, API Creation and integration. If you need anything please contact me via my website
 
codexPOSed and CathalMF

thank you very much for your answers. The Disable application bit is disabled, and I still have to use the button to initialize the dll.
 
What version of Simphony?

Specialist in creating custom applications for the Micros POS range: 3700, 9700, Simphony FE, Simphony. SIM Scripts, Data Exports, Simphony extension applications, API Creation and integration. If you need anything please contact me via my website
 
Have a look at the egateway log file to see if there is some error when loading your dll. Look for any references to your dll or extension application name.
Do a clean startup of the servicehost and then look at the log.

You should see an entry like this:

06/20/21 20:07:03.703, 0, 0,OPS , 13,=== extension app found in [YourDllName.dll] [Application],

Have you enabled any other option bits in the extension application configuration?

Specialist in creating custom applications for the Micros POS range: 3700, 9700, Simphony FE, Simphony. SIM Scripts, Data Exports, Simphony extension applications, API Creation and integration. If you need anything please contact me via my website
 
Hi CathalMF

No bit is enabled.

I found the following error:




06/20/21 16:09:55.298, 0, 0,LoadHandlers, 15,ExtensibilityServicesList: [ExtApp]: error initializing dll [C:\Users\Camilo\Desktop\MyDll.dll]: System.IO.FileNotFoundException: Could not load file or assembly 'file:///C:\Users\Camilo\Desktop\MyDll.dll' or one of its dependencies. The system cannot find the file specified.
File name: 'file:///C:\Users\Camilo\Desktop\MyDll.dll'
at System.Reflection.RuntimeAssembly._nLoad(AssemblyName fileName‚ String codeBase‚ Evidence assemblySecurity‚ RuntimeAssembly locationHint‚ StackCrawlMark& stackMark‚ IntPtr pPrivHostBinder‚ Boolean throwOnFileNotFound‚ Boolean forIntrospection‚ Boolean suppressSecurityChecks)
at System.Reflection.RuntimeAssembly.nLoad(AssemblyName fileName‚ String codeBase‚ Evidence assemblySecurity‚ RuntimeAssembly locationHint‚ StackCrawlMark& stackMark‚ IntPtr pPrivHostBinder‚ Boolean throwOnFileNotFound‚ Boolean forIntrospection‚ Boolean suppressSecurityChecks)
at System.Reflection.RuntimeAssembly.InternalLoadAssemblyName(AssemblyName assemblyRef‚ Evidence assemblySecurity‚ RuntimeAssembly reqAssembly‚ StackCrawlMark& stackMark‚ IntPtr pPrivHostBinder‚ Boolean throwOnFileNotFound‚ Boolean forIntrospection‚ Boolean suppressSecurityChecks)
at System.Reflection.RuntimeAssembly.InternalLoadFrom(String assemblyFile‚ Evidence securityEvidence‚ Byte[] hashValue‚ AssemblyHashAlgorithm hashAlgorithm‚ Boolean forIntrospection‚ Boolean suppressSecurityChecks‚ StackCrawlMark& stackMark)
at System.Reflection.Assembly.LoadFrom(String assemblyFile)
at ExtensibilityServiceHandler.ExtensibilityServicesList.TryWriteDll(ExtensibilityService service‚ Boolean ret‚ DllEntry dllEntry‚ String filename‚ String displayname)

WRN: Assembly binding logging is turned OFF.
To enable assembly bind failure logging‚ set the registry value [HKLM\Software\Microsoft\Fusion!EnableLog] (DWORD) to 1.
Note: There is some performance penalty associated with assembly bind failure logging.
To turn this feature off‚ remove the registry value [HKLM\Software\Microsoft\Fusion!EnableLog].
 
Thats a weird error due to the DLL path.

You have not written a Extensibility Service so i dont expect this to load but the error about not initialising the DLL due to it not being found in the c:\users\camilo\desktop path is weird.

When you launch the servicehost are you using a shortcut? Do you have any custom "start in" directory for the shortcut?
Can you try launching the servicehost directly by running the .exe instead of a shortcut?

Specialist in creating custom applications for the Micros POS range: 3700, 9700, Simphony FE, Simphony. SIM Scripts, Data Exports, Simphony extension applications, API Creation and integration. If you need anything please contact me via my website
 
Hi CathalMF

I already did the test by running servicehost directly but it didn't work.
 
Very strange.

Id be happy to take a quick look at your system later today if you want?

Specialist in creating custom applications for the Micros POS range: 3700, 9700, Simphony FE, Simphony. SIM Scripts, Data Exports, Simphony extension applications, API Creation and integration. If you need anything please contact me via my website
 
Yes, of course. I would appreciate it immensely. Please confirm me the hour you can do it.
 
Send me a message on my website. Im free now.

Specialist in creating custom applications for the Micros POS range: 3700, 9700, Simphony FE, Simphony. SIM Scripts, Data Exports, Simphony extension applications, API Creation and integration. If you need anything please contact me via my website
 
I already sent it. Very thank you.
 
The problem was that JCCR was using this debug feature by modifying the web.config.txt

<add key="Debug.[my-app-name].LoadDLLFromFileNameOrigin" value="1" />


I have never used that, so i dont know why it causing it to fail. But removing it from the web.config.txt allowed the Extension Application to work normally.



Specialist in creating custom applications for the Micros POS range: 3700, 9700, Simphony FE, Simphony. SIM Scripts, Data Exports, Simphony extension applications, API Creation and integration. If you need anything please contact me via my website
 
CathalMF

Very very thanks.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top