示例#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 the object type is a string then extract the id and type
                id = Convert.ToInt32(strTemp[0]);
                type = strTemp[1];
            }
            else
            {
                id = ((Route)obj).node_id;
                type = "all";                                                               // object is a cable and get all information
            }
            _route = new Route();                                                           // create new instance of object
            _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 "routeloca":
                        FetchRoutelocaList(id, _dbmgr);
                        return _route.routelocalist;
                    case "routelocadwg":
                        FetchRoutelocaList(id, _dbmgr);
                        FetchDrawingList(_route.routelocalist, _dbmgr);
                        return _route.drawinglist;
                    case "bdendpoint":
                        FetchBDEndpointList(id, _dbmgr);
                        return _route.bdendpointlist;
                    case "cable":
                        FetchCableList(id, _dbmgr);
                        return _route.cablelist;
                    default:
                        FetchRoute(id, _dbmgr);
                        FetchRoutelocaList(id, _dbmgr);
                        FetchBDEndpointList(id, _dbmgr);
                        FetchDrawingList(_route.routelocalist, _dbmgr);
                        FetchCableList(id, _dbmgr);
                        return _route;
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
            finally
            {
                _dbmgr.Dispose();
            }
        }
示例#2
0
 public Route(Route 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 FetchRoute(int id, IDBManager dbmgr)
        {
            string qryLocal = "SELECT * FROM viewROUTELIST WHERE NODE_ID=@id ORDER BY NODE";

            dbmgr.CreateParameters(1);
            dbmgr.AddParameters(0, "@id", id);
            dbmgr.ExecuteReader(CommandType.Text, qryLocal);
            if (dbmgr.DataReader.Read())
            {
                PropertyInfo[] p = _route.GetType().GetProperties();
                _route = (Route)FetchObject(_route, p, dbmgr);
            }

            dbmgr.CloseReader();
        }