protected void btnExecute_Click(object sender, EventArgs e) { OSAEMethodManager.MethodQueueAdd(gvObjects.DataKeys[gvObjects.SelectedIndex]["object_name"].ToString(), ddlMethod.SelectedItem.Value, txtParam1.Text, txtParam2.Text, Session["Username"].ToString()); lblAlert.Text = "Method successfuly executed: " + ddlMethod.SelectedItem.Text; alert.Visible = true; divParameters.Visible = false; }
private void Button_Click(object sender, RoutedEventArgs e) { if (ctrlType == "Method") { if (inputParam1.Text == "[ASK]" | inputParam2.Text == "[ASK]") { // invalid input BadInputLab.Visibility = System.Windows.Visibility.Visible; OKButt.IsEnabled = false; } else { // Input Changed BadInputLab.Visibility = System.Windows.Visibility.Hidden; OKButt.IsEnabled = true; if (Param1 == "[ASK]") { Param1 = inputParam1.Text; } if (Param2 == "[ASK]") { Param2 = inputParam2.Text; } } OSAEMethodManager.MethodQueueAdd(ObjectName, MethodName, Param1, Param2, "GUI"); NotifyParentFinished(); } }
protected void ddlMethod_SelectedIndexChanged(object sender, EventArgs e) { DataSet ds = OSAESql.RunSQL("SELECT param_1_label, param_2_label, param_1_default, param_2_default FROM osae_v_object_type_method otm INNER JOIN osae_object oo ON oo.object_type_id = otm.object_type_id WHERE object_name = '" + hdnSelectedObjectName.Text.Replace("'", "''") + "' AND method_name = '" + ddlMethod.SelectedItem.Value + "'"); DataTable dt = ds.Tables[0]; if (dt.Rows.Count > 0) { if (!string.IsNullOrEmpty(dt.Rows[0]["param_1_label"].ToString())) { divParameters.Visible = true; txtParam1.Text = dt.Rows[0]["param_1_default"].ToString(); txtParam2.Text = dt.Rows[0]["param_2_default"].ToString(); if (!String.IsNullOrEmpty(dt.Rows[0]["param_1_label"].ToString())) { lblParam1.Text = "(" + dt.Rows[0]["param_1_label"].ToString() + ")"; } if (!String.IsNullOrEmpty(dt.Rows[0]["param_2_label"].ToString())) { lblParam2.Text = "(" + dt.Rows[0]["param_2_label"].ToString() + ")"; } } else { OSAEMethodManager.MethodQueueAdd(hdnSelectedObjectName.Text, ddlMethod.SelectedItem.Value, "", "", "Web UI"); lblAlert.Text = "Method successfuly executed: " + ddlMethod.SelectedItem.Text; alert.Visible = true; } } else { OSAEMethodManager.MethodQueueAdd(hdnSelectedObjectName.Text, ddlMethod.SelectedItem.Value, "", "", "Web UI"); lblAlert.Text = "Method successfuly executed: " + ddlMethod.SelectedItem.Text; alert.Visible = true; } }
public Boolean ExecuteMethod(string name, string method, string param1, string param2) { // execute a method on an object OSAEMethodManager.MethodQueueAdd(name, method, param1, param2, "Rest"); Log.Debug("Executing Method: " + name + "." + method + "." + param1 + "." + param2); return(true); }
protected override void ProcessRecord() { Log.Debug("Invoke-OSA - ProcessRecord - Started"); OSAEMethodManager.MethodQueueAdd(Name, Method, parameter1, parameter2, "PowerShell"); WriteObject(true); }
protected void btnExecute_Click(object sender, EventArgs e) { OSAEMethodManager.MethodQueueAdd(hdnSelectedObjectName.Text, ddlMethod.SelectedItem.Value, txtParam1.Text, txtParam2.Text, "Web UI"); lblAlert.Text = "Method successfuly executed: " + ddlMethod.SelectedItem.Text; alert.Visible = true; divParameters.Visible = false; }
protected void Button1_Click(object sender, EventArgs e) { if (CurState == "ON") { OSAEMethodManager.MethodQueueAdd(ObjectName, "OFF", "", "", "MYStateButton"); } else { OSAEMethodManager.MethodQueueAdd(ObjectName, "ON", "", "", "MYStateButton"); } }
protected void btnState_Click(object sender, EventArgs e) { if (CurState == State1Name) { OSAEMethodManager.MethodQueueAdd(ObjectName, State2Name, "0", "", "SYSTEM"); OSAEObjectStateManager.ObjectStateSet(ObjectName, State2Name, "SYSTEM"); } else { OSAEMethodManager.MethodQueueAdd(ObjectName, State1Name, "0", "", "SYSTEM"); OSAEObjectStateManager.ObjectStateSet(ObjectName, State1Name, "SYSTEM"); } }
private void State_Image_MouseLeftButtonUp(object sender, MouseEventArgs e) { if (CurState == "ON") { OSAEMethodManager.MethodQueueAdd(ObjectName, "OFF", "", "", "GUI"); OSAEObjectStateManager.ObjectStateSet(ObjectName, "OFF", "GUI"); } else { OSAEMethodManager.MethodQueueAdd(ObjectName, "ON", "", "", "GUI"); OSAEObjectStateManager.ObjectStateSet(ObjectName, "ON", "GUI"); } }
public Boolean ExecuteMethod(string name, string method, string param1, string param2, string authkey) { string uAuth = OSAESecurity.DecryptUser(authkey); if (uAuth != null) { // execute a method on an object OSAEMethodManager.MethodQueueAdd(name, method, param1, param2, uAuth); Log.Debug("Executing Method: " + name + "." + method + "." + param1 + "." + param2); return(true); } else { return(false); } }
private void btnState_Click(object sender, RoutedEventArgs e) { if (currentUser == "") { return; } if (CurState == State1Name) { OSAEMethodManager.MethodQueueAdd(objName, State2Name, "0", "", currentUser); OSAEObjectStateManager.ObjectStateSet(objName, State2Name, currentUser); } else { OSAEMethodManager.MethodQueueAdd(objName, State1Name, "0", "", currentUser); OSAEObjectStateManager.ObjectStateSet(objName, State1Name, currentUser); } }
private void State_Image_MouseLeftButtonUp(object sender, MouseEventArgs e) { string param1 = "", param2 = "", newState = ""; string currentUser = OSAE.OSAEObjectPropertyManager.GetObjectPropertyValue(gAppName, "Current User").Value; if (currentUser == "") { return; } if (StateMatch == "State 1") { newState = OSAEObjectPropertyManager.GetObjectPropertyValue(screenObject.Name.ToString(), "State 2 Name").Value; } else { newState = OSAEObjectPropertyManager.GetObjectPropertyValue(screenObject.Name.ToString(), "State 1 Name").Value; } bool found = OSAEObjectTypeManager.ObjectTypeMethodExists(LinkedObject.Type, newState); if (found) { DataSet ds = OSAESql.RunSQL("SELECT param_1_label, param_2_label, param_1_default, param_2_default FROM osae_v_object_type_method WHERE object_type = '" + LinkedObject.Type.Replace("'", "''") + "' AND method_name = '" + newState + "'"); DataTable dt = ds.Tables[0]; if (dt.Rows.Count > 0) { if (!string.IsNullOrEmpty(dt.Rows[0]["param_1_label"].ToString())) { param1 = dt.Rows[0]["param_1_default"].ToString(); param2 = dt.Rows[0]["param_2_default"].ToString(); } } OSAEMethodManager.MethodQueueAdd(ObjectName, newState, param1, param2, currentUser); } else { OSAEObjectStateManager.ObjectStateSet(ObjectName, newState, currentUser); } }
private void Method_Image_MouseLeftButtonUp(object sender, MouseEventArgs e) { if (Param1 == "[ASK]" | Param2 == "[ASK]") { ParamInput addControl = new ParamInput("Method", screenObject); string cppX = screenObject.Property("X").Value; string cppY = screenObject.Property("Y").Value; double cpp_X = Convert.ToDouble(cppX); double cpp_Y = Convert.ToDouble(cppY); if (cpp_X < 320) { cpp_X = cpp_X + 200; } addControl.Left = cpp_X; addControl.Top = cpp_Y; addControl.Show(); } else { OSAEMethodManager.MethodQueueAdd(ObjectName, MethodName, Param1, Param2, "GUI"); } }
private void Click_Image_MouseLeftButtonUp(object sender, MouseEventArgs e) { string imgName = screenObject.Property("Normal Image").Value; OSAEImage img = imgMgr.GetImage(imgName); if (img.Data != null) { var imageStream = new MemoryStream(img.Data); var bitmapImage = new BitmapImage(); bitmapImage.BeginInit(); bitmapImage.StreamSource = imageStream; bitmapImage.EndInit(); Image.Source = bitmapImage; Image.Visibility = System.Windows.Visibility.Visible; } else { Image.Source = null; Image.Visibility = System.Windows.Visibility.Hidden; } if (ReleaseMethodName != "") { if (ReleaseMethodParam1 == "[ASK]" | ReleaseMethodParam2 == "[ASK]") { ParamInput addControl = new ParamInput("Method", screenObject); string cppX = screenObject.Property("X").Value; string cppY = screenObject.Property("Y").Value; double cpp_X = Convert.ToDouble(cppX); double cpp_Y = Convert.ToDouble(cppY); if (cpp_X < 320) { cpp_X = cpp_X + 200; } addControl.Left = cpp_X; addControl.Top = cpp_Y; addControl.Show(); } else { OSAEMethodManager.MethodQueueAdd(ReleaseObjectName, ReleaseMethodName, ReleaseMethodParam1, ReleaseMethodParam2, "GUI"); } } if (PressScriptName != "") { if (PressScriptParam1 == "[ASK]" | PressScriptParam2 == "[ASK]") { ParamInput addControl = new ParamInput("Method", screenObject); string cppX = screenObject.Property("X").Value; string cppY = screenObject.Property("Y").Value; double cpp_X = Convert.ToDouble(cppX); double cpp_Y = Convert.ToDouble(cppY); if (cpp_X < 320) { cpp_X = cpp_X + 200; } addControl.Left = cpp_X; addControl.Top = cpp_Y; addControl.Show(); } else { OSAEMethodManager.MethodQueueAdd(ReleaseObjectName, ReleaseMethodName, ReleaseMethodParam1, ReleaseMethodParam2, "GUI"); } } }
private void Click_Image_MouseLeftButtonDown(object sender, MouseEventArgs e) { string currentUser = OSAE.OSAEObjectPropertyManager.GetObjectPropertyValue(gAppName, "Current User").Value; if (currentUser == "") { return; } string imgName = screenObject.Property("Pressed Image").Value; OSAEImage img = imgMgr.GetImage(imgName); if (img != null) { var imageStream = new MemoryStream(img.Data); var bitmapImage = new BitmapImage(); bitmapImage.BeginInit(); bitmapImage.StreamSource = imageStream; bitmapImage.EndInit(); Image.Source = bitmapImage; Image.Visibility = System.Windows.Visibility.Visible; } // else // { // Image.Source = null; // Image.Visibility = System.Windows.Visibility.Hidden; // } if (PressMethodName != "") { if (PressMethodParam1 == "[ASK]" | PressMethodParam2 == "[ASK]") { ParamInput addControl = new ParamInput("Method", screenObject, currentUser); string cppX = screenObject.Property("X").Value; string cppY = screenObject.Property("Y").Value; double cpp_X = Convert.ToDouble(cppX); double cpp_Y = Convert.ToDouble(cppY); if (cpp_X < 320) { cpp_X = cpp_X + 200; } addControl.Left = cpp_X; addControl.Top = cpp_Y; addControl.Show(); } else { OSAEMethodManager.MethodQueueAdd(PressObjectName, PressMethodName, PressMethodParam1, PressMethodParam2, currentUser); } } if (PressScriptName != "") { if (PressMethodParam1 == "[ASK]" | PressMethodParam2 == "[ASK]") { ParamInput addControl = new ParamInput("Method", screenObject, currentUser); string cppX = screenObject.Property("X").Value; string cppY = screenObject.Property("Y").Value; double cpp_X = Convert.ToDouble(cppX); double cpp_Y = Convert.ToDouble(cppY); if (cpp_X < 320) { cpp_X = cpp_X + 200; } addControl.Left = cpp_X; addControl.Top = cpp_Y; addControl.Show(); } else { OSAEMethodManager.MethodQueueAdd(PressObjectName, PressMethodName, PressMethodParam1, PressMethodParam2, currentUser); } } }
public Boolean ExecuteMethod(string name, string method, string param1, string param2) { // execute a method on an object OSAEMethodManager.MethodQueueAdd(name, method, param1, param2, sourceName); return(true); }
private void Method_Image_MouseLeftButtonUp(object sender, MouseEventArgs e) { OSAEMethodManager.MethodQueueAdd(ObjectName, MethodName, Param1, Param2, "GUI"); }
public bool InstallPlugin(string PluginPackagePath, ref string ErrorText) { string exePath = Path.GetDirectoryName(Application.ExecutablePath); if (Directory.Exists(exePath + "/tempDir/")) { Directory.Delete(exePath + "/tempDir/", true); } PluginDescription desc = new PluginDescription(); string tempfolder = exePath + "/tempDir/"; string zipFileName = Path.GetFullPath(PluginPackagePath); string DescPath = null; bool NoError = true; ICSharpCode.SharpZipLib.Zip.FastZip fastZip = new ICSharpCode.SharpZipLib.Zip.FastZip(); try { fastZip.ExtractZip(zipFileName, tempfolder, null); // find all included plugin descriptions and install the plugins List <string> osapdFiles = new List <string>(); List <string> sqlFiles = new List <string>(); string[] pluginFile = Directory.GetFiles(tempfolder, "*.osapd", SearchOption.TopDirectoryOnly); osapdFiles.AddRange(pluginFile); string[] sqlFile = Directory.GetFiles(tempfolder, "*.sql", SearchOption.TopDirectoryOnly); sqlFiles.AddRange(sqlFile); if (osapdFiles.Count == 0) { MessageBox.Show("No plugin description files found."); return(false); } if (osapdFiles.Count > 1) { MessageBox.Show("More than one plugin description file found."); return(false); } if (osapdFiles.Count == 1) { DescPath = osapdFiles[0]; } if (!string.IsNullOrEmpty(DescPath)) { desc.Deserialize(DescPath); //NoError = desc.VerifyInstall(ref ErrorText); //uninstall previous plugin and delete the folder if (UninstallPlugin(desc)) { // get the plugin folder path string pluginFolder = desc.Path; if (!string.IsNullOrEmpty(pluginFolder)) //only extract valid plugins { string[] files = System.IO.Directory.GetFiles(tempfolder); string ConnectionString = string.Format("Uid={0};Pwd={1};Server={2};Port={3};Database={4};allow user variables=true", Common.DBUsername, Common.DBPassword, Common.DBConnection, Common.DBPort, Common.DBName); MySql.Data.MySqlClient.MySqlConnection connection = new MySql.Data.MySqlClient.MySqlConnection(ConnectionString); connection.Open(); foreach (string s in sqlFile) { try { MySql.Data.MySqlClient.MySqlScript script = new MySql.Data.MySqlClient.MySqlScript(connection, File.ReadAllText(s)); script.Execute(); } catch (Exception ex) { this.Log.Error("Error running sql script: " + s, ex); } } System.IO.Directory.Move(tempfolder, exePath + "/Plugins/" + pluginFolder); //Check if we are running a x64 bit architecture (This is a silly way to do it since I am not sure if every 64 bit machine has this directory...) bool is64bit = Environment.Is64BitOperatingSystem; //Do a check for any x64 assemblies, and prompt the user to install them if they are running a 64 bit machine if (is64bit && (desc.x64Assemblies.Count > 0)) { /* x64 assemblies generally have the same name as their x32 counterparts when referenced by the OSA app * however they are packaged as "filename.ext.x64" so we will replace the 32bit file which is installed by * default with the 64bit versioin with the same filename.ext */ if (MessageBox.Show( "You are running an x64 architecture and this plugin has specific assemblies built for 64bit machines." + " It is highly recommended that you install the 64bit versions to ensure proper compatibility", "Install 64bit Assemblies?", MessageBoxButtons.YesNo) == DialogResult.Yes) { //Install the 64bit assemblies over the 32 bit ones... string[] x64files = System.IO.Directory.GetFiles(exePath + "/Plugins/" + pluginFolder, "*.x64"); foreach (string str in x64files) { string destFile = System.IO.Path.Combine(exePath + "/Plugins/" + pluginFolder + "/", System.IO.Path.GetFileNameWithoutExtension(str)); //Copy it to the new destination overwriting the old file if it exists System.IO.File.Copy(str, destFile, true); } } } //Delete all the files with .x64 extensions since they aren't needed anymore string[] delfiles = System.IO.Directory.GetFiles(exePath + "/Plugins/" + pluginFolder, "*.x64"); foreach (string str in delfiles) { System.IO.File.Delete(str); } this.Log.Info("Sending message to service to load plugin."); } } else { return(false); } } } catch (Exception ex) { MessageBox.Show("catch: " + ex.Message); return(false); } if (Directory.Exists(exePath + "/tempDir/")) { deleteFolder(exePath + "/tempDir/"); } OSAEMethodManager.MethodQueueAdd("SERVICE-" + Common.ComputerName, "RELOAD PLUGINS", "", "", "Plugin Installer"); return(NoError); }
private void search() { try { Guid uuid = BluetoothService.L2CapProtocol; BluetoothDeviceInfo bdi; BluetoothAddress ba; byte tmp; bool found = false; int discarded; try { bc = new BluetoothClient(); } catch { Log.Error("No Bluetooth Adapters found!"); OSAEMethodManager.MethodQueueAdd(gAppName, "OFF", "", "", gAppName); return; } bc.InquiryLength = new TimeSpan(0, 0, 0, int.Parse(OSAEObjectPropertyManager.GetObjectPropertyValue(gAppName, "Discover Length").Value), 0); nearosaeDevices = bc.DiscoverDevices(10, false, false, true); for (int j = 0; j < nearosaeDevices.Length; j++) { string addr = nearosaeDevices[j].DeviceAddress.ToString(); Object obj = OSAEObjectManager.GetObjectByAddress(addr); if (obj == null) { if (OSAEObjectPropertyManager.GetObjectPropertyValue(gAppName, "Learning Mode").Value == "TRUE") { OSAEObjectManager.ObjectAdd(nearosaeDevices[j].DeviceName, "", nearosaeDevices[j].DeviceName, "BLUETOOTH DEVICE", nearosaeDevices[j].DeviceAddress.ToString(), string.Empty, 50, true); OSAEObjectPropertyManager.ObjectPropertySet(nearosaeDevices[j].DeviceName, "Discover Type", "0", gAppName); if (gDebug) { Log.Debug(addr + " - " + nearosaeDevices[j].DeviceName + ": added to OSA"); } } } } OSAEObjectCollection objects = OSAEObjectManager.GetObjectsByType("BLUETOOTH DEVICE"); foreach (OSAEObject obj in objects) { found = false; string address = obj.Address; byte[] byteArray = HexEncoding.GetBytes(address, out discarded); tmp = byteArray[0]; byteArray[0] = byteArray[5]; byteArray[5] = tmp; tmp = byteArray[1]; byteArray[1] = byteArray[4]; byteArray[4] = tmp; tmp = byteArray[2]; byteArray[2] = byteArray[3]; byteArray[3] = tmp; ba = new BluetoothAddress(byteArray); bdi = new BluetoothDeviceInfo(ba); //if (gDebug) Log.Debug("Begin search for " + address); for (int j = 0; j < nearosaeDevices.Length; j++) { if (nearosaeDevices[j].DeviceAddress.ToString() == address) { found = true; if (gDebug) { Log.Debug(address + " - " + obj.Name + ": found with DiscoverDevices"); } } } if (!found) { if (gDebug) { Log.Debug(address + " - " + obj.Name + ": failed with DiscoverDevices"); } } try { if (!found && (int.Parse(OSAEObjectPropertyManager.GetObjectPropertyValue(obj.Name, "Discover Type").Value) == 2 || Int32.Parse(OSAEObjectPropertyManager.GetObjectPropertyValue(obj.Name, "Discover Type").Value) == 0)) { if (gDebug) { Log.Debug(address + " - " + obj.Name + ": attempting GetServiceRecords"); } bdi.GetServiceRecords(uuid); found = true; if (gDebug) { Log.Debug(address + " - " + obj.Name + " found with GetServiceRecords"); } } } catch (Exception ex) { if (gDebug) { Log.Debug(address + " - " + obj.Name + " failed GetServiceRecords. exception: " + ex.Message); } } try { if (!found && (int.Parse(OSAEObjectPropertyManager.GetObjectPropertyValue(obj.Name, "Discover Type").Value) == 3 || int.Parse(OSAEObjectPropertyManager.GetObjectPropertyValue(obj.Name, "Discover Type").Value) == 0)) { if (gDebug) { Log.Debug(address + " - " + obj.Name + ": attempting Connection"); } //attempt a connect BluetoothEndPoint ep; ep = new BluetoothEndPoint(bdi.DeviceAddress, BluetoothService.Handsfree); //MessageBox.Show("attempt connect: " + pairedDevices[i].DeviceAddress); bc.Connect(ep); if (gDebug) { Log.Debug(address + " - " + obj.Name + " found with Connect attempt"); } bc.Close(); found = true; } } catch (Exception ex) { Log.Error(address + " - " + obj.Name + " failed with Connect attempt. exception: " + ex.Message); } if (found) { OSAEObjectStateManager.ObjectStateSet(obj.Name, "ON", gAppName); if (gDebug) { Log.Debug(obj.Name + " Status Updated in osae"); } } else { OSAEObjectStateManager.ObjectStateSet(obj.Name, "OFF", gAppName); if (gDebug) { Log.Debug(obj.Name + " Status Updated in osae"); } } } } catch (Exception ex) { Log.Error("Error searching for devices", ex); } }
private void Slider_MouseUp(object sender, MouseButtonEventArgs e) { OSAEMethodManager.MethodQueueAdd(ObjectName, SliderMethod, Convert.ToUInt16(sldSlider.Value).ToString(), "", gAppName); updatingSlider = false; }