Skip to content

Commit 8830930

Browse files
committed
update contracttools
1 parent e58c4fb commit 8830930

24 files changed

+864
-285
lines changed

Source/Tools/ContractTools/db/mssql/创建表脚本.sql

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/*
1+
/*
22
参数:
33
$dbpath 数据库存储路径
44
*/
@@ -134,4 +134,11 @@ go
134134

135135
alter table [Contract] add [VerId] int not null default(0);
136136
alter table [ParamInfo] add [VerId] int not null default(0);
137-
go
137+
go
138+
139+
140+
alter table [Solutions] add [SerUseScript] varchar(20);
141+
alter table [Solutions] add [CliUseScript] varchar(20);
142+
alter table [Solutions] add [IsDParam] bit not null default(1);
143+
alter table [Solutions] add [RespContentType] int not null default(0);
144+
go

Source/Tools/ContractTools/db/mysql/importdb.sql

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3290,3 +3290,9 @@ INSERT INTO `solutions` VALUES ('5', '口袋天界', 'ZyGames.Tianjiexing.BLL.Ac
32903290
INSERT INTO `solutions` VALUES ('6', '斗地主', 'ZyGames.HallCenter.Action', '', '127.0.0.1:9500', '7');
32913291
INSERT INTO `solutions` VALUES ('7', '分服中心', 'ZyGames.DirCenter.Action', '', 'http://dir.36you.net/Service.aspx', '6');
32923292
INSERT INTO `solutions` VALUES ('8', 'Scut Demo', 'Scut.Demo.Script.CsScript.Action', 'using ZyGames.Framework.Game.Contract;', '', '1');
3293+
3294+
3295+
alter table `Solutions` add `SerUseScript` varchar(20);
3296+
alter table `Solutions` add `CliUseScript` varchar(20);
3297+
alter table `Solutions` add `IsDParam` bit not null default 1;
3298+
alter table `Solutions` add `RespContentType` int not null default 0;

Source/Tools/ContractTools/src/ContractTools.WebApp/Base/BasePage.cs

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,35 @@ public byte[] ReadBytes(bool isBom)
3636

3737
public class BasePage : System.Web.UI.Page
3838
{
39+
public static KeyValuePair<int, string>[][] FieldTypeMaps = new[]
40+
{
41+
new []{
42+
new KeyValuePair<int, string>(-1,"Password"),
43+
new KeyValuePair<int, string>(1,"Int"),
44+
new KeyValuePair<int, string>(2,"String"),
45+
new KeyValuePair<int, string>(3,"Short"),
46+
new KeyValuePair<int, string>(4,"Byte"),
47+
new KeyValuePair<int, string>(8,"Long"),
48+
new KeyValuePair<int, string>(9,"Bool")
49+
},
50+
new []{
51+
new KeyValuePair<int, string>(1,"Int"),
52+
new KeyValuePair<int, string>(2,"String"),
53+
new KeyValuePair<int, string>(3,"Short"),
54+
new KeyValuePair<int, string>(4,"Byte"),
55+
new KeyValuePair<int, string>(5,"Record"),
56+
new KeyValuePair<int, string>(6,"End"),
57+
new KeyValuePair<int, string>(7,"Void"),
58+
new KeyValuePair<int, string>(8,"Long"),
59+
new KeyValuePair<int, string>(9,"Bool"),
60+
new KeyValuePair<int, string>(10,"Float"),
61+
new KeyValuePair<int, string>(11,"Double"),
62+
new KeyValuePair<int, string>(12,"Date"),
63+
new KeyValuePair<int, string>(13,"UInt"),
64+
new KeyValuePair<int, string>(14,"UShort"),
65+
new KeyValuePair<int, string>(15,"ULong")
66+
}
67+
};
3968
protected void Alert(string msg, string url)
4069
{
4170
Response.Write(string.Format("<script language=javascript>alert('{0}');location.href ='{1}';</script>", msg, url));

Source/Tools/ContractTools/src/ContractTools.WebApp/Base/DbDataLoader.cs

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,10 @@ public static int Add(SolutionModel model)
5858
command.AddParameter("RefNamespace", model.RefNamespace);
5959
command.AddParameter("Url", model.Url);
6060
command.AddParameter("GameID", model.GameID);
61+
command.AddParameter("SerUseScript", model.SerUseScript);
62+
command.AddParameter("CliUseScript", model.CliUseScript);
63+
command.AddParameter("IsDParam", model.IsDParam);
64+
command.AddParameter("RespContentType", model.RespContentType);
6165
command.ReturnIdentity = true;
6266
command.Parser();
6367
return _dbBaseProvider.ExecuteQuery(CommandType.Text, command.Sql, command.Parameters);
@@ -71,6 +75,10 @@ public static bool Update(SolutionModel model)
7175
command.AddParameter("RefNamespace", model.RefNamespace);
7276
command.AddParameter("Url", model.Url);
7377
command.AddParameter("GameID", model.GameID);
78+
command.AddParameter("SerUseScript", model.SerUseScript);
79+
command.AddParameter("CliUseScript", model.CliUseScript);
80+
command.AddParameter("IsDParam", model.IsDParam);
81+
command.AddParameter("RespContentType", model.RespContentType);
7482
command.Filter = _dbBaseProvider.CreateCommandFilter();
7583
command.Filter.Condition = _dbBaseProvider.FormatFilterParam("SlnID");
7684
command.Filter.AddParam("SlnID", model.SlnID);
@@ -110,7 +118,7 @@ public static SolutionModel GetSolution(int slnId)
110118
public static List<SolutionModel> GetSolution(Action<CommandFilter> match)
111119
{
112120
var command = _dbBaseProvider.CreateCommandStruct("Solutions", CommandMode.Inquiry);
113-
command.Columns = "SlnID,SlnName,Namespace,RefNamespace,Url,GameID";
121+
command.Columns = "SlnID,SlnName,Namespace,RefNamespace,Url,GameID,SerUseScript,CliUseScript,IsDParam,RespContentType";
114122
command.OrderBy = "SlnID ASC";
115123
command.Filter = _dbBaseProvider.CreateCommandFilter();
116124
if (match != null)
@@ -130,6 +138,10 @@ public static List<SolutionModel> GetSolution(Action<CommandFilter> match)
130138
model.Namespace = reader["Namespace"].ToNotNullString();
131139
model.RefNamespace = reader["RefNamespace"].ToNotNullString();
132140
model.Url = reader["Url"].ToNotNullString();
141+
model.SerUseScript = reader["SerUseScript"].ToNotNullString();
142+
model.CliUseScript = reader["CliUseScript"].ToNotNullString();
143+
model.IsDParam = reader["IsDParam"].ToBool();
144+
model.RespContentType = reader["RespContentType"].ToInt();
133145
list.Add(model);
134146
}
135147
}
@@ -542,7 +554,7 @@ public static List<ParamInfoModel> GetParamInfo(int slnId, int contractId, int p
542554

543555
public static List<ParamInfoModel> GetParamInfo(int slnId, int contractId, int versionId)
544556
{
545-
return GetParamInfo(f =>
557+
var result = GetParamInfo(f =>
546558
{
547559
if (versionId > 0)
548560
{
@@ -555,6 +567,8 @@ public static List<ParamInfoModel> GetParamInfo(int slnId, int contractId, int v
555567
f.AddParam("ContractID", contractId);
556568
f.AddParam("SlnID", slnId);
557569
});
570+
571+
return TemplateHelper.InitParamDepth(result);
558572
}
559573

560574
public static List<ParamInfoModel> GetParamInfo(Action<CommandFilter> match)

Source/Tools/ContractTools/src/ContractTools.WebApp/Base/NetHelper.cs

Lines changed: 18 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -43,23 +43,23 @@ namespace ContractTools.WebApp.Base
4343
{
4444
public static class NetHelper
4545
{
46-
public static int LoginActionId = ConfigUtils.GetSetting("UnitTest.LoginActionId", 1004);
46+
public static String LoginActionId = ConfigUtils.GetSetting("UnitTest.LoginActionId", "1001,1003,1004");
4747
private static string SignKey = ConfigUtils.GetSetting("Product.SignKey");
4848
public static string ClientDesDeKey = ConfigUtils.GetSetting("Product.ClientDesDeKey", "j6=9=1ac");
4949
private static bool IsGet = true;
5050

51-
public static MessageStructure Create(string serverUrl, string requestParams, out MessageHead header, bool isSocket, int actionId, string pid, CookieContainer cookies)
51+
public static Stream Create(string serverUrl, string requestParams, bool isSocket, int actionId, string pid, bool includeParam, CookieContainer cookies)
5252
{
53-
header = null;
5453
MessageStructure msgReader = null;
5554
if (isSocket)
5655
{
57-
msgReader = DoRequest(serverUrl, requestParams, actionId, pid);
56+
return DoRequest(serverUrl, requestParams, actionId, pid, includeParam);
5857
}
5958
else
6059
{
6160
Encoding encode = Encoding.GetEncoding("utf-8");
62-
string postData = "d=" + GetSign(requestParams);
61+
string postData = GetSign(requestParams, includeParam);
62+
if (includeParam) postData = "d=" + postData;
6363
HttpWebRequest serverRequest;
6464
if (IsGet)
6565
{
@@ -81,14 +81,9 @@ public static MessageStructure Create(string serverUrl, string requestParams, ou
8181
//
8282
HttpWebResponse serverResponse = (HttpWebResponse)serverRequest.GetResponse();
8383
cookies.Add(serverResponse.Cookies);
84-
Stream responseStream = serverResponse.GetResponseStream();
85-
msgReader = MessageStructure.Create(responseStream, Encoding.UTF8);
84+
return serverResponse.GetResponseStream();
8685
}
87-
if (msgReader != null)
88-
{
89-
header = msgReader.ReadHeadGzip();
90-
}
91-
return msgReader;
86+
9287
}
9388

9489
public static bool GetFieldValue(MessageStructure ms, FieldType fieldType, ref string val)
@@ -158,30 +153,32 @@ public static bool GetFieldValue(MessageStructure ms, FieldType fieldType, ref s
158153
return result;
159154
}
160155

161-
public static string GetSign(string requestParams)
156+
public static string GetSign(string requestParams, bool includeParam)
162157
{
163158
string sign = "";
164159
if (!string.IsNullOrEmpty(SignKey))
165160
{
166161
sign = FormsAuthentication.HashPasswordForStoringInConfigFile(requestParams + SignKey, "MD5").ToLower();
167162
}
168-
return Uri.EscapeDataString(string.Format("{0}&sign={1}", requestParams, sign));
163+
if (includeParam)
164+
return Uri.EscapeDataString(string.Format("{0}&sign={1}", requestParams, sign));
165+
return string.Format("{0}&sign={1}", requestParams, sign);
169166
}
170167

171-
private static MessageStructure DoRequest(string server, string param, int actionId, string pid)
168+
private static Stream DoRequest(string server, string param, int actionId, string pid, bool includeParam)
172169
{
173170
string[] serverArray = server.Split(':');
174-
return DoRequest(serverArray[0], Convert.ToInt32(serverArray[1]), GetSign(param), actionId, pid);
171+
return DoRequest(serverArray[0], Convert.ToInt32(serverArray[1]), GetSign(param, includeParam), actionId, pid);
175172
}
176173

177-
private static MessageStructure DoRequest(string host, int port, string param, int actionId, string pid)
174+
private static Stream DoRequest(string host, int port, string param, int actionId, string pid)
178175
{
179176
var remoteEndPoint = new IPEndPoint(Dns.GetHostAddresses(host)[0], port);
180177
return DoRequest(remoteEndPoint, param, 1024, actionId, pid);
181178
}
182179

183180
private static ConcurrentDictionary<string, MyConnect> _clientSockets = new ConcurrentDictionary<string, MyConnect>();
184-
private static MessageStructure DoRequest(IPEndPoint remoteEndPoint, string param, int bufferSize, int actionId, string pid)
181+
private static Stream DoRequest(IPEndPoint remoteEndPoint, string param, int bufferSize, int actionId, string pid)
185182
{
186183
byte[] data = Encoding.UTF8.GetBytes("?d=" + param);
187184
MyConnect myConnect = null;
@@ -227,7 +224,7 @@ internal class MyConnect
227224
private int _actionId;
228225
private ConcurrentQueue<MyPack> actionPools = new ConcurrentQueue<MyPack>();
229226
private ConcurrentQueue<MyPack> pushPools = new ConcurrentQueue<MyPack>();
230-
private MessageStructure ms;
227+
private Stream ms;
231228
private Timer checkTimer;
232229
private int _isRunning = 0;
233230

@@ -260,7 +257,7 @@ private static void OnCheckPack(object state)
260257
{
261258
if (pack.Head.Action == myConnect._actionId)
262259
{
263-
myConnect.ms = new MessageStructure(pack.Data);
260+
myConnect.ms = new MemoryStream(pack.Data);
264261
myConnect.singal.Set();
265262
}
266263
else
@@ -298,7 +295,7 @@ private static void OnReceive(object sender, SocketEventArgs e)
298295
}
299296

300297

301-
public MessageStructure GetResult()
298+
public Stream GetResult()
302299
{
303300
singal.WaitOne(10000);
304301
return ms;

0 commit comments

Comments
 (0)