private void GenCoding(string charset, string codeProjectPath, string codeSrc, string codeWeb, string templatesPath, Hashtable templateHt, Hashtable paramsHt, string _frame, string _namespace, string _module, string _webmodule, string _table, string _model, string _comment ) { _namespace = BuilderUtil.GetToPath(_namespace); _module = BuilderUtil.GetToPath(_module); _webmodule = BuilderUtil.GetToPath(_webmodule); string tmp_namespace = _namespace; if (_namespace.StartsWith("/")) { tmp_namespace = _namespace.Substring(1, _namespace.Length - 1); } TableModel tableModel = BuilderUtil.GetTableModel(_table, dbFileName, dbTypeName, dbUrlName); tableModel.AddParam("Frame", _frame); tableModel.AddParam("Namespace", tmp_namespace.Replace("/", ".")); tableModel.AddParam("Module", _module.Replace("/", "")); // csharp里不支持多级 tableModel.AddParam("Javamodule", _module.Replace("/", ".")); tableModel.AddParam("Webmodule", _webmodule); tableModel.AddParam("Model", _model); tableModel.AddParam("ModelName", _model.Substring(0, 1).ToLower() + _model.Substring(1, _model.Length - 1)); Hashtable ht = new Hashtable(); ht.Add("vo", tableModel); // 替换或增加vo属性 if (paramsHt != null && paramsHt.Count > 0) { IDictionaryEnumerator dictenum = paramsHt.GetEnumerator(); while (dictenum.MoveNext()) { try { if (dictenum.Key.ToString() != "vo") { ht.Add(dictenum.Key.ToString(), dictenum.Value); } } catch { } } } if (templateHt != null && templateHt.Count > 0) { IDictionaryEnumerator dictenum = templateHt.GetEnumerator(); while (dictenum.MoveNext()) { try { String key = dictenum.Key.ToString(); TempModel value = (TempModel)dictenum.Value; if (value.comment == "" || value.comment == _comment) { String _path = value.path.Replace("{src}", codeSrc).Replace("{web}", codeWeb).Replace("{module}", _module).Replace("{webmodule}", _webmodule).Replace("{model}", _model).Replace("{namespace}", _namespace.Replace(".", "/")).Replace("\\", "/").Replace("//", "/"); System.Console.Write(" 模板ID[" + value.id + "]文件:" + _path); string parsedStr = BuilderUtil.GenByTemplate(templatesPath, value.viewpath, ht, charset); //解析后的代码 BuilderUtil.WriteFile(BuilderUtil.GetPath(codeProjectPath, _path), parsedStr, charset, false); //写入文件 System.Console.WriteLine(",生成成功!"); } else { System.Console.WriteLine(" 模板ID[" + value.id + "]被跳过!"); } } catch (Exception ex) { Console.WriteLine(",生成错误,原因:" + ex.Message); } } } }