Ejemplo n.º 1
0
        /// <summary>
        /// 保存配置信息
        /// </summary>
        private void SaveConfigInfo(string path)
        {
            XmlDocument doc        = EntityMappingConfig.NewXmlDocument();
            XmlNode     configNode = doc.CreateElement("config");

            doc.AppendChild(configNode);

            XmlAttribute att = doc.CreateAttribute("tier");

            att.InnerText = this.Tier.ToString();
            configNode.Attributes.Append(att);

            att           = doc.CreateAttribute("isAllDal");
            att.InnerText = this.IsAllDal ? "1" : "0";
            configNode.Attributes.Append(att);

            att           = doc.CreateAttribute("summary");
            att.InnerText = ((int)this.SummaryShow).ToString();
            configNode.Attributes.Append(att);

            att           = doc.CreateAttribute("entityToDirectory");
            att.InnerText = this.EntityToDirectory ? "1" : "0";
            configNode.Attributes.Append(att);

            int    last     = path.LastIndexOf(".xml");
            string savePath = path;

            if (last > 0)
            {
                savePath  = path.Substring(0, last);
                savePath += ".config.xml";
            }
            EntityMappingConfig.SaveXML(savePath, doc);
        }
        /// <summary>
        /// 初始化信息
        /// </summary>
        private void Init()
        {
            //FileInfo classFile = new FileInfo(EntityFileName);
            string dicName = GenerateBasePath + "\\BEM\\";

            if (!Directory.Exists(dicName))
            {
                Directory.CreateDirectory(dicName);
            }
            _fileName = dicName + DBName + ".BDM.xml";
            if (File.Exists(_fileName))
            {
                try
                {
                    _doc.Load(_fileName);
                    XmlNodeList rootNodes = _doc.GetElementsByTagName("dataaccess");
                    XmlNodeList boNodes   = _doc.GetElementsByTagName("business");
                    if (rootNodes.Count <= 0 || boNodes.Count <= 0)
                    {
                        _doc = EntityMappingConfig.NewXmlDocument();
                    }
                    else
                    {
                        _rootNode = rootNodes[0];
                        _boNode   = boNodes[0];
                    }
                }
                catch
                {
                }
            }
            if (_rootNode == null)
            {
                XmlNode root = _doc.CreateElement("root");
                _doc.AppendChild(root);
                XmlNode dalNode = _doc.CreateElement("dataaccess");
                root.AppendChild(dalNode);
                XmlAttribute att = _doc.CreateAttribute("name");
                att.InnerText = DBName;
                dalNode.Attributes.Append(att);

                XmlNode boNode = _doc.CreateElement("business");
                root.AppendChild(boNode);

                _boNode   = boNode;
                _rootNode = dalNode;
            }
        }
Ejemplo n.º 3
0
        /// <summary>
        /// 保存
        /// </summary>
        /// <param name="path"></param>
        public void SaveConfig(string path)
        {
            XmlDocument doc        = EntityMappingConfig.NewXmlDocument();
            XmlNode     configNode = doc.CreateElement("config");

            doc.AppendChild(configNode);

            XmlAttribute att = doc.CreateAttribute("connectionString");

            att.InnerText = this.ConnectionString;
            configNode.Attributes.Append(att);

            att           = doc.CreateAttribute("dbType");
            att.InnerText = this.DbType;
            configNode.Attributes.Append(att);

            att           = doc.CreateAttribute("appnamespace");
            att.InnerText = this.AppNamespace;
            configNode.Attributes.Append(att);

            att           = doc.CreateAttribute("assembly");
            att.InnerText = this.Assembly;
            configNode.Attributes.Append(att);

            att           = doc.CreateAttribute("name");
            att.InnerText = this.DbName;
            configNode.Attributes.Append(att);

            att           = doc.CreateAttribute("cache");
            att.InnerText = this.CacheType;
            configNode.Attributes.Append(att);

            att           = doc.CreateAttribute("cacheConnString");
            att.InnerText = this.CacheConnString;
            configNode.Attributes.Append(att);

            att           = doc.CreateAttribute("allCache");
            att.InnerText = this.IsAllTable ? "1" : "0";
            configNode.Attributes.Append(att);

            att           = doc.CreateAttribute("lazy");
            att.InnerText = ((int)this.AllowLazy).ToString();
            configNode.Attributes.Append(att);

            EntityMappingConfig.SaveXML(path, doc);
            SaveConfigInfo(path);
        }