GetLogger() public static method

Get the current logger, if no logger has been specified in a previous call then the default logger will be returned
public static GetLogger ( ) : Logging
return Logging
Ejemplo n.º 1
0
 /// <summary>
 /// Delete an object type
 /// </summary>
 /// <param name="Name"></param>
 public static void ObjectTypeDelete(string Name)
 {
     using (MySqlCommand command = new MySqlCommand())
     {
         command.CommandText = "CALL osae_sp_object_type_delete (@Name)";
         command.Parameters.AddWithValue("@Name", Name);
         try
         { OSAESql.RunQuery(command); }
         catch (Exception ex)
         { Logging.GetLogger().AddToLog("API - ObjectTypeDelete error: " + command.CommandText + " - error: " + ex.Message, true); }
     }
 }
Ejemplo n.º 2
0
        /// <summary>
        /// Loads the requested object Type
        /// </summary>
        /// <param name="name">The name of the object type to load</param>
        /// <returns>The requested object type</returns>
        public static OSAEObjectType ObjectTypeLoad(string name)
        {
            MySqlCommand command = new MySqlCommand();
            DataSet      dataset = new DataSet();

            try
            {
                command.CommandText = "SELECT object_type, object_type_description, object_type_owner, container, hide_redundant_events, base_type, object_name, system_hidden, object_type_tooltip FROM osae_v_object_type WHERE object_type=@Name";
                command.Parameters.AddWithValue("@Name", name);
                dataset = OSAESql.RunQuery(command);

                if (dataset.Tables[0].Rows.Count > 0)
                {
                    OSAEObjectType type = new OSAEObjectType();
                    type.BaseType    = dataset.Tables[0].Rows[0]["base_type"].ToString();
                    type.Description = dataset.Tables[0].Rows[0]["object_type_description"].ToString();
                    type.Name        = dataset.Tables[0].Rows[0]["object_type"].ToString();
                    type.OwnedBy     = dataset.Tables[0].Rows[0]["object_name"].ToString();
                    type.Tooltip     = dataset.Tables[0].Rows[0]["object_type_tooltip"].ToString();
                    type.Owner       = false;
                    if (dataset.Tables[0].Rows[0]["object_type_owner"].ToString() == "1")
                    {
                        type.Owner = true;
                    }
                    type.SysType = false;
                    if (dataset.Tables[0].Rows[0]["system_hidden"].ToString() == "1")
                    {
                        type.SysType = true;
                    }
                    type.Container = false;
                    if (dataset.Tables[0].Rows[0]["container"].ToString() == "1")
                    {
                        type.Container = true;
                    }
                    type.HideRedundant = false;
                    if (dataset.Tables[0].Rows[0]["hide_redundant_events"].ToString() == "1")
                    {
                        type.HideRedundant = true;
                    }
                    return(type);
                }
                else
                {
                    return(null);
                }
            }
            catch (Exception ex)
            {
                Logging.GetLogger().AddToLog("API - GetObjectTypeLoad (" + name + ")error: " + ex.Message, true);
                return(null);
            }
        }
Ejemplo n.º 3
0
 /// <summary>
 /// Delete method from the queue
 /// </summary>
 /// <param name="methodID"></param>
 public static void MethodQueueDelete(int methodID)
 {
     using (MySqlCommand command = new MySqlCommand())
     {
         command.CommandText = "CALL osae_sp_method_queue_delete (@ID)";
         command.Parameters.AddWithValue("@ID", methodID);
         try
         {
             OSAESql.RunQuery(command);
         }
         catch (Exception ex)
         { Logging.GetLogger().AddToLog("API - MethodQueueDelete error: " + command.CommandText + " - error: " + ex.Message, true); }
     }
 }
Ejemplo n.º 4
0
 public static void ObjectTypePropertyOptionDelete(string objectType, string propertyName, string option)
 {
     using (MySqlCommand command = new MySqlCommand())
     {
         command.CommandText = "CALL osae_sp_object_type_property_option_delete (@objectName, @propertyName, @option)";
         command.Parameters.AddWithValue("@objectName", objectType);
         command.Parameters.AddWithValue("@propertyName", propertyName);
         command.Parameters.AddWithValue("@option", option);
         try
         { OSAESql.RunQuery(command); }
         catch (Exception ex)
         { Logging.GetLogger().AddToLog("API - ObjectTypePropertyOptionDelete error: " + command.CommandText + " - error: " + ex.Message, true); }
     }
 }
Ejemplo n.º 5
0
 /// <summary>
 /// Add a state to an object type
 /// </summary>
 /// <param name="Name"></param>
 /// <param name="Label"></param>
 /// <param name="ObjectType"></param>
 public static void ObjectTypeStateAdd(string ObjectType, string Name, string Label)
 {
     using (MySqlCommand command = new MySqlCommand())
     {
         command.CommandText = "CALL osae_sp_object_type_state_add (@ObjectType, @Name, @Label)";
         command.Parameters.AddWithValue("@ObjectType", ObjectType);
         command.Parameters.AddWithValue("@Name", Name);
         command.Parameters.AddWithValue("@Label", Label);
         try
         { OSAESql.RunQuery(command); }
         catch (Exception ex)
         { Logging.GetLogger().AddToLog("API - ObjectTypeStateAdd error: " + command.CommandText + " - error: " + ex.Message, true); }
     }
 }
        public static OSAERecurringSchedule GetRecurringSchedule(string name)
        {
            try
            {
                using (MySqlCommand command = new MySqlCommand())
                {
                    DataSet           dataset = new DataSet();
                    OSAEScreenControl ctrl    = new OSAEScreenControl();

                    command.CommandText = "SELECT schedule_name, parameter_1, parameter_2, recurring_time, monday, tuesday, wednesday, thursday, friday, saturday, sunday, interval_unit, recurring_minutes," +
                                          "recurring_day, recurring_date, script_name, method_name, object_name, active " +
                                          "FROM osae.osae_v_schedule_recurring WHERE schedule_name=@Name";
                    command.Parameters.AddWithValue("@Name", name);
                    dataset = OSAESql.RunQuery(command);

                    if (dataset.Tables[0].Rows.Count > 0)
                    {
                        OSAERecurringSchedule schedule = new OSAERecurringSchedule();
                        schedule.Name      = name;
                        schedule.Param1    = dataset.Tables[0].Rows[0]["parameter_1"].ToString();
                        schedule.Param2    = dataset.Tables[0].Rows[0]["parameter_2"].ToString();
                        schedule.Time      = dataset.Tables[0].Rows[0]["recurring_time"].ToString();
                        schedule.Monday    = dataset.Tables[0].Rows[0]["monday"].ToString();
                        schedule.Tuesday   = dataset.Tables[0].Rows[0]["tuesday"].ToString();
                        schedule.Wednesday = dataset.Tables[0].Rows[0]["wednesday"].ToString();
                        schedule.Thursday  = dataset.Tables[0].Rows[0]["thursday"].ToString();
                        schedule.Friday    = dataset.Tables[0].Rows[0]["friday"].ToString();
                        schedule.Saturday  = dataset.Tables[0].Rows[0]["saturday"].ToString();
                        schedule.Sunday    = dataset.Tables[0].Rows[0]["sunday"].ToString();
                        schedule.Interval  = dataset.Tables[0].Rows[0]["interval_unit"].ToString();
                        schedule.Minutes   = dataset.Tables[0].Rows[0]["recurring_minutes"].ToString();
                        schedule.MonthDay  = dataset.Tables[0].Rows[0]["recurring_day"].ToString();
                        schedule.Date      = dataset.Tables[0].Rows[0]["recurring_date"].ToString();
                        schedule.Script    = dataset.Tables[0].Rows[0]["script_name"].ToString();
                        schedule.Method    = dataset.Tables[0].Rows[0]["method_name"].ToString();
                        schedule.Object    = dataset.Tables[0].Rows[0]["object_name"].ToString();
                        schedule.Active    = dataset.Tables[0].Rows[0]["active"].ToString();
                        return(schedule);
                    }
                }

                return(null);
            }
            catch (Exception ex)
            {
                Logging.GetLogger().AddToLog("API - GetRecurringScedule error: " + ex.Message, true);
                return(null);
            }
        }
 /// <summary>
 ///
 /// </summary>
 public static void ProcessRecurring()
 {
     using (MySqlCommand command = new MySqlCommand())
     {
         command.CommandText = "CALL osae_sp_process_recurring";
         try
         {
             OSAESql.RunQuery(command);
         }
         catch (Exception ex)
         {
             Logging.GetLogger().AddToLog("API - ProcessRecurring error: " + command.CommandText + " - error: " + ex.Message, true);
         }
     }
 }
Ejemplo n.º 8
0
        public static void ScreenObjectAdd(string screen, string objectName, string controlName)
        {
            using (MySqlCommand command = new MySqlCommand())
            {
                command.CommandText = "CALL osae_sp_screen_object_add(@Screen, @ObjectName, @ControlName)";
                command.Parameters.AddWithValue("@Screen", screen);
                command.Parameters.AddWithValue("@ObjectName", objectName);
                command.Parameters.AddWithValue("@ControlName", controlName);

                try
                { OSAESql.RunQuery(command); }
                catch (Exception ex)
                { Logging.GetLogger().AddToLog("ScreenObjectAdd error: " + command.CommandText + " - error: " + ex.Message, true); }
            }
        }
Ejemplo n.º 9
0
 /// <summary>
 /// Update an existing state from an object type
 /// </summary>
 /// <param name="oldName"></param>
 /// <param name="newName"></param>
 /// <param name="label"></param>
 /// <param name="objectType"></param>
 public static void ObjectTypeStateUpdate(string oldName, string newName, string newLabel, string objectType)
 {
     using (MySqlCommand command = new MySqlCommand())
     {
         command.CommandText = "CALL osae_sp_object_type_state_update (@OldName, @NewName, @Label, @ObjectType)";
         command.Parameters.AddWithValue("@OldName", oldName);
         command.Parameters.AddWithValue("@NewName", newName);
         command.Parameters.AddWithValue("@Label", newLabel);
         command.Parameters.AddWithValue("@ObjectType", objectType);
         try
         { OSAESql.RunQuery(command); }
         catch (Exception ex)
         { Logging.GetLogger().AddToLog("ObjectTypeStateUpdate error: " + command.CommandText + " - error: " + ex.Message, true); }
     }
 }
Ejemplo n.º 10
0
 /// <summary>
 /// Deletes all items from a property array
 /// </summary>
 /// <param name="objectName"></param>
 /// <param name="propertyName"></param>
 public static void ObjectPropertyArrayDeleteAll(string objectName, string propertyName)
 {
     using (MySqlCommand command = new MySqlCommand())
     {
         command.CommandText = "CALL osae_sp_object_property_array_delete_all (@ObjectName, @PropertyName)";
         command.Parameters.AddWithValue("@ObjectName", objectName);
         command.Parameters.AddWithValue("@PropertyName", propertyName);
         try
         {
             OSAESql.RunQuery(command);
         }
         catch (Exception ex)
         { Logging.GetLogger().AddToLog("API - ObjectPropertyArrayDeleteAll error: " + command.CommandText + " - error: " + ex.Message, true); }
     }
 }
 /// <summary>
 ///
 /// </summary>
 public static void RunScheduledMethods()
 {
     using (MySqlCommand command = new MySqlCommand())
     {
         command.CommandText = "CALL osae_sp_run_scheduled_methods";
         try
         {
             OSAESql.RunQuery(command);
         }
         catch (Exception ex)
         {
             Logging.GetLogger().AddToLog("API - RunScheduledMethods error: " + command.CommandText + " - error: " + ex.Message, true);
         }
     }
 }
Ejemplo n.º 12
0
        /// <summary>
        /// propertyLabel is usually left null
        /// </summary>
        /// <param name="objectName"></param>
        /// <param name="propertyName"></param>
        /// <param name="propertyValue"></param>
        /// <param name="propertyLabel"></param>
        public static void ObjectPropertyScraperDelete(int scraperid)
        {
            using (MySqlCommand command = new MySqlCommand())
            {
                command.CommandText = "CALL osae_sp_object_property_scraper_delete (@ScraperID)";
                command.Parameters.AddWithValue("@ScraperID", scraperid);

                try
                {
                    OSAESql.RunQuery(command);
                }
                catch (Exception ex)
                { Logging.GetLogger().AddToLog("API - ObjectPropertyArrayAdd error: " + command.CommandText + " - error: " + ex.Message, true); }
            }
        }
        public static DataSet ObjectStateListGet(string objectName)
        {
            DataSet ds = new DataSet();

            using (MySqlCommand command = new MySqlCommand())
            {
                command.CommandText = "SELECT state_name,state_label FROM osae_v_object_state WHERE UPPER(object_name) = UPPER('" + objectName + "') OR UPPER(object_alias) = UPPER('" + objectName + "') ORDER BY state_label asc";
                try
                {
                    ds = OSAESql.RunQuery(command);
                }
                catch (Exception ex)
                { Logging.GetLogger().AddToLog("API - ObjectStateHistoryGet error: " + command.CommandText + " - error: " + ex.Message, true); }
            }
            return(ds);
        }
Ejemplo n.º 14
0
        public static DataSet ObjectPropertyHistoryGet(string objectName, string propertyName, string from, string to)
        {
            DataSet ds = new DataSet();

            using (MySqlCommand command = new MySqlCommand())
            {
                command.CommandText = "SELECT history_timestamp, CASE property_datatype WHEN 'Boolean' THEN IF(property_value='TRUE', 1, 0) ELSE property_value END AS property_value FROM osae_v_object_property_history WHERE (UPPER(object_name) = UPPER('" + objectName + "') OR UPPER(object_alias) = UPPER('" + objectName + "')) and property_name = '" + propertyName + "' AND history_timestamp BETWEEN '" + from + "' AND '" + to + "' ORDER BY history_timestamp asc";
                try
                {
                    ds = OSAESql.RunQuery(command);
                }
                catch (Exception ex)
                { Logging.GetLogger().AddToLog("API - ObjectPropertyHistoryGet error: " + command.CommandText + " - error: " + ex.Message, true); }
            }
            return(ds);
        }
Ejemplo n.º 15
0
 /// <summary>
 /// Delete an object
 /// </summary>
 /// <param name="Name"></param>
 public static void ObjectDeleteByAddress(string address)
 {
     using (MySqlCommand command = new MySqlCommand())
     {
         command.CommandText = "CALL osae_sp_object_delete_by_address (@Address)";
         command.Parameters.AddWithValue("@Address", address);
         try
         {
             OSAESql.RunQuery(command);
         }
         catch (Exception ex)
         {
             Logging.GetLogger().AddToLog("API - ObjectDeleteByAddress error: " + command.CommandText + " - error: " + ex.Message, true);
         }
     }
 }
        public static void ObjectTypeEventScriptDelete(string eventScriptID)
        {
            MySqlCommand command = new MySqlCommand();

            command.CommandText = "CALL osae_sp_object_type_event_script_delete (@pobjtypeeventscriptid)";
            command.Parameters.AddWithValue("@pobjtypeeventscriptid", eventScriptID);

            try
            {
                OSAESql.RunQuery(command);
            }
            catch (Exception ex)
            {
                Logging.GetLogger().AddToLog("API - ObjectTypeEventScriptDelete error: " + command.CommandText + " - error: " + ex.Message, true);
            }
        }
        public static void PatternScriptDelete(string patternScriptID)
        {
            MySqlCommand command = new MySqlCommand();

            command.CommandText = "CALL osae_sp_pattern_script_delete (@ppatternscriptid)";
            command.Parameters.AddWithValue("@ppatternscriptid", patternScriptID);

            try
            {
                OSAESql.RunQuery(command);
            }
            catch (Exception ex)
            {
                Logging.GetLogger().AddToLog("API - PatternScriptDelete error: " + command.CommandText + " - error: " + ex.Message, true);
            }
        }
        public static DataSet ObjectStateHistoryGet(string objectName, string from, string to)
        {
            DataSet ds = new DataSet();

            using (MySqlCommand command = new MySqlCommand())
            {
                command.CommandText = "SELECT history_timestamp, object_name, state_label FROM osae_v_object_state_change_history WHERE (UPPER(object_name) = UPPER('" + objectName + "') OR UPPER(object_alias) = UPPER('" + objectName + "')) AND history_timestamp BETWEEN '" + from + "' AND '" + to + "' ORDER BY history_timestamp asc";
                try
                {
                    ds = OSAESql.RunQuery(command);
                }
                catch (Exception ex)
                { Logging.GetLogger().AddToLog("API - ObjectStateHistoryGet error: " + command.CommandText + " - error: " + ex.Message, true); }
            }
            return(ds);
        }
        /// <summary>
        /// Create a new object
        /// </summary>
        /// <param name="name"></param>
        /// <param name="description"></param>
        /// <param name="objectType"></param>
        /// <param name="address"></param>
        /// <param name="container"></param>
        public static void ObjectAdd(string name, string alias, string description, string objectType, string address, string container, int minTrustLevel, bool enabled)
        {
            Logging logging = Logging.GetLogger();

            using (MySqlCommand command = new MySqlCommand())
            {
                command.CommandText = "osae_sp_object_add";
                command.CommandType = CommandType.StoredProcedure;

                command.Parameters.AddWithValue("?pname", name);
                command.Parameters.AddWithValue("?palias", alias);
                command.Parameters.AddWithValue("?pdescription", description);
                command.Parameters.AddWithValue("?pobjecttype", objectType);
                command.Parameters.AddWithValue("?paddress", address);
                command.Parameters.AddWithValue("?pcontainer", container);
                command.Parameters.AddWithValue("?pmintrustlevel", minTrustLevel);
                command.Parameters.AddWithValue("?penabled", enabled);
                command.Parameters.Add(new MySqlParameter("?results", MySqlDbType.Int32));
                command.Parameters["?results"].Direction = ParameterDirection.Output;

                try
                {
                    MySqlConnection connection = new MySqlConnection(Common.ConnectionString);
                    command.Connection = connection;
                    command.Connection.Open();
                    command.ExecuteNonQuery();

                    if (command.Parameters["?results"].Value.ToString() == "1")
                    {
                        logging.AddToLog("API - ObjectAdded successfully", true);
                    }
                    else if (command.Parameters["?results"].Value.ToString() == "2")
                    {
                        logging.AddToLog("API - ObjectAdd failed.  Object type doesn't exist.", true);
                    }
                    else if (command.Parameters["?results"].Value.ToString() == "3")
                    {
                        logging.AddToLog("API - ObjectAdd failed.  Object with same name or address already exists", true);
                    }
                }
                catch (Exception ex)
                {
                    logging.AddToLog("API - ObjectAdd error: " + command.CommandText + " - error: " + ex.Message, true);
                }
            }
        }
        /// <summary>
        ///
        /// </summary>
        /// <param name="scheduleName"></param>
        public static void ScheduleRecurringDelete(string scheduleName)
        {
            using (MySqlCommand command = new MySqlCommand())
            {
                command.CommandText = "CALL osae_sp_schedule_recurring_delete(@ScheduleName)";
                command.Parameters.AddWithValue("@ScheduleName", scheduleName);

                try
                {
                    OSAESql.RunQuery(command);
                }
                catch (Exception ex)
                {
                    Logging.GetLogger().AddToLog("ScheduleRecurringDelete error: " + command.CommandText + " - error: " + ex.Message, true);
                }
            }
        }
        public static void PatternAdd(string name)
        {
            using (MySqlCommand command = new MySqlCommand())
            {
                command.CommandText = "CALL osae_sp_pattern_add (@Name)";
                command.Parameters.AddWithValue("@Name", name);

                try
                {
                    OSAESql.RunQuery(command);
                }
                catch (Exception ex)
                {
                    Logging.GetLogger().AddToLog("API - PatterAdd error: " + command.CommandText + " - error: " + ex.Message, true);
                }
            }
        }
Ejemplo n.º 22
0
 /// <summary>
 /// Add a property to an object type
 /// </summary>
 /// <param name="Name"></param>
 /// <param name="ParameterType"></param>
 /// <param name="ObjectType"></param>
 public static void ObjectTypePropertyAdd(string ObjectType, string Name, string ParameterType, string ParameterObjectType, string ParameterDefault, bool TrackHistory)
 {
     using (MySqlCommand command = new MySqlCommand())
     {
         command.CommandText = "CALL osae_sp_object_type_property_add (@ObjectType, @Name, @ParameterType, @ParameterObjectType, @ParameterDefault, @TrackHistory)";
         command.Parameters.AddWithValue("@ObjectType", ObjectType);
         command.Parameters.AddWithValue("@Name", Name);
         command.Parameters.AddWithValue("@ParameterType", ParameterType);
         command.Parameters.AddWithValue("@ParameterObjectType", ParameterObjectType);
         command.Parameters.AddWithValue("@ParameterDefault", ParameterDefault);
         command.Parameters.AddWithValue("@TrackHistory", TrackHistory);
         try
         { OSAESql.RunQuery(command); }
         catch (Exception ex)
         { Logging.GetLogger().AddToLog("API - ObjectTypePropertyAdd error: " + command.CommandText + " - error: " + ex.Message, true); }
     }
 }
Ejemplo n.º 23
0
        /// <summary>
        /// Returns a Dataset of all objects in a specified container
        /// </summary>
        /// <param name="ContainerName"></param>
        /// <returns></returns>
        public static OSAEObjectCollection GetObjectsByContainer(string ContainerName)
        {
            MySqlCommand         command = new MySqlCommand();
            DataSet              dataset = new DataSet();
            OSAEObject           obj     = new OSAEObject();
            OSAEObjectCollection objects = new OSAEObjectCollection();

            try
            {
                if (ContainerName == string.Empty)
                {
                    command.CommandText = "SELECT object_name, object_alias, object_description, object_type, address, container_name, enabled, state_name, base_type, coalesce(time_in_state, 0) as time_in_state, last_updated FROM osae_v_object WHERE container_name is null ORDER BY object_name ASC";
                }
                else
                {
                    command.CommandText = "SELECT object_name, object_alias, object_description, object_type, address, container_name, enabled, state_name, base_type, coalesce(time_in_state, 0) as time_in_state, last_updated FROM osae_v_object WHERE container_name=@ContainerName AND enabled = 1 ORDER BY object_name ASC";
                    command.Parameters.AddWithValue("@ContainerName", ContainerName);
                }

                dataset = OSAESql.RunQuery(command);
                if (dataset.Tables[0].Rows.Count > 0)
                {
                    foreach (DataRow dr in dataset.Tables[0].Rows)
                    {
                        obj                   = new OSAEObject(dr["object_name"].ToString(), dr["object_alias"].ToString(), dr["object_description"].ToString(), dr["object_type"].ToString(), dr["address"].ToString(), dr["container_name"].ToString(), int.Parse(dr["enabled"].ToString()));
                        obj.State.Value       = dr["state_name"].ToString();
                        obj.State.TimeInState = Convert.ToInt64(dr["time_in_state"]);
                        obj.BaseType          = dr["base_type"].ToString();
                        obj.LastUpd           = dr["last_updated"].ToString();
                        obj.Properties        = OSAEObjectPropertyManager.GetObjectProperties(obj.Name);
                        obj.Methods           = GetObjectMethods(obj.Name);
                        objects.Add(obj);
                    }

                    return(objects);
                }

                return(objects);
            }
            catch (Exception ex)
            {
                Logging.GetLogger().AddToLog("API - GetObjectsByContainer error: " + ex.Message, true);
                return(objects);
            }
        }
        public static DataSet ObjectPropertyListGet(string objectName)
        {
            DataSet ds = new DataSet();

            using (MySqlCommand command = new MySqlCommand())
            {
                command.CommandText = "SELECT property_name FROM osae_v_object_property WHERE object_name = '" + objectName + "' ORDER BY property_name asc";
                try
                {
                    ds = OSAESql.RunQuery(command);
                }
                catch (Exception ex)
                {
                    Logging.GetLogger().AddToLog("API - ObjectPropertyListGet error: " + command.CommandText + " - error: " + ex.Message, true);
                }
            }
            return(ds);
        }
        public static void PatternMatchAdd(string pattern, string match)
        {
            using (MySqlCommand command = new MySqlCommand())
            {
                command.CommandText = "CALL osae_sp_pattern_match_add (@Pattern, @Match)";
                command.Parameters.AddWithValue("@Match", match);
                command.Parameters.AddWithValue("@Pattern", pattern);

                try
                {
                    OSAESql.RunQuery(command);
                }
                catch (Exception ex)
                {
                    Logging.GetLogger().AddToLog("API - PatternMatchAdd error: " + command.CommandText + " - error: " + ex.Message, true);
                }
            }
        }
Ejemplo n.º 26
0
 public static void ClearMethodQueue()
 {
     try
     {
         using (MySqlConnection connection = new MySqlConnection(Common.ConnectionString))
         {
             connection.Open();
             using (MySqlCommand command = new MySqlCommand())
             {
                 command.Connection  = connection;
                 command.CommandText = "SET sql_safe_updates=0; DELETE FROM osae_method_queue;";
                 OSAESql.RunQuery(command);
             }
         }
     }
     catch (Exception ex)
     { Logging.GetLogger().AddToLog("Error clearing method queue details: \r\n" + ex.Message, true); }
 }
        public static void AddScriptProcessor(string Name, string pluginName)
        {
            using (MySqlCommand command = new MySqlCommand())
            {
                command.CommandText = "CALL osae_sp_script_processor_add (@pname, @ppluginname)";
                command.Parameters.AddWithValue("@pname", Name);
                command.Parameters.AddWithValue("@ppluginname", pluginName);

                try
                {
                    OSAESql.RunQuery(command);
                }
                catch (Exception ex)
                {
                    Logging.GetLogger().AddToLog("API - AddScriptProcessor error: " + command.CommandText + " - error: " + ex.Message, true);
                }
            }
        }
        /// <summary>
        /// Set the state of an object
        /// </summary>
        /// <param name="ObjectName">The name of the object to set the state of</param>
        /// <param name="State">The state to set the object too</param>
        /// <param name="source">Where the message was genreated from e.g. the plugin name (pName)</param>
        public static void ObjectStateSet(string ObjectName, string State, string source)
        {
            using (MySqlCommand command = new MySqlCommand())
            {
                command.CommandText = "CALL osae_sp_object_state_set(@ObjectName, @State, @FromObject, @DebugInfo)";
                command.Parameters.AddWithValue("@ObjectName", ObjectName);
                command.Parameters.AddWithValue("@State", State);
                command.Parameters.AddWithValue("@FromObject", source);
                command.Parameters.AddWithValue("@DebugInfo", null);

                try
                {
                    OSAESql.RunQuery(command);
                }
                catch (Exception ex)
                { Logging.GetLogger().AddToLog("ObjectStateSet error: " + command.CommandText + " - error: " + ex.Message, true); }
            }
        }
        public static List <OSAEScreenControl> GetScreenControls(string screenName)
        {
            List <OSAEScreenControl> controls = new List <OSAEScreenControl>();

            try
            {
                using (MySqlCommand command = new MySqlCommand())
                {
                    DataSet           dataset = new DataSet();
                    OSAEScreenControl ctrl    = new OSAEScreenControl();

                    command.CommandText = "SELECT object_name, control_name, control_type, state_name, last_updated, coalesce(property_last_updated,NOW()) as property_last_updated, coalesce(time_in_state, 0) as time_in_state FROM osae_v_screen_object WHERE screen_name=@ScreenName AND control_enabled = 1";
                    command.Parameters.AddWithValue("@ScreenName", screenName);
                    dataset = OSAESql.RunQuery(command);

                    if (dataset.Tables[0].Rows.Count > 0)
                    {
                        foreach (DataRow dr in dataset.Tables[0].Rows)
                        {
                            ctrl             = new OSAEScreenControl();
                            ctrl.ObjectState = dr["state_name"].ToString();

                            ctrl.TimeInState         = Convert.ToInt64(dr["time_in_state"]).ToString();
                            ctrl.ControlName         = dr["control_name"].ToString();
                            ctrl.ControlType         = dr["control_type"].ToString();
                            ctrl.LastUpdated         = DateTime.Parse(dr["last_updated"].ToString());
                            ctrl.PropertyLastUpdated = DateTime.Parse(dr["property_last_updated"].ToString());
                            ctrl.ObjectName          = dr["object_name"].ToString();

                            controls.Add(ctrl);
                        }

                        return(controls);
                    }
                }

                return(controls);
            }
            catch (Exception ex)
            {
                Logging.GetLogger().AddToLog("API - GetObjectsByBaseType error: " + ex.Message, true);
                return(controls);
            }
        }
        public static void ScriptAdd(string name, string scriptProcessor, string script)
        {
            using (MySqlCommand command = new MySqlCommand())
            {
                command.CommandText = "CALL osae_sp_script_add (@pname, @pscriptprocessor, @pscript)";
                command.Parameters.AddWithValue("@pname", name);
                command.Parameters.AddWithValue("@pscriptprocessor", scriptProcessor);
                command.Parameters.AddWithValue("@pscript", script);

                try
                {
                    OSAESql.RunQuery(command);
                }
                catch (Exception ex)
                {
                    Logging.GetLogger().AddToLog("API - ScriptAdd error: " + command.CommandText + " - error: " + ex.Message, true);
                }
            }
        }