/// <summary> /// 根据模板创建文件. /// </summary> public void CreateByTemplate() { List<ModuleInfo> mods = ExCodeTreeCtrl.Ins.getCheckedEntities(); AppConf.Ins.CurrentExeModules = mods; TemplateURLControl control = new TemplateURLControl(); // 否则就不取值. // 设置全局模板名称. AppConf.ExeTemplatename = checkedTemplate[0]; foreach (ModuleInfo mo in mods) { foreach (EntityInfo entity in mo.Entitys) { if (entity.operaters == null || entity.operaters.Count <= 0) { DEFAULT_OPERATE_READER.Instance.INIT_DEFAULT_OPERA(); entity.operaters = DEFAULT_OPERATE_READER.Instance.DEFAULT_OPERATE; } AppConf.Ins.CurrentExeEntity = entity; control.LoadTemplateURL("Template/" + checkedTemplate[0]); control.Execute(entity, this.txSaveFolder.Text); } } MessageBox.Show("文档生成成功! CheckedEntity.ModulesCount:" + mods.Count); }
/// <summary> /// 根据模板创建文件. /// </summary> public void CreateByTemplate() { List<EntityInfo> modulestable = new List<EntityInfo>(); ModuleInfo checkedModule; if (chkModules.CheckedItems.Count == 1) // 如果是1,则取当前一个, { checkedModule = AppConf.Ins.Application.Modules[chkModules.CheckedIndices[0]]; foreach (int ind in chkEntity.CheckedIndices) { modulestable.Add(checkedModule.Entitys[ind]); } } else if (chkModules.CheckedItems.Count > 1) //取全部的. { foreach (int mind in chkModules.CheckedIndices) { checkedModule = AppConf.Ins.Application.Modules[mind] as ModuleInfo; modulestable.AddRange(checkedModule.Entitys); } } TemplateURLControl control = new TemplateURLControl(); // 否则就不取值. foreach (EntityInfo entity in modulestable) { AppConf.Ins.CurrentExeEntity = entity; control.LoadTemplateURL("Template/" + checkedTemplate[0]); control.Execute(entity, this.txSaveFolder.Text); } MessageBox.Show("文档生成成功! CheckedEntity:" + modulestable.Count); }