コード例 #1
0
        public object Fetch(object obj)
        {
            int id;
            string type;                                                                    // type of object passed
            string objtype = obj.GetType().ToString();                                      // get object type

            if (objtype == "System.String")
            {
                string[] strTemp = ((string)obj).Split(new char[] { '|' });                 // if object type is a string then extract the id and type
                id = Convert.ToInt32(strTemp[0]);
                type = strTemp[1];
            }
            else
            {
                id = ((Power)obj).power_id;
                type = "all";                                                               // object is  drawing and get all information
            }

            _power = new Power();
            _user = (User)System.Web.HttpContext.Current.Session[Constant.session.User];
            _dbmgr = new DBManager(_user.plantDBStr);
            _dbmgr.ConnectionString = _user.plantDBStr;

            try
            {
                _dbmgr.Open();

                switch (type)
                {
                    case "component":
                        FetchComponentList(id, _dbmgr);
                        return _power.componentlist;
                    case "psload":
                        FetchPSLoadList(id, _dbmgr);
                        return _power.psloadlist;
                    case "psbkrcab":
                        FetchPSBkrCabList(id, _dbmgr);
                        return _power.psbkrcablist;
                    case "cabroutelist":
                        FetchCabRoutelist(id, _dbmgr);
                        return _power.cabroutelist;
                    default:
                        FetchPower(id, _dbmgr);
                        FetchComponentList(id, _dbmgr);
                        FetchPSLoadList(id, _dbmgr);
                        return _power;
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
            finally
            {
                _dbmgr.Dispose();
            }
        }
コード例 #2
0
ファイル: Power.cs プロジェクト: DanielSpalding/Projects
 public Power(Power 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
     }
 }
コード例 #3
0
        private void FetchPower(int id, IDBManager dbmgr)
        {
            string qryLocal = "SELECT * FROM viewPOWERLIST WHERE POWER_ID=@id ORDER BY POWER";

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

            dbmgr.CloseReader();
        }