diff --git a/MgmSys/MgmSys.sln b/MgmSys/MgmSys.sln deleted file mode 100644 index abb2cab..0000000 --- a/MgmSys/MgmSys.sln +++ /dev/null @@ -1,44 +0,0 @@ - -Microsoft Visual Studio Solution File, Format Version 12.00 -# Visual Studio 2013 -VisualStudioVersion = 12.0.40629.0 -MinimumVisualStudioVersion = 10.0.40219.1 -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MgmSysApp", "MgmSysApp\MgmSysApp.csproj", "{8924FC9E-8A06-4971-A717-20B5371C3F9C}" -EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MyStuMgmSysLib", "MyStuMgmSysLib\MyStuMgmSysLib.csproj", "{3AA339B4-AD71-4674-8BBE-FDD69F963AE8}" -EndProject -Global - GlobalSection(SolutionConfigurationPlatforms) = preSolution - Debug|Any CPU = Debug|Any CPU - Debug|Mixed Platforms = Debug|Mixed Platforms - Debug|Win32 = Debug|Win32 - Release|Any CPU = Release|Any CPU - Release|Mixed Platforms = Release|Mixed Platforms - Release|Win32 = Release|Win32 - EndGlobalSection - GlobalSection(ProjectConfigurationPlatforms) = postSolution - {8924FC9E-8A06-4971-A717-20B5371C3F9C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {8924FC9E-8A06-4971-A717-20B5371C3F9C}.Debug|Any CPU.Build.0 = Debug|Any CPU - {8924FC9E-8A06-4971-A717-20B5371C3F9C}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU - {8924FC9E-8A06-4971-A717-20B5371C3F9C}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU - {8924FC9E-8A06-4971-A717-20B5371C3F9C}.Debug|Win32.ActiveCfg = Debug|Any CPU - {8924FC9E-8A06-4971-A717-20B5371C3F9C}.Release|Any CPU.ActiveCfg = Release|Any CPU - {8924FC9E-8A06-4971-A717-20B5371C3F9C}.Release|Any CPU.Build.0 = Release|Any CPU - {8924FC9E-8A06-4971-A717-20B5371C3F9C}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU - {8924FC9E-8A06-4971-A717-20B5371C3F9C}.Release|Mixed Platforms.Build.0 = Release|Any CPU - {8924FC9E-8A06-4971-A717-20B5371C3F9C}.Release|Win32.ActiveCfg = Release|Any CPU - {3AA339B4-AD71-4674-8BBE-FDD69F963AE8}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {3AA339B4-AD71-4674-8BBE-FDD69F963AE8}.Debug|Any CPU.Build.0 = Debug|Any CPU - {3AA339B4-AD71-4674-8BBE-FDD69F963AE8}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU - {3AA339B4-AD71-4674-8BBE-FDD69F963AE8}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU - {3AA339B4-AD71-4674-8BBE-FDD69F963AE8}.Debug|Win32.ActiveCfg = Debug|Any CPU - {3AA339B4-AD71-4674-8BBE-FDD69F963AE8}.Release|Any CPU.ActiveCfg = Release|Any CPU - {3AA339B4-AD71-4674-8BBE-FDD69F963AE8}.Release|Any CPU.Build.0 = Release|Any CPU - {3AA339B4-AD71-4674-8BBE-FDD69F963AE8}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU - {3AA339B4-AD71-4674-8BBE-FDD69F963AE8}.Release|Mixed Platforms.Build.0 = Release|Any CPU - {3AA339B4-AD71-4674-8BBE-FDD69F963AE8}.Release|Win32.ActiveCfg = Release|Any CPU - EndGlobalSection - GlobalSection(SolutionProperties) = preSolution - HideSolutionNode = FALSE - EndGlobalSection -EndGlobal diff --git a/StuMgmServer/StuMgmLib/MyNameSpace/BinaryED.cs b/StuMgmServer/StuMgmLib/MyNameSpace/BinaryED.cs deleted file mode 100644 index f0642f0..0000000 --- a/StuMgmServer/StuMgmLib/MyNameSpace/BinaryED.cs +++ /dev/null @@ -1,40 +0,0 @@ -/* Describtion : Class for Binary Serialize and Deserialize - * Company : Wuxi Xinje - * Author : Somuns - * DateTime : 2021/1/18 - */ -using System.IO; -using System.Runtime.Serialization.Formatters.Binary; - -namespace StuMgmLib.MyNameSpace -{ - public class BinaryED // 序列化与反序列化 - { - /// - /// 序列化 - /// - public static byte[] Serialize(T c) - { - MemoryStream ms = new MemoryStream(); - BinaryFormatter iFormatter = new BinaryFormatter(); - iFormatter.Serialize(ms, c); - byte[] buf = ms.GetBuffer(); - return buf; - } - - /// - /// 反序列化 - /// - public static T Deserialize(byte[] buf) - { - MemoryStream ms = new MemoryStream(buf); - BinaryFormatter iFormatter = new BinaryFormatter(); - var obj = (T)iFormatter.Deserialize(ms); - return obj; - } - } - - - - -} diff --git a/StuMgmServer/StuMgmLib/MyNameSpace/CommonData.cs b/StuMgmServer/StuMgmLib/MyNameSpace/CommonData.cs index 4b882fa..9267894 100644 --- a/StuMgmServer/StuMgmLib/MyNameSpace/CommonData.cs +++ b/StuMgmServer/StuMgmLib/MyNameSpace/CommonData.cs @@ -22,8 +22,10 @@ namespace StuMgmLib.MyNameSpace VerifyLogin = 1, GetCourseInfo = 2, GetUserCourseInfo = 3, + SUpdateCourse = 4, + TUpdateCourse = 5, } - public enum LvErr + public enum Lvl { NotFound = -1, Error = -2, @@ -44,13 +46,11 @@ namespace StuMgmLib.MyNameSpace } [Serializable] - public class UserInfo + public class UserInfoLogin { - public short Account; + public short Account; public string Password; - public Int16 Token; - public LvErr UserLev; - public UserInfo(short account, string password) // Changed + public UserInfoLogin(short account, string password) // Changed { Account = account; Password = password; @@ -58,15 +58,21 @@ namespace StuMgmLib.MyNameSpace } [Serializable] - public class CourseInfo + public class UserCourseInfoReq { - public short Id; - public short Pid; - public int Time; - public string Name; - public string Content; + public short Job_Id; + public int Token; } + [Serializable] + public class UserCourseInfoOper // T represents teacher, S ->student + { + public short Job_Id; + public int Token; + public string sqlStr; + } + + [Serializable] public enum CourseStatusEnum { @@ -74,6 +80,39 @@ namespace StuMgmLib.MyNameSpace //...// } + + #endregion + + #region ServerClass + [Serializable] + public class ServerResponse + { + public object Object; + public ServerResponse(object obj) + { + Object = obj; + } + + } + + [Serializable] + public class LoginResponse + { + public int Token; + public Lvl Level; + public bool Final; + } + + [Serializable] + public class CourseInfo + { + public short Id; + public short Pid; + public int Time; + public string Name; + public string Content; + } + [Serializable] public class UserCourseInfo { @@ -83,23 +122,14 @@ namespace StuMgmLib.MyNameSpace // ..public DateTime Entry; public string Details;//信息描述 } - #endregion - #region ServerClass [Serializable] - public class ServerResponse + public class UpdateRp // 数据库操作反馈信息 { - public LvErr Lev; - public int Token; - //public string CourseStatus; - public object Object; - //public ServerResponse(object obj) - //{ - // Object = obj; - //} - } + public bool Final; + public string ErrMessge; #endregion - + } } diff --git a/StuMgmServer/StuMgmLib/MyNameSpace/Data.cs b/StuMgmServer/StuMgmLib/MyNameSpace/Data.cs deleted file mode 100644 index c6b321b..0000000 --- a/StuMgmServer/StuMgmLib/MyNameSpace/Data.cs +++ /dev/null @@ -1,85 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Data; - -namespace StuMgmLib.MyNameSpace -{ - - enum CommErr - { - Success, - FailSerial, - FailDeserial, - FailConnect, - FailSend, - FailReceive, - ErrData, - } - - public enum ClientFunc - { - VerifLogin = 1, - GetCourseInfo = 2, - GetUserCourseInfo = 3, - } - public enum LvErr - { - 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 UserInfo - { - public string Account; - public string Password; - public string Token; - public LvErr UserRole; - public UserInfo(string account, string password) - { - Account = account; - Password = password; - } - } - - public class CourseInfo - { - public short Id; - public short Pid; - public int Time; - public string Name; - public string Content; - } - - - [Serializable] - public enum CourseStatusEnum - { - //lll, - //...// - } - - [Serializable] - public class UserCourseInfo - { - public short JobId;//工号 - public string Name;//姓名 -// ..public DateTime Entry; - public string InfoDescribe;//信息描述 - } -} \ No newline at end of file diff --git a/StuMgmServer/StuMgmLib/MyNameSpace/DataAnalyze.cs b/StuMgmServer/StuMgmLib/MyNameSpace/DataAnalyze.cs deleted file mode 100644 index abb192e..0000000 --- a/StuMgmServer/StuMgmLib/MyNameSpace/DataAnalyze.cs +++ /dev/null @@ -1,183 +0,0 @@ -/* Describtion : Class for Data Analyze - * Company : Wuxi Xinje - * Author : Somuns - * DateTime : 2021/1/18 - */ -using MySql.Data.MySqlClient; -using System.Data; -using System.Windows.Forms; - -namespace StuMgmLib.MyNameSpace -{ - /// - /// 数据操作 - /// - public class DataAnalyze - { - - private enum verifyCode : short - { - notFound = -1, - error = -2, - admin = 1, - teacher = 2, - student = 3, - } - private const string conStr = "data source=localhost; initial catalog=xinje; user id=root; pwd=980505;charset = utf8"; - - /* Recv: ___________________________________________________________________ - * | Account | Password | (SqlOperate) | - * |___short_____string______string[]________________________________________| - * Analyze: - * Account Permission (SqlOperate) - * - * Send: ____________________________________________________________________ - * | Permission | DataSet | - * |___short________DS___________________________________________________| - * - */ - - /// - /// 解析ClientSend - /// - public static ServerSend ClientSendAnalyze(ClientSend cs) - { - ServerSend ss = new ServerSend(); - ss.Permission = loginVerify(cs.Account, cs.Password); // 验证身份 - if (ss.Permission < 0) // 小于0,则权限有误 - { - ss.Ds = null; - return ss; - } - - string[] tbName; - bool stuFlag = false; - switch (ss.Permission) - { - case (short)verifyCode.admin: - tbName = new string[] { "user_info", "course_info", "user" }; - break; - case (short)verifyCode.teacher: - tbName = new string[] { "user_info", "course_info" }; - break; - case (short)verifyCode.student: - tbName = new string[] { "user_info", "course_info" }; - stuFlag = true; break; - default: - tbName = null; - break; - } - - ss.SqlSucceed = false; - if (cs.SqlStr != null) // sql语句为空,则表示仅登录验证;若不为空,则取数据库操作返回值,并返回SS; - { - ss.SqlSucceed = mySqlModify(tbName, cs.SqlStr); - return ss; - } - - ss.Ds = getDataSet(tbName, stuFlag, cs.Account); - return ss; - } - - /// - /// 登录验证,若失败,则返回错误码;若身份验证成功,则返回用户权限; - /// - private static short loginVerify(short account, string psw) - { - short notFound = -1; - short error = -2; - string qStu = "select * from user where account = " + account + " and password = '" + psw + "'"; - MySqlConnection con = new MySqlConnection(conStr); - try - { - con.Open(); - MySqlCommand mCmd = new MySqlCommand(qStu, con); - MySqlDataReader mReader = mCmd.ExecuteReader(); - if (mReader.HasRows) - { - mReader.Read(); - return mReader.GetInt16("permission"); - } - else - return notFound; - } - catch (MySqlException) - { - return error; - } - finally - { - con.Close(); - } - } - - /// - /// 改 - /// - private static bool mySqlModify(string[] tbName, string[] sqlStr) // Need to change ...... - { - MySqlConnection con = new MySqlConnection(conStr); - try - { - con.Open(); - int len = sqlStr.Length; - for (int index = 0; index < len; index++) - { - MySqlCommand mCmd = new MySqlCommand(sqlStr[index], con); // 优化:所操作数据表是否匹配权限 - mCmd.ExecuteNonQuery(); - } - return true; - } - catch - { - return false; - } - finally - { - con.Close(); - } - } - - /// - /// 查 将各表填入dataset - /// - private static DataSet getDataSet(string[] tbName, bool stuFlag, int account) - { - string str = "select * from "; - MySqlConnection con = new MySqlConnection(conStr); - try - { - con.Open(); - DataSet ds = new DataSet(); - for (int index = 0; index < tbName.Length; index++) - { - string newStr = str + " " + tbName[index]; - if ((stuFlag == true) && (tbName[index] == "user_info")) - { - newStr += " where job_id = " + account.ToString(); // 学员权限时,返回该学员数据项 - } - MySqlCommand mCmd = new MySqlCommand(newStr, con); - MySqlDataReader mReader = mCmd.ExecuteReader(); - DataTable dt = new DataTable(); - dt.Load(mReader); - dt.TableName = tbName[index]; - ds.Tables.Add(dt); - } - return ds; - } - catch (MySqlException mySqlEx) - { - MessageBox.Show(mySqlEx.Message); - return null; - } - finally - { - con.Close(); - } - } - - - - } - -} \ No newline at end of file diff --git a/StuMgmServer/StuMgmLib/MyNameSpace/SystemComm.cs b/StuMgmServer/StuMgmLib/MyNameSpace/SystemComm.cs deleted file mode 100644 index 35e833b..0000000 --- a/StuMgmServer/StuMgmLib/MyNameSpace/SystemComm.cs +++ /dev/null @@ -1,95 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Diagnostics; -using System.Net; -using System.Net.Sockets; - -namespace StuMgmLib.MyNameSpace -{ - class SystemComm - { - #region 基本函数 - const int bufSize = 1024 * 1024; - static IPEndPoint m_ipEndpoint; - static Socket m_socket; - static byte[] m_buf; - - internal static void Init(string ip, int port) - { - IPAddress ipAdress = IPAddress.Parse(ip); - m_ipEndpoint = new IPEndPoint(ipAdress, port); - m_buf = new byte[bufSize]; - } - static bool Connect() - { - try - { - m_socket = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp); - m_socket.Connect(m_ipEndpoint); - return m_socket.Connected; - } - catch (Exception ex) - { - Debug.Print(ex.Message); - return false; - } - } - static bool Send(byte[] data) - { - try - { - m_socket.Send(data); - return true; - } - catch(Exception e) - { - Debug.Print(e.Message); - return false; - } - } - static bool Receive() - { - try - { - Array.Clear(m_buf, 0, m_buf.Length); - m_socket.Receive(m_buf); - return true; - } - catch (Exception e) - { - Debug.Print(e.Message); - return false; - } - } - static void DisConnect() - { - m_socket.Close(); - } - #endregion - - internal static CommErr GetData(ClientRequest req,out object o) - { - o = null; - - if (!Connect()) - return CommErr.FailConnect; - - byte[] sendBuf; - if (!Utility.BinSerialize(req, out sendBuf)) - return CommErr.FailSerial; - - if (!Send(sendBuf)) - return CommErr.FailSend; - - if (!Receive()) - return CommErr.FailReceive; - - DisConnect(); - - if (!Utility.BinDeserialize(m_buf, out o)) - return CommErr.FailDeserial; - return CommErr.Success; - } - } -} - diff --git a/StuMgmServer/StuMgmLib/MyNameSpace/SystemCtrl.cs b/StuMgmServer/StuMgmLib/MyNameSpace/SystemCtrl.cs index 3b7bb21..56cdf13 100644 --- a/StuMgmServer/StuMgmLib/MyNameSpace/SystemCtrl.cs +++ b/StuMgmServer/StuMgmLib/MyNameSpace/SystemCtrl.cs @@ -13,6 +13,7 @@ namespace StuMgmLib.MyNameSpace { class SystemCtrl { + #region 流 /// /// 序列化 /// @@ -35,6 +36,8 @@ namespace StuMgmLib.MyNameSpace var obj = (T)iFormatter.Deserialize(ms); return obj; } + #endregion + /// /// 获取返回数据 @@ -43,48 +46,114 @@ namespace StuMgmLib.MyNameSpace { try { - var cs = Deserialize(clientRequset); + var cr = Deserialize(clientRequset); - ServerResponse sr = new ServerResponse(); + ServerResponse sr = null; - switch (cs.Func) + switch (cr.Func) { case ClientFunc.VerifyLogin: - UserInfo ui = (UserInfo)cs.Object; + UserInfoLogin uil = (UserInfoLogin)cr.Object; + LoginResponse lr = new LoginResponse(); + + if (getPermission(uil, out lr.Level)) + lr.Token = addToken(uil.Account, ref Info.myToken); - if (verifyLogin(ui, out sr.Lev)) - sr.Token = addToken(ui.Account, ref Info.myToken); + sr = new ServerResponse(lr); break; case ClientFunc.GetCourseInfo: - sr.Object = getCourseInfo(); + + sr = new ServerResponse(getCourseInfo()); Debug.Print(sr.Object.GetType().ToString()); break; - case ClientFunc.GetUserCourseInfo: - short job_id; + case ClientFunc.GetUserCourseInfo: // 获取学员个人课程信息,详情 + + UserCourseInfoReq ucir = (UserCourseInfoReq)cr.Object; UserCourseInfo uc = new UserCourseInfo(); - if (verifyToken((Dictionary)cs.Object, out job_id)) - if (getUserCourseStatus(job_id, out uc.Status, out uc.Details)) - sr.Object = uc; + + if (!verifyToken(ucir.Job_Id, ucir.Token)) + break; + + if (getUserCourseStatus(ucir.Job_Id, out uc.Status, out uc.Details)) + sr = new ServerResponse(uc); break; - } + case ClientFunc.SUpdateCourse: // 学生修改课程信息,仅有权修改自己的个别类型状态 + /* Todo + verify (jobid token) + update */ + UserCourseInfoOper suico = (UserCourseInfoOper)cr.Object; + UpdateRp urs = new UpdateRp(); + + if (!verifyToken(suico.Job_Id, suico.Token)) + break; + + sUpdateInfo(suico.Job_Id, suico.sqlStr, out urs.Final, out urs.ErrMessge); + + sr = new ServerResponse(urs); + break; + case ClientFunc.TUpdateCourse: + /*Todo + 教师修改课程信息,有权更改学生课程状态 + verify (jobid,token) + verify(permission) + update*/ + UserCourseInfoOper tucio = (UserCourseInfoOper)cr.Object; + UpdateRp urt = new UpdateRp(); + + if (!verifyToken(tucio.Job_Id, tucio.Token)) + break; + + Lvl l = Lvl.Error; + if (!getPermission(tucio.Job_Id, out l)) + break; + + if (!(l == Lvl.Teacher || l == Lvl.Teacher)) + { + urt.Final = false; + urt.ErrMessge = "permission err"; + break; + } + + tUpdateInfo(tucio.sqlStr, out urt.Final, out urt.ErrMessge); + sr = new ServerResponse(urt); + + break; + } + if (null == sr) + return null; return Serialize(sr); } catch { - return null; + return null; // 非客户端连接:用调试助手连接服务器 } } const string conStr = "data source=localhost; initial catalog=xinje; user id=root; pwd=980505;charset = utf8"; - static bool verifyLogin(UserInfo userInfo, out LvErr level) + #region Verify + + static bool getPermission(object o, out Lvl level) { - level = LvErr.Error; - string qStu = "select * from user where account = " + userInfo.Account + " and password = '" + userInfo.Password + "'"; + level = Lvl.Error; + + string qStu = "select * from user where account = "; + + if (o is UserInfoLogin) + { + UserInfoLogin uil = (UserInfoLogin)o; + qStu += uil.Account + " and password = '" + uil.Password + "'"; + } // 首次登陆验证 + else if (o is UserCourseInfoOper) + { + UserCourseInfoOper ucio = (UserCourseInfoOper)o; + qStu += ucio.Job_Id + ucio.sqlStr; + } // 数据库操作验证权限 + MySqlConnection con = new MySqlConnection(conStr); try { @@ -94,18 +163,17 @@ namespace StuMgmLib.MyNameSpace if (mReader.HasRows) { mReader.Read(); - level = (LvErr)mReader.GetInt16("level"); + level = (Lvl)mReader.GetInt16("level"); return true; } else { - level = LvErr.NotFound; + level = Lvl.NotFound; return false; } } catch (MySqlException) { - level = LvErr.Error; return false; } finally @@ -131,25 +199,16 @@ namespace StuMgmLib.MyNameSpace return token; } - static bool verifyToken(Dictionary dic, out short account) + static bool verifyToken(short job_id, int token) { - account = 0; - if (dic.Count != 1) - return false; - - foreach (var item in dic) - { - if (!Info.myToken.ContainsKey(item.Key)) - return false; - if (Info.myToken[item.Key] == item.Value) - { - account = item.Key; - return true; - } - } + if (Info.myToken[job_id] == token) + return true; return false; } + #endregion + + #region CourseInfo const int nameColumn = 1; const int contentColumn = 3; static List getCourseInfo() @@ -184,8 +243,15 @@ namespace StuMgmLib.MyNameSpace con.Close(); } } + #endregion + + #region UserCourseInfo const int statusColumn = 3; const int detailsColumn = 4; + + /// + /// 员工获取课程信息 + /// static bool getUserCourseStatus(short jobId, out string status, out string details) { status = ""; @@ -212,6 +278,73 @@ namespace StuMgmLib.MyNameSpace } } + #endregion + + #region Update + + #region Student + + /// + /// 学员更改个人课程状态 + /// + static void sUpdateInfo(short job_id, string sqlStr, out bool final, out string eMessage) + { + final = false; + eMessage = null; + string str = "select * from usercourse_info where account = " + job_id + sqlStr; + MySqlConnection conn = new MySqlConnection(); + try + { + MySqlCommand cmd = new MySqlCommand(str, conn); + if (cmd.ExecuteNonQuery() > 0) + final = true; + } + catch (MySqlException e) + { + eMessage = e.Message; + Debug.Print(e.Message); // 可以去掉 + } + finally + { + conn.Close(); + } + } + + #endregion + + #region Teacher + + static void tUpdateInfo(string sqlStr, out bool final, out string eMessage) + { + final = false; + eMessage = null; + string str = "select * from usercourse_info where " + sqlStr; + MySqlConnection conn = new MySqlConnection(); + try + { + MySqlCommand cmd = new MySqlCommand(str, conn); + if (cmd.ExecuteNonQuery() > 0) + final = true; + } + catch (MySqlException e) + { + eMessage = e.Message; + Debug.Print(e.Message); // 可以去掉 + } + finally + { + conn.Close(); + } + } + + + + #endregion + + #endregion + + + } diff --git a/StuMgmServer/StuMgmLib/MyNameSpace/SystemData.cs b/StuMgmServer/StuMgmLib/MyNameSpace/SystemData.cs deleted file mode 100644 index fbcdd62..0000000 --- a/StuMgmServer/StuMgmLib/MyNameSpace/SystemData.cs +++ /dev/null @@ -1,40 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Text; - -namespace StuMgmLib.MyNameSpace -{ - class SystemData - { - static Dictionary allCourseInfo; - static Dictionary allCourseStatus; - - - internal static CommErr InitSystemData() - { - CommErr err; - err = InitCourseInfo(); - if (err != CommErr.Success) - return err; - return CommErr.Success; - } - static CommErr InitCourseInfo() - { - CommErr err; - List courseInfo; - err = SystemCtrl.GetCourseInfo(out courseInfo); - if (err != CommErr.Success) - return err; - ...//将List转为Dictionary - return CommErr.Success; - } - - internal static CommErr RefreshUserCourseInfo(UserCourseInfo info) - { - ...//将UserCourseInfo转为Dictionary - return CommErr.Success; - } - - - } -} diff --git a/StuMgmServer/StuMgmServer.sln b/StuMgmServer/StuMgmServer.sln index 6eb86ba..70a6d25 100644 --- a/StuMgmServer/StuMgmServer.sln +++ b/StuMgmServer/StuMgmServer.sln @@ -7,8 +7,6 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "StuMgmServer", "StuMgmServe EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "StuMgmLib", "StuMgmLib\StuMgmLib.csproj", "{725C2786-699E-424F-8F3E-FB5BB4E5A3A5}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Test", "Test\Test.csproj", "{E3D7C7F1-F922-4C6B-A44A-86F4DC73951A}" -EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -23,10 +21,6 @@ Global {725C2786-699E-424F-8F3E-FB5BB4E5A3A5}.Debug|Any CPU.Build.0 = Debug|Any CPU {725C2786-699E-424F-8F3E-FB5BB4E5A3A5}.Release|Any CPU.ActiveCfg = Release|Any CPU {725C2786-699E-424F-8F3E-FB5BB4E5A3A5}.Release|Any CPU.Build.0 = Release|Any CPU - {E3D7C7F1-F922-4C6B-A44A-86F4DC73951A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {E3D7C7F1-F922-4C6B-A44A-86F4DC73951A}.Debug|Any CPU.Build.0 = Debug|Any CPU - {E3D7C7F1-F922-4C6B-A44A-86F4DC73951A}.Release|Any CPU.ActiveCfg = Release|Any CPU - {E3D7C7F1-F922-4C6B-A44A-86F4DC73951A}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE diff --git a/StuMgmServer/Test/Data.cs b/StuMgmServer/Test/Data.cs deleted file mode 100644 index 1ca13f7..0000000 --- a/StuMgmServer/Test/Data.cs +++ /dev/null @@ -1,201 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Data; - - - -namespace StuMgmClient -{ - - enum ErrCode - { - Success, - FailSerial, - FailDeserial, - FailConnect, - FailSend, - FailReceive, - ErrData, - } - - public enum FuncCode - { - VerifLogin = 1, - GetCourseInfo, - GetUserCourseInfo, - } - public enum Roles - { - NotFound = -1, - Error = -2, - Admin = 1, - Teacher = 2, - Student = 3, - } - - [Serializable] - public class ClientRequest - { - public FuncCode Func; - public object Object; - public ClientRequest(FuncCode func, object obj) - { - Func = func; - Object = obj; - } - } - - [Serializable] - public class UserInfo - { - public short Account; // Changed - public string Password; - public Int16 Token; - public Roles UserRole; - public UserInfo(short account, string password) // Changed - { - Account = account; - Password = password; - } - } - - public class CourseInfo - { - public short Id; - public short Pid; - public int Time; - public string Name; - public string Content; - } - - - [Serializable] - public enum CourseStatusEnum - { - lll, - ...// - } - - [Serializable] - public class UserCourseInfo - { - public short JobId;//工号 - public string Name;//姓名 - ..public DateTime Entry; - public string InfoDescribe;//信息描述 - } - - - - - /* - - - #region 学生题目信息一览 - - #endregion - - #region 学生单题详细信息 - public class HistoryInfo - { - DateTime Time; - string Describe; - } - public class DetailInfo - { - public short CourseId; - public short JobId; - List Describes; - } - #endregion - - */ - - - - - - - - //[Serializable] - //public class ServerSend - //{ - // public short permission { get; set; } - // public DataSet ds { get; set; } - //} - - -} - - -namespace StuMgmClient -{ - - //class Data - //{ - // //状态值字符串转字典 - // public Dictionary StateParsing(DataTable table) - // { - // Dictionary myDictionary = new Dictionary(); - // ClientMysql cm = new ClientMysql(); - // DataSet ds = cm.SelectState(); - // DataRow dr = ds.Tables["user_info"].Rows[0]; - // string state = dr["course_status"].ToString(); - // int num = 0; - // int oldTem = 0; - // //切割字符串 - // string[] sArray = state.Split(new char[2] { ':', ';' }); - // foreach (string i in sArray) - // { - // if (i.Equals("")) { break; } - // int tem = Convert.ToInt32(i); - // num++; - // if (num % 2 != 0) - // { - // myDictionary.Add(tem, 0); - // oldTem = tem; - // } - // else - // { - // myDictionary[oldTem] = tem; - // } - // } - // return myDictionary; - // } - // //字典转字符串 - // public string DicParsing(Dictionary dic) - // { - // string stateText = ""; - // foreach (var item in dic) - // { - // stateText = stateText + item.Key + ":" + item.Value + ";"; - // } - // return stateText; - // } - // //查询所有子节点 - // public void GetAllNodes(string id, DataTable table, ref Dictionary nodesDic) - // { - - // //把父节点的数据筛选出来 - // DataRow[] rows = table.Select("pid =" + id);//取根 - // if (rows.Length <= 0) - // { - // nodesDic.Add(Convert.ToInt32(id), 0); - // return; - // } - // foreach (DataRow dr in rows) - // { - // GetAllNodes(dr["id"].ToString(), table, ref nodesDic); - // } - - // } - // //获取所有子节点Dictionary - // public Dictionary GetNodesDic(DataTable table) - // { - // Dictionary nodesDic = new Dictionary(); - // GetAllNodes("0", table, ref nodesDic); - // return nodesDic; - // } - //} - -} diff --git a/StuMgmServer/Test/Form1.Designer.cs b/StuMgmServer/Test/Form1.Designer.cs deleted file mode 100644 index 571b2a2..0000000 --- a/StuMgmServer/Test/Form1.Designer.cs +++ /dev/null @@ -1,159 +0,0 @@ -namespace Test -{ - partial class Form1 - { - /// - /// Required designer variable. - /// - private System.ComponentModel.IContainer components = null; - - /// - /// Clean up any resources being used. - /// - /// true if managed resources should be disposed; otherwise, false. - protected override void Dispose(bool disposing) - { - if (disposing && (components != null)) - { - components.Dispose(); - } - base.Dispose(disposing); - } - - #region Windows Form Designer generated code - - /// - /// Required method for Designer support - do not modify - /// the contents of this method with the code editor. - /// - private void InitializeComponent() - { - this.button1 = new System.Windows.Forms.Button(); - this.button2 = new System.Windows.Forms.Button(); - this.dataGridView1 = new System.Windows.Forms.DataGridView(); - this.dataGridView2 = new System.Windows.Forms.DataGridView(); - this.dataGridView3 = new System.Windows.Forms.DataGridView(); - this.tableLayoutPanel1 = new System.Windows.Forms.TableLayoutPanel(); - this.tableLayoutPanel2 = new System.Windows.Forms.TableLayoutPanel(); - ((System.ComponentModel.ISupportInitialize)(this.dataGridView1)).BeginInit(); - ((System.ComponentModel.ISupportInitialize)(this.dataGridView2)).BeginInit(); - ((System.ComponentModel.ISupportInitialize)(this.dataGridView3)).BeginInit(); - this.tableLayoutPanel1.SuspendLayout(); - this.tableLayoutPanel2.SuspendLayout(); - this.SuspendLayout(); - // - // button1 - // - this.button1.Dock = System.Windows.Forms.DockStyle.Fill; - this.button1.Location = new System.Drawing.Point(557, 3); - this.button1.Name = "button1"; - this.button1.Size = new System.Drawing.Size(549, 55); - this.button1.TabIndex = 0; - this.button1.Text = "button1"; - this.button1.UseVisualStyleBackColor = true; - this.button1.Click += new System.EventHandler(this.button1_Click); - // - // button2 - // - this.button2.Dock = System.Windows.Forms.DockStyle.Fill; - this.button2.Location = new System.Drawing.Point(3, 3); - this.button2.Name = "button2"; - this.button2.Size = new System.Drawing.Size(548, 55); - this.button2.TabIndex = 1; - this.button2.Text = "button2"; - this.button2.UseVisualStyleBackColor = true; - this.button2.Click += new System.EventHandler(this.button2_Click); - // - // dataGridView1 - // - this.dataGridView1.AllowUserToAddRows = false; - this.dataGridView1.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize; - this.dataGridView1.Dock = System.Windows.Forms.DockStyle.Fill; - this.dataGridView1.Location = new System.Drawing.Point(3, 3); - this.dataGridView1.Name = "dataGridView1"; - this.dataGridView1.RowTemplate.Height = 27; - this.dataGridView1.Size = new System.Drawing.Size(1103, 216); - this.dataGridView1.TabIndex = 2; - // - // dataGridView2 - // - this.dataGridView2.AllowUserToAddRows = false; - this.dataGridView2.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize; - this.dataGridView2.Dock = System.Windows.Forms.DockStyle.Fill; - this.dataGridView2.Location = new System.Drawing.Point(3, 447); - this.dataGridView2.Name = "dataGridView2"; - this.dataGridView2.Size = new System.Drawing.Size(1103, 218); - this.dataGridView2.TabIndex = 3; - // - // dataGridView3 - // - this.dataGridView3.AllowUserToAddRows = false; - this.dataGridView3.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize; - this.dataGridView3.Dock = System.Windows.Forms.DockStyle.Fill; - this.dataGridView3.Location = new System.Drawing.Point(3, 225); - this.dataGridView3.Name = "dataGridView3"; - this.dataGridView3.Size = new System.Drawing.Size(1103, 216); - this.dataGridView3.TabIndex = 4; - // - // tableLayoutPanel1 - // - this.tableLayoutPanel1.ColumnCount = 2; - this.tableLayoutPanel1.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 50F)); - this.tableLayoutPanel1.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 50F)); - this.tableLayoutPanel1.Controls.Add(this.button2, 0, 0); - this.tableLayoutPanel1.Controls.Add(this.button1, 1, 0); - this.tableLayoutPanel1.Dock = System.Windows.Forms.DockStyle.Top; - this.tableLayoutPanel1.Location = new System.Drawing.Point(0, 0); - this.tableLayoutPanel1.Name = "tableLayoutPanel1"; - this.tableLayoutPanel1.RowCount = 1; - this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 50F)); - this.tableLayoutPanel1.Size = new System.Drawing.Size(1109, 61); - this.tableLayoutPanel1.TabIndex = 5; - // - // tableLayoutPanel2 - // - this.tableLayoutPanel2.ColumnCount = 1; - this.tableLayoutPanel2.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 100F)); - this.tableLayoutPanel2.Controls.Add(this.dataGridView1, 0, 0); - this.tableLayoutPanel2.Controls.Add(this.dataGridView3, 0, 1); - this.tableLayoutPanel2.Controls.Add(this.dataGridView2, 0, 2); - this.tableLayoutPanel2.Dock = System.Windows.Forms.DockStyle.Fill; - this.tableLayoutPanel2.Location = new System.Drawing.Point(0, 61); - this.tableLayoutPanel2.Name = "tableLayoutPanel2"; - this.tableLayoutPanel2.RowCount = 3; - this.tableLayoutPanel2.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 33.33333F)); - this.tableLayoutPanel2.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 33.33333F)); - this.tableLayoutPanel2.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 33.33333F)); - this.tableLayoutPanel2.Size = new System.Drawing.Size(1109, 668); - this.tableLayoutPanel2.TabIndex = 6; - // - // Form1 - // - this.AutoScaleDimensions = new System.Drawing.SizeF(8F, 15F); - this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; - this.ClientSize = new System.Drawing.Size(1109, 729); - this.Controls.Add(this.tableLayoutPanel2); - this.Controls.Add(this.tableLayoutPanel1); - this.Name = "Form1"; - this.Text = "Form1"; - this.Load += new System.EventHandler(this.Form1_Load); - ((System.ComponentModel.ISupportInitialize)(this.dataGridView1)).EndInit(); - ((System.ComponentModel.ISupportInitialize)(this.dataGridView2)).EndInit(); - ((System.ComponentModel.ISupportInitialize)(this.dataGridView3)).EndInit(); - this.tableLayoutPanel1.ResumeLayout(false); - this.tableLayoutPanel2.ResumeLayout(false); - this.ResumeLayout(false); - - } - - #endregion - - private System.Windows.Forms.Button button1; - private System.Windows.Forms.Button button2; - private System.Windows.Forms.DataGridView dataGridView1; - private System.Windows.Forms.DataGridView dataGridView2; - private System.Windows.Forms.DataGridView dataGridView3; - private System.Windows.Forms.TableLayoutPanel tableLayoutPanel1; - private System.Windows.Forms.TableLayoutPanel tableLayoutPanel2; - } -} \ No newline at end of file diff --git a/StuMgmServer/Test/Form1.cs b/StuMgmServer/Test/Form1.cs deleted file mode 100644 index 1f58e7b..0000000 --- a/StuMgmServer/Test/Form1.cs +++ /dev/null @@ -1,74 +0,0 @@ -using System; -using System.Collections.Generic; -using System.ComponentModel; -using System.Data; -using System.Drawing; -using System.Net; -using System.Net.Sockets; -using System.Text; -using System.Windows.Forms; -using StuMgmLib.MyNameSpace; - -namespace Test -{ - public partial class Form1 : Form - { - IPEndPoint IPP = null; - Socket socket = null; - public Form1() - { - InitializeComponent(); - } - private void Form1_Load(object sender, EventArgs e) - { - - } - - private void button1_Click(object sender, EventArgs e) - { - Info.ClientSend cs = new Info.ClientSend(); - cs.account = 01941; - cs.password = "980505"; - cs.sqlStr = null; - //cs.sqlStr = new string[1]; - //cs.sqlStr[0] = "UPDATE user_info set course_status = '李俊阳是个憨憨' WHERE job_id=1941"; - if (socket != null) - { - byte[] send = BinaryED.Serialize(cs); - socket.Send(send); - byte[] recv = new byte[65535]; - socket.Receive(recv); - Info.ServerSend ss = BinaryED.Deserialize(recv); - //short per = ss.permission; - DataSet ds = ss.ds; - if (ds != null) - { - DataTable dt1 = ds.Tables["course_info"]; - DataTable dt2 = ds.Tables["user_info"]; - DataTable dt3 = ds.Tables["user"]; - dataGridView1.DataSource = dt1; - dataGridView2.DataSource = dt2; - dataGridView3.DataSource = dt3; - } - } - socket = null; - } - - private void button2_Click(object sender, EventArgs e) - { - try - { - string ip = "10.10.0.44"; - int port = 502; - IPP = new IPEndPoint(IPAddress.Parse(ip), port); - socket = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp); - socket.Connect(IPP); - } - catch (Exception econnect) - { - MessageBox.Show(econnect.Message); - } - } - - } -} diff --git a/StuMgmServer/Test/Form1.resx b/StuMgmServer/Test/Form1.resx deleted file mode 100644 index 7080a7d..0000000 --- a/StuMgmServer/Test/Form1.resx +++ /dev/null @@ -1,120 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - text/microsoft-resx - - - 2.0 - - - System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - \ No newline at end of file diff --git a/StuMgmServer/Test/Program.cs b/StuMgmServer/Test/Program.cs deleted file mode 100644 index 86fd0fb..0000000 --- a/StuMgmServer/Test/Program.cs +++ /dev/null @@ -1,20 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Windows.Forms; - -namespace Test -{ - static class Program - { - /// - /// 应用程序的主入口点。 - /// - [STAThread] - static void Main() - { - Application.EnableVisualStyles(); - Application.SetCompatibleTextRenderingDefault(false); - Application.Run(new Form1()); - } - } -} diff --git a/StuMgmServer/Test/Properties/AssemblyInfo.cs b/StuMgmServer/Test/Properties/AssemblyInfo.cs deleted file mode 100644 index 510adb9..0000000 --- a/StuMgmServer/Test/Properties/AssemblyInfo.cs +++ /dev/null @@ -1,36 +0,0 @@ -using System.Reflection; -using System.Runtime.CompilerServices; -using System.Runtime.InteropServices; - -// 有关程序集的常规信息通过以下 -// 特性集控制。更改这些特性值可修改 -// 与程序集关联的信息。 -[assembly: AssemblyTitle("Test")] -[assembly: AssemblyDescription("")] -[assembly: AssemblyConfiguration("")] -[assembly: AssemblyCompany("")] -[assembly: AssemblyProduct("Test")] -[assembly: AssemblyCopyright("Copyright © 2021")] -[assembly: AssemblyTrademark("")] -[assembly: AssemblyCulture("")] - -// 将 ComVisible 设置为 false 使此程序集中的类型 -// 对 COM 组件不可见。 如果需要从 COM 访问此程序集中的类型, -// 则将该类型上的 ComVisible 特性设置为 true。 -[assembly: ComVisible(false)] - -// 如果此项目向 COM 公开,则下列 GUID 用于类型库的 ID -[assembly: Guid("39f78726-24f8-499a-86d5-1758f9b27e0f")] - -// 程序集的版本信息由下面四个值组成: -// -// 主版本 -// 次版本 -// 生成号 -// 修订号 -// -// 可以指定所有这些值,也可以使用“生成号”和“修订号”的默认值, -// 方法是按如下所示使用“*”: -// [assembly: AssemblyVersion("1.0.*")] -[assembly: AssemblyVersion("1.0.0.0")] -[assembly: AssemblyFileVersion("1.0.0.0")] diff --git a/StuMgmServer/Test/Properties/Resources.Designer.cs b/StuMgmServer/Test/Properties/Resources.Designer.cs deleted file mode 100644 index f32afcf..0000000 --- a/StuMgmServer/Test/Properties/Resources.Designer.cs +++ /dev/null @@ -1,71 +0,0 @@ -//------------------------------------------------------------------------------ -// -// 此代码由工具生成。 -// 运行时版本: 4.0.30319.42000 -// -// 对此文件的更改可能会导致不正确的行为,并且如果 -// 重新生成代码,这些更改将丢失。 -// -//------------------------------------------------------------------------------ - -namespace Test.Properties -{ - - - /// - /// 一个强类型的资源类,用于查找本地化的字符串等。 - /// - // 此类是由 StronglyTypedResourceBuilder - // 类通过类似于 ResGen 或 Visual Studio 的工具自动生成的。 - // 若要添加或移除成员,请编辑 .ResX 文件,然后重新运行 ResGen - // (以 /str 作为命令选项),或重新生成 VS 项目。 - [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "4.0.0.0")] - [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] - internal class Resources - { - - private static global::System.Resources.ResourceManager resourceMan; - - private static global::System.Globalization.CultureInfo resourceCulture; - - [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")] - internal Resources() - { - } - - /// - /// 返回此类使用的、缓存的 ResourceManager 实例。 - /// - [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] - internal static global::System.Resources.ResourceManager ResourceManager - { - get - { - if ((resourceMan == null)) - { - global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("Test.Properties.Resources", typeof(Resources).Assembly); - resourceMan = temp; - } - return resourceMan; - } - } - - /// - /// 为所有资源查找重写当前线程的 CurrentUICulture 属性, - /// 方法是使用此强类型资源类。 - /// - [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] - internal static global::System.Globalization.CultureInfo Culture - { - get - { - return resourceCulture; - } - set - { - resourceCulture = value; - } - } - } -} diff --git a/StuMgmServer/Test/Properties/Resources.resx b/StuMgmServer/Test/Properties/Resources.resx deleted file mode 100644 index af7dbeb..0000000 --- a/StuMgmServer/Test/Properties/Resources.resx +++ /dev/null @@ -1,117 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - text/microsoft-resx - - - 2.0 - - - System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - \ No newline at end of file diff --git a/StuMgmServer/Test/Properties/Settings.Designer.cs b/StuMgmServer/Test/Properties/Settings.Designer.cs deleted file mode 100644 index a8cf573..0000000 --- a/StuMgmServer/Test/Properties/Settings.Designer.cs +++ /dev/null @@ -1,30 +0,0 @@ -//------------------------------------------------------------------------------ -// -// This code was generated by a tool. -// Runtime Version:4.0.30319.42000 -// -// Changes to this file may cause incorrect behavior and will be lost if -// the code is regenerated. -// -//------------------------------------------------------------------------------ - -namespace Test.Properties -{ - - - [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] - [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "11.0.0.0")] - internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase - { - - private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings()))); - - public static Settings Default - { - get - { - return defaultInstance; - } - } - } -} diff --git a/StuMgmServer/Test/Properties/Settings.settings b/StuMgmServer/Test/Properties/Settings.settings deleted file mode 100644 index 3964565..0000000 --- a/StuMgmServer/Test/Properties/Settings.settings +++ /dev/null @@ -1,7 +0,0 @@ - - - - - - - diff --git a/StuMgmServer/Test/SystemComm.cs b/StuMgmServer/Test/SystemComm.cs deleted file mode 100644 index 3041005..0000000 --- a/StuMgmServer/Test/SystemComm.cs +++ /dev/null @@ -1,95 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Diagnostics; -using System.Net; -using System.Net.Sockets; - -namespace StuMgmClient -{ - class SystemComm - { - #region 基本函数 - const int bufSize = 1024 * 1024; - static IPEndPoint m_ipEndpoint; - static Socket m_socket; - static byte[] m_buf; - - internal static void Init(string ip, int port) - { - IPAddress ipAdress = IPAddress.Parse(ip); - m_ipEndpoint = new IPEndPoint(ipAdress, port); - m_buf = new byte[bufSize]; - } - static bool Connect() - { - try - { - m_socket = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp); - m_socket.Connect(m_ipEndpoint); - return m_socket.Connected; - } - catch (Exception ex) - { - Debug.Print(ex.Message); - return false; - } - } - static bool Send(byte[] data) - { - try - { - m_socket.Send(data); - return true; - } - catch(Exception e) - { - Debug.Print(e.Message); - return false; - } - } - static bool Receive() - { - try - { - Array.Clear(m_buf, 0, m_buf.Length); - m_socket.Receive(m_buf); - return true; - } - catch (Exception e) - { - Debug.Print(e.Message); - return false; - } - } - static void DisConnect() - { - m_socket.Close(); - } - #endregion - - internal static ErrCode GetData(ClientRequest req,out object o) - { - o = null; - - if (!Connect()) - return ErrCode.FailConnect; - - byte[] sendBuf; - if (!Utility.BinSerialize(req, out sendBuf)) - return ErrCode.FailSerial; - - if (!Send(sendBuf)) - return ErrCode.FailSend; - - if (!Receive()) - return ErrCode.FailReceive; - - DisConnect(); - - if (!Utility.BinDeserialize(m_buf, out o)) - return ErrCode.FailDeserial; - return ErrCode.Success; - } - } -} - diff --git a/StuMgmServer/Test/SystemCtrl.cs b/StuMgmServer/Test/SystemCtrl.cs deleted file mode 100644 index 32a2be8..0000000 --- a/StuMgmServer/Test/SystemCtrl.cs +++ /dev/null @@ -1,88 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Text; - -namespace StuMgmClient -{ - class SystemCtrl - { - internal static ErrCode VerifLogin(string userName, string pawssword, out Roles role, out string token) - { - role = Roles.Error; - token = string.Empty; - - UserInfo cs = new UserInfo(userName, pawssword); - ClientRequest req = new ClientRequest(FuncCode.VerifLogin, cs); - - object o; - ErrCode err = SystemComm.GetData(req, out o); - if (err != ErrCode.Success) - return err; - - if (!(o is UserInfo)) - return ErrCode.ErrData; - - role = ((UserInfo)o).UserRole; - token = ((UserInfo)o).Token; - return ErrCode.Success; - } - - internal static ErrCode GetCourseInfo(out List courseInfo) - { - courseInfo = null; - //****** - ClientRequest req = new ClientRequest(FuncCode.GetCourseInfo, null); - - object o; - ErrCode err = SystemComm.GetData(req, out o); - if (err != ErrCode.Success) - return err; - - if (!(o is List)) - return ErrCode.ErrData; - - courseInfo = (List)o; - return ErrCode.Success; - } - - internal static ErrCode RefreshUserCourseInfo(string token) - { - UserCourseInfo info; - ErrCode err; - - err = GetUserCourseInfo(token, out info); - if (err != ErrCode.Success) - return err; - - err = SystemData.RefreshUserCourseInfo(info); - if (err != ErrCode.Success) - return err; - - return ErrCode.Success; - } - - static ErrCode GetUserCourseInfo(string token ,out UserCourseInfo info) - { - info = null; - ClientRequest req = new ClientRequest(FuncCode.GetUserCourseInfo, token); - - object o; - ErrCode err = SystemComm.GetData(req, out o); - if (err != ErrCode.Success) - return err; - - if (!(o is UserCourseInfo)) - return ErrCode.ErrData; - - info = (UserCourseInfo)o; - return ErrCode.Success; - } - - - - - - - - } -} diff --git a/StuMgmServer/Test/SystemData.cs b/StuMgmServer/Test/SystemData.cs deleted file mode 100644 index 7818bc5..0000000 --- a/StuMgmServer/Test/SystemData.cs +++ /dev/null @@ -1,40 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Text; - -namespace StuMgmClient -{ - class SystemData - { - static Dictionary allCourseInfo; - static Dictionary allCourseStatus; - - - internal static ErrCode InitSystemData() - { - ErrCode err; - err = InitCourseInfo(); - if (err != ErrCode.Success) - return err; - return ErrCode.Success; - } - static ErrCode InitCourseInfo() - { - ErrCode err; - List courseInfo; - err = SystemCtrl.GetCourseInfo(out courseInfo); - if (err != ErrCode.Success) - return err; - ...//将List转为Dictionary - return ErrCode.Success; - } - - internal static ErrCode RefreshUserCourseInfo(UserCourseInfo info) - { - ...//将UserCourseInfo转为Dictionary - return ErrCode.Success; - } - - - } -} diff --git a/StuMgmServer/Test/Test.csproj b/StuMgmServer/Test/Test.csproj deleted file mode 100644 index 00f25e9..0000000 --- a/StuMgmServer/Test/Test.csproj +++ /dev/null @@ -1,91 +0,0 @@ - - - - - Debug - AnyCPU - {E3D7C7F1-F922-4C6B-A44A-86F4DC73951A} - WinExe - Properties - Test - Test - v2.0 - 512 - - - AnyCPU - true - full - false - bin\Debug\ - DEBUG;TRACE - prompt - 4 - - - AnyCPU - pdbonly - true - bin\Release\ - TRACE - prompt - 4 - - - - - - - - - - - - - Form - - - Form1.cs - - - - - - - - Form1.cs - - - ResXFileCodeGenerator - Resources.Designer.cs - Designer - - - True - Resources.resx - - - SettingsSingleFileGenerator - Settings.Designer.cs - - - True - Settings.settings - True - - - - - {725c2786-699e-424f-8f3e-fb5bb4e5a3a5} - StuMgmLib - - - - - \ No newline at end of file