Example #1
0
        /// <summary>
        /// 创建Model
        /// </summary>
        /// <param name="config"></param>
        /// <returns></returns>
        public static IDBViewerModel CreateModel(DBViewerConfig config)
        {
            IDBViewerModel dbViewerModel = dicViewerModel[config.DbType].CreateModel() as IDBViewerModel;

            if (dbViewerModel != null)
            {
                dbViewerModel.Coinfig = config;
            }
            return(dbViewerModel);
        }
Example #2
0
        ///// <summary>
        ///// 读取配置信息
        ///// </summary>
        ///// <param name="config"></param>
        //public static DBViewerConfig GetConfig(string fileName)
        //{
        //    XmlDocument doc = new XmlDocument();
        //    doc.Load(fileName);
        //    XmlNode node = doc.SelectSingleNode("//dbtype");
        //    DBViewerConfig config = DBViewerConfig.Create(node);
        //    return config;
        //}

        /// <summary>
        /// 读取默认的配置信息
        /// </summary>
        /// <param name="config"></param>
        public static DBViewerConfig GetConfig(string fileName)
        {
            XmlDocument doc = new XmlDocument();

            doc.Load(fileName);
            XmlNode        root   = doc?.SelectSingleNode("/dbTypes");
            var            type   = root.Attributes["default"].Value;
            XmlNode        node   = root?.SelectSingleNode($"//dbtype[@type='{type}']");
            DBViewerConfig config = DBViewerConfig.Create(node);

            return(config);
        }
Example #3
0
        public static IDBViewerModel CreateCurrentModel(string fileName)
        {
            DBViewerConfig config = GetConfig(fileName);

            if (config != null)
            {
                return(CreateModel(config));
            }
            else
            {
                return(null);
            }
        }
Example #4
0
        public static DBViewerConfig Create(XmlNode node)
        {
            DBViewerConfig config = new DBViewerConfig();
            XmlAttribute   attr   = node.Attributes["type"];

            if (attr != null)
            {
                config.DbType = (EnumDBType)Enum.Parse(typeof(EnumDBType), node.Attributes["type"].Value);
                bool result;
                bool.TryParse(node.SelectSingleNode("displaynull").InnerXml, out result);
                config.DisplayNull   = result;
                config.UserFieldName = node.SelectSingleNode("userfieldname").InnerXml;
                config.Server        = node.SelectSingleNode("server").InnerXml;
                config.User          = node.SelectSingleNode("user").InnerXml;
                config.Password      = node.SelectSingleNode("password").InnerXml;
                config.DbName        = node.SelectSingleNode("dbname").InnerXml;
                config.TraceUser     = node.SelectSingleNode("traceuser").InnerXml;
                return(config);
            }
            return(null);
        }