baannoob
15th January 2015, 22:09
Hi,
I am Baan newbie and I am currently working on an Web Interface as a replacement for the Baan Session and I came to know that Baan has the concept of Application locks which helps prevent multiple users from accessing the same record/field.
I was researching that I read somewhere that some the Baan functionality can be exposed as a COM DLL.
In my usecase, I want to play nice with Baan so that other sessions which might be using the record that I am editing using the Web interface follows the same Baan rules.
Essentially, I would to expose certain Baan internal programming API via a Helper COM Dll that I can use in my .NET application to perform the same locking that would happen as if I was coding in the Baan session.
The ones that I am interested in are:
appl.delete
appl.get.user
appl.modify
appl.set
Is this even possible or am I missing something very basic?:confused:
Thanks for your help!
mark_h
16th January 2015, 00:19
First thought - if you are creating an application lock that a baan standard session will lock for then the lock needs to be created just like the standard baan session does. Of course we don't own source so I could not check how sessions do it. It would probably be easy to just check what was created.
Since I am not a .net application I can't say for sure you can't use the commands themselves. What I know you can do - is create a baan dll that you pass the parameters to - and have it create the lock for you. You can search for like ole and excel, maybe vb.net. You should find threads on how people solve items like this.
You could also probably just write the record directly to the oracle table that the locks are stored in - my system I think it is ttadv998 for company 000. I am just not sure what all the fields are or how they should be filled.
baannoob
16th January 2015, 02:32
Thanks Mark. I think you cleared my doubt. I am pretty close to creating a DLL which exposes standard Application lock functionality so that I can call it directly from my C# program.
You are correct, TRITON.TTTADV998000 is the table and I have already verified that and as you said, I am not exactly sure what goes into all these columns highlighted in my attachment. (Please see attachment)
When I tried a simple code, I was expecting an error (Please see attachment) on saying that the BaanDLL is not valid but I got an connection error. By any chance do you know what's going on?
Thanks again for your help.
baannoob
16th January 2015, 02:33
Sorry missed my attachment in my previous post
bhushanchanda
16th January 2015, 11:31
Hi,
If you want a session to have a Web interface and have application lock, you can write a few lines of code in that session. I guess you do not need an additional DLL to apply application locks.
You can use this function in your session:-
function domain tcbool set.appli.lock()
{
long ret
ret = appl.set("appln_lock_name", APPL.EXCL)
if (ret = -1) or (ret > 0) then
ret = appl.get.user("appln_lock_name",a.user)
message("User %s is currently using session",
a.user)
return(false)
else
if ret = -3 then
message("Not able to set application lock.")
return(false)
endif
endif
return(true)
}
About the error, I am not sure about you calls, but here's a way I did in VB (http://www.baanboard.com/baanboard/showthread.php?p=182493#post182493)
baannoob
16th January 2015, 16:01
Thank you Bhusan for your response. But for me to call Baan code from an external program, I thought I have to compile it as a DLL (C Library).
Am I missing something here?
Thanks,
bhushanchanda
16th January 2015, 16:04
Hi,
What I meant is, you can write a single DLL having logic to set and check application locks as well in addition to your logic for handling data.
mark_h
17th January 2015, 20:10
Follow the link bhushan posted. It shows how to setup a connect to baan using the createobject. Looks like from you screen shots you need that. The other thing is I am not sure how you would fill some of those fields.
baannoob
22nd January 2015, 00:25
Thank u Bhushan and Mark for your responses.
When I try to connection from the VB example, I get the following error.
ActiveX component can't create object or return reference to this object (Error 429)
Ref:https://msdn.microsoft.com/en-us/library/aa231060(v=vs.60).aspx
Also, I am including my username and password inside the .bwc file and set ShowLoginDialog = NO. I hope thats not messing with what I am trying to do.
Am I doing something incorrect?
Thanks
bhushanchanda
22nd January 2015, 10:50
Hi,
I guess you don't need to set ShowLoginDialog = NO Keep it as it is. Also, can you please post your code. One can try it out. Also, I am assuming you are using proper object name.
baannoob
22nd January 2015, 22:06
Thanks Bhushan.
Actually the problem was that I actually didn't configure a default BWC. So I open the BWC and clicked on making it the default and the VB code actually started working.
But since I had ShowLoginDialog =YES, it brought up the Baan login screen and after I put in the username and password, it worked.
Thank you very much for the VB DLL code. :)
bhushanchanda
23rd January 2015, 10:49
Glad that you managed to solve it. You can click on save password for the bwc configuration and you won't see the dialog as well. Thanks for sharing your solution.
baannoob
11th February 2015, 00:25
Bhushan,
I think I am still missing something. Our Baan developers wrote the code and compiled it into a DLL and when I tried to invoke it, I got the attached error messages.
Is there a special way to compile these DLL's.? Also do we need to put these DLL's in a specific directory for my login to be able to invoke it?
Please help! Thanks
baannoob
11th February 2015, 00:27
Files attached.
baannoob
11th February 2015, 00:38
This is the code in my C# program
- Please note that I had to specify the entire path to the Baan DLL for even to try executing the code.
object Baan = null;
Type t = Type.GetTypeFromProgID("Baan4.Application.baandev");
Baan = Activator.CreateInstance(t);
Console.WriteLine("After Baan Object Creation");
object[] Parameters = new Object[1];
Parameters[0] = 3600;
//Baan.Timeout = 3600;
Baan.GetType().InvokeMember("Timeout", BindingFlags.SetProperty, null, Baan, Parameters);
Console.WriteLine("After Baan Timeout");
Parameters = new Object[2];
Parameters[0] = "/apps/Baan4b/bse/application/isB40O_b2_mdv0/oissls/baanlib"; // DLL Name
Parameters[1] = "set.line.lock(\"1001\",\"25\")"; // Function Name
Baan.GetType().InvokeMember("ParseExecFunction", BindingFlags.InvokeMethod, null, Baan, Parameters);
Console.WriteLine("After ParseExecFunction ");
//Baan.Quit();
Baan.GetType().InvokeMember("Quit", BindingFlags.InvokeMethod, null, Baan, null);
Console.WriteLine("After Quit ");
bhushanchanda
11th February 2015, 06:10
Hi,
I can see #include<stdio.h>
Please remove that. It is not present in Baan but in C.
Also, if that works, I guess you need to have one more function to check if there is already an application lock. I guess your developers know that.
Please try to remove that header and try again. Make sure your Baan Dev compiles it without any errors.
Note- All headers need to be under declaration: section. Not sure how they compiled the DLL successfully.
baannoob
12th February 2015, 17:41
Hi Bhushan,
If you notice the code carefully, that <stdio.h> reference is commented out with the pipe symbol so I don't believe that the error is coming from the Baan code.
Do you think the error is coming from the C output file which is compiled? Maybe the DLL is being placed in a directory which does not have access to the standard C libraries? Do you think that might be the reason.
Also, I am assuming that the Baan Code must first be converted to a C DLL using the following commands. If my understanding is incorrect, please let me know
Convert a baan dll to a C lib.
bic_cstub6.1 –s –a –d oisslsdllc001 –o baanlib.c
-s – Single bit code
-a ANSI-C source
-d Baan Dll
-o C lib. (Source code)
cc –c –I baanlib.c -o baanlib.o
And then I believe we have to put that DLL somewhere (I don't know exactly where that location is :(). Maybe that's where the problem is.
Another question that I had is, whether you can share the steps that you took to compile your code and expose it to be accessed by VB through excel.
Thanks again for your guidance.
bhushanchanda
12th February 2015, 17:53
Hi,
I am not a C# expert so can't really help with that part. Also, I am not sure why you need to provide full path.
One more thing what I noticed is, you are not prefixing the DLL with "o". You can try to change that odll_name
Here is the Thread (http://www.baanboard.com/baanboard/showthread.php?p=182493#post182493) again and attached are my DLL & VB Scripts.
baannoob
13th February 2015, 22:14
Hi Bhushan,
1) Can you please share the commands and steps that you took to convert Baan Code to a DLL?
2) Is the DLL a C object file (ending with extension ".o")?
Thanks,
Juma
bhushanchanda
13th February 2015, 23:09
Hi,
In Baan/LN, when you create a script, you have to mention the type of script.
To create a DLL, select script type as DLL and create it.
I guess you developer might have used some other script type and hence it might be showing that error.
baannoob
14th February 2015, 00:55
Hi Bhushan,
Thanks for your response. We are on Baan 4.2b not on Baan LN. Not sure whether that makes a difference.:confused:
Thanks,
hklett
15th February 2015, 00:50
I think OLE automation is available since Baan4 C.
So maybee it will not work on Baa4 B