Hot Topic (More than 10 Replies) On auto-printing a record from web data (Read 1453 times)
chaven
Member
*
Offline


There's no way out of
here...

Posts: 18
Joined: Apr 2nd, 2013
On auto-printing a record from web data
Apr 2nd, 2013 at 8:48pm
Print Post Print Post  
I am developing a system that allows employees to access a local webpage and submit a Maintenance request that will automatically print at our Maintenance department printer. 

The webpage is constructed, and when data is entered it is updated into the database on the Sesame web-server.  I can also print correctly from the application itself through Sesame.exe

My question is, how do I tell the Sesame server to automatically print a record when it arrives after the user submits it?  That is, without having someone actively open the application. 

I am aware of "On Form Entry" and "On Form Change" I could use to trigger the code...but are these events triggered by records appearing via the "web?" 

Just wondering if anyone else has done this?  I am going to begin this part of development tomorrow, but was unable to find anything in the documentation that concretely says it's possible.

Thanks all!  Cool
  

...when you come in, you're in, for good.
Back to top
 
IP Logged
 
chaven
Member
*
Offline


There's no way out of
here...

Posts: 18
Joined: Apr 2nd, 2013
Re: On auto-printing a record from web data
Reply #1 - Apr 3rd, 2013 at 2:55pm
Print Post Print Post  
No luck yet...

I have tried triggering the code using multiple ways and I got nothing so far.  Anybody have any ideas on triggering Sesame code from a web based record being created?

-=K=-
  

...when you come in, you're in, for good.
Back to top
 
IP Logged
 
The Cow
YaBB Administrator
*****
Offline



Posts: 2530
Joined: Nov 22nd, 2002
Re: On auto-printing a record from web data
Reply #2 - Apr 3rd, 2013 at 4:31pm
Print Post Print Post  
Are you using the internal Sesame web server or are you using the Sesame API to talk to a Sesame server from a web server such as Apache?

In either case, you will need to either run a client and attach to the Sesame server. You can either run the client on an interval and have it run some SBasic code in the application open event, or you can keep a client open and attached and run some code on an interval.

The code will then check if there are any additional records and print them as necessary.

In general, the server does not run any SBasic code. You can run Mass Updates on the server directly.

If it is absolutely cannot use an attached client and you are using the Sesame API, you can call SesameRunProgram to run a bit of SBasic on a result set without a client.
  

Mark Lasersohn&&Programmer&&Lantica Software, LLC
Back to top
IP Logged
 
chaven
Member
*
Offline


There's no way out of
here...

Posts: 18
Joined: Apr 2nd, 2013
Re: On auto-printing a record from web data
Reply #3 - Apr 3rd, 2013 at 8:59pm
Print Post Print Post  
I am using an internal Sesame server. 

I already have a client running the application on the server machine.  Sesame requires this as a security measure in order to update/add records to a database from a webpage. 

An interval is not a bad idea...hmmmm...

Originally, I wanted it to print the moment we received the order, but I suppose I could try it with a moderate interval and see how that goes.  Excellent idea, I'll give it a try.  However, I wouldn't even know where to begin telling Sesame to only query and print new orders, as opposed to those already printed.

Perhaps I could make 2 separate databases:

1 That collects the requests and hold them for a specific interval.  It then prints ALL its records, copies those records to another database, then deletes said records from it-self.

It might work.....yeah.....it has to work....

Until tomorrow!  Ill keep you posted...

-=K=-
  

...when you come in, you're in, for good.
Back to top
 
IP Logged
 
The Cow
YaBB Administrator
*****
Offline



Posts: 2530
Joined: Nov 22nd, 2002
Re: On auto-printing a record from web data
Reply #4 - Apr 3rd, 2013 at 9:05pm
Print Post Print Post  
Instead of two databases, just add a field indicating whether the record has been printed. When you print it - set the field. When scanning (probably XResultSetSearch) for records to print, search on that field and only print records wherein it has not been set.
  

Mark Lasersohn&&Programmer&&Lantica Software, LLC
Back to top
IP Logged
 
chaven
Member
*
Offline


There's no way out of
here...

Posts: 18
Joined: Apr 2nd, 2013
Re: On auto-printing a record from web data
Reply #5 - Apr 4th, 2013 at 5:04pm
Print Post Print Post  
I cant come up with a way to get the print timer working without completely locking up the application:

I tried using For/While loops on Form Reveal and this locks up the application before the form loads.  I'm using @ServerTime to calculate the print job in 1 minute intervals.

I tried using "Loiter(60000)" so the code block would wait 60 seconds before running again.  However, this seemingly locks up the application entirely for that 60 seconds. 

Neither option allowed me to load data into it from the webpage because the loop (obviously) is never being left on Form Reveal.  Perhaps I could try attaching it to a different element - not sure if that would make a difference or not.

Does anyone know of a way to run a piece of code, at an interval, without using For/While loops that hog up control of the program and prevent adding data?
  

...when you come in, you're in, for good.
Back to top
 
IP Logged
 
The Cow
YaBB Administrator
*****
Offline



Posts: 2530
Joined: Nov 22nd, 2002
Re: On auto-printing a record from web data
Reply #6 - Apr 4th, 2013 at 5:11pm
Print Post Print Post  
You will probably want to use RunEntryOnInterval.

You can use a while loop, but yes it will stop you from using that client interactively until the while loop completes.
  

Mark Lasersohn&&Programmer&&Lantica Software, LLC
Back to top
IP Logged
 
chaven
Member
*
Offline


There's no way out of
here...

Posts: 18
Joined: Apr 2nd, 2013
Re: On auto-printing a record from web data
Reply #7 - Apr 4th, 2013 at 6:37pm
Print Post Print Post  
The Cow = The Genius

After some stumbling over the syntax, I got this command to work.  I'm ashamed I didn't come across it myself while pouring over my programming guide. 

I now have a button on the server-side application that can be pressed to "Start Auto Printing."  Another press shuts it off. 

Now I know how to automate the code, its only a matter of changing it too pull the correct records and alter them after they have been printed.

Thanks for all your help Cow, I'll let you know how it turns out.

Cool

-=K=-
  

...when you come in, you're in, for good.
Back to top
 
IP Logged
 
The Cow
YaBB Administrator
*****
Offline



Posts: 2530
Joined: Nov 22nd, 2002
Re: On auto-printing a record from web data
Reply #8 - Apr 4th, 2013 at 6:50pm
Print Post Print Post  
I'm not really a genius, I just have a lot of "inside information". But still, thanks. Please let us know how it goes.

If your application is for general public consumption, or needs to be secure, please consider using a more complete web server, like Apache, and the Sesame API. The API is available in C, C++, C#, Java, Perl, Python, and PHP, allowing you to access your Sesame server from pretty much any CGI code.
  

Mark Lasersohn&&Programmer&&Lantica Software, LLC
Back to top
IP Logged
 
chaven
Member
*
Offline


There's no way out of
here...

Posts: 18
Joined: Apr 2nd, 2013
Re: On auto-printing a record from web data
Reply #9 - Apr 5th, 2013 at 4:45pm
Print Post Print Post  
Success!

Application is working as intended so far.  Users all over campus can now access the local webpage, fill out a form, and it prints at the maintenance shop automatically.

The program scans its records once every 60 seconds ( I may change this as the database grows ) and finds records that have not been printed.  It then prints those records and sets the records as "printed." 

When accessing the application directly, edits can be made to records and the status changed to "not printed;" this will force the record to print on the next cycle.  A "print now" button could be added easily.

There are a few minor things I need to fix with the format, but otherwise it seems to work pretty well.  I tested it's ability to overcome tragedies, like when the printer jams or runs out of paper:  because all printing is done through the spooler on the server system, the jobs are simply stored until more paper is fed to the printer.  I may try a more extensive test of this later...

I'm not too worried about security at this point, as the data is backed up and it's not sensitive.  The next thing I will add is attaching a unique ID to each work order as it is created, as well as a few bells and whistles to make the application easier to work with.

Not bad for my first real Sesame application.  Thanks again to "The Cow" for all the help. 

-=K=-
  

...when you come in, you're in, for good.
Back to top
 
IP Logged
 
The Cow
YaBB Administrator
*****
Offline



Posts: 2530
Joined: Nov 22nd, 2002
Re: On auto-printing a record from web data
Reply #10 - Apr 5th, 2013 at 5:17pm
Print Post Print Post  
You're welcome.
  

Mark Lasersohn&&Programmer&&Lantica Software, LLC
Back to top
IP Logged