예제 #1
0
 public OSAEObject(string name, string description, string type, string address, string container, int enabled)
 {
     _name = name;
     _type = type;
     _address = address;
     _container = container;
     _enabled = enabled;
     _description = description;
     _state = new OSAEObjectState();
 }
 public OSAEObject(string name, string description, string type, string address, string container, int enabled)
 {
     _name        = name;
     _type        = type;
     _address     = address;
     _container   = container;
     _enabled     = enabled;
     _description = description;
     _state       = new OSAEObjectState();
 }
 public OSAEObject(string name, string description, string type, string address, string container, int enabled)
 {
     Name = name;
     Type = type;
     Address = address;
     Container = container;
     Enabled = enabled;
     Description = description;
     State = new OSAEObjectState();
 }
예제 #4
0
 public OSAEObject(string name, string alias, string description, string type, string address, string container, int mintrustlevel, bool enabled)
 {
     _name          = name;
     _alias         = alias;
     _type          = type;
     _address       = address;
     _container     = container;
     _minTrustLevel = mintrustlevel;
     _enabled       = enabled;
     _description   = description;
     _state         = new OSAEObjectState();
 }
 public OSAEObject(string name, string alias, string description, string type, string address, string container, int mintrustlevel, bool enabled)
 {
     _name = name;
     _alias = alias;
     _type = type;
     _address = address;
     _container = container;
     _minTrustLevel = mintrustlevel;
     _enabled = enabled;
     _description = description;
     _state = new OSAEObjectState();
 }
        /// <summary>
        /// Returns a OSAEObjectState object
        /// </summary>
        /// <param name="ObjectName">The object name to get the state of</param>
        /// <returns>The state of the requested object</returns>
        public static OSAEObjectState GetObjectStateValue(string ObjectName)
        {
            DataSet dataset = new DataSet();
            OSAEObjectState state = new OSAEObjectState();

            try
            {
                using (MySqlCommand command = new MySqlCommand())
                {
                    command.CommandText = "SELECT state_name,state_label,coalesce(time_in_state, 0) as time_in_state,COALESCE(last_state_change,NOW()) as last_state_change FROM osae_v_object WHERE UPPER(object_name)=UPPER(@ObjectName) OR UPPER(object_alias)=UPPER(@ObjectName)";
                    command.Parameters.AddWithValue("@ObjectName", ObjectName);
                    dataset = OSAESql.RunQuery(command);
                }

                if (dataset.Tables[0].Rows.Count > 0)
                {
                    state.Value = dataset.Tables[0].Rows[0]["state_name"].ToString();
                    state.StateLabel = dataset.Tables[0].Rows[0]["state_label"].ToString();
                    state.TimeInState = Convert.ToInt64(dataset.Tables[0].Rows[0]["time_in_state"]);
                    state.LastStateChange = Convert.ToDateTime(dataset.Tables[0].Rows[0]["last_state_change"]);
                    return state;
                }
                else
                {
                    Logging.GetLogger().AddToLog("API - GetObjectStateValue error: Object does not exist | ObjectName: " + ObjectName, true);
                    return null;
                }
            }
            catch (Exception ex)
            {
                Logging.GetLogger().AddToLog("API - GetObjectStateValue error: " + ex.Message + " | ObjectName: " + ObjectName, true);
                return null;
            }
            finally
            {
                dataset.Dispose();
            }
        }
        /// <summary>
        /// Returns a OSAEObjectState object
        /// </summary>
        /// <param name="ObjectName">The object name to get the state of</param>
        /// <returns>The state of the requested object</returns>
        public static OSAEObjectState GetObjectStateValue(string ObjectName)
        {
            DataSet         dataset = new DataSet();
            OSAEObjectState state   = new OSAEObjectState();

            try
            {
                using (MySqlCommand command = new MySqlCommand())
                {
                    command.CommandText = "SELECT state_name,state_label,coalesce(time_in_state, 0) as time_in_state,COALESCE(last_state_change,NOW()) as last_state_change FROM osae_v_object WHERE UPPER(object_name)=UPPER(@ObjectName) OR UPPER(object_alias)=UPPER(@ObjectName)";
                    command.Parameters.AddWithValue("@ObjectName", ObjectName);
                    dataset = OSAESql.RunQuery(command);
                }

                if (dataset.Tables[0].Rows.Count > 0)
                {
                    state.Value           = dataset.Tables[0].Rows[0]["state_name"].ToString();
                    state.StateLabel      = dataset.Tables[0].Rows[0]["state_label"].ToString();
                    state.TimeInState     = Convert.ToInt64(dataset.Tables[0].Rows[0]["time_in_state"]);
                    state.LastStateChange = Convert.ToDateTime(dataset.Tables[0].Rows[0]["last_state_change"]);
                    return(state);
                }
                else
                {
                    Logging.GetLogger().AddToLog("API - GetObjectStateValue error: Object does not exist | ObjectName: " + ObjectName, true);
                    return(null);
                }
            }
            catch (Exception ex)
            {
                Logging.GetLogger().AddToLog("API - GetObjectStateValue error: " + ex.Message + " | ObjectName: " + ObjectName, true);
                return(null);
            }
            finally
            {
                dataset.Dispose();
            }
        }
예제 #8
0
 public OSAEObject()
 {
     State = new OSAEObjectState();
 }
예제 #9
0
 public OSAEObject()
 {
     State = new OSAEObjectState();
 }