Ejemplo n.º 1
0
 public Cable(Cable 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;                                                                    // 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 = ((Cable)obj).cable_id;
                type = "all";                                                               // object is a cable and get all information
            }

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

            switch (type)
            {
                case "component":
                    FetchComponentList(id, _dbmgr);
                    return _cable.componentlist;
                case "drawing":
                    FetchDrawingList(id, _dbmgr);
                    return _cable.drawinglist;
                case "routechg":
                    FetchRoutechgList(id, _dbmgr);
                    return _cable.routechglist;
                case "all":
                    FetchCable(id, _dbmgr);
                    FetchComponentList(id, _dbmgr);
                    FetchDrawingList(id, _dbmgr);
                    FetchRoutechgList(id, _dbmgr);
                    FetchRouteList(id, _dbmgr);
                    FetchCRDPowerList(id, _dbmgr);
                    return _cable;
            }
            return _cable;
        }
Ejemplo n.º 3
0
 private void UpdateStatus(IDBManager dbmgr, Cable item, int statustype_id, string user_id, DateTime status_date)
 {
     if ((user_id == "N/A") || (user_id == ""))
     {
         // delete status
         dbmgr.CreateParameters(2);
         dbmgr.AddParameters(0, "@cable_id", item.cable_id);
         dbmgr.AddParameters(1, "@statustype_id", statustype_id);
         dbmgr.ExecuteNonQuery(CommandType.StoredProcedure, "dbo.CABSTATUS_d");
     }
     else
     {
         // update status
         dbmgr.CreateParameters(4);
         dbmgr.AddParameters(0, "@cable_id", item.cable_id);
         dbmgr.AddParameters(1, "@statustype_id", statustype_id);
         dbmgr.AddParameters(2, "@user_id", user_id);
         if (status_date == Convert.ToDateTime(null))
             // set date to null
             dbmgr.AddParameters(3, "@status_date", null);
         else
             // update date
             dbmgr.AddParameters(3, "@status_date", status_date);
         dbmgr.ExecuteNonQuery(CommandType.StoredProcedure, "dbo.CABSTATUS_u");
     }
 }
Ejemplo n.º 4
0
 private void FetchCable(int id, IDBManager dbmgr)
 {
     string qryLocal = "SELECT *, dbo.GET_LOCATION(FR_EQUIP) AS FR_EQUIP_LOC, dbo.GET_LOCATION(TO_EQUIP) AS TO_EQUIP_LOC, " +
         " dbo.GET_LOCATION(FR_EQUIP_ORIG) AS FR_EQUIP_ORIG_LOC, dbo.GET_LOCATION(TO_EQUIP_ORIG) AS TO_EQUIP_ORIG_LOC " +
         " FROM viewCABLIST WHERE CABLE_ID = @id";
     try
     {
         dbmgr.Open();
         dbmgr.CreateParameters(1);
         dbmgr.AddParameters(0, "@id", id);
         dbmgr.ExecuteReader(CommandType.Text, qryLocal);
         if (dbmgr.DataReader.Read())
         {
             PropertyInfo[] p = _cable.GetType().GetProperties();                    // get properties of object
             _cable = (Cable)FetchObject(_cable, p, dbmgr);
         }
     }
     catch (Exception ex)
     {
         throw ex;
     }
     finally
     {
         dbmgr.Dispose();
     }
 }