Example #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;
            }
        }
Example #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);
        }
Example #4
0
        /// <summary>
        /// 生成扩展代码
        /// </summary>
        private void GenerateExtenCode()
        {
            BQLEntityGenerater bqlEntity = new BQLEntityGenerater(this);

            GenerateExtendCode();
            if (_currentDBConfigInfo.Tier == 3)
            {
                Generate3Tier g3t = new Generate3Tier(this);
                g3t.GenerateBusiness();
                if (!string.IsNullOrEmpty(this.TableName))
                {
                    g3t.GenerateIDataAccess();
                    g3t.GenerateDataAccess();
                    g3t.GenerateBQLDataAccess();
                }
            }
            bqlEntity.GenerateBQLEntityDB();
            bqlEntity.GenerateBQLEntity();
            EntityMappingConfig.SaveXML(this);
        }
Example #5
0
        /// <summary>
        /// 初始化字段信息
        /// </summary>
        private void InitField()
        {
            List <ClrField> lstFields = GetAllMember <ClrField>(_classType, false);

            _fields = new Dictionary <string, CodeElementPosition>();
            for (int j = 0; j < lstFields.Count; j++)
            {
                ClrField field = lstFields[j];
                if (field == null)
                {
                    continue;
                }
                if (field.SourceCodePositions == null)
                {
                    continue;
                }
                foreach (CodeElementPosition cp in field.SourceCodePositions)
                {
                    if (!IsManyOne(field))
                    {
                        EntityParamField epf = new EntityParamField(cp, field, this);
                        epf.AllowNull = EntityFieldBase.IsNullProperty(field.MemberTypeShortName);
                        _eParamFields.Add(epf);
                    }
                    else
                    {
                        EntityRelationItem erf = new EntityRelationItem(cp, field, this);
                        _eRelation.Add(erf);
                    }

                    _fields[field.Name] = cp;
                }
                _eParamFields.SortItem();
                _eRelation.SortItem();
            }
            _hasConfig = EntityMappingConfig.LoadConfigInfo(this);
        }
 /// <summary>
 /// 保存XML信息
 /// </summary>
 /// <param name="entity"></param>
 public void SaveXML()
 {
     EntityMappingConfig.SaveXML(_fileName, _doc);
     EnvDTE.ProjectItem newit = DesignerInfo.CurrentProject.ProjectItems.AddFromFile(_fileName);
     newit.Properties.Item("BuildAction").Value = (int)BuildAction.Resource;
 }