| @@ -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 | |||
| @@ -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 // 序列化与反序列化 | |||
| { | |||
| /// <summary> | |||
| /// 序列化 | |||
| /// </summary> | |||
| public static byte[] Serialize<T>(T c) | |||
| { | |||
| MemoryStream ms = new MemoryStream(); | |||
| BinaryFormatter iFormatter = new BinaryFormatter(); | |||
| iFormatter.Serialize(ms, c); | |||
| byte[] buf = ms.GetBuffer(); | |||
| return buf; | |||
| } | |||
| /// <summary> | |||
| /// 反序列化 | |||
| /// </summary> | |||
| public static T Deserialize<T>(byte[] buf) | |||
| { | |||
| MemoryStream ms = new MemoryStream(buf); | |||
| BinaryFormatter iFormatter = new BinaryFormatter(); | |||
| var obj = (T)iFormatter.Deserialize(ms); | |||
| return obj; | |||
| } | |||
| } | |||
| } | |||
| @@ -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 | |||
| } | |||
| } | |||
| @@ -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;//信息描述 | |||
| } | |||
| } | |||
| @@ -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 | |||
| { | |||
| /// <summary> | |||
| /// 数据操作 | |||
| /// </summary> | |||
| 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___________________________________________________| | |||
| * | |||
| */ | |||
| /// <summary> | |||
| /// 解析ClientSend | |||
| /// </summary> | |||
| 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; | |||
| } | |||
| /// <summary> | |||
| /// 登录验证,若失败,则返回错误码;若身份验证成功,则返回用户权限; | |||
| /// </summary> | |||
| 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(); | |||
| } | |||
| } | |||
| /// <summary> | |||
| /// 改 | |||
| /// </summary> | |||
| 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(); | |||
| } | |||
| } | |||
| /// <summary> | |||
| /// 查 将各表填入dataset | |||
| /// </summary> | |||
| 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(); | |||
| } | |||
| } | |||
| } | |||
| } | |||
| @@ -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; | |||
| } | |||
| } | |||
| } | |||
| @@ -13,6 +13,7 @@ namespace StuMgmLib.MyNameSpace | |||
| { | |||
| class SystemCtrl | |||
| { | |||
| #region 流 | |||
| /// <summary> | |||
| /// 序列化 | |||
| /// </summary> | |||
| @@ -35,6 +36,8 @@ namespace StuMgmLib.MyNameSpace | |||
| var obj = (T)iFormatter.Deserialize(ms); | |||
| return obj; | |||
| } | |||
| #endregion | |||
| /// <summary> | |||
| /// 获取返回数据 | |||
| @@ -43,48 +46,114 @@ namespace StuMgmLib.MyNameSpace | |||
| { | |||
| try | |||
| { | |||
| var cs = Deserialize<ClientRequest>(clientRequset); | |||
| var cr = Deserialize<ClientRequest>(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<short, int>)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<ServerResponse>(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<short, int> 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<CourseInfo> getCourseInfo() | |||
| @@ -184,8 +243,15 @@ namespace StuMgmLib.MyNameSpace | |||
| con.Close(); | |||
| } | |||
| } | |||
| #endregion | |||
| #region UserCourseInfo | |||
| const int statusColumn = 3; | |||
| const int detailsColumn = 4; | |||
| /// <summary> | |||
| /// 员工获取课程信息 | |||
| /// </summary> | |||
| static bool getUserCourseStatus(short jobId, out string status, out string details) | |||
| { | |||
| status = ""; | |||
| @@ -212,6 +278,73 @@ namespace StuMgmLib.MyNameSpace | |||
| } | |||
| } | |||
| #endregion | |||
| #region Update | |||
| #region Student | |||
| /// <summary> | |||
| /// 学员更改个人课程状态 | |||
| /// </summary> | |||
| 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 | |||
| } | |||
| @@ -1,40 +0,0 @@ | |||
| using System; | |||
| using System.Collections.Generic; | |||
| using System.Text; | |||
| namespace StuMgmLib.MyNameSpace | |||
| { | |||
| class SystemData | |||
| { | |||
| static Dictionary<short, CourseInfo> allCourseInfo; | |||
| static Dictionary<short,CourseStatusEnum> 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> courseInfo; | |||
| err = SystemCtrl.GetCourseInfo(out courseInfo); | |||
| if (err != CommErr.Success) | |||
| return err; | |||
| ...//将List<CourseInfo>转为Dictionary<short, CourseInfo> | |||
| return CommErr.Success; | |||
| } | |||
| internal static CommErr RefreshUserCourseInfo(UserCourseInfo info) | |||
| { | |||
| ...//将UserCourseInfo转为Dictionary<short,CourseStatusEnum> | |||
| return CommErr.Success; | |||
| } | |||
| } | |||
| } | |||
| @@ -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 | |||
| @@ -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<HistoryInfo> Describes; | |||
| } | |||
| #endregion | |||
| */ | |||
| //[Serializable] | |||
| //public class ServerSend | |||
| //{ | |||
| // public short permission { get; set; } | |||
| // public DataSet ds { get; set; } | |||
| //} | |||
| } | |||
| namespace StuMgmClient | |||
| { | |||
| //class Data | |||
| //{ | |||
| // //状态值字符串转字典 | |||
| // public Dictionary<int, int> StateParsing(DataTable table) | |||
| // { | |||
| // Dictionary<int, int> myDictionary = new Dictionary<int, int>(); | |||
| // 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<int, int> 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<int, int> 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<int, int> GetNodesDic(DataTable table) | |||
| // { | |||
| // Dictionary<int, int> nodesDic = new Dictionary<int, int>(); | |||
| // GetAllNodes("0", table, ref nodesDic); | |||
| // return nodesDic; | |||
| // } | |||
| //} | |||
| } | |||
| @@ -1,159 +0,0 @@ | |||
| namespace Test | |||
| { | |||
| partial class Form1 | |||
| { | |||
| /// <summary> | |||
| /// Required designer variable. | |||
| /// </summary> | |||
| private System.ComponentModel.IContainer components = null; | |||
| /// <summary> | |||
| /// Clean up any resources being used. | |||
| /// </summary> | |||
| /// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param> | |||
| protected override void Dispose(bool disposing) | |||
| { | |||
| if (disposing && (components != null)) | |||
| { | |||
| components.Dispose(); | |||
| } | |||
| base.Dispose(disposing); | |||
| } | |||
| #region Windows Form Designer generated code | |||
| /// <summary> | |||
| /// Required method for Designer support - do not modify | |||
| /// the contents of this method with the code editor. | |||
| /// </summary> | |||
| 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; | |||
| } | |||
| } | |||
| @@ -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<Info.ClientSend>(cs); | |||
| socket.Send(send); | |||
| byte[] recv = new byte[65535]; | |||
| socket.Receive(recv); | |||
| Info.ServerSend ss = BinaryED.Deserialize<Info.ServerSend>(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); | |||
| } | |||
| } | |||
| } | |||
| } | |||
| @@ -1,120 +0,0 @@ | |||
| <?xml version="1.0" encoding="utf-8"?> | |||
| <root> | |||
| <!-- | |||
| Microsoft ResX Schema | |||
| Version 2.0 | |||
| The primary goals of this format is to allow a simple XML format | |||
| that is mostly human readable. The generation and parsing of the | |||
| various data types are done through the TypeConverter classes | |||
| associated with the data types. | |||
| Example: | |||
| ... ado.net/XML headers & schema ... | |||
| <resheader name="resmimetype">text/microsoft-resx</resheader> | |||
| <resheader name="version">2.0</resheader> | |||
| <resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader> | |||
| <resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader> | |||
| <data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data> | |||
| <data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data> | |||
| <data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64"> | |||
| <value>[base64 mime encoded serialized .NET Framework object]</value> | |||
| </data> | |||
| <data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64"> | |||
| <value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value> | |||
| <comment>This is a comment</comment> | |||
| </data> | |||
| There are any number of "resheader" rows that contain simple | |||
| name/value pairs. | |||
| Each data row contains a name, and value. The row also contains a | |||
| type or mimetype. Type corresponds to a .NET class that support | |||
| text/value conversion through the TypeConverter architecture. | |||
| Classes that don't support this are serialized and stored with the | |||
| mimetype set. | |||
| The mimetype is used for serialized objects, and tells the | |||
| ResXResourceReader how to depersist the object. This is currently not | |||
| extensible. For a given mimetype the value must be set accordingly: | |||
| Note - application/x-microsoft.net.object.binary.base64 is the format | |||
| that the ResXResourceWriter will generate, however the reader can | |||
| read any of the formats listed below. | |||
| mimetype: application/x-microsoft.net.object.binary.base64 | |||
| value : The object must be serialized with | |||
| : System.Runtime.Serialization.Formatters.Binary.BinaryFormatter | |||
| : and then encoded with base64 encoding. | |||
| mimetype: application/x-microsoft.net.object.soap.base64 | |||
| value : The object must be serialized with | |||
| : System.Runtime.Serialization.Formatters.Soap.SoapFormatter | |||
| : and then encoded with base64 encoding. | |||
| mimetype: application/x-microsoft.net.object.bytearray.base64 | |||
| value : The object must be serialized into a byte array | |||
| : using a System.ComponentModel.TypeConverter | |||
| : and then encoded with base64 encoding. | |||
| --> | |||
| <xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata"> | |||
| <xsd:import namespace="http://www.w3.org/XML/1998/namespace" /> | |||
| <xsd:element name="root" msdata:IsDataSet="true"> | |||
| <xsd:complexType> | |||
| <xsd:choice maxOccurs="unbounded"> | |||
| <xsd:element name="metadata"> | |||
| <xsd:complexType> | |||
| <xsd:sequence> | |||
| <xsd:element name="value" type="xsd:string" minOccurs="0" /> | |||
| </xsd:sequence> | |||
| <xsd:attribute name="name" use="required" type="xsd:string" /> | |||
| <xsd:attribute name="type" type="xsd:string" /> | |||
| <xsd:attribute name="mimetype" type="xsd:string" /> | |||
| <xsd:attribute ref="xml:space" /> | |||
| </xsd:complexType> | |||
| </xsd:element> | |||
| <xsd:element name="assembly"> | |||
| <xsd:complexType> | |||
| <xsd:attribute name="alias" type="xsd:string" /> | |||
| <xsd:attribute name="name" type="xsd:string" /> | |||
| </xsd:complexType> | |||
| </xsd:element> | |||
| <xsd:element name="data"> | |||
| <xsd:complexType> | |||
| <xsd:sequence> | |||
| <xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" /> | |||
| <xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" /> | |||
| </xsd:sequence> | |||
| <xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" /> | |||
| <xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" /> | |||
| <xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" /> | |||
| <xsd:attribute ref="xml:space" /> | |||
| </xsd:complexType> | |||
| </xsd:element> | |||
| <xsd:element name="resheader"> | |||
| <xsd:complexType> | |||
| <xsd:sequence> | |||
| <xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" /> | |||
| </xsd:sequence> | |||
| <xsd:attribute name="name" type="xsd:string" use="required" /> | |||
| </xsd:complexType> | |||
| </xsd:element> | |||
| </xsd:choice> | |||
| </xsd:complexType> | |||
| </xsd:element> | |||
| </xsd:schema> | |||
| <resheader name="resmimetype"> | |||
| <value>text/microsoft-resx</value> | |||
| </resheader> | |||
| <resheader name="version"> | |||
| <value>2.0</value> | |||
| </resheader> | |||
| <resheader name="reader"> | |||
| <value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value> | |||
| </resheader> | |||
| <resheader name="writer"> | |||
| <value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value> | |||
| </resheader> | |||
| </root> | |||
| @@ -1,20 +0,0 @@ | |||
| using System; | |||
| using System.Collections.Generic; | |||
| using System.Windows.Forms; | |||
| namespace Test | |||
| { | |||
| static class Program | |||
| { | |||
| /// <summary> | |||
| /// 应用程序的主入口点。 | |||
| /// </summary> | |||
| [STAThread] | |||
| static void Main() | |||
| { | |||
| Application.EnableVisualStyles(); | |||
| Application.SetCompatibleTextRenderingDefault(false); | |||
| Application.Run(new Form1()); | |||
| } | |||
| } | |||
| } | |||
| @@ -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")] | |||
| @@ -1,71 +0,0 @@ | |||
| //------------------------------------------------------------------------------ | |||
| // <auto-generated> | |||
| // 此代码由工具生成。 | |||
| // 运行时版本: 4.0.30319.42000 | |||
| // | |||
| // 对此文件的更改可能会导致不正确的行为,并且如果 | |||
| // 重新生成代码,这些更改将丢失。 | |||
| // </auto-generated> | |||
| //------------------------------------------------------------------------------ | |||
| namespace Test.Properties | |||
| { | |||
| /// <summary> | |||
| /// 一个强类型的资源类,用于查找本地化的字符串等。 | |||
| /// </summary> | |||
| // 此类是由 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() | |||
| { | |||
| } | |||
| /// <summary> | |||
| /// 返回此类使用的、缓存的 ResourceManager 实例。 | |||
| /// </summary> | |||
| [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; | |||
| } | |||
| } | |||
| /// <summary> | |||
| /// 为所有资源查找重写当前线程的 CurrentUICulture 属性, | |||
| /// 方法是使用此强类型资源类。 | |||
| /// </summary> | |||
| [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] | |||
| internal static global::System.Globalization.CultureInfo Culture | |||
| { | |||
| get | |||
| { | |||
| return resourceCulture; | |||
| } | |||
| set | |||
| { | |||
| resourceCulture = value; | |||
| } | |||
| } | |||
| } | |||
| } | |||
| @@ -1,117 +0,0 @@ | |||
| <?xml version="1.0" encoding="utf-8"?> | |||
| <root> | |||
| <!-- | |||
| Microsoft ResX Schema | |||
| Version 2.0 | |||
| The primary goals of this format is to allow a simple XML format | |||
| that is mostly human readable. The generation and parsing of the | |||
| various data types are done through the TypeConverter classes | |||
| associated with the data types. | |||
| Example: | |||
| ... ado.net/XML headers & schema ... | |||
| <resheader name="resmimetype">text/microsoft-resx</resheader> | |||
| <resheader name="version">2.0</resheader> | |||
| <resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader> | |||
| <resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader> | |||
| <data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data> | |||
| <data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data> | |||
| <data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64"> | |||
| <value>[base64 mime encoded serialized .NET Framework object]</value> | |||
| </data> | |||
| <data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64"> | |||
| <value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value> | |||
| <comment>This is a comment</comment> | |||
| </data> | |||
| There are any number of "resheader" rows that contain simple | |||
| name/value pairs. | |||
| Each data row contains a name, and value. The row also contains a | |||
| type or mimetype. Type corresponds to a .NET class that support | |||
| text/value conversion through the TypeConverter architecture. | |||
| Classes that don't support this are serialized and stored with the | |||
| mimetype set. | |||
| The mimetype is used for serialized objects, and tells the | |||
| ResXResourceReader how to depersist the object. This is currently not | |||
| extensible. For a given mimetype the value must be set accordingly: | |||
| Note - application/x-microsoft.net.object.binary.base64 is the format | |||
| that the ResXResourceWriter will generate, however the reader can | |||
| read any of the formats listed below. | |||
| mimetype: application/x-microsoft.net.object.binary.base64 | |||
| value : The object must be serialized with | |||
| : System.Serialization.Formatters.Binary.BinaryFormatter | |||
| : and then encoded with base64 encoding. | |||
| mimetype: application/x-microsoft.net.object.soap.base64 | |||
| value : The object must be serialized with | |||
| : System.Runtime.Serialization.Formatters.Soap.SoapFormatter | |||
| : and then encoded with base64 encoding. | |||
| mimetype: application/x-microsoft.net.object.bytearray.base64 | |||
| value : The object must be serialized into a byte array | |||
| : using a System.ComponentModel.TypeConverter | |||
| : and then encoded with base64 encoding. | |||
| --> | |||
| <xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata"> | |||
| <xsd:element name="root" msdata:IsDataSet="true"> | |||
| <xsd:complexType> | |||
| <xsd:choice maxOccurs="unbounded"> | |||
| <xsd:element name="metadata"> | |||
| <xsd:complexType> | |||
| <xsd:sequence> | |||
| <xsd:element name="value" type="xsd:string" minOccurs="0" /> | |||
| </xsd:sequence> | |||
| <xsd:attribute name="name" type="xsd:string" /> | |||
| <xsd:attribute name="type" type="xsd:string" /> | |||
| <xsd:attribute name="mimetype" type="xsd:string" /> | |||
| </xsd:complexType> | |||
| </xsd:element> | |||
| <xsd:element name="assembly"> | |||
| <xsd:complexType> | |||
| <xsd:attribute name="alias" type="xsd:string" /> | |||
| <xsd:attribute name="name" type="xsd:string" /> | |||
| </xsd:complexType> | |||
| </xsd:element> | |||
| <xsd:element name="data"> | |||
| <xsd:complexType> | |||
| <xsd:sequence> | |||
| <xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" /> | |||
| <xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" /> | |||
| </xsd:sequence> | |||
| <xsd:attribute name="name" type="xsd:string" msdata:Ordinal="1" /> | |||
| <xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" /> | |||
| <xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" /> | |||
| </xsd:complexType> | |||
| </xsd:element> | |||
| <xsd:element name="resheader"> | |||
| <xsd:complexType> | |||
| <xsd:sequence> | |||
| <xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" /> | |||
| </xsd:sequence> | |||
| <xsd:attribute name="name" type="xsd:string" use="required" /> | |||
| </xsd:complexType> | |||
| </xsd:element> | |||
| </xsd:choice> | |||
| </xsd:complexType> | |||
| </xsd:element> | |||
| </xsd:schema> | |||
| <resheader name="resmimetype"> | |||
| <value>text/microsoft-resx</value> | |||
| </resheader> | |||
| <resheader name="version"> | |||
| <value>2.0</value> | |||
| </resheader> | |||
| <resheader name="reader"> | |||
| <value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value> | |||
| </resheader> | |||
| <resheader name="writer"> | |||
| <value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value> | |||
| </resheader> | |||
| </root> | |||
| @@ -1,30 +0,0 @@ | |||
| //------------------------------------------------------------------------------ | |||
| // <auto-generated> | |||
| // 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. | |||
| // </auto-generated> | |||
| //------------------------------------------------------------------------------ | |||
| 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; | |||
| } | |||
| } | |||
| } | |||
| } | |||
| @@ -1,7 +0,0 @@ | |||
| <?xml version='1.0' encoding='utf-8'?> | |||
| <SettingsFile xmlns="http://schemas.microsoft.com/VisualStudio/2004/01/settings" CurrentProfile="(Default)"> | |||
| <Profiles> | |||
| <Profile Name="(Default)" /> | |||
| </Profiles> | |||
| <Settings /> | |||
| </SettingsFile> | |||
| @@ -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; | |||
| } | |||
| } | |||
| } | |||
| @@ -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) | |||
| { | |||
| 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<CourseInfo>)) | |||
| return ErrCode.ErrData; | |||
| courseInfo = (List<CourseInfo>)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; | |||
| } | |||
| } | |||
| } | |||
| @@ -1,40 +0,0 @@ | |||
| using System; | |||
| using System.Collections.Generic; | |||
| using System.Text; | |||
| namespace StuMgmClient | |||
| { | |||
| class SystemData | |||
| { | |||
| static Dictionary<short, CourseInfo> allCourseInfo; | |||
| static Dictionary<short,CourseStatusEnum> 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> courseInfo; | |||
| err = SystemCtrl.GetCourseInfo(out courseInfo); | |||
| if (err != ErrCode.Success) | |||
| return err; | |||
| ...//将List<CourseInfo>转为Dictionary<short, CourseInfo> | |||
| return ErrCode.Success; | |||
| } | |||
| internal static ErrCode RefreshUserCourseInfo(UserCourseInfo info) | |||
| { | |||
| ...//将UserCourseInfo转为Dictionary<short,CourseStatusEnum> | |||
| return ErrCode.Success; | |||
| } | |||
| } | |||
| } | |||
| @@ -1,91 +0,0 @@ | |||
| <?xml version="1.0" encoding="utf-8"?> | |||
| <Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> | |||
| <Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" /> | |||
| <PropertyGroup> | |||
| <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> | |||
| <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform> | |||
| <ProjectGuid>{E3D7C7F1-F922-4C6B-A44A-86F4DC73951A}</ProjectGuid> | |||
| <OutputType>WinExe</OutputType> | |||
| <AppDesignerFolder>Properties</AppDesignerFolder> | |||
| <RootNamespace>Test</RootNamespace> | |||
| <AssemblyName>Test</AssemblyName> | |||
| <TargetFrameworkVersion>v2.0</TargetFrameworkVersion> | |||
| <FileAlignment>512</FileAlignment> | |||
| </PropertyGroup> | |||
| <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "> | |||
| <PlatformTarget>AnyCPU</PlatformTarget> | |||
| <DebugSymbols>true</DebugSymbols> | |||
| <DebugType>full</DebugType> | |||
| <Optimize>false</Optimize> | |||
| <OutputPath>bin\Debug\</OutputPath> | |||
| <DefineConstants>DEBUG;TRACE</DefineConstants> | |||
| <ErrorReport>prompt</ErrorReport> | |||
| <WarningLevel>4</WarningLevel> | |||
| </PropertyGroup> | |||
| <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' "> | |||
| <PlatformTarget>AnyCPU</PlatformTarget> | |||
| <DebugType>pdbonly</DebugType> | |||
| <Optimize>true</Optimize> | |||
| <OutputPath>bin\Release\</OutputPath> | |||
| <DefineConstants>TRACE</DefineConstants> | |||
| <ErrorReport>prompt</ErrorReport> | |||
| <WarningLevel>4</WarningLevel> | |||
| </PropertyGroup> | |||
| <ItemGroup> | |||
| <Reference Include="System" /> | |||
| <Reference Include="System.Data" /> | |||
| <Reference Include="System.Deployment" /> | |||
| <Reference Include="System.Drawing" /> | |||
| <Reference Include="System.Windows.Forms" /> | |||
| <Reference Include="System.Xml" /> | |||
| </ItemGroup> | |||
| <ItemGroup> | |||
| <Compile Include="Data.cs" /> | |||
| <Compile Include="Form1.cs"> | |||
| <SubType>Form</SubType> | |||
| </Compile> | |||
| <Compile Include="Form1.Designer.cs"> | |||
| <DependentUpon>Form1.cs</DependentUpon> | |||
| </Compile> | |||
| <Compile Include="Program.cs" /> | |||
| <Compile Include="Properties\AssemblyInfo.cs" /> | |||
| <Compile Include="SystemComm.cs" /> | |||
| <Compile Include="SystemCtrl.cs" /> | |||
| <Compile Include="SystemData.cs" /> | |||
| <EmbeddedResource Include="Form1.resx"> | |||
| <DependentUpon>Form1.cs</DependentUpon> | |||
| </EmbeddedResource> | |||
| <EmbeddedResource Include="Properties\Resources.resx"> | |||
| <Generator>ResXFileCodeGenerator</Generator> | |||
| <LastGenOutput>Resources.Designer.cs</LastGenOutput> | |||
| <SubType>Designer</SubType> | |||
| </EmbeddedResource> | |||
| <Compile Include="Properties\Resources.Designer.cs"> | |||
| <AutoGen>True</AutoGen> | |||
| <DependentUpon>Resources.resx</DependentUpon> | |||
| </Compile> | |||
| <None Include="Properties\Settings.settings"> | |||
| <Generator>SettingsSingleFileGenerator</Generator> | |||
| <LastGenOutput>Settings.Designer.cs</LastGenOutput> | |||
| </None> | |||
| <Compile Include="Properties\Settings.Designer.cs"> | |||
| <AutoGen>True</AutoGen> | |||
| <DependentUpon>Settings.settings</DependentUpon> | |||
| <DesignTimeSharedInput>True</DesignTimeSharedInput> | |||
| </Compile> | |||
| </ItemGroup> | |||
| <ItemGroup> | |||
| <ProjectReference Include="..\StuMgmLib\StuMgmLib.csproj"> | |||
| <Project>{725c2786-699e-424f-8f3e-fb5bb4e5a3a5}</Project> | |||
| <Name>StuMgmLib</Name> | |||
| </ProjectReference> | |||
| </ItemGroup> | |||
| <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" /> | |||
| <!-- To modify your build process, add your task inside one of the targets below and uncomment it. | |||
| Other similar extension points exist, see Microsoft.Common.targets. | |||
| <Target Name="BeforeBuild"> | |||
| </Target> | |||
| <Target Name="AfterBuild"> | |||
| </Target> | |||
| --> | |||
| </Project> | |||