diff --git a/StuMgmServer/StuMgmLib/CommonData.cs b/StuMgmServer/StuMgmLib/CommonData.cs
new file mode 100644
index 0000000..a59b435
--- /dev/null
+++ b/StuMgmServer/StuMgmLib/CommonData.cs
@@ -0,0 +1,192 @@
+/* Describtion : Class for Data Send From Client / Server
+ * Company : Wuxi Xinje
+ * Author : Somuns
+ * DateTime : 2021/1/18
+ */
+using System;
+using System.Collections.Generic;
+
+namespace StuMgmLib
+{
+ public enum ClientFunc
+ {
+ // 普通用户允许的操作
+ ///
+ /// 验证登录
+ ///
+ VerifyLogin = 1,
+ ///
+ /// 获取所有课程信息
+ ///
+ GetCourseInfo,
+ ///
+ /// 获取用户信息
+ ///
+ GetUserInfo,
+ ///
+ /// 修改课程状态
+ ///
+ ChangeCourseStatus,
+
+ // 老师允许的操作
+ //100
+
+ //// 管理员允许的操作
+ //200
+
+
+
+ //GetSomeoneUserCInfo = 6,
+ //SUpdateCourse = 4,
+ //TUpdateCourse = 5,
+ }
+ public enum Lvl
+ {
+ NotFound = -1,
+ Error = -2,
+ Student = 99,
+ Teacher = 199,
+ Admin = 299,
+ }
+ public enum CourseStatus
+ {
+
+ }
+ #region 基本收发类
+ [Serializable]
+ public class Request
+ {
+ public ClientFunc Func;
+ public short JobId;
+ public string Token;
+ public Request() { }
+ public Request(ClientFunc func)
+ {
+ Func = func;
+ }
+ }
+ [Serializable]
+ public class Response
+ {
+ public bool Res;
+ public string ErrMsg;
+ public Response()
+ {
+ Res = true;
+ }
+ public Response(string errMsg)
+ {
+ Res = false;
+ ErrMsg = errMsg;
+ }
+ }
+ #endregion
+ #region 用户登录
+
+ [Serializable]
+ public class LoginReq : Request
+ {
+ public string Password;
+ public LoginReq(string password) // Changed
+ {
+ Password = password;
+ }
+ }
+ [Serializable]
+ public class LoginRes : Response
+ {
+ public string Token;
+ public Lvl Level;
+ public LoginRes(string token, Lvl level)
+ {
+ Token = token;
+ Level = level;
+ }
+ }
+ #endregion
+ #region 获取所有课程信息
+ [Serializable]
+ public class CourseInfoReq : Request
+ {
+ }
+ [Serializable]
+ public class CourseInfoRes : Response
+ {
+ ///
+ /// 课程ID
+ ///
+ public short Id;
+ public short Pid;
+ ///
+ /// 该题所需用时(单位s)
+ ///
+ public int Time;
+ public string Name;
+ public string Content;
+ public CourseInfoRes(short id, short pid, int time, string name, string content)
+ {
+ Id = id;
+ Pid = pid;
+ Time = time;
+ Name = name;
+ Content = content;
+ }
+ }
+ #endregion
+ #region 用户信息
+ [Serializable]
+ public class UserInfoReq : Request
+ {
+ public short User;
+ public UserInfoReq(short user)
+ {
+ short User = user;
+ }
+ }
+ [Serializable]
+ public class UserInfoRes : Response
+ {
+ public short JobId;//工号
+ public string Name;//姓名
+ ///
+ /// 各课程的当前状态
+ ///
+ public string Status;
+ public UserInfoRes(short jobId, string name, string status)
+ {
+ short JobId = jobId;
+ string Name = name;
+ string Status = status;
+ }
+ // ..public DateTime Entry;
+ //public string Details;//老师对于该生的描述
+ }
+ #endregion
+ #region 用户课程状态修改
+ public class CrsStasReq : Request
+ {
+ ///
+ /// 需要修改者的工号
+ ///
+ public short User;
+ ///
+ /// 需要修改的课程
+ ///
+ public short Id;
+ public CourseStatus Status;
+ public CrsStasReq(short user, short id, CourseStatus status)
+ {
+ short User = user;
+ short Id = id;
+ CourseStatus Status = status;
+ }
+ }
+ public class CrsStasRes : Response
+ {
+
+ }
+ #endregion
+}
+
+
+
diff --git a/StuMgmServer/StuMgmLib/MyNameSpace/CommonData.cs b/StuMgmServer/StuMgmLib/MyNameSpace/CommonData.cs
deleted file mode 100644
index b151974..0000000
--- a/StuMgmServer/StuMgmLib/MyNameSpace/CommonData.cs
+++ /dev/null
@@ -1,140 +0,0 @@
-/* Describtion : Class for Data Send From Client / Server
- * Company : Wuxi Xinje
- * Author : Somuns
- * DateTime : 2021/1/18
- */
-using System;
-using System.Collections.Generic;
-
-namespace StuMgmLib.MyNameSpace
-{
- #region QuickTable
-
- internal class QTInfo
- {
- public int Token;
- public Lvl Level;
- public QTInfo(int token, Lvl lv)
- {
- Token = token;
- Level = lv;
- }
- }
- public class QT // quickTable
- {
- internal const Int16 tokenMaxCount = 32767;
- internal static Dictionary quickTable = new Dictionary();
- }
-
- #endregion
-
- #region ClientClass
-
- public enum ClientFunc
- {
- VerifyLogin = 1,
- GetCourseInfo = 2,
- GetSelfUserCourseInfo = 3,
- GetSomeoneUserCInfo = 6,
- SUpdateCourse = 4,
- TUpdateCourse = 5,
-
- }
- public enum Lvl
- {
- NotFound = -1,
- Error = -2,
- Admin = 1,
- Teacher = 2,
- Student = 3,
- }
- [Serializable]
- public class ClientRequest
- {
- public ClientFunc Func;
- public object Object;
- public ClientRequest(ClientFunc func, object obj)
- {
- Func = func;
- Object = obj;
- }
- }
-
- [Serializable]
- public class UserInfoLogin
- {
- public short Account;
- public string Password;
- public UserInfoLogin(short account, string password) // Changed
- {
- Account = account;
- Password = password;
- }
- }
-
- [Serializable]
- public class UserCourseInfoReq
- {
- public short Job_Id;
- public int Token;
- }
-
- [Serializable]
- public class UserCourseInfoOper
- {
- public short Job_Id;
- public int Token;
- public string Status;
- }
-
-
- #endregion
-
- #region ServerClass
- [Serializable]
- public class ServerResponse
- {
- public bool Final;
- public string ErrMessage;
- public object Object;
- public ServerResponse(object obj)
- {
- Object = obj;
- }
-
- }
-
- [Serializable]
- public class LoginResponse
- {
- public int Token;
- public Lvl Level;
- }
-
- [Serializable]
- public class CourseInfo
- {
- public short Id;
- public short Pid;
- public int Time;
- public string Name;
- public string Content;
- }
-
- [Serializable]
- public class UserCourseInfo
- {
- public short JobId;//工号
- public string Name;//姓名
- public string Status;
- // ..public DateTime Entry;
- public string Details;//信息描述
- }
-
-
- #endregion
-
-}
-
-
-
diff --git a/StuMgmServer/StuMgmLib/StuMgmLib.csproj b/StuMgmServer/StuMgmLib/StuMgmLib.csproj
index 80299fe..95aebb5 100644
--- a/StuMgmServer/StuMgmLib/StuMgmLib.csproj
+++ b/StuMgmServer/StuMgmLib/StuMgmLib.csproj
@@ -43,12 +43,9 @@
-
-
- Code
-
-
+
+
diff --git a/StuMgmServer/StuMgmLib/Utility.cs b/StuMgmServer/StuMgmLib/Utility.cs
new file mode 100644
index 0000000..8c653be
--- /dev/null
+++ b/StuMgmServer/StuMgmLib/Utility.cs
@@ -0,0 +1,31 @@
+using System.IO;
+using System.Runtime.Serialization.Formatters.Binary;
+namespace StuMgmLib
+{
+ class Utility
+ {
+ ///
+ /// 序列化
+ ///
+ public static byte[] SerializeBin(T c)
+ {
+ MemoryStream ms = new MemoryStream();
+ BinaryFormatter iFormatter = new BinaryFormatter();
+ iFormatter.Serialize(ms, c);
+ byte[] buf = ms.GetBuffer();
+ return buf;
+ }
+
+ ///
+ /// 反序列化
+ ///
+ public static T DeserializeBin(byte[] buf)
+ {
+ MemoryStream ms = new MemoryStream(buf);
+ BinaryFormatter iFormatter = new BinaryFormatter();
+ var obj = (T)iFormatter.Deserialize(ms);
+ return obj;
+ }
+ }
+
+}
diff --git a/StuMgmServer/StuMgmServer/StuMgmServer.csproj b/StuMgmServer/StuMgmServer/StuMgmServer.csproj
index 77a5bbe..83d2ee6 100644
--- a/StuMgmServer/StuMgmServer/StuMgmServer.csproj
+++ b/StuMgmServer/StuMgmServer/StuMgmServer.csproj
@@ -51,6 +51,9 @@
+
+
+
ResXFileCodeGenerator
Resources.Designer.cs
diff --git a/StuMgmServer/StuMgmLib/MyNameSpace/SystemCtrl.cs b/StuMgmServer/StuMgmServer/SystemCtrl.cs
similarity index 92%
rename from StuMgmServer/StuMgmLib/MyNameSpace/SystemCtrl.cs
rename to StuMgmServer/StuMgmServer/SystemCtrl.cs
index ae679ae..1d7043d 100644
--- a/StuMgmServer/StuMgmLib/MyNameSpace/SystemCtrl.cs
+++ b/StuMgmServer/StuMgmServer/SystemCtrl.cs
@@ -14,30 +14,7 @@ namespace StuMgmLib.MyNameSpace
{
public class SystemCtrl
{
- #region 流
- ///
- /// 序列化
- ///
- static byte[] Serialize(T c)
- {
- MemoryStream ms = new MemoryStream();
- BinaryFormatter iFormatter = new BinaryFormatter();
- iFormatter.Serialize(ms, c);
- byte[] buf = ms.GetBuffer();
- return buf;
- }
-
- ///
- /// 反序列化
- ///
- static T Deserialize(byte[] buf)
- {
- MemoryStream ms = new MemoryStream(buf);
- BinaryFormatter iFormatter = new BinaryFormatter();
- var obj = (T)iFormatter.Deserialize(ms);
- return obj;
- }
- #endregion
+
///
/// 获取返回数据
@@ -48,14 +25,14 @@ namespace StuMgmLib.MyNameSpace
{
var cr = Deserialize(clientRequset);
- ServerResponse sr = new ServerResponse(null);
+ Response sr = new Response(null);
switch (cr.Func)
{
case ClientFunc.VerifyLogin:
#region 登陆验证
LoginResponse lr = new LoginResponse();
- sr = new ServerResponse(lr);
+ sr = new Response(lr);
UserInfoLogin login = (UserInfoLogin)cr.Object;
getPerFromDB(login, out sr.Final, out sr.ErrMessage, out lr.Level);
@@ -66,7 +43,7 @@ namespace StuMgmLib.MyNameSpace
#endregion
case ClientFunc.GetCourseInfo:
#region 获取课程表
- sr.Object = getCosInfo(out sr.Final, out sr.ErrMessage);
+ sr.Data = getCosInfo(out sr.Final, out sr.ErrMessage);
break;
#endregion
case ClientFunc.GetSelfUserCourseInfo:
@@ -74,7 +51,7 @@ namespace StuMgmLib.MyNameSpace
UserCourseInfoReq ucir = (UserCourseInfoReq)cr.Object;
UserCourseInfo uc = new UserCourseInfo();
- sr = new ServerResponse(uc);
+ sr = new Response(uc);
vrTokenFrT(ucir.Job_Id, ucir.Token, out sr.Final, out sr.ErrMessage);
if (!sr.Final)
@@ -98,7 +75,7 @@ namespace StuMgmLib.MyNameSpace
if (!sr.Final)
break;
- sr.Object = getUsrCosStatus(uciO.Status, out sr.Final, out sr.ErrMessage);
+ sr.Data = getUsrCosStatus(uciO.Status, out sr.Final, out sr.ErrMessage);
break;
#endregion
diff --git a/StuMgmServer/StuMgmLib/MyNameSpace/TcpConn.cs b/StuMgmServer/StuMgmServer/TcpConn.cs
similarity index 100%
rename from StuMgmServer/StuMgmLib/MyNameSpace/TcpConn.cs
rename to StuMgmServer/StuMgmServer/TcpConn.cs
diff --git a/StuMgmServer/StuMgmServer/Utility.cs b/StuMgmServer/StuMgmServer/Utility.cs
new file mode 100644
index 0000000..fe14f9b
--- /dev/null
+++ b/StuMgmServer/StuMgmServer/Utility.cs
@@ -0,0 +1,52 @@
+using System.IO;
+using System.Runtime.Serialization.Formatters.Binary;
+namespace StuMgmLib
+{
+ class Utility
+ {
+ ///
+ /// 序列化
+ ///
+ static byte[] Serialize(T c)
+ {
+ MemoryStream ms = new MemoryStream();
+ BinaryFormatter iFormatter = new BinaryFormatter();
+ iFormatter.Serialize(ms, c);
+ byte[] buf = ms.GetBuffer();
+ return buf;
+ }
+
+ ///
+ /// 反序列化
+ ///
+ static T Deserialize(byte[] buf)
+ {
+ MemoryStream ms = new MemoryStream(buf);
+ BinaryFormatter iFormatter = new BinaryFormatter();
+ T obj = (T)iFormatter.Deserialize(ms);
+ return obj;
+ }
+ }
+
+}
+
+
+#region QuickTable
+
+internal class QTInfo
+{
+ public int Token;
+ public Lvl Level;
+ public QTInfo(int token, Lvl lv)
+ {
+ Token = token;
+ Level = lv;
+ }
+}
+public class QT // quickTable
+{
+ internal const Int16 tokenMaxCount = 32767;
+ internal static Dictionary quickTable = new Dictionary();
+}
+
+#endregion
\ No newline at end of file