QS Hook Function Question

Jun 28, 2005 9 Replies

Based on the surfpro.dll example, I have roughed out a prospective function that I hope will allow me to initiate a membership style control over POS transactions. I'm not 100% sure how to call a QSBridge FireEvent -- ClearCustomer as the POS requires a Customer to complete a sale, so I figure no customer, or take away the customer, no sale... right?



In VB6 this morning, the Date function, literally returned 6/28/2005. Great! If the Customer Expiration Date is stored in CustomDate1, then a quick subtraction and a few conditionals should do it. The subtraction returned an integer calc of the difference. Perfect! Could someone enlighten me as to how to call one of those QSBridge events. Even if it's not totally clean, or requires a tweak and recompilation down the road in the event of RMS changes, that's fine, I just need to introduce this tweak.



Oh yeah, can it be called in the status.htm at the start of transaction? I don't want to have to rely on a cashier to push or enable a macro to get this going. I want it loaded at transaction runtime. I thought if maybe I put it before the TimerID, it'd guarantee a once-only load-up.



Thanks! Kevin


Public Function Profess(Session As Object) As Boolean Dim MembershipEnd As Date 'Session is a QSRules.Session Object



If Session.Transaction.Customer.Loaded Then MembershipEnd = Date - Session.Transaction.Customer.CustomDate1



If Session.Transaction.Customer.CustomDate1 = "" Then MsgBox "Attention! This membership needs an expiration date!", vbCritical



'This is a call to QSBridge FireEvent ClearCustomer, to prevent null dates from continuing Call ClearCustomer End If



If MembershipEnd


I believe the call context should be:

QSRules.Session.Transaction.ClearCustomer instead of my "Call ClearCustomer"

Finally, I believe the most appropriate hooktype that I'd use should be

6 "hooktypeInitializeTransaction"

Can anyone advise me as to whether or not this would work out best? Or does the hooktype start a transaction and has a problem with being called while a transaction is already started (after logging into the POS)?

Sorry, I'm waiting for my VB6 w/comiler to show up!

Thanks, Kevin

Fisher wrote:

Initialize Tranasction is only called at the begining of a new transaction. I think you probably just want to block sales, so you would be better off with a Begin Tender.

Thanks everyone. Now when I try to run my ActiveX DLL, I get the following error:

Attempt to exceute COM object 'Profile1.Process' failed. Could not create object.

I have attached the code and the reg edits that I made:

HKEY_LOCAL_MACHINE\Microsoft\Retail Management System\Store Operations:

\Hooks Count 1

\Hooks\000 Default (value not set) Caption Member Eval Description Membership Qualifier HookType 6 ObjectName Profile1.Process Parameter 1

------ I copied Profile1.dll to my windows\system32 folder and regsvr32'd it.

The Hooks folders were 000 - 029 and all seemed empty. Default install.

The HookType will likely be better as 11 hooktype SaveCustomer (I think if it involves setting the Customer at POS, not making a Customer)

------

The surfpro example that I copied from never contained the whole code. I don't know if PriceSlasher is the name of the function or some variable/pointer declared elsewhere. Could someone give me additional info to figure this one out?

Thanks as always! Kevin

Public Function Process(Session As Object) As Boolean

Dim MembershipEnd As Date 'Session is a QSRules.Session Object

If QSRules.Session.Transaction.Customer.Loaded Then MembershipEnd = Date - Session.Transaction.Customer.CustomDate1

If QSRules.Session.Transaction.Customer.CustomDate1 = "" Then MsgBox "Attention! This membership needs an expiration date!", vbCritical 'This is a call to QSBridge FireEvent ClearCustomer, to prevent null dates from continuing QSRules.Session.Transaction.ClearCustomer End If

If MembershipEnd 0 Then MsgBox "This membership needs to be renewed within " & MembershipEnd & " days!", vbOKOnly End If End If

If MembershipEnd

Try copying the DLL to your RMS add-in's directory.

If you put a MsgBox at the very beginning of the Process function you can determine if the problem is when trying to load the DLL, or if it's code inside the DLL.

Also, to answer your question from your first post, you cannot run QSBridge events from a .DLL, you can only use QSRules. QSBridge is for HTML pages.

Thank you for your responses gentlemen. The "Process" is Public Function Process. This was the syntax listed by the surfpro hook example. My problem was that I couldn't ascertain what the "PriceSlasher" component was. I believe now, the PriceSlasher is the Class.

In my case, the DLL is named Member.dll. The Class is MemberEval.

So in accordance with the above: ProjectName.ClassName It should be Member.MemberEval

I'm going to try and regsvr32 it in the add-in directory and outside and keep tweaking it. Does everyone else's install have 30 folders for numbered hooks in the registry pre-established? I was using the 000 folder.

Thanks for the advice, I feel a lot closer now that I know exactly what the software is expecting. The MsgBox trick wasn't working. It hadn't successfully initialized the object period. I put a MsgBox Hello World for old time's sake.

I'll keep you posted either way! Thanks! Kevin

OK, everything is working normally, that is to say there aren't anymore syntax/naming errors and I have a triggered event working here. The DLL was registered in the same folder with QSRules, the main program folder.

I have my POS set to auto-prompt for a Customer. After I select the customer, a hooktype 5 (Refresh Display) successfully triggers the event and logic.

The bad news, I can't get the proper call to close the POS, abort the transaction. I'm digging through the QSRules right now. Anyone have a suggestion to which one they use? Maybe a force to post tender?

If you could recommend any QSRules derived line, I'd be done! Something like Session.Transaction.Cancel or Closeout. Sorry to be posting like a maniac, but the local Partner that we were in discussions with felt that these customizations were too much for them to handle! So I'm taking matters into my own hands.

My new VB6 code if anyone wants it is (One caveat, this requires two DLLs, one to reset the counter and this to provide the date check... I used another DLL with hooktype 6 (Initialize Transaction) to reset the Session.Variable(10) counter.):

Public Function Process(Session As Object) As Boolean

Dim MembershipEnd As Integer Dim String1 As String Dim String2 As String

If Not Session.Variable(10) > 0 Then

If Session.Transaction.Customer.Loaded Then MembershipEnd = Date - Session.Transaction.Customer.CustomDate1 MsgBox MembershipEnd, vbCritical

If MembershipEnd > 335 Then If MembershipEnd < 365 Then String1 = "This membership needs to be renewed within " & MembershipEnd & " days!" MsgBox String1, vbOKOnly Else String2 = "This membership is overdue for renewal. Please renew the membership!" MsgBox String2, vbCritical 'Close Out Transaction! INSERT COMMAND HERE End If End If

Session.Variable(10) = Session.Variable(10) + 1

Process = True End If

End If

End Function

Thanks, Kevin

Is Process the name of your class?

The registry syntax is: ProjectName.ClassName

ProjectName is usually the same as the DLL's filename, but does not have to be. A Project or DLL may contain many classes - all of which may include a Process Function.

Process is the name of the function - it may also be the name of the class, but that would be unusual...

Also, if this was installed to a machine other than the one it was developed on, just copying the DLL is usually not enough. This looks like VB6, which has a dependency on the VB Runtime if nothing else - use the package and deployment wizard to create a setup package which will include any dependencies.

If I can't get a QSRules command, I might set the session variable to

100, and on the refresh, the status.htm with QSbridge can do the Cleartransaction or ClearCustomer with a conditional. I'm puzzled as to why the QSRules doesn't have all the functionality of the QSBridge? Likely, my lack of knowledge of the dll is the problem.

Thanks, Kevin

Join the Discussion

Have something to add? Share your thoughts — no account required.

Didn't find your answer?

Ask the community — no account required