-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathashxHandler.ashx
172 lines (155 loc) · 5.93 KB
/
ashxHandler.ashx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
<%@ WebHandler Language="C#" Class="ashxHandler" %>
using System;
using System.Web;
using System.IO;
using com.xiechan.Core.CommonIO;
using com.xiechan.Core.Mongo;
using System.Collections.Generic;
using com.xiechan.Core.MsgComm;
using com.xiechan.Core.Redis;
using sdV2._1.Handler;
using sdV2._1;
using sdV2._1.entity;
public class ashxHandler : IHttpHandler {
public void ProcessRequest(HttpContext context)
{
context.Response.ContentType = "application/json";
Handler.ip = "mongoip address";
Handler.db = "mongo db name";
string action = context.Request.Params["action"];
string actionType = context.Request.Params["actionType"];
if (context.Request.HttpMethod == "GET")
{
if (action != null)
{
if (action == "list")
{
if (actionType != null )
{
string s = Handler.List(actionType);
s = s.Replace("ObjectId(\"", "\"ObjectId(\\\"").Replace("\")", "\\\")\"");
string result = "{\"data\":$$1}";
context.Response.Write(result.Replace("$$1", s));
}
}
/*
if (action == "getSetting")
{
//string s=Handler.GetSetting();
string s = "{\"a\":\"bc\"}";
context.Response.Write(s.Trim());
}
*/
}
}
else if (context.Request.HttpMethod == "POST")
{
string data = "";
if (context.Request.Params["data"] != null)
{
data = context.Server.UrlDecode(context.Request.Params["data"]);
if (action == "addItem")
{
Entity doc = null;
//1
if (actionType == "SalesOrderItem")
{
doc = Utils.DecodeJson2Object<SalesOrderItem>(data);
}
//2 3
if (actionType == "ShippingRequestItem")
{
doc = Utils.DecodeJson2Object<ShippingRequestItem>(data);
}
if (actionType == "CancelShippingRequestItem")
{
doc = Utils.DecodeJson2Object<CancelShippingRequestItem>(data);
}
//4
if (actionType == "PurchaseOrderItem")
{
doc = Utils.DecodeJson2Object<PurchaseOrderItem>(data);
}
//5 6
if (actionType == "PurchaseRequestItem")
{
doc = Utils.DecodeJson2Object<PurchaseRequestItem>(data);
}
if (actionType == "CancelPurchaseRequestItem")
{
doc = Utils.DecodeJson2Object<CancelPurchaseRequestItem>(data);
}
//7 8 9
if (actionType == "SdkRequestItem")
{
doc = Utils.DecodeJson2Object<SdkRequestItem>(data);
}
if (actionType == "CancelSdkRequestItem")
{
doc = Utils.DecodeJson2Object<CancelSdkRequestItem>(data);
}
if (actionType == "SdkReceiveItem")
{
doc = Utils.DecodeJson2Object<SdkReceiveItem>(data);
}
//10
if (actionType == "InWareHouseRequestItem")
{
doc = Utils.DecodeJson2Object<InWareHouseRequestItem>(data);
}
//11 12
if (actionType == "ExportOrderItem")
{
doc = Utils.DecodeJson2Object<ExportOrderItem>(data);
}
if (actionType == "ImportOrderItem")
{
doc = Utils.DecodeJson2Object<ImportOrderItem>(data);
}
//13 14
if (actionType == "ProductReplaceItem")
{
doc = Utils.DecodeJson2Object<ProductReplaceItem>(data);
}
if (actionType == "ProductLostItem")
{
doc = Utils.DecodeJson2Object<ProductLostItem>(data);
}
//15
if (actionType == "RedrawPurchaseOrderItem")
{
doc = Utils.DecodeJson2Object<RedrawPurchaseOrderItem>(data);
}
Msg msg = Handler.AddOrModifyItem(doc);
context.Response.Write(Utils.Encode2Json(msg));
}
if (action == "deleteItem")
{
List<string> toBeDelete = Utils.DecodeJson2Object<List<string>>(data);
Msg msg = Handler.DeleteItems(toBeDelete, actionType);
context.Response.Write(Utils.Encode2Json(msg));
}
/*
if (action == "updateSetting")
{
Msg msg = Handler.UpdateSetting(data);
context.Response.Write(Utils.Encode2Json(msg));
}
if (action == "setOfficeDepot")
{
OfficeDepot item = Utils.DecodeJson2Object<OfficeDepot>(data);
Msg msg = Handler.SetOfficeDepot(item);
context.Response.Write(Utils.Encode2Json(msg));
}
*/
}
}
}
public bool IsReusable
{
get
{
return false;
}
}
}