企业开发宗旨在于高效与便捷以及系统升级与维护的稳定.此框架为此而架构设计,目标在于打造一个高效能的.NET开发框架。
Moon.NET由两部分组成:Qin.Data(一个高性能的ORM系统,其特色是提供便捷的开发和高效的数据库访问性能以及方便便捷的系统升级,内含代码生成器、代码自动编译);Qin.Web(一个快速的ASP.NET服务端框架,内含一个前端js脚本一引擎[有了它,你只需专注于业务逻辑,几乎绝大部分代码由引擎生成]、以及实现权限认证的AOP方案和一个前端UI库).其中的Qin.Data已被用于合富网络有限公司的数据层取代原有的实体框架.
Qin.Data的相关介绍
Qin.Web相关介绍
2.强大的脚本引擎
实现一个页面数据的加载和数据更新
前端代码
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="WebForm1.aspx.cs" Inherits="MoonAjax.WebForm1" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>model加载和数据更新</title>
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
<meta http-equiv="CACHE-CONTROL" content="NO-CACHE" />
<meta http-equiv="PRAGMA" content="NO-CACHE" />
<script type="text/javascript" src="Scripts/jquery-1.6.2.min.js"></script>
<script type="text/javascript" src="Scripts/Qin.Tool.js"></script>
<script src="Thrid/art/artDialog.js?skin=aero" type="text/javascript"></script>
<script>
$(function () {
Qin_LoadDataToDom("MoonAjax.UserInfoAction", "GetUserInfo", {}, "form_UserInfo");
});
function AjaxUpdateUserInfo() {
var ID = $("#keyID").val();
Qin_AjaxUpdate("MoonAjax.UserInfoAction", "AjaxUpdateUserInfo", "form_UserInfo", "ID", ID, { otherData: 22 }, function (data) {
alert("主键为"+data+" update success");
});
};
</script>
</head>
<body>
<form id="form_UserInfo" >
<input id="keyID" class="Key" field="ID" type="hidden" />
<table style="width: 100%;">
<tr>
<td>
姓名:
</td>
<td>
<input field="UserName" type="text" />
</td>
</tr>
<tr>
<td>
性别
</td>
<td>
<input name="Sex" field="Sex" value="true" type="radio" />男<input name="Sex" field="Sex"
value="false" type="radio" />女
</td>
</tr>
<tr>
<td>
年龄
</td>
<td>
<input field="Age" type="text" />
</td>
</tr>
<tr>
<td>
北京户口
</td>
<td>
<input field="IsBeiJing" type="checkbox" />
</td>
</tr>
<tr>
<td>
年龄段
</td>
<td>
<select field="AgePeriod"><option value="1">老年人</option><option value="2">中年人</option><option value="3">年轻人</option></select>
</td>
</tr>
</table>
<input type="button" onclick="AjaxUpdateUserInfo();" value="更新用户数据" />
</form>
</body>
</html>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>model加载和数据更新</title>
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
<meta http-equiv="CACHE-CONTROL" content="NO-CACHE" />
<meta http-equiv="PRAGMA" content="NO-CACHE" />
<script type="text/javascript" src="Scripts/jquery-1.6.2.min.js"></script>
<script type="text/javascript" src="Scripts/Qin.Tool.js"></script>
<script src="Thrid/art/artDialog.js?skin=aero" type="text/javascript"></script>
<script>
$(function () {
Qin_LoadDataToDom("MoonAjax.UserInfoAction", "GetUserInfo", {}, "form_UserInfo");
});
function AjaxUpdateUserInfo() {
var ID = $("#keyID").val();
Qin_AjaxUpdate("MoonAjax.UserInfoAction", "AjaxUpdateUserInfo", "form_UserInfo", "ID", ID, { otherData: 22 }, function (data) {
alert("主键为"+data+" update success");
});
};
</script>
</head>
<body>
<form id="form_UserInfo" >
<input id="keyID" class="Key" field="ID" type="hidden" />
<table style="width: 100%;">
<tr>
<td>
姓名:
</td>
<td>
<input field="UserName" type="text" />
</td>
</tr>
<tr>
<td>
性别
</td>
<td>
<input name="Sex" field="Sex" value="true" type="radio" />男<input name="Sex" field="Sex"
value="false" type="radio" />女
</td>
</tr>
<tr>
<td>
年龄
</td>
<td>
<input field="Age" type="text" />
</td>
</tr>
<tr>
<td>
北京户口
</td>
<td>
<input field="IsBeiJing" type="checkbox" />
</td>
</tr>
<tr>
<td>
年龄段
</td>
<td>
<select field="AgePeriod"><option value="1">老年人</option><option value="2">中年人</option><option value="3">年轻人</option></select>
</td>
</tr>
</table>
<input type="button" onclick="AjaxUpdateUserInfo();" value="更新用户数据" />
</form>
</body>
</html>
后端代码(绝大部分逻辑代码由引擎自动生成).
/*
* 由SharpDevelop创建。
* 用户: qinshichuan
* 日期: 2011-12-9
* 时间: 11:03
*
* 要改变这种模板请点击 工具|选项|代码编写|编辑标准头文件
*/
using System;
using Qin.Web;
using Qin.Data;
using MoonModel;
namespace MoonAjax
{
/// <summary>
/// Description of UserInfo.
/// </summary>
public class UserInfoAction:QinAction
{
public static void GetStringData()
{
ReturnTextString("秦时明月Ajax框架欢迎你");
}
public static void GetJSONData()
{
var userName = Request["userName"];
var password = Request["password"];
var data = new { Age=12,Address="重庆"};
ReturnJSONString(data);
}
public static void InsertFormData()
{
}
public static void AjaxInsertUserInfo()
{
DBTool db = new DBTool(Table.PersonSet);
var UserName = Request["UserName"];
var Sex = Request["Sex"];
var Age = Request["Age"];
var IsBeiJing = Request["IsBeiJing"];
var AgePeriod = Request["AgePeriod"];
var otherData = Request["otherData"];
db.SetInsertField(PersonSet.UserName_, UserName);
db.SetInsertField(PersonSet.Sex_, Sex);
db.SetInsertField(PersonSet.Age_, Age);
db.SetInsertField(PersonSet.IsBeiJing_, IsBeiJing);
db.SetInsertField(PersonSet.AgePeriod_, AgePeriod);
//db.SetInsertField(PersonSet.otherData_, otherData);
db.SaveChanges();
ReturnTextString(db.NewID);
}
[Log()]
public static void AjaxUpdateUserInfo()
{
DBTool db = new DBTool(Table.PersonSet);
db.Where = PersonSet.ID_.Equals_(Request["PrimaryKey"]);
var ID = Request["ID"];
var UserName = Request["UserName"];
var Sex = Request["Sex"];
var Age = Request["Age"];
var IsBeiJing = Request["IsBeiJing"];
var AgePeriod = Request["AgePeriod"];
var otherData = Request["otherData"];
var PrimaryKey = Request["PrimaryKey"];
db.SetUpdateField(PersonSet.UserName_, UserName);
db.SetUpdateField(PersonSet.Sex_, Sex);
db.SetUpdateField(PersonSet.Age_, Age);
db.SetUpdateField(PersonSet.IsBeiJing_, IsBeiJing);
db.SetUpdateField(PersonSet.AgePeriod_, AgePeriod);
db.SaveChanges();
ReturnTextString(PrimaryKey);
}
[Log()]
public static void GetUserInfo(){
DBTool db = new DBTool(PersonSet.TableName_Qin);
db.Where = PersonSet.ID_.Equals_(1);
var user = db.GetEntity<PersonSet>();
ReturnJSONString(user);
}
}
}
* 由SharpDevelop创建。
* 用户: qinshichuan
* 日期: 2011-12-9
* 时间: 11:03
*
* 要改变这种模板请点击 工具|选项|代码编写|编辑标准头文件
*/
using System;
using Qin.Web;
using Qin.Data;
using MoonModel;
namespace MoonAjax
{
/// <summary>
/// Description of UserInfo.
/// </summary>
public class UserInfoAction:QinAction
{
public static void GetStringData()
{
ReturnTextString("秦时明月Ajax框架欢迎你");
}
public static void GetJSONData()
{
var userName = Request["userName"];
var password = Request["password"];
var data = new { Age=12,Address="重庆"};
ReturnJSONString(data);
}
public static void InsertFormData()
{
}
public static void AjaxInsertUserInfo()
{
DBTool db = new DBTool(Table.PersonSet);
var UserName = Request["UserName"];
var Sex = Request["Sex"];
var Age = Request["Age"];
var IsBeiJing = Request["IsBeiJing"];
var AgePeriod = Request["AgePeriod"];
var otherData = Request["otherData"];
db.SetInsertField(PersonSet.UserName_, UserName);
db.SetInsertField(PersonSet.Sex_, Sex);
db.SetInsertField(PersonSet.Age_, Age);
db.SetInsertField(PersonSet.IsBeiJing_, IsBeiJing);
db.SetInsertField(PersonSet.AgePeriod_, AgePeriod);
//db.SetInsertField(PersonSet.otherData_, otherData);
db.SaveChanges();
ReturnTextString(db.NewID);
}
[Log()]
public static void AjaxUpdateUserInfo()
{
DBTool db = new DBTool(Table.PersonSet);
db.Where = PersonSet.ID_.Equals_(Request["PrimaryKey"]);
var ID = Request["ID"];
var UserName = Request["UserName"];
var Sex = Request["Sex"];
var Age = Request["Age"];
var IsBeiJing = Request["IsBeiJing"];
var AgePeriod = Request["AgePeriod"];
var otherData = Request["otherData"];
var PrimaryKey = Request["PrimaryKey"];
db.SetUpdateField(PersonSet.UserName_, UserName);
db.SetUpdateField(PersonSet.Sex_, Sex);
db.SetUpdateField(PersonSet.Age_, Age);
db.SetUpdateField(PersonSet.IsBeiJing_, IsBeiJing);
db.SetUpdateField(PersonSet.AgePeriod_, AgePeriod);
db.SaveChanges();
ReturnTextString(PrimaryKey);
}
[Log()]
public static void GetUserInfo(){
DBTool db = new DBTool(PersonSet.TableName_Qin);
db.Where = PersonSet.ID_.Equals_(1);
var user = db.GetEntity<PersonSet>();
ReturnJSONString(user);
}
}
}
脚本引擎代码生成
1 /*
2 * 创建者:秦仕川
3 * Date: 2010-7-30
4 * Time: 11:41
5 * 解决问题:建一个对象转换为json格式.比较json.net优势在于直接继承接口就可以实现json格式的转化.详情请看下面源代码 .qq 564064202
6 */
7 using System;
8 using System.Collections.Generic;
9 using System.Reflection;
10 using System.Text;
11
12 namespace QSMY.JSON
13 {
14 /// <summary>
15 /// 实现Json的基类
16 /// </summary>
17 public abstract class IJson
18 {
19 public string ToJson()
20 {
21 StringBuilder result=new StringBuilder();
22 result.Append("{");
23 Type ownType=this.GetType();
24 PropertyInfo[] properties = ownType.GetProperties();
25 for (int i=0;i<properties.Length ;i++ )
26 {
27 PropertyInfo info=properties[i];
28 #region 一般的成员属性
29 if (info.PropertyType.ToString().Contains("[")==false)
30 {
31 if(i!=properties.Length-1)
32 {
33 result.Append("\"");
34 result.Append(info.Name);
35 result.Append("\":");
36
37 result.Append("\"");
38 result.Append(info.GetValue(this,null).ToString());
39 result.Append("\",");
40 }
41 else
42 {
43 result.Append("\"");
44 result.Append(info.Name);
45 result.Append("\":");
46
47 result.Append("\"");
48 result.Append(info.GetValue(this,null).ToString());
49 result.Append("\"");
50 }
51 }
52 #endregion
53
54 #region 数组形式的成员属性
55 else{
56 result.Append("\"");
57 result.Append(info.Name);
58 result.Append("\":[");
59
60 if(i!=properties.Length-1)
61 {
62 Type t=info.PropertyType;
63 bool isGeneric=info.PropertyType.IsGenericType;
64 if (isGeneric==true && info.PropertyType.ToString().Contains("List")==true)
65 {
66 List<object> myList=(List<object>)info.GetValue(this,null);
67 for (int y=0;y<myList.Count ;y++ )
68 {
69 if(y!=myList.Count-1){
70 result.Append("\"");
71 result.Append(myList[y].ToString());
72 result.Append("\",");
73 }
74 else{
75 result.Append("\"");
76 result.Append(myList[y].ToString());
77 result.Append("\",");
78 }
79 }
80 }
81
82 else if(info.PropertyType.ToString()=="System.Object[]")
83 {
84 object[] objs=(System.Object[])info.GetValue(this,null);
85 for(int j=0;j<objs.Length;j++)
86 {
87 if (j!=objs.Length-1)
88 {
89 result.Append("\"");
90 result.Append(objs[j].ToString());
91 result.Append("\",");
92 }
93 else
94 {
95 result.Append("\"");
96 result.Append(objs[j].ToString());
97 result.Append("\"");
98 }
99 }
100
101 }
102 result.Append("],");
103 }
104 else//zui hou yige shuxing
105 {
106 Type t=info.PropertyType;
107 bool isGeneric=info.PropertyType.IsGenericType;
108 if (isGeneric==true && info.PropertyType.ToString().Contains("List")==true)
109 {
110 List<object> myList=(List<object>)info.GetValue(this,null);
111 for (int y=0;y<myList.Count ;y++ ) {
112 if(y!=myList.Count-1){
113 result.Append("\"");
114 result.Append(myList[y].ToString());
115 result.Append("\",");
116 }
117 else{
118 result.Append("\"");
119 result.Append(myList[y].ToString());
120 result.Append("\"");
121 }
122 }
123 }
124
125 else if( info.PropertyType.ToString()=="System.Object[]")
126 {
127 object[] objs=(System.Object[])info.GetValue(this,null);
128 for(int j=0;j<objs.Length;j++)
129 {
130 if (j!=objs.Length-1)
131 {
132 result.Append("\"");
133 result.Append(objs[j].ToString());
134 result.Append("\",");
135 }
136 else
137 {
138 result.Append("\"");
139 result.Append(objs[j].ToString());
140 result.Append("\"");
141 }
142 }
143
144 }
145 result.Append("]");
146 }
147 #endregion
148 }
149 }
150
151 result.Append("}");
152 return result.ToString();
153
154 }
155 }
156 }
2 * 创建者:秦仕川
3 * Date: 2010-7-30
4 * Time: 11:41
5 * 解决问题:建一个对象转换为json格式.比较json.net优势在于直接继承接口就可以实现json格式的转化.详情请看下面源代码 .qq 564064202
6 */
7 using System;
8 using System.Collections.Generic;
9 using System.Reflection;
10 using System.Text;
11
12 namespace QSMY.JSON
13 {
14 /// <summary>
15 /// 实现Json的基类
16 /// </summary>
17 public abstract class IJson
18 {
19 public string ToJson()
20 {
21 StringBuilder result=new StringBuilder();
22 result.Append("{");
23 Type ownType=this.GetType();
24 PropertyInfo[] properties = ownType.GetProperties();
25 for (int i=0;i<properties.Length ;i++ )
26 {
27 PropertyInfo info=properties[i];
28 #region 一般的成员属性
29 if (info.PropertyType.ToString().Contains("[")==false)
30 {
31 if(i!=properties.Length-1)
32 {
33 result.Append("\"");
34 result.Append(info.Name);
35 result.Append("\":");
36
37 result.Append("\"");
38 result.Append(info.GetValue(this,null).ToString());
39 result.Append("\",");
40 }
41 else
42 {
43 result.Append("\"");
44 result.Append(info.Name);
45 result.Append("\":");
46
47 result.Append("\"");
48 result.Append(info.GetValue(this,null).ToString());
49 result.Append("\"");
50 }
51 }
52 #endregion
53
54 #region 数组形式的成员属性
55 else{
56 result.Append("\"");
57 result.Append(info.Name);
58 result.Append("\":[");
59
60 if(i!=properties.Length-1)
61 {
62 Type t=info.PropertyType;
63 bool isGeneric=info.PropertyType.IsGenericType;
64 if (isGeneric==true && info.PropertyType.ToString().Contains("List")==true)
65 {
66 List<object> myList=(List<object>)info.GetValue(this,null);
67 for (int y=0;y<myList.Count ;y++ )
68 {
69 if(y!=myList.Count-1){
70 result.Append("\"");
71 result.Append(myList[y].ToString());
72 result.Append("\",");
73 }
74 else{
75 result.Append("\"");
76 result.Append(myList[y].ToString());
77 result.Append("\",");
78 }
79 }
80 }
81
82 else if(info.PropertyType.ToString()=="System.Object[]")
83 {
84 object[] objs=(System.Object[])info.GetValue(this,null);
85 for(int j=0;j<objs.Length;j++)
86 {
87 if (j!=objs.Length-1)
88 {
89 result.Append("\"");
90 result.Append(objs[j].ToString());
91 result.Append("\",");
92 }
93 else
94 {
95 result.Append("\"");
96 result.Append(objs[j].ToString());
97 result.Append("\"");
98 }
99 }
100
101 }
102 result.Append("],");
103 }
104 else//zui hou yige shuxing
105 {
106 Type t=info.PropertyType;
107 bool isGeneric=info.PropertyType.IsGenericType;
108 if (isGeneric==true && info.PropertyType.ToString().Contains("List")==true)
109 {
110 List<object> myList=(List<object>)info.GetValue(this,null);
111 for (int y=0;y<myList.Count ;y++ ) {
112 if(y!=myList.Count-1){
113 result.Append("\"");
114 result.Append(myList[y].ToString());
115 result.Append("\",");
116 }
117 else{
118 result.Append("\"");
119 result.Append(myList[y].ToString());
120 result.Append("\"");
121 }
122 }
123 }
124
125 else if( info.PropertyType.ToString()=="System.Object[]")
126 {
127 object[] objs=(System.Object[])info.GetValue(this,null);
128 for(int j=0;j<objs.Length;j++)
129 {
130 if (j!=objs.Length-1)
131 {
132 result.Append("\"");
133 result.Append(objs[j].ToString());
134 result.Append("\",");
135 }
136 else
137 {
138 result.Append("\"");
139 result.Append(objs[j].ToString());
140 result.Append("\"");
141 }
142 }
143
144 }
145 result.Append("]");
146 }
147 #endregion
148 }
149 }
150
151 result.Append("}");
152 return result.ToString();
153
154 }
155 }
156 }
//下面是示例代码
1 /*
2 * 创建者:秦仕川
3 * Date: 2010-7-30
4 * Time: 12:30
5 *
6 */
7 using System;
8 using System.Collections.Generic;
9 using QSMY.JSON;
10
11 namespace test
12 {
13 class Person:IJson{//此处实现接口即可
14 public String Name{
15 get;
16 set;
17 }
18 public Object[] Names{
19 get{
20 return new string[] { "Small", "Medium", "Large" };
21 }
22
23 }
24 public List<object> abc{
25 get{
26 List<object> abc=new List<object>();
27 abc.Add("ddsd");
28 abc.Add("ddd");
29 return abc;
30 }
31 }
32 }
33 class Program
34 {
35 public static void Main(string[] args)
36 {
37 Person P=new Person();
38 P.Name="秦仕川";
39 string s= P.ToJson();
40 Console.WriteLine(s);
41 Console.Write("Press any key to continue . . . ");
42 Console.ReadKey(true);
43 }
44 }
45 }
2 * 创建者:秦仕川
3 * Date: 2010-7-30
4 * Time: 12:30
5 *
6 */
7 using System;
8 using System.Collections.Generic;
9 using QSMY.JSON;
10
11 namespace test
12 {
13 class Person:IJson{//此处实现接口即可
14 public String Name{
15 get;
16 set;
17 }
18 public Object[] Names{
19 get{
20 return new string[] { "Small", "Medium", "Large" };
21 }
22
23 }
24 public List<object> abc{
25 get{
26 List<object> abc=new List<object>();
27 abc.Add("ddsd");
28 abc.Add("ddd");
29 return abc;
30 }
31 }
32 }
33 class Program
34 {
35 public static void Main(string[] args)
36 {
37 Person P=new Person();
38 P.Name="秦仕川";
39 string s= P.ToJson();
40 Console.WriteLine(s);
41 Console.Write("Press any key to continue . . . ");
42 Console.ReadKey(true);
43 }
44 }
45 }
//运行效果
//注释:由于时间有限给出主要思路,想要升华,各位可自己来.欢迎指教,(不要抨击就是)