Exemple #1
0
        public object GetRemoteEquipmentList(string parentId)
        {
            try
            {
                ExeConfigurationFileMap fileMap = new ExeConfigurationFileMap();
                fileMap.ExeConfigFilename = System.Web.HttpContext.Current.Server.MapPath(@"~/XmlConfig/remote_database.config");
                Configuration      config        = ConfigurationManager.OpenMappedExeConfiguration(fileMap, ConfigurationUserLevel.None);
                AppSettingsSection appsection    = (AppSettingsSection)config.GetSection("appSettings");
                string             connectstring = appsection.Settings["RemoteBaseDb"].Value;
                IDatabase          dbBase        = new OracleDatabase(connectstring);
                string             strWhere      = " 1=1";

                if (!string.IsNullOrEmpty(parentId))
                {
                    strWhere += string.Format(" and parentid ='{0}' ");
                }
                else
                {
                    strWhere += string.Format(" and id ='-1' "); //根
                }
                string sql = string.Format("select facname,faccode,parentid, id from FACTBFACILITY t where {0} order by faccode", strWhere);

                DataTable dt = dbBase.FindTable(sql);

                dbBase.Close();

                return(new { code = 0, info = "获取数据成功", count = dt.Rows.Count, data = dt });
            }
            catch (Exception ex)
            {
                return(new { code = -1, info = ex.Message, count = 0 });
            }
        }