コード例 #1
0
        // fetches object and object items
        // user has option of passing object itself OR a string with id and type delimited by '|'
        public object Fetch(object obj)
        {
            int id = ((CableBlock)obj).comp_id;

            // create new object and database connection
            _cabBlock = new CableBlock();
            _user = (User)System.Web.HttpContext.Current.Session[Constant.session.User];
            _dbmgr = new DBManager(_user.plantDBStr);
            _dbmgr.ConnectionString = _user.plantDBStr;

            try
            {
                _dbmgr.Open();

                FetchComponent(id, _dbmgr);
                FetchCableBlock(id, _dbmgr);
                FetchVertexList(id, _dbmgr);
                return _cabBlock;
            }
            catch (Exception ex)
            {
                throw ex;
            }
            finally
            {
                _dbmgr.Dispose();
            }
        }
コード例 #2
0
ファイル: CableBlock.cs プロジェクト: DanielSpalding/Projects
 public CableBlock(CableBlock oldobj)
 {
     PropertyInfo[] p = oldobj.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(oldobj, null), null);                 // set entity's property values to obj properties
     }
 }
コード例 #3
0
        // procedure fetches a component with a given id
        private void FetchComponent(int id, IDBManager dbmgr)
        {
            string qryLocal = "SELECT * FROM viewCOMPLIST WHERE COMP_ID=@id";

            dbmgr.CreateParameters(1);                                                      // create required parameters
            dbmgr.AddParameters(0, "@id", id);
            dbmgr.ExecuteReader(CommandType.Text, qryLocal);                                // execute reader
            if (dbmgr.DataReader.Read())
            {
                // get properties of object and fetch object
                PropertyInfo[] p = _cabBlock.GetType().GetProperties();
                _cabBlock = (CableBlock)FetchObject(_cabBlock, p, dbmgr);
            }

            dbmgr.CloseReader();
        }