public SqliteCommand getNewSqlCommand(string sqlText, SqliteParameter[] par) { ToolMobile.log(sqlText); SqliteCommand cmd = new SqliteCommand(); cmd.CommandText = this.prepareSqlText(sqlText); cmd.Connection = this.getConnection(); cmd.Transaction = this.getTransaction(); //cmd.CommandTimeout = this.getSqlTimeOut(); if (par != null) { cmd.Parameters.AddRange(par); } return(cmd); }
public static void setEnvironment(IEnvironment pEnv) { if (_environment != null) { var x = _environment; _environment = null; x.Dispose(); } _environment = pEnv; if (_environment == null) { ToolMobile.log("environment stoped"); } else { ToolMobile.log("environment starting"); } }
internal bool openBT() { BluetoothAdapter mBluetoothAdapter = getAdapter(); BluetoothDevice mmDevice = null; if (mBluetoothAdapter == null) { ToolMobile.log("no bt adapter"); ToolMsg.show(null, MessageCollection.T_MSG_ERROR_CONNECTION + " [BLUETOOTH]", null); return(false); } if (!mBluetoothAdapter.IsEnabled) { ToolMobile.log("enable bt adapter"); mBluetoothAdapter.Enable(); for (int i = 0; i < 15; ++i) { if (mBluetoothAdapter.IsEnabled) { break; } Thread.Sleep(100); } if (!mBluetoothAdapter.IsEnabled) { ToolMsg.show(null, MessageCollection.T_MSG_ERROR_CONNECTION + " [BLUETOOTH]", null); return(false); } } List <string> list = new List <string>(); foreach (BluetoothDevice dev_ in mBluetoothAdapter.BondedDevices) { list.Add(dev_.Name); if (dev_.Name == CurrentVersion.ENV.getPrinter()) { mmDevice = dev_; break; } } if (mmDevice == null) { string[] arr_ = list.ToArray(); ToolMsg.askList(null, arr_, (o, e) => { if (e.Which >= 0 && e.Which < arr_.Length) { CurrentVersion.ENV.setPrinter(arr_[e.Which]); } }); // ToolMsg.show(null, MessageCollection.T_MSG_ERROR_NO_DATA + " BLUETOOTH = [" + CurrentVersion.ENV.getPrinter() + "]", null); return(false); } try { //mBluetoothAdapter.StartDiscovery(); //for (int i = 0; i < 10; ++i) //{ // if (mBluetoothAdapter.IsDiscovering) // break; // Thread.Sleep(100); //} // UUID uuid = UUID.FromString("00001101-0000-1000-8000-00805f9b34fb"); IntPtr createRfcommSocket = JNIEnv.GetMethodID(mmDevice.Class.Handle, "createRfcommSocket", "(I)Landroid/bluetooth/BluetoothSocket;"); IntPtr _socket = JNIEnv.CallObjectMethod(mmDevice.Handle, createRfcommSocket, new Android.Runtime.JValue(1)); mmSocket = Java.Lang.Object.GetObject <BluetoothSocket>(_socket, JniHandleOwnership.TransferLocalRef); mBluetoothAdapter.CancelDiscovery(); mmSocket.Connect(); // Method m = mmDevice.GetType().GetMethod("CreateRfcommSocket", new Type[] {int.class}); //tmp = (BluetoothSocket) m.invoke(device, 1); // mmSocket = mmDevice.CreateRfcommSocketToServiceRecord(uuid); // mmSocket.Connect(); //time out not supported // mmInputStream.ReadTimeout = mmInputStream.WriteTimeout = mmOutputStream.ReadTimeout = mmOutputStream.WriteTimeout = 5000; return(true); } catch (Exception exc) { ToolMobile.log(exc.ToString()); ToolMobile.setExceptionInner(exc); } finally { } return(false); }