Is there any input / output to the local device? - genexus

Are there external objects or functions that can be read and written to the local device as an alternative to ClientStorage in an online application?
I want to use it as an alternative to WebSession.

Why don't you using "file" datatype? this is just my opinion.
Event 'write'
//&tempstring is Character(999), &tempstrings is Character(999) and collection
&file.Source = Directory.TemporaryFilesPath + &file.Separator + "myFile.txt"
&tempstrings.Clear()
&tempstrings.Add(&tempstring)
&file.AppendAllLines(&tempstrings)
Endevent
Event 'read'
&file.Source = Directory.TemporaryFilesPath + &file.Separator + "myFile.txt"
&tempstring = &file.ReadAllText()
Endevent

Related

Appcelerator Ti.Blob text property is null

I came across a strange issue while reading files from Ti.Filesystem.applicationDataDirectory. Whenever I want to access the text property of the Ti.Blob returned by Ti.Filesystem.File.read() I get null
var f = Ti.Filesystem.getFile(Ti.Filesystem.applicationDataDirectory,'foo.key');
var contents = f.read();
Ti.API.debug('contents: ' + JSON.stringify(contents));
var text = contents.text;
Ti.API.debug('text: ' + JSON.stringify(text)); // is NULL
The file was created like so
var f = Ti.Filesystem.getFile(Ti.Filesystem.applicationDataDirectory,'foo.key');
f.write(JSON.stringify({foo: 'bar'});
I'm developing on Android by the way with 6.0.1.GA
TL;DR it's the file extension that's causing the problem
When looking at the Ti.Blob more thoroughly I found that it says mimeType : application/gpg-keys. After updating my code above so it uses foo.json as filename everything works as expected.

register custom tel/callto app in Windows 10

I built this script I share with you here that worked perfectly on my Windows 7 computer to dail a tel:-link in a webpage with my Yealink VOIP phone. With the 'reg-file' you see in the comment I activated the tel-link uasage of my script. But now in Windows 10 I can't get it to work any more! Can anyone help me how I can "link" the "tel link" in a browser to my script again in Windows 10?
/*
test usage: cscript Z:\tel_link_open\tel.js [phone number]
create register_me.reg with:
REGEDIT4
[HKEY_CLASSES_ROOT\tel]
#="URL:knoop.frl Custom Telephone Protocol for VoIP phone"
"URL Protocol"=""
[HKEY_CLASSES_ROOT\tel\shell]
[HKEY_CLASSES_ROOT\tel\shell\open]
[HKEY_CLASSES_ROOT\tel\shell\open\command]
#="cscript \"Z:\\tel_link_open\\tel.js\" -c \"\\%1\""
*/
var call_number = WScript.Arguments(0);
call_number = call_number.replace(/\|.+/g,'');
// spatie -.
call_number = call_number.replace(/(\\tel:|%20|\(|\)|[a-z:\\ -]+)/g,'');
// + 31 ( 0 )
call_number = call_number.replace(/(\+|%2b)([0-9]+)(\(|%28)0(\)|%29)/ig,'00$2');
call_number = call_number.replace(/^0031/ig,'0');
WScript.Echo("\n\nGoing to dail: " + call_number + "\n\n");
//WScript.Sleep(50000000);
var outgoing_uri = "31"+"513"+"[number]"+"[internal extension]";
var login_name = "XXX";
var login_pass = "yyy";
var get_url = "http://192.168.xx.yy/servlet?number=" + call_number + "&outgoing_uri=" + outgoing_uri;
// Load the WinHttpRequest object.
var WinHttpReq = new ActiveXObject("WinHttp.WinHttpRequest.5.1");
// HttpRequest SetCredentials flags
HTTPREQUEST_SETCREDENTIALS_FOR_SERVER = 0;
// Specify the target resource.
WinHttpReq.open( "GET",
get_url,
false );
if (login_name.length) { // Set credentials for server.
WinHttpReq.SetCredentials( login_name,
login_pass,
HTTPREQUEST_SETCREDENTIALS_FOR_SERVER);
}
// It might also be necessary to supply credentials
// to the proxy if you connect to the Internet
// through a proxy that requires authentication.
// Send a request to the server and wait for
// a response.
WinHttpReq.send( );
// Display the results of the request.
WScript.Echo( "Result status: " + WinHttpReq.Status + " " + WinHttpReq.StatusText + "\n");
WScript.Echo( WinHttpReq.GetAllResponseHeaders( ) );
/* To save a binary file use this code instead of previous line
BinStream = new ActiveXObject("ADODB.Stream");
BinStream.Type = 1;
BinStream.Open();
BinStream.Write(WinHttpReq.ResponseBody);
BinStream.SaveToFile("out.bin");
*/
I think you can find a solution at MSDN Microsoft:
*Registering the Application Handling the Custom URI Scheme
To register an application to handle a particular URI scheme, add a new key, along with the appropriate subkeys and values, to HKEY_CLASSES_ROOT. The root key must match the URI scheme that is being added. For instance, to add a scheme, add an [Protocol Name] key to HKEY_CLASSES_ROOT, as follows:
HKEY_CLASSES_ROOT
[Protocol Name]
URL Protocol = ""
Under this new key, the URL Protocol string value indicates that this key declares a custom pluggable protocol handler. Without this key, the handler application will not launch. The value should be an empty string.
...
When a user clicks a link containing your custom URI scheme, Windows Internet Explorer launches the pluggable protocol handler registered for that URI scheme. If the specified open command specified in the registry contains a %1 parameter, Internet Explorer passes the URI to the registered pluggable protocol handler application.*
further details see under
Registering an Application to a URI Scheme
This is working for tel-URI, but callto-URI is somewhere registered by Skype. You have to search in registry for it and add your application there.

Create and show a PDF file from a Lotus Notes action

I'm using an action inside a form to create a Word document, using the CreateObject("Word.application") method, then I modify it to my liking and save it in a temp directory.
I can show the Word document as soon as it is created by calling nameOfTheDocument.visible(true), and by modifying the Save action I can save the newly created document as a PDF, however I can't find a way to show it to the user.
Trying to call visible(true) on the PDF object results in error "Instance member VISIBLE does not exist"
Hmmm... The best and right way - use OS file association.
I'm use java way:
//Win
Process p = Runtime.getRuntime().exec("rundll32 url.dll,FileProtocolHandler " + filePath);
p.waitFor();
//MacOS.*Nix
Process p = Runtime.getRuntime().exec("/usr/bin/open " + filePath);
p.waitFor();
But you can call this command on Lotusscript:
Shell({rundll32 url.dll,FileProtocolHandler } & fullFilePath,1)
'or
Shell({/usr/bin/open } & fullFilePath,1)
We have used the Shell command to launch PDFs in the past. Something like the below. The only downside to this is if the location of the executable changes (whether from upgrade or change to a different program) the code breaks.
Dim ProgPath$, FilePath$
Dim result As Integer
'Path of the executable
ProgPath$ = |"C:\Program Files (x86)\Adobe\Acrobat 7.0\Acrobat\Acrobat.exe"|
'Path of the file to open
FilePath$ = | "C:\TestFile.PDF"|
result = Shell(ProgPath$ & FilePath$,1)

How do I call a batch of Laravel5 commands?

I have a few complex commands that I split up into "sub commands" (Example following). As my site is multi-domain, I need the capability of customizing the sequence and composition of the sub commands to perform (so far I had this in a config under L4). With the migration to L5, I'm refactoring this functionality using the Command bus.
Example of a command sequence:
Site A:
1) AuthorizeCharge
2) DoSomethingA
3) DoSomethingB
4) Charge
Site B
1) AuthorizeCharge
2) DoSomethingA
3) DoSomethingC
4) DoSomethingD
5) Charge
Each of these line items is a Command with it's Handler. This part is fairly clear to me (and works fine).
How can I dispatch this elegantly in my controller?
Here is what I already tried.
Fixed version (works)(in controller):
$return = $this->dispatch( new DoSomethingACommand($form));
$return[] = $this->dispatch( new DoSomethingBCommand($form));
Variable version (pseudo code):
someconfig.php
return [
'DoSomethingACommand',
'DoSomethingBCommand'
];
App\Namespace\Http\Controller\SomeController.php
...
//loop over all scenario commands
for ($j = 0; $j < count($commands); $j++)
{
//make the object which we need to act on
$object = \App::make( $this->_namespace . '\\'. $commands[ $j ] );
$return[] = $this->dispatchFrom( $object, $form ); //Doesnt work
}
I'm a bit stuck on how to solve this. Any advice on how I could implement this?
Why dont you just have a main command that then calls all the other sub-commands itself?
So have one major command called from your controller called HandlePaymentProcessCommand. Then inside that command you then call the sub-commands
1) AuthorizeCharge
2) DoSomethingA
3) DoSomethingC
4) DoSomethingD
5) Charge
This way the sub-commands are all handled in one location (the main command) - and is easily configurable to be changed.

Print current frame during command line render?

Is there a way to basically print my own output during a command line render?
Let's say I don't need/want all the other output that maya spits out by default, I know you can change the verbosity level, but there's very specific things I'd like to output but I can't figure it out. I currently render out the verbosity output to file, so I wanted to print in the terminal (I'm using MAC) the frame that the render is currently up to.
This may just be simple minded, but here's what I tried:
Render -preFrame "print `currentTime -q`;" -s 1 -e 20 -rd /render/directory/ maya_file.mb
Obviously, -preFrame expects a string, according to the docs this can take mel commands, but obviously this is limited to certain commands, I'm assuming the currentTime command is pulling the information from the timeline in maya, not queering it from the Renderer it self... When I run the above command, straight away, it spits out this: -bash: currentTime: command not found and soon after the render fails/doesn't start.
Idealy, I'd like to print the following as it starts each frame:
"Started rendering frame XXXX at TIME GOES HERE", that way, I can quickly look at the terminal, and see if the renderer has failed, stuck or where it's up to and when it started it.
So my question is, seeing is currentTime is a mel command used from within Maya, is there another way I could print this information?
Cheers,
Shannon
After many hours of searching for this answer, I ended up finding out that you can start maya as an interactive shell. By doing this, I was able to source a script as I opened it, and run whatever I want into memory as If I had Maya open at the time.
/Applications/Autodesk/maya2014/Maya.app/Contents/MacOS/maya -prompt -script "/Volumes/raid/farm_script/setupRender.mel"
In the setupRender.mel file, I was able to assign variables, containing options for renders etc, in doing this, I was also able to create a global variable for the frame number, and increment it during the preFrame callback, like so:
int $startFrame = 100;
int $endFrame = 1110;
global int $frameCount = 0;
string $preRenderStatistics = "'global int $frameCount; $frameCount = " + $startFrame + ";'";
string $preFrameStatistics = "'print(\"Rendering frame: \" + $frameCount++)'";
string $additionalFlags = "";
string $sceneFilePath = "'/Volumes/path/to/file/intro_video_001.mb'";
system("Render -preRender " + $preRenderStatistics + " -preFrame " + $preFrameStatistics + " -s " + $startFrame + " -e " + $endFrame + " -x " + $additionalFlags + " " + $sceneFilePath);
This is a very simplified version of what I currently have, but hopefully this will help others if they stumble across it.
Take a look at the pre render layer MEL and/or pre render frame MEL section of the Render Settings.
It expects MEL, so you'll either need to write it in MEL or wrap your python in MEL. For such a simple use, I'd say just write it in MEL:
print `currentTime -q`

Resources