/// <summary> /// This Method is a javascript callable method. /// </summary> /// <param name="e">A parameter from javascript.</param> /// <param name="y">A callback to javascript.</param> public void WebMethod2(string e, Action<string> y) { var x = new NameValueCollection(); var w = new StringBuilder(); w.AppendLine("adding foo"); //x.Add("foo", e); x["foo"] = e; w.AppendLine("reading foo"); var foo = x["foo"]; var message = new { //w = w.ToString(), foo }; y(message.ToString()); }
// https://sites.google.com/a/jsc-solutions.net/backlog/knowledge-base/2014/201405/20140511/roslyn /// <summary> /// This is a javascript application. /// </summary> /// <param name="page">HTML document rendered by the web server which can now be enhanced.</param> public Application(IApp page) { var i = 13; var u = new { i }; // did jsc stack rewriter fix roslyn tostring thingy for jsc? WriteLine(u.ToString()); }
/// <summary> /// This Method is a javascript callable method. /// </summary> /// <param name="e">A parameter from javascript.</param> /// <param name="y">A callback to javascript.</param> public void WebMethod2(string e, Action<string> y) { var x = typeof(string); var xx = e.GetType(); var xxx = ((object)e) is string; var message = new { x, xx, xxx }; y(message.ToString()); }
public void __connect_baduser(string e, Action<string> y) { Native.API.error_reporting(64); var m = new mysqli( "localhost", "noroot", "" ); var message = new { m.connect_errno, m.errno }; y(message.ToString()); }
public void WebMethod2(string e, Action<string> y) { try { new Table1(MyDataSource).With( Table1 => { if (!string.IsNullOrEmpty(e)) { var Last = -1L; Table1.Last( //value => Last value => Last = value ); Table1.Add( // new Tables.Table1.AddQueryParameters new Table1Queries.Insert { // implicit? ContentValue = new { Last, e }.ToString() } ); } Console.WriteLine("before Enumerate"); Table1.Enumerate( // dynamic until we can actually infer what // fields we are getting reader => { var data = new { reader.ContentKey, reader.ContentValue }; // Send it back to the caller. y(data.ToString()); } ); Console.WriteLine("after Enumerate"); } ); } catch { throw; } }
// https://sites.google.com/a/jsc-solutions.net/backlog/knowledge-base/2012/2012/20121217 public void __connect_badhost(string e, Action<string> y) { // <br /> //<b>Warning</b>: mysqli::mysqli(): php_network_getaddresses: getaddrinfo failed: No such host is known. in <b>B:\inc\SimpleMySQLiConsole.ApplicationWebService.exe\class.SimpleMySQLiConsole.ApplicationWebService.php</b> on line <b>17</b><br /> //<br /> //<b>Warning</b>: mysqli::mysqli(): (HY000/2002): php_network_getaddresses: getaddrinfo failed: No such host is known. in <b>B:\inc\SimpleMySQLiConsole.ApplicationWebService.exe\class.SimpleMySQLiConsole.ApplicationWebService.php</b> on line <b>17</b><br /> // http://php.net/manual/en/function.error-reporting.php Native.API.error_reporting(64); var m = new mysqli( "nolocalhost", "noroot", "" ); var message = new { m.connect_errno }; y(message.ToString()); }
public void WebMethod2(string e, Action<string> y) { var m = new mysqli( "localhost", "root", "" ); // <document><y><obj>{ server_info = 5.5.25a, server_version = 50525 }</obj></y></document> //<b>Warning</b>: mysqli::mysqli(): (HY000/1049): Unknown database 'datasource1001' in <b>B:\inc\SimpleMySQLiConsole.ApplicationWebService.exe\class.SimpleMySQLiConsole.ApplicationWebService.php</b> on line <b>17</b><br /> // http://svn2.assembla.com/svn/nooku-framework/trunk/code/libraries/koowa/database/adapter/mysqli.php // http://stackoverflow.com/questions/2203110/check-if-a-variable-is-of-type-mysqli-object //var __is_mysqli = m is mysqli; var message = new { m.server_info, m.server_version, m.stat }; // Send it back to the caller. y(message.ToString()); }
public void __mysqli_query( string sql, Action<string> __y, Action<string, string> yield_field, Action<XElement> yield_resultset ) { __y.ToConsoleOut(); Action<string> y = x => Console.WriteLine("__mysqli_query" + x); Console.WriteLine("hey!"); var h = new History(); h.Insert( new HistoryQueries.Insert { query = sql, context = "__mysqli_query" } ); var m = new mysqli( "localhost", "root", "" ); var flag = m.multi_query(sql); var sqlindex = 0; { var message = new { sqlindex, m.errno, m.error, m.insert_id, }; y(message.ToString()); } while (flag) { var rr = m.store_result(); //Native.Dump(rr); (rr as mysqli_result).With( result => { #region mysqli_result //var f0 = result.fetch_field_direct(0); //var d0 = Native.DumpToString(f0); var message = new { sqlindex, m.errno, m.error, result.field_count, result.num_rows, m.insert_id, //, d0 }; y(message.ToString()); //Console.WriteLine("before fields"); var resultset = new XElement("table"); var resultset_th = new XElement("th"); resultset.Add(resultset_th); var fields = Enumerable.Range(0, result.field_count).Select( // jsc can we have implicit delegates to natives? x => result.fetch_field_direct(x) ).Select( (f, i) => { var n = new { f.name, i, f.type }; //Console.WriteLine("field: " + n); resultset_th.Add( new XElement("td", new XAttribute("title", "type " + f.type), f.name ) ); yield_field(f.name, "" + f.type); return n; } ).ToArray(); //Console.WriteLine("after fields"); for (int row = 0; row < result.num_rows; row++) { result.data_seek(row); var resultset_row = new XElement("tr"); resultset_row.Add( new XAttribute("title", "row " + row) ); var row_data = result.fetch_row(); //Console.WriteLine("row: " + row); // broken? //fields.WithEach( for (int i = 0; i < fields.Length; i++) { fields[i].With( f => { //Console.WriteLine("field: " + f.name); var data = row_data[f.i]; resultset_row.Add( new XElement("td", "" + data ) ); } ); } //resultset_row.Add( // new XElement("dump", Native.DumpToString(row_data)) //); resultset.Add(resultset_row); } yield_resultset(resultset); result.close(); #endregion } ); // mysqli::next_result(): There is no next result set. Please, call mysqli_more_results()/mysqli::more_results() to check whether to call this function/method flag = m.more_results(); if (flag) { flag = m.next_result(); { var message = new { sqlindex, m.errno, m.error, m.insert_id, }; y(message.ToString()); } } sqlindex++; } m.close(); }
/// <summary> /// This Method is a javascript callable method. /// </summary> /// <param name="e">A parameter from javascript.</param> /// <param name="y">A callback to javascript.</param> public void WebMethod2(string e, Action<string> y) { // https://sites.google.com/a/jsc-solutions.net/backlog/knowledge-base/2013/201301/20130101 var x = new __ConsoleToDatabaseWriter(y); Native.API.error_reporting(-1); Console.WriteLine("before data"); var m = new mysqli( "127.0.0.1", "root", "" ); #region query Action<string> query = _sql => { (m.query(_sql) as mysqli_result).With( r => { r.close(); } ); if (m.errno != 0) { var message = new { m.errno, m.error, _sql }; Console.WriteLine(message.ToString()); } }; #endregion query("CREATE DATABASE IF NOT EXISTS `datasource1001`"); query("use `datasource1001`"); { #region create table.sql var sql = @" create table if not exists TheGridTable ( ContentKey INTEGER PRIMARY KEY AUTOINCREMENT , ContentValue text not null , ContentComment text not null , ParentContentKey INTEGER , FOREIGN KEY(ParentContentKey) REFERENCES TheGridTable (ContentKey) ) "; sql = ScriptCoreLib.PHP.Data.SQLiteToMySQLConversion.Convert(sql); #endregion query(sql); } { var sql = @" insert into TheGridTable (ContentValue, ContentComment, ParentContentKey) values ( ? /* text */ , ? /* text */ , ? ) "; (m.prepare(sql) as mysqli_stmt).With( stmt => { Console.WriteLine("in prepare " + new { sql }); string n = null; stmt.bind_param_array("sss", "a ContentValue", "a ContentComment", n ); stmt.execute(); var id = m.insert_id; Console.WriteLine("new item " + new { id }); (m.prepare(sql) as mysqli_stmt).With( cstmt => { //Console.WriteLine("in prepare " + new { sql }); //string n = null; stmt.bind_param_array("ssi", "a ContentValue", "a ContentComment", id ); stmt.execute(); var cid = m.insert_id; Console.WriteLine("new child item " + new { cid }); } ); } ); } { var sql = @" select t1.ContentKey , t1.ContentValue , t1.ContentComment , (select count(*) from TheGridTable t2 where t2.ParentContentKey = t1.ContentKey) as ContentChildren from TheGridTable t1 -- best way where (t1.ParentContentKey is null and (? is null or ? = '')) or t1.ParentContentKey = ? "; Console.WriteLine("x before select"); var stmt = (m.prepare(sql) as mysqli_stmt); if (m.errno != 0) { var message = new { m.errno, m.error, sql }; Console.WriteLine(message.ToString()); } if (stmt != null) { Console.WriteLine("x in prepare " + new { sql }); var aa = new List<object>(); //aa.Add(null); // what if android cannot handle nulls? aa.Add(""); aa.Add(""); aa.Add(""); var aaa = aa.ToArray(); // will it work? stmt.bind_param_array("sss", aaa ); stmt.execute(); stmt.store_result(); Console.WriteLine("x store_result " + new { stmt.num_rows, stmt.field_count }); for (int i = 0; i < stmt.num_rows; i++) { var a = stmt.__fetch_array(); var ContentKey = (int)a["ContentKey"]; var ContentValue = (string)a["ContentValue"]; var ContentComment = (string)a["ContentComment"]; var ContentChildren = (int)a["ContentChildren"]; //var message = new { i, a = Native.DumpToString(a) }; var message = new { i, a = new { ContentKey, ContentValue, ContentComment, ContentChildren } }; Console.WriteLine(message.ToString()); if (ContentChildren > 0) { (m.prepare(sql) as mysqli_stmt).With( cstmt => { cstmt.bind_param_array("iii", ContentKey, ContentKey, ContentKey ); cstmt.execute(); cstmt.store_result(); Console.WriteLine("x child store_result " + new { cstmt.num_rows, cstmt.field_count }); cstmt.free_result(); } ); } } //reader.dispose stmt.free_result(); } } Console.WriteLine("all done"); x.Dispose(); }
/// <summary> /// This is a javascript application. /// </summary> /// <param name="page">HTML document rendered by the web server which can now be enhanced.</param> public Application(IApp page) { // Z:\jsc.svn\examples\javascript\io\DropLESTToDisplay\DropLESTToDisplay\Application.cs // http://xgis.maaamet.ee/xGIS/XGis?app_id=UU82&user_id=at&bbox=529464.185181536,6581178.67615528,549196.965601648,6593508.79911233&LANG=1 // http://www.maaamet.ee/rr/geo-lest/files/geo-lest_function_vba.txt // can we have a list of cities on ? var Helsinki = new { x = 6671069.664199971, y = 552396.6626611819 }; var Tallinn = new { x = 6589000.065127177, y = 542791.0230507818 }; var Haapsalu = new { x = 6533398.0, y = 480832.0 }; var Narva = new { x = 6589333.658324879, y = 737954.1228769943 }; var Tartu = new { x = 6474047.4766877275, y = 659622.4604005406 }; // alright lets do this. new { }.With( async delegate { await google.maps.api; var div = new IHTMLDiv { }.AttachToDocument(); div.style.border = "1px dashed red"; div.style.height = "300px"; div.style.left = "0px"; div.style.right = "0px"; // Z:\jsc.svn\examples\javascript\io\DropLESTToDisplay\DropLESTToDisplay\Application.cs var map = new google.maps.Map(div, new { center = new { lat = 59.4329527, lng = 24.7023564 }, zoom = 6.0 } ); var all = new[] { Helsinki, Tallinn, Haapsalu, Narva, Tartu }; all.WithEach( data => { var marker = new google.maps.Marker( new { position = new { lat = LEST97.lest_function_vba.lest_geo(data.x, data.y, 0), lng = LEST97.lest_function_vba.lest_geo(data.x, data.y, 1) }, //label = "T", //title = "Tallinn", map } ); } ); new IHTMLPre { () => new { map.getCenter().lat, map.getCenter().lng, x = LEST97.lest_function_vba.geo_lest( map.getCenter().lat, map.getCenter().lng, 0), y = LEST97.lest_function_vba.geo_lest( map.getCenter().lat, map.getCenter().lng, 1), } }.AttachToDocument(); // Cannot read property 'getSouthWest' of undefined new IHTMLPre { // rectangle.addListener('bounds_changed', showNewRect); delegate { if (map.getBounds() == null) { return "n/a"; } var getSouthWest_lat = map.getBounds().getSouthWest().lat; var getSouthWest_lng = map.getBounds().getSouthWest().lng; var getNorthEast_lat = map.getBounds().getNorthEast().lat; var getNorthEast_lng = map.getBounds().getNorthEast().lng; var count = ( from data in all let lat = (double)LEST97.lest_function_vba.lest_geo(data.x, data.y, 0) let lng = (double)LEST97.lest_function_vba.lest_geo(data.x, data.y, 1) // lng left to right // lng bottom to top where lat <= getNorthEast_lat where lng <= getNorthEast_lng where lat >= getSouthWest_lat where lng >= getSouthWest_lng select data ).Count(); return new { getSouthWest_lat, getSouthWest_lng, getNorthEast_lat, getNorthEast_lng, count }.ToString(); } }.AttachToDocument(); // http://stackoverflow.com/questions/2472957/how-can-i-change-the-color-of-a-google-maps-marker #region Add new IHTMLButton { "Add" }.AttachToDocument().onclick += delegate { var data = new { map.getCenter().lat, map.getCenter().lng, x = LEST97.lest_function_vba.geo_lest(map.getCenter().lat, map.getCenter().lng, 0), y = LEST97.lest_function_vba.geo_lest(map.getCenter().lat, map.getCenter().lng, 1), }; new IHTMLPre { "new { x = " + data.x + ", y = " + data.y + " }" }.AttachToDocument(); var marker = new google.maps.Marker( new { position = new { lat = LEST97.lest_function_vba.lest_geo(data.x, data.y, 0), lng = LEST97.lest_function_vba.lest_geo(data.x, data.y, 1) }, //label = "H", title = data.ToString(), map } ); }; #endregion #region Add Bounds new IHTMLButton { "Add Bounds" }.AttachToDocument().onclick += delegate { new google.maps.Marker( new { position = new { map.getBounds().getSouthWest().lat, map.getBounds().getSouthWest().lng, }, map } ); new google.maps.Marker( new { position = new { map.getBounds().getNorthEast().lat, map.getBounds().getNorthEast().lng, }, map } ); new google.maps.Marker( new { position = new { map.getBounds().getSouthWest().lat, map.getBounds().getNorthEast().lng, }, map } ); new google.maps.Marker( new { position = new { map.getBounds().getNorthEast().lat, map.getBounds().getSouthWest().lng, }, map } ); }; #endregion } ); }
public static __WebGLShader createShader(this gl gl, ScriptCoreLib.GLSL.VertexShader fragmentShader) { return gl.createShader(GLES20.GL_VERTEX_SHADER, fragmentShader.ToString()); }
public static __WebGLShader createShader(this gl gl, ScriptCoreLib.GLSL.FragmentShader fragmentShader) { return gl.createShader(GLES20.GL_FRAGMENT_SHADER, fragmentShader.ToString()); }
/// <summary> /// This is a javascript application. /// </summary> /// <param name="page">HTML document rendered by the web server which can now be enhanced.</param> public Application(IApp page) { new IHTMLTable().With( table => { var tbody = table.AddBody(); var selectedRow_plus_2 = 0; var selectedRow_minus_2 = 0; var selectedRow = 0; var selectedColumn = 0; // Uncaught TypeError: Cannot call method 'agAABmASXzSNfpl_bHJLUOA' of null //tbody.css.first.child.adjacentSibling["*"].style.backgroundColor = "red"; //tbody.css[IHTMLElement.HTMLElementEnum.tr][() => selectedRow][IHTMLElement.HTMLElementEnum.td].style.backgroundColor = "yellow"; tbody.css[() => selectedRow][IHTMLElement.HTMLElementEnum.td].style.backgroundColor = "yellow"; //tbody.css[() => selectedRow][IHTMLElement.HTMLElementEnum.td].siblings.style.backgroundColor = "green"; //tbody.css[() => selectedRow][IHTMLElement.HTMLElementEnum.td].adjacentSibling.style.backgroundColor = "red"; //tbody.css[() => selectedRow][">td"].style.backgroundColor = "yellow"; tbody.css[IHTMLElement.HTMLElementEnum.tr][IHTMLElement.HTMLElementEnum.td][() => selectedColumn].style.backgroundColor = "yellow"; //tbody.css[">tr"][() => selectedColumn].style.backgroundColor = "cyan"; // { selectorText = >td, rule = [style-id="0"] > tr:nth-child(1) > td } //var header = tbody.css[IHTMLElement.HTMLElementEnum.tr][1][IHTMLElement.HTMLElementEnum.td]; tbody.css[0][IHTMLElement.HTMLElementEnum.td].style.backgroundColor = "gray"; tbody.css[0][0].style.backgroundColor = "red"; tbody.css[() => selectedRow][() => selectedColumn].style.backgroundColor = "red"; tbody.css.odd.style.backgroundColor = "cyan"; var tbody_css_selectedRow_minus_2 = tbody.css[() => selectedRow_minus_2]; var tbody_css_selectedRow_plus_2 = tbody.css[() => selectedRow_plus_2]; (tbody_css_selectedRow_minus_2 | tbody_css_selectedRow_plus_2)[IHTMLElement.HTMLElementEnum.td].style.backgroundColor = "gray"; //tbody.css[1][1].siblings["(:nth-child(8))"].style.backgroundColor = "red"; //tbody.css[1][IHTMLElement.HTMLElementEnum.td].style.backgroundColor = "gray"; for (int y = 0; y < 22; y++) { var tr = tbody.AddRow(); for (int x = 0; x < 22; x++) { var td = tr.AddColumn("?"); var p = new { x, y }; td.onmousemove += delegate { Native.document.title = p.ToString(); selectedRow = p.y; selectedRow_minus_2 = p.y - 2; selectedRow_plus_2 = p.y + 2; selectedColumn = p.x; }; } } } ).AttachToDocument(); }