示例#1
0
        private void btnGen_Click(object sender, EventArgs e)
        {
            SaveItemInfos();
            SaveClassItemInfo();

            if (cmbModels.Value != null)
            {
                UIProject project = cmbModels.Value as UIProject;
                if (project != null)
                {
                    try
                    {
                        Project selectedProject = cmbProjects.Value as Project;
                        project.GenerateCode(_curEntityInfo, _config, selectedProject, GetProperty(false), _classInfo);
                        this.Close();
                    }
                    catch (CompileException cex)
                    {
                        FrmCompileResault.ShowCompileResault(cex.Code, cex.ToString(), "编译错误");
                    }
                    catch (Exception ex)
                    {
                        FrmCompileResault.ShowCompileResault(null, ex.ToString(), "编译错误");
                        return;
                    }
                }
            }
        }
示例#2
0
 /// <summary>
 /// 填充项目项
 /// </summary>
 /// <param name="node"></param>
 private void FillProjectItems(XmlNode node)
 {
     _projects = new List <UIProject>();
     foreach (XmlNode projectNode in node.ChildNodes)
     {
         if (!projectNode.Name.Equals("project", StringComparison.CurrentCultureIgnoreCase))
         {
             continue;
         }
         UIProject    objProject = new UIProject();
         XmlAttribute att        = projectNode.Attributes["name"];
         if (att != null)
         {
             objProject.Name = att.InnerText;
         }
         FillProjectItem(projectNode, objProject.LstItems);
         _projects.Add(objProject);
     }
 }
示例#3
0
        /// <summary>
        /// 保存类信息
        /// </summary>
        private void SaveClassItemInfo()
        {
            XmlDocument doc  = EntityMappingConfig.NewXmlDocument();
            XmlNode     root = doc.CreateElement("root");

            doc.AppendChild(root);

            XmlAttribute attRoot  = doc.CreateAttribute("model");
            UIProject    uproject = cmbModels.Value as UIProject;

            if (uproject != null)
            {
                attRoot.InnerText = uproject.Name;
                root.Attributes.Append(attRoot);
            }

            attRoot = doc.CreateAttribute("project");
            Project project = cmbProjects.Value as Project;

            if (project != null)
            {
                attRoot.InnerText = project.Name;
                root.Attributes.Append(attRoot);
            }


            Dictionary <string, object> div = _classInfo.CheckItem;

            _classInfo.WriteNode(root);

            string directory = ModelPath + "\\";

            if (!Directory.Exists(directory))
            {
                Directory.CreateDirectory(directory);
                File.SetAttributes(directory, FileAttributes.Hidden);
            }
            string fileName = directory + "\\classinfo.cache.xml";

            doc.Save(fileName);
        }