Difference between revisions of "UBIK Console"
Line 2: | Line 2: | ||
== Concept == | == Concept == | ||
− | C# code will be interpreted like script code. This script can be either loaded from file and executed at start up or directly typed into a console window. | + | C# code will be interpreted like script code. This script can be either loaded from file and executed at start up or directly typed into a console window. When starting up the console it will automatically execute some common using statements in order to comfortably with code from these assemblies: System, UBIK, UBIK.Kernel, System.Collections.Generic, UBIK.Dynamic, System.Linq. If you need other namespaces you need to load them in your code. |
== Example using Script file == | == Example using Script file == | ||
− | In order to execute a C# script file using the {{UBIK}} Console you need execute the UBIK.Console.exe using the ''-cmdfile'' parameter. If you add the ''-connectionstring'' parameter as shown in the example the console will instantiate UBIKEnvironmentConnection variable called ubikEnvironmentConnection | + | In order to execute a C# script file using the {{UBIK}} Console you need execute the UBIK.Console.exe using the ''-cmdfile'' parameter. If you add the ''-connectionstring'' parameter as shown in the example the console will instantiate UBIKEnvironmentConnection variable called ''ubikEnvironmentConnection''. This variable is then accessible in your script and can be used. |
<source lang="xml"> | <source lang="xml"> | ||
UBIK.Console.exe -cmdfile "\\PathToScript\script.txt" -connectionstring "Data Source = ...; Initial Catalog = ...; User ID = ...; Password = ..." | UBIK.Console.exe -cmdfile "\\PathToScript\script.txt" -connectionstring "Data Source = ...; Initial Catalog = ...; User ID = ...; Password = ..." | ||
+ | </source> | ||
+ | |||
+ | The following script code is taken from the example script file and shows how to work with {{UBIK}} Console via script file. | ||
+ | <source = lang"csharp"> | ||
+ | #r "C:\\Users\\cle\\Documents\\Dev\\UBIK.Server\\Branches\\2.6\\UBIK.Console\\bin\\Debug\\DBTool.exe" | ||
+ | System.Data.SqlClient.SqlConnectionStringBuilder scsb = new System.Data.SqlClient.SqlConnectionStringBuilder(ubikEnvironmentConnection.ConnectionString); | ||
+ | string backUpDir = @"C:\SQL\bakup"; | ||
+ | |||
+ | bool isTrue = UBIK.Runtime.WorkflowUtility.Str2Bool("1"); //% | ||
+ | System.Console.WriteLine(isTrue.ToString()); //% | ||
+ | |||
+ | |||
+ | DBTool.MSSQLTools.BackupDatabase(scsb.DataSource, scsb.UserID, scsb.Password, false, scsb.InitialCatalog, bak: string.Format(@"{0}\{1}_{2}_{3}.bak", backUpDir, scsb.InitialCatalog, DateTime.Now.ToString("yyyyMMdd"), DateTime.Now.ToString("HHmm"))); | ||
+ | |||
</source> | </source> | ||
Revision as of 13:36, 16 April 2018
The UBIK® Console project allows a user to interact with UBIK via C# code.
Concept
C# code will be interpreted like script code. This script can be either loaded from file and executed at start up or directly typed into a console window. When starting up the console it will automatically execute some common using statements in order to comfortably with code from these assemblies: System, UBIK, UBIK.Kernel, System.Collections.Generic, UBIK.Dynamic, System.Linq. If you need other namespaces you need to load them in your code.
Example using Script file
In order to execute a C# script file using the UBIK® Console you need execute the UBIK.Console.exe using the -cmdfile parameter. If you add the -connectionstring parameter as shown in the example the console will instantiate UBIKEnvironmentConnection variable called ubikEnvironmentConnection. This variable is then accessible in your script and can be used.
The following script code is taken from the example script file and shows how to work with UBIK® Console via script file.
Invalid language.
You need to specify a language like this: <source lang="html4strict">...</source>
Supported languages for syntax highlighting:
4cs, 6502acme, 6502kickass, 6502tasm, 68000devpac, abap, actionscript, actionscript3, ada, algol68, apache, applescript, apt_sources, arm, asm, asp, asymptote, autoconf, autohotkey, autoit, avisynth, awk, bascomavr, bash, basic4gl, bf, bibtex, blitzbasic, bnf, boo, c, c_loadrunner, c_mac, caddcl, cadlisp, cfdg, cfm, chaiscript, cil, clojure, cmake, cobol, coffeescript, cpp, cpp-qt, csharp, css, cuesheet, d, dcl, dcpu16, dcs, delphi, diff, div, dos, dot, e, ecmascript, eiffel, email, epc, erlang, euphoria, f1, falcon, fo, fortran, freebasic, freeswitch, fsharp, gambas, gdb, genero, genie, gettext, glsl, gml, gnuplot, go, groovy, gwbasic, haskell, haxe, hicest, hq9plus, html4strict, html5, icon, idl, ini, inno, intercal, io, j, java, java5, javascript, jquery, kixtart, klonec, klonecpp, latex, lb, ldif, lisp, llvm, locobasic, logtalk, lolcode, lotusformulas, lotusscript, lscript, lsl2, lua, m68k, magiksf, make, mapbasic, matlab, mirc, mmix, modula2, modula3, mpasm, mxml, mysql, nagios, netrexx, newlisp, nsis, oberon2, objc, objeck, ocaml, ocaml-brief, octave, oobas, oorexx, oracle11, oracle8, oxygene, oz, parasail, parigp, pascal, pcre, per, perl, perl6, pf, php, php-brief, pic16, pike, pixelbender, pli, plsql, postgresql, povray, powerbuilder, powershell, proftpd, progress, prolog, properties, providex, purebasic, pycon, pys60, python, q, qbasic, rails, rebol, reg, rexx, robots, rpmspec, rsplus, ruby, sas, scala, scheme, scilab, sdlbasic, smalltalk, smarty, spark, sparql, sql, stonescript, systemverilog, tcl, teraterm, text, thinbasic, tsql, typoscript, unicon, upc, urbi, uscript, vala, vb, vbnet, vedit, verilog, vhdl, vim, visualfoxpro, visualprolog, whitespace, whois, winbatch, xbasic, xml, xorg_conf, xpp, yaml, z80, zxbasic
#r "C:\\Users\\cle\\Documents\\Dev\\UBIK.Server\\Branches\\2.6\\UBIK.Console\\bin\\Debug\\DBTool.exe" System.Data.SqlClient.SqlConnectionStringBuilder scsb = new System.Data.SqlClient.SqlConnectionStringBuilder(ubikEnvironmentConnection.ConnectionString); string backUpDir = @"C:\SQL\bakup"; bool isTrue = UBIK.Runtime.WorkflowUtility.Str2Bool("1"); //% System.Console.WriteLine(isTrue.ToString()); //% DBTool.MSSQLTools.BackupDatabase(scsb.DataSource, scsb.UserID, scsb.Password, false, scsb.InitialCatalog, bak: string.Format(@"{0}\{1}_{2}_{3}.bak", backUpDir, scsb.InitialCatalog, DateTime.Now.ToString("yyyyMMdd"), DateTime.Now.ToString("HHmm")));
PwdTool
If you do not want to type in your password in plain text you can first generate an encrypted password by executing Pwd.Encrpyt in the UBIK® Console.