Skip to content

Commit 5503d49

Browse files
YanZhYanZh
authored andcommitted
coding
1 parent 8209a86 commit 5503d49

13 files changed

+5889
-6076
lines changed

YanZhiwei.JavaScript.Utilities/BackHandler/BaseHandler.ashx.cs

Lines changed: 91 additions & 78 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,13 @@
33
using System.Linq;
44
using System.Net;
55
using System.Web;
6+
using YanZhiwei.DotNet2.Utilities.Collection;
7+
using YanZhiwei.DotNet2.Utilities.Common;
8+
using YanZhiwei.DotNet2.Utilities.DataOperator;
9+
using YanZhiwei.DotNet2.Utilities.Enum;
10+
using YanZhiwei.DotNet3._5.Utilities.Common;
611
using YanZhiwei.DotNet3._5.Utilities.Model;
7-
using YanZhiwei.DotNet3._5.Utilities.WebForm.Jquery;
12+
using YanZhiwei.DotNet3._5.Utilities.WebForm.JqueryPlugin;
813
using YanZhiwei.JavaScript.Utilities.Model;
914

1015
namespace YanZhiwei.JavaScript.Utilities.BackHandler
@@ -16,7 +21,7 @@ public class BaseHandler : IHttpHandler
1621
{
1722
public static IEnumerable<Person> GetPersons()
1823
{
19-
for (int i = 0; i < 57; i++)
24+
for(int i = 0; i < 57; i++)
2025
{
2126
yield return new Person
2227
{
@@ -25,87 +30,97 @@ public static IEnumerable<Person> GetPersons()
2530
};
2631
}
2732
}
28-
33+
2934
public void ProcessRequest(HttpContext context)
3035
{
31-
context.ExecutePageQuery<Person>((pageLength, pageIndex, orderIndex, orderBy) =>
36+
string _actionType = context.Request.Params["action"].ToStringOrDefault("UnKown");
37+
38+
if(_actionType.CompareIgnoreCase("getLocationList"))
39+
{
40+
SqlServerDataOperator _helper = new SqlServerDataOperator(@"Server=YANZHIWEI-PC\SQLEXPRESS;database=JooWMS;user id=sa;Password=sasa");
41+
PagedList<Location> _pageResult = _helper.ExecutePageQuery<Location>("[Location]", "*", "ID", OrderType.Desc, string.Empty, 10, 1);
42+
string _json = SerializeHelper.JsonSerialize(_pageResult).ParseJsonDateTime();
43+
context.Response.Write(_json);
44+
}
45+
else
3246
{
33-
var persons = GetPersons();
34-
Func<Person, object> order = p =>
47+
context.ExecutePageQuery<Person>((pageLength, pageIndex, orderIndex, orderBy) =>
3548
{
36-
if (orderIndex == 0)
49+
var persons = GetPersons();
50+
Func<Person, object> order = p =>
3751
{
38-
return p.Id;
52+
if(orderIndex == 0)
53+
{
54+
return p.Id;
55+
}
56+
57+
return p.Name;
58+
};
59+
60+
if("desc" == orderBy)
61+
{
62+
persons = persons.OrderByDescending(order);
3963
}
40-
return p.Name;
41-
};
42-
if ("desc" == orderBy)
43-
{
44-
persons = persons.OrderByDescending(order);
45-
}
46-
else
47-
{
48-
persons = persons.OrderBy(order);
49-
}
50-
//错误测试
51-
//DataTablePageResult result = new DataTablePageResult();
52-
//result.ExecuteMessage = "测试错误";
53-
//result.ExecuteState = HttpStatusCode.BadGateway;
54-
//正确测试
55-
DataTablePageResult result = new DataTablePageResult();
56-
result.iTotalDisplayRecords = persons.Count();
57-
List<Person> _personList = new List<Person>();
58-
result.iTotalRecords = persons.Count();
59-
result.aaData = persons.Skip(pageIndex).Take(pageLength);
60-
result.ExecuteState = HttpStatusCode.OK;
61-
return result;
62-
});
63-
// // Those parameters are sent by the plugin
64-
// var iDisplayLength = int.Parse(context.Request["iDisplayLength"]);
65-
// var iDisplayStart = int.Parse(context.Request["iDisplayStart"]);
66-
// var iSortCol = int.Parse(context.Request["iSortCol_0"]);
67-
// var iSortDir = context.Request["sSortDir_0"];
68-
69-
// // Fetch the data from a repository (in my case in-memory)
70-
// var persons = GetPersons();
71-
72-
// // Define an order function based on the iSortCol parameter
73-
// Func<Person, object> order = p =>
74-
// {
75-
// if (iSortCol == 0)
76-
// {
77-
// return p.Id;
78-
// }
79-
// return p.Name;
80-
// };
81-
82-
// // Define the order direction based on the iSortDir parameter
83-
// if ("desc" == iSortDir)
84-
// {
85-
// persons = persons.OrderByDescending(order);
86-
// }
87-
// else
88-
// {
89-
// persons = persons.OrderBy(order);
90-
// }
91-
92-
// // prepare an anonymous object for JSON serialization
93-
// var result = new
94-
// {
95-
// iTotalRecords = persons.Count(),
96-
// iTotalDisplayRecords = persons.Count(),
97-
// aaData = persons
98-
// .Skip(iDisplayStart)
99-
// .Take(iDisplayLength)
100-
// };
101-
102-
// //var serializer = new JavaScriptSerializer();
103-
//// var json = SerializationHelper.JsonSerialize(result);// serializer.Serialize(result);
104-
// context.CreateResponse(result, System.Net.HttpStatusCode.OK);
105-
// //context.Response.ContentType = "application/json";
106-
// //context.Response.Write(json);
64+
else
65+
{
66+
persons = persons.OrderBy(order);
67+
}
68+
69+
//错误测试
70+
//DataTablePageResult result = new DataTablePageResult();
71+
//result.ExecuteMessage = "测试错误";
72+
//result.ExecuteState = HttpStatusCode.BadGateway;
73+
//正确测试
74+
DataTablePageResult result = new DataTablePageResult();
75+
result.iTotalDisplayRecords = persons.Count();
76+
List<Person> _personList = new List<Person>();
77+
result.iTotalRecords = persons.Count();
78+
result.aaData = persons.Skip(pageIndex).Take(pageLength);
79+
result.ExecuteState = HttpStatusCode.OK;
80+
return result;
81+
});
82+
// // Those parameters are sent by the plugin
83+
// var iDisplayLength = int.Parse(context.Request["iDisplayLength"]);
84+
// var iDisplayStart = int.Parse(context.Request["iDisplayStart"]);
85+
// var iSortCol = int.Parse(context.Request["iSortCol_0"]);
86+
// var iSortDir = context.Request["sSortDir_0"];
87+
// // Fetch the data from a repository (in my case in-memory)
88+
// var persons = GetPersons();
89+
// // Define an order function based on the iSortCol parameter
90+
// Func<Person, object> order = p =>
91+
// {
92+
// if (iSortCol == 0)
93+
// {
94+
// return p.Id;
95+
// }
96+
// return p.Name;
97+
// };
98+
// // Define the order direction based on the iSortDir parameter
99+
// if ("desc" == iSortDir)
100+
// {
101+
// persons = persons.OrderByDescending(order);
102+
// }
103+
// else
104+
// {
105+
// persons = persons.OrderBy(order);
106+
// }
107+
// // prepare an anonymous object for JSON serialization
108+
// var result = new
109+
// {
110+
// iTotalRecords = persons.Count(),
111+
// iTotalDisplayRecords = persons.Count(),
112+
// aaData = persons
113+
// .Skip(iDisplayStart)
114+
// .Take(iDisplayLength)
115+
// };
116+
// //var serializer = new JavaScriptSerializer();
117+
//// var json = SerializationHelper.JsonSerialize(result);// serializer.Serialize(result);
118+
// context.CreateResponse(result, System.Net.HttpStatusCode.OK);
119+
// //context.Response.ContentType = "application/json";
120+
// //context.Response.Write(json);
121+
}
107122
}
108-
123+
109124
public bool IsReusable
110125
{
111126
get
@@ -114,6 +129,4 @@ public bool IsReusable
114129
}
115130
}
116131
}
117-
118-
119132
}
0 Bytes
Binary file not shown.
-7 KB
Binary file not shown.

0 commit comments

Comments
 (0)