Ejemplo n.º 1
0
 public FireRoom(FireZone obj)
 {
     PropertyInfo[] p = obj.GetType().GetProperties();                               // get entity properties
     for (int i = 0; i < (p.Length); i++)
     {
         if (!p[i].PropertyType.Name.Contains("list") && !p[i].Name.Contains("arg"))
             p[i].SetValue(this, p[i].GetValue(obj, null), null);                    // set entity's property values to obj properties
     }
 }
Ejemplo n.º 2
0
        public object Fetch(object obj)
        {
            int id;
            string type;

            // determine id and type
            string objtype = obj.GetType().ToString();
            if (objtype == "System.String")
            {
                string[] strTemp = ((string)obj).Split(new char[] { '|' });
                id = Convert.ToInt32(strTemp[0]);
                type = strTemp[1];
            }
            else
            {
                id = ((FireZone)obj).fz_id;
                type = "all";
            }

            // initialize
            _firezone = new FireZone();
            _user = (User)System.Web.HttpContext.Current.Session[Constant.session.User];
            _dbmgr = new DBManager(_user.plantDBStr);
            _dbmgr.ConnectionString = _user.plantDBStr;

            try
            {
                _dbmgr.Open();

                // fetch object information
                switch (type)
                {
                    case "firezone":
                        FetchFireZone(id, _dbmgr);
                        return _firezone;
                    case "protection":
                        FetchProtectionList(id, _dbmgr);
                        return _firezone;
                    case "ignition":
                        FetchIgnitionList(id, _dbmgr);
                        return _firezone;
                    case "ignitionimpact":
                        // TODO: Need to pass ignition information
                        //FetchIgnitionImpactList(id, _dbmgr);
                        return _firezone;
                    case "all":
                        FetchFireZone(id, _dbmgr);
                        FetchComponentList(id, _dbmgr);
                        FetchCableList(id, _dbmgr);
                        FetchRouteList(id, _dbmgr);
                        FetchProtectionList(id, _dbmgr);
                        FetchIgnitionList(id, _dbmgr);
                        return _firezone;
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
            finally
            {
                _dbmgr.Dispose();
            }

            return _firezone;
        }
Ejemplo n.º 3
0
        // procedure fetches fire zone information
        private void FetchFireZone(int id, IDBManager dbmgr)
        {
            string qryString = "SELECT * FROM viewFZLIST WHERE FZ_ID=@id";

            dbmgr.CreateParameters(1);
            dbmgr.AddParameters(0, "@id", id);
            dbmgr.ExecuteReader(CommandType.Text, qryString);
            if (dbmgr.DataReader.Read())
            {
                // get properties of object and fetch object
                PropertyInfo[] p = _firezone.GetType().GetProperties();
                _firezone = (FireZone)FetchObject(_firezone, p, dbmgr);
            }

            dbmgr.CloseReader();
        }