What do you do for scanning from withing Filepro
Brian K. White
brian at aljex.com
Wed Mar 29 13:08:27 PDT 2017
On 3/29/2017 2:08 PM, Bob Rasmussen wrote:
> Brian, thanks for the explanation. How do the server and the client-side
> piece communicate, when no terminal emulator is involved? A socket?
The client does the same thing whether the process is kicked off by
terminal emulator or by a link in a web page.
It's all done by firing off eitheer regular urls to load the cgi to view
stuff, or firing off a custom url to trigger a scan-and-upload (which is
installed and registered by the client installer package, an NSIS
installer on windows, and just part of the plist in the .app on osx.)
The server assembles the necessary metadata into a string and encrypts
it. That encrypted string is the entirety of a query string which is
passed to the client, and the client just passes back to the sever
without ever decrypting it.
So to view all the scans attached to a given record somewhere in the
app, be it from filepro or web front-end, you build the necessary query
string to view. The plaintext before encryption is a csv record like
company,doctype,docnum,,,,sessid
The empty fields are various options that are used for other operations.
sessid is just a random number usually only used to ensure the page
never loads from browser cache.
Then it's encrypted (use whatever type you want, there is a little shell
script with an openssl command in it that's used to encrypt and decrypt)
then run through a url-safe variant of base64, so the entire string
becomes url-safe enough to use as a query string. That's the entire
query string so it's like /http://host/cgi-bin/tsu?HyThkg39ux4tYt8lS2nM...
To do a scan, a similar string is assembled, but it's used with the
custom url, which looks like "as:,hostname,HyThkg39ux4tYt8lS2nM..."
The client OS reacts to the custom url by running the special handler
app, which is just a .cmd fileon windows or a .sh file on osx (really on
osx there is an applescript wrapper which runs the .sh script).
In either case, the batch/shell script performs the scan and generates a
temp pdf, and then does an http POST back to the cgi on the host,
passing the encrypted string as the query string to the cgi, and the pdf
as the POST, no encoding or mime in the post, just the raw binary
contents of the pdf are 100% of the post, all metadata comes from the
query string. In the windows package, it includes a windows executable
of wget or curl (I have used either at different times.) in the osx
case, it uses the OS's curl.
The server cgi knows how to decrypt the query string and file the pdf
away where it should go, or, if the qs fails to decrypt then the post
data is thrown away and nothing happens.
You can generate an as:... url equally easily from filepro or from a cgi
or other server side web language. There is no special sockets or anything.
As for nat, if you can view web pages on the server, then you can scan
to the server. Nat doesn't matter on either client or server side.
If you can ONLY ssh to a server but do not have port 80 forwarded
through nat or firewall, then you could even still do it with ssh
forwarding, if you have the ssh server configured to allow it.
--
bkw
> And how does the server know what the client's IP address is? Will this
> all fail if Network Address Translation sits between client and server?
>
> On Wed, 29 Mar 2017, Brian K. White via Filepro-list wrote:
>
>> On 3/23/2017 5:13 PM, Boaz Bezborodko via Filepro-list wrote:
>>> I'm looking to scan in files linked to specific Filepro records. This
>>> is the first time I'm doing any kind of work like this.
>>>
>>> What methods do you folks use to accomplish this?
>>> What software/hardware combinations make it easier?
>>>
>>> I was thinking of creating separate documents, saved to specific
>>> directories, and storing the file names and locations in the record.
>>> But I don't know what software to use that could trigger the scan and
>>> specify the file name, directory, etc.
>>>
>>> I'm working with Filepro 5.6.10R9 running on Windows7 machines.
>>>
>>> Thanks,
>>> Boaz
>>>
>>
>> I feel bad, I think we have a pretty neat scanning system we've been
>> using for 15 years by now, but I just have not had *any* time the last
>> couple weeks to show it to you. We just instituted all developers
>> using git and not working as root. Not exactly a smooth and painless
>> transition ;)
>>
>> Anyway our scanning process is mostly a cgi that runs in the web
>> server on the same server with filepro, and a small client package (we
>> have windows and osx versions) that has a commandline scanning util,
>> which is run by os registry entries to recognize a custom url, and/or
>> a terminal emulator that has a "run-program" escape sequence feature.
>> You don't have to use the bundled terminal emulator, several other
>> terminal emulators have a similar feature, but the included one is
>> free and open source so no serial numbers or anything to worry about.
>> Just click-n-go.
>>
>> Images are displayed to the user via web browser, and uploaded to the
>> server via http-post, or by the user using a drag-n-drop area in the
>> browser.
>>
>> In filepro you just fire off the right url which pops up the browser
>> on the client to either display previous scans or allow uploading new
>> ones. For more streamlined user process, you can also invoke the
>> scan-and-upload directly from filepro in the terminal without popping
>> up the browser.
>>
>> The files are stored on the filesystem in a directory structure that
>> simply matches your applications natural filepro file structure. If
>> you have an invoice file, and one of the records in the invoice file
>> is invoice 236517, then the files for that invoice end up being stored
>> in a path like:
>> /pix/app-or-system-or-customer-name/invoice/23/65/17-###.pdf
>> where ## is 1 to 100, up to 100 files per customer-doctype-docnumber
>> triplex. The "docnumber" (invoice number in this case) is split up
>> into 2-byte chunks just to keep the filesystem fast by not having a
>> million files in any single directory.
>>
>> (in our case, we have multiple companies or customers using their own
>> datasets (qualifiers) in the same application. So to address a
>> document uniquely, you need 3 pieces of info, company, doctype (quote,
>> invoice, check, etc), docnumber (quote#, invoice#, check#, etc).
>>
>> The worst part is the cgi ksh script that does all the work is kind of
>> a big ugly monster by now after 15 years or so! But, it's still
>> ultimately just a ksh script. There are a few other bits and pieces in
>> total but it's pretty simple.
>>
>> You don't do much extra in filepro at all to add document imaging to
>> any screen in your app. You mostly just add a gosub to any input table
>> and edit 2 values at the top of the gosub for doctype and docnumber to
>> whatever makes sense for that screen in your app.
>>
>> I'd say go to aljex.com and sit in on a sales demo, which will cover
>> the scanning, and you can actually use it in the demo system yourself,
>> but I don't know how much uninteresting trucking logistics stuff you'd
>> have to suffer through to get to the scanning.
>>
>> The client-side code is not only free but open-source, except the
>> windows scanning util is a commercial product we purchased. There are
>> a few different similar utils that can be used for that. I do have a
>> very crude open source scanning util also, but it it is really really
>> crude. It only scans one page at a time, and only outputs a .bmp!
>> There are open source graphics libraries that could be added and used
>> to make a better scanner util, but I'm not a good enough c or windows
>> developer to manage it. The client-side code for osx is 100% open
>> source, including the scanning util, though the osx scanning util is
>> simple and doesn't work on a lot of scanners. Apparently scanner
>> drivers on osx are not consistent at all and many scanners come with
>> their own scanner programs and that is the only thing that works with
>> the scanner. But other scanners do support a common osx image capture
>> api, and those work. The server side, I guess you would have to talk
>> to our owner. I do have a crude proof-of-concept server-side script
>> that is shareable which takes in a scan and just displays it back. But
>> from there you can modify however you want. Even the crude script
>> collects the file and displays it. So just add code to that to do
>> something else with the file like save it in a directory structure of
>> your choice.
>>
>> --
>> bkw
>> _______________________________________________
>> Filepro-list mailing list
>> Filepro-list at lists.celestial.com
>> Subscribe/Unsubscribe/Subscription Changes
>> http://mailman.celestial.com/mailman/listinfo/filepro-list
>>
>
> Regards,
> ....Bob Rasmussen, President, Rasmussen Software, Inc.
>
> personal e-mail: ras at anzio.com
> company e-mail: rsi at anzio.com
> voice: (US) 503-624-0360 (9:00-6:00 Pacific Time)
> fax: (US) 503-624-0760
> web: http://www.anzio.com
> street address: Rasmussen Software, Inc.
> 10240 SW Nimbus, Suite L9
> Portland, OR 97223 USA
>
More information about the Filepro-list
mailing list