Esempio n. 1
0
 public Document(Document 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
     }
 }
Esempio 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 = ((Document)obj).doc_id;
                type = "all";                                                               //object is  document and get all information
            }

            _document = new Document();
            _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 "firearea":
                        FetchFAList(id, _dbmgr);
                        return _document.falist;
                    default:
                        FetchDocument(id, _dbmgr);
                        FetchFAList(id, _dbmgr);
                        return _document;
                }

            }
            catch (Exception ex)
            {
                throw ex;
            }
            finally
            {
                _dbmgr.Dispose();
            }
        }
Esempio n. 3
0
        private void FetchDocument(int id, IDBManager dbmgr)
        {
            string qryLocal = "SELECT * FROM viewDOCLIST WHERE DOC_ID=@id";

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

            dbmgr.CloseReader();
        }