Пример #1
0
        /// <summary>Get components in possession of component with given ID</summary>
        /// <param name="lID">The id of the Pilot or Drone to get the components in possession for</param>
        /// <returns>The components in possession if found, an empty ArrayList otherwise</returns>
        public ArrayList getComponentsInPossession(long lID)
        {
            //EventLogger.Log(String.Format("{0}::{1} - {2}", mClassName, "getComponentsInPossession", String.Format("Calling for ID: {0}", lID)));

            ArrayList       oCompArray   = new ArrayList();
            MySqlDataReader oMySQLReader = null;

            try
            {
                ComponentPersistence oCP = new ComponentPersistence();
                String       sSql        = "select_components_in_possession;";
                MySqlCommand oCmd        = new MySqlCommand(sSql, DBSupport.Conn);
                oCmd.CommandType = System.Data.CommandType.StoredProcedure;
                oCmd.Parameters.AddWithValue("_comp_id", lID);
                oCmd.Parameters["_comp_id"].Direction = System.Data.ParameterDirection.Input;
                oMySQLReader = oCmd.ExecuteReader();
                while (oMySQLReader.Read())
                {
                    oCompArray.Add(oCP.CreateComponent(oMySQLReader));
                }
            }
            catch (Exception ex)
            {
                //EventLogger.Log(String.Format("{0}::{1} - {2}", mClassName, "getComponentsInPossession", ex));
            }
            finally
            {
                if (oMySQLReader != null && !oMySQLReader.IsClosed)
                {
                    oMySQLReader.Close();
                }
                oMySQLReader = null;
            }
            return(oCompArray);
        }
Пример #2
0
        public ArrayList getComponents(string sSql)
        {
            ArrayList oCompArray = new ArrayList();

            try
            {
                Component            oComp        = null;
                ComponentPersistence oCP          = new ComponentPersistence();
                MySqlDataReader      oMySQLReader = null;
                MySqlCommand         oCmd         = new MySqlCommand(sSql, Conn);
                oMySQLReader = oCmd.ExecuteReader();
                while (oMySQLReader.Read())
                {
                    oComp = oCP.CreateComponent(oMySQLReader);
                    oCompArray.Add(oComp);
                }
                oMySQLReader.Close();
            }
            catch (Exception ex)
            {
                //EventLogger.Log(String.Format("{0}::{1} - {2}", mClassName, "getComponents", ex));
            }
            return(oCompArray);
        }
Пример #3
0
        /// <summary>Get Drone for Pilot with given ID</summary>
        /// <param name="lID">The id of the Pilot of the Drone to get</param>
        /// <returns>The Drone if found, an empty ArrayList otherwise</returns>
        public ArrayList getDrone(long lID)
        {
            ArrayList       oCompArray   = new ArrayList();
            MySqlDataReader oMySQLReader = null;

            try
            {
                Component    oThisDrone = null;
                String       sSql       = "select_drone;";
                MySqlCommand oCmd       = new MySqlCommand(sSql, DBSupport.Conn);
                oCmd.CommandType = System.Data.CommandType.StoredProcedure;
                oCmd.Parameters.AddWithValue("_pilot_id", lID);
                oCmd.Parameters["_pilot_id"].Direction = System.Data.ParameterDirection.Input;
                oMySQLReader = oCmd.ExecuteReader();
                if (oMySQLReader.Read())
                {
                    ComponentPersistence oComponentPersistence = new ComponentPersistence();
                    oThisDrone = oComponentPersistence.CreateComponent(oMySQLReader);
                    oMySQLReader.Close();
                    oCompArray.Add(oThisDrone);
                }
            }
            catch (Exception ex)
            {
                //EventLogger.Log(String.Format("{0}::{1} - {2}", mClassName, "getDrone", ex));
            }
            finally
            {
                if (oMySQLReader != null && !oMySQLReader.IsClosed)
                {
                    oMySQLReader.Close();
                }
                oMySQLReader = null;
            }
            return(oCompArray);
        }
Пример #4
0
        /// <summary>Get components in range of component with given ID</summary>
        /// <param name="lID">The id of the Pilot or Drone to get the components in range for</param>
        /// <returns>The components in range if found, an empty ArrayList otherwise</returns>
        public ArrayList getComponentsInRange(long lID)
        {
            //EventLogger.Log(String.Format("{0}::{1} - {2}", mClassName, "getComponentsInRange", String.Format("Calling for ID: {0}", lID)));

            ArrayList       oCompArray   = new ArrayList();
            MySqlDataReader oMySQLReader = null;

            try
            {
                ComponentPersistence oCP = new ComponentPersistence();
                oCompArray = oCP.getComponent(lID);
                if (oCompArray.Count == 1)
                {
                    Component   oComp = (Component)oCompArray[0];
                    Models.Type oType = new Models.Type();
                    if (oComp.Type == 2)
                    {
                        // For a Pilot, skip adding its Drone
                        oType.ID = 3;
                    }
                    else if (oComp.Type == 3)
                    {
                        // For a Drone, skip adding its Pilot
                        oType.ID = 2;
                    }
                    String       sSql = "select_components_in_range;";
                    MySqlCommand oCmd = new MySqlCommand(sSql, DBSupport.Conn);
                    oCmd.CommandType = System.Data.CommandType.StoredProcedure;
                    oCmd.Parameters.AddWithValue("iLon", oComp.Lon);
                    oCmd.Parameters["iLon"].Direction = System.Data.ParameterDirection.Input;
                    oCmd.Parameters.AddWithValue("iLat", oComp.Lat);
                    oCmd.Parameters["iLat"].Direction = System.Data.ParameterDirection.Input;
                    oCmd.Parameters.AddWithValue("iOffset", 1); // Properties.Settings.Default.CIROffset);
                    oCmd.Parameters["iOffset"].Direction = System.Data.ParameterDirection.Input;
                    // Clear array
                    oCompArray   = new ArrayList();
                    oMySQLReader = oCmd.ExecuteReader();
                    while (oMySQLReader.Read())
                    {
                        // Skip adding this Pilot/Drone and its Drone/Pilot (making it easier to process result client-side)
                        oComp = oCP.CreateComponent(oMySQLReader);
                        if (oComp.ID != lID && (oComp.Parent != lID || (oType.ID > 0 && oComp.Type != oType.ID)))
                        {
                            oCompArray.Add(oComp);
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                //EventLogger.Log(String.Format("{0}::{1} - {2}", mClassName, "getComponentsInRange", ex));
            }
            finally
            {
                if (oMySQLReader != null && !oMySQLReader.IsClosed)
                {
                    oMySQLReader.Close();
                }
                oMySQLReader = null;
            }
            return(oCompArray);
        }