C# 把数据字典表的数据自动生成为 js 键值对形式
来源:互联网 发布:unity3d 联网 编辑:程序博客网 时间:2024/04/29 22:59
/// <summary>
/// 生成数字字典Js文件
/// </summary>
/// <returns></returns>
public ActionResult GenerateDictJs()
{
var path = Path.Combine(HttpRuntime.AppDomainAppPath, @"KScripts\_wisdomsite\dictionary.js");
if (System.IO.File.Exists(path))
{
System.IO.File.Delete(path);
}
using (var tt = new RealNameSystemEntities())
{
var ts = tt.sys_dict_type.Where(p => p.is_selectable == 0).ToDictionary(p => p.type_code, p => p.type_name);
using (StreamWriter sw = System.IO.File.AppendText(path))
{
sw.WriteLine("window.dictTransfer = {");
foreach (var t in ts)
{
sw.WriteLine(" /** {0} **/", t.Value);
sw.WriteLine(" {0}: [", t.Key);
foreach (var item in tt.sys_dict_item.Where(p => p.type_code == t.Key && p.del_flag == 0).ToList())
{
sw.WriteLine(" {{ text: '{0}', value: '{1}' }},", item.name, item.code);
}
sw.WriteLine(" ],");
}
sw.WriteLine("}");
sw.Flush();
}
}
return Json("生成成功", JsonRequestBehavior.AllowGet);
/// 生成数字字典Js文件
/// </summary>
/// <returns></returns>
public ActionResult GenerateDictJs()
{
var path = Path.Combine(HttpRuntime.AppDomainAppPath, @"KScripts\_wisdomsite\dictionary.js");
if (System.IO.File.Exists(path))
{
System.IO.File.Delete(path);
}
using (var tt = new RealNameSystemEntities())
{
var ts = tt.sys_dict_type.Where(p => p.is_selectable == 0).ToDictionary(p => p.type_code, p => p.type_name);
using (StreamWriter sw = System.IO.File.AppendText(path))
{
sw.WriteLine("window.dictTransfer = {");
foreach (var t in ts)
{
sw.WriteLine(" /** {0} **/", t.Value);
sw.WriteLine(" {0}: [", t.Key);
foreach (var item in tt.sys_dict_item.Where(p => p.type_code == t.Key && p.del_flag == 0).ToList())
{
sw.WriteLine(" {{ text: '{0}', value: '{1}' }},", item.name, item.code);
}
sw.WriteLine(" ],");
}
sw.WriteLine("}");
sw.Flush();
}
}
return Json("生成成功", JsonRequestBehavior.AllowGet);
}
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
window.dictTransfer = {
/** 是否 **/
SYS_YES_NO: [
{ text: '是', value: 'YES' },
{ text: '否', value: 'NO' },
]
}
阅读全文
0 0
- C# 把数据字典表的数据自动生成为 js 键值对形式
- c# 将json中的数据转为键值的形式放入字典Dictionary并进行拼接md5加密
- SharedPreferences轻量级数据存贮,键值对形式
- C# 键值对数据排序
- C# 将json字符串转换为键值对形式,用于执行form表单形式的请求
- Python 查询的数据库中的数据 关键值转换成键值对形式
- SqlServer2005自动生成数据字典
- SqlServer2005自动生成数据字典
- Laravel 自动生成数据字典
- php自动生成数据字典
- unity 在ios上的 c#键值对数据排序
- 让axios发送表单请求形式的键值对post数据
- 让axios发送表单请求形式的键值对post数据
- 实现把字典转换为XML数据
- JS自动获取Form表单数据并转换成键值对 ajax提交Form
- js 把数据生成word
- js中自定义键值对形式的Map结构
- js把科学计数法形式的数据转换成非科学计数法的形式
- spring <context:component-scan>使用说明(转)
- 阿里负载均衡,配置中间证书问题(在starcom申请免费DV ssl)
- Golang构建简单web框架
- msm8916 dt选用规则
- 【C语言】实现一个简单SHELL应用
- C# 把数据字典表的数据自动生成为 js 键值对形式
- python lxml 安装
- QT编译出现错误 “undefined reference to ‘vtable for xxx’”
- BZOJ 1053 反素数【DFS剪枝】
- 微软有哪些很好的框架和设计理念?
- 机器翻译重要过程(1)---数据预处理
- PL\SQL Developer的安装
- 挑战程序竞赛系列(23):3.2折半枚举
- 简单封装strstr()