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 the object type is a string then extract the id and type
                id = Convert.ToInt32(strTemp[0]);
                type = strTemp[1];
            }
            else
            {
                id = ((Disposition)obj).disp_id;
                type = "all";                                                               //object is a cable and get all information
            }

            _disp = new Disposition();                                                     //create new instance of object
            _user = (User)System.Web.HttpContext.Current.Session[Constant.session.User];
            _dbmgr = new DBManager(_user.plantDBStr);
            _dbmgr.ConnectionString = _user.plantDBStr;

            switch (type)
            {
                case "facompcabdisp":
                    FetchFACompCabList(id, _dbmgr);
                    return _disp.facompcablist;
                case "all":
                    FetchDisposition(id, _dbmgr);
                    FetchFACompCabList(id, _dbmgr);
                    return _disp;
            }
            return _disp;
        }
Example #2
0
 public Disposition(Disposition 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
     }
 }
 private void FetchDisposition(int id, IDBManager dbmgr)
 {
     string qryLocal = "SELECT * FROM viewDISPLIST WHERE DISP_ID=@id";
     try
     {
         dbmgr.Open();
         dbmgr.CreateParameters(1);
         dbmgr.AddParameters(0, "@id", id);
         dbmgr.ExecuteReader(CommandType.Text, qryLocal);
         if (dbmgr.DataReader.Read())
         {
             PropertyInfo[] p = _disp.GetType().GetProperties();                     // get properties of object
             _disp = (Disposition)FetchObject(_disp, p, dbmgr);
         }
     }
     catch (Exception ex)
     {
         throw ex;
     }
     finally
     {
         dbmgr.Dispose();
     }
 }