Exemplo n.º 1
0
        private void Menubind()
        {
            //数据库表列表
            List <string> list = MenuList.GetList();

            foreach (string tablename in list)
            {
                cklTableTree.Items.Add(tablename);
            }


            #region 生成代码 文件
            //int count = project.ProjectItems.Count;
            //int indexCode = 0;
            //for (int i = 1; i < count; i++)
            //{
            //	if (project.ProjectItems.Item(i).Name == "Code")
            //	{
            //		indexCode = i;

            //		break;
            //	}
            //}
            #endregion

            //var projectBusCode = project.ProjectItems.Item(indexCode);

            //filePath = projectBusCode.get_FileNames(1);

            //listFileBusCode = new List<String>();

            //for (int i = 1; i <= projectBusCode.ProjectItems.Count; i++)
            //{

            //	string fileName = projectBusCode.ProjectItems.Item(i).Name;
            //	string fileNameShort = string.Empty;
            //	if (fileName.Contains('.'))
            //	{
            //		fileNameShort = fileName.Split('.')[0].ToString().Trim();
            //	}

            //	listFileBusCode.Add(fileNameShort);
            //}
        }
Exemplo n.º 2
0
        /// <summary>
        /// 全部生成
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btnStartAll_Click(object sender, EventArgs e)
        {
            Generate gen = new Generate(this.txtPath.Text, this.txtDataPath.Text + @"\",
                                        "Common.Business", "Common.DalFactory", "CMFactory");

            gen.CanBus = cbBus.Checked;
            gen.CanDal = cbDal.Checked;

            List <string> list = MenuList.GetList();           //数据库表

            #region 生成代码 文件
            int count     = project.ProjectItems.Count;
            int indexCode = 0;
            for (int i = 1; i < count; i++)
            {
                if (project.ProjectItems.Item(i).Name == "Code")
                {
                    indexCode = i;

                    break;
                }
            }
            #endregion

            var projectBusCode = project.ProjectItems.Item(indexCode);

            //删除多余Bus
            for (int i = listFileBusCode.Count; i > 0; i--)
            {
                string fileNameShort = listFileBusCode[i - 1].Trim();
                if (!list.Contains(fileNameShort))
                {
                    //string delFilePath = filePath + fileName;
                    //从项目中移除文件
                    listFileBusCode.RemoveAt(i - 1);
                    projectBusCode.ProjectItems.Item(i).Remove();
                    //删除移除的文件
                    //File.Delete(delFilePath);
                }
            }

            //新增新表Bus
            foreach (string tablename in list)
            {
                //try
                //{
                if (!listFileBusCode.Contains(tablename))
                {
                    //生成只读业务对象
                    gen.ProgCreateReadOnly(tablename, project);
                    break;
                }


                //}
                //catch (Exception)
                //{
                //	MessageBox.Show("生成失败");
                //	return;
                //}
            }
        }