Browse Source

生成树 有bug

Client
WIN-G7N5C0B818G\Administrator 4 years ago
parent
commit
ac5d3f717e
16 changed files with 264 additions and 70 deletions
  1. +10
    -6
      StuMgmClient/Data.cs
  2. +17
    -12
      StuMgmClient/LoginForm.cs
  3. +12
    -2
      StuMgmClient/Properties/Resources.Designer.cs
  4. +10
    -3
      StuMgmClient/Properties/Resources.resx
  5. +1
    -1
      StuMgmClient/Properties/Settings.Designer.cs
  6. +1
    -2
      StuMgmClient/SelectFrom.designer.cs
  7. +26
    -3
      StuMgmClient/SelectFrom.resx
  8. +7
    -2
      StuMgmClient/StuMgmClient.csproj
  9. +6
    -0
      StuMgmClient/StuMgmClient.sln
  10. +5
    -6
      StuMgmClient/StudentForm.cs
  11. +3
    -3
      StuMgmClient/SystemComm.cs
  12. +29
    -22
      StuMgmClient/SystemCtrl.cs
  13. +23
    -4
      StuMgmClient/SystemData.cs
  14. +4
    -3
      StuMgmClient/Utility.cs
  15. +106
    -0
      StuMgmLib/MyNameSpace/CommonData.cs
  16. +4
    -1
      StuMgmLib/StuMgmLib.csproj

+ 10
- 6
StuMgmClient/Data.cs View File

@@ -7,7 +7,7 @@ using System.Data;
namespace StuMgmClient
{

enum ErrCode
public enum ErrCode
{
Success,
FailSerial,
@@ -18,7 +18,7 @@ namespace StuMgmClient
ErrData,
}

public enum FuncCode
public enum ClientFunc
{
VerifLogin = 1,
GetCourseInfo,
@@ -36,9 +36,9 @@ namespace StuMgmClient
[Serializable]
public class ClientRequest
{
public FuncCode Func;
public ClientFunc Func;
public object Object;
public ClientRequest(FuncCode func, object obj)
public ClientRequest(ClientFunc func, object obj)
{
Func = func;
Object = obj;
@@ -72,8 +72,12 @@ namespace StuMgmClient
[Serializable]
public enum CourseStatusEnum
{
lll,
...//
NoStart=0,
Begin,
WaitCheckig,
CheckigSuccess,
CheckigFail,
//
}

[Serializable]


+ 17
- 12
StuMgmClient/LoginForm.cs View File

@@ -1,5 +1,6 @@
using System;
using System.Windows.Forms;
using StuMgmLib.MyNameSpace;

namespace StuMgmClient
{
@@ -17,7 +18,7 @@ namespace StuMgmClient
if (SystemData.InitSystemData() != ErrCode.Success)
throw new Exception("初始化异常,请重新启动");
}
////账号密码正则校验
//public bool RegexUser(string u, string p)
//{
@@ -49,16 +50,16 @@ namespace StuMgmClient

private void btnSubmit_Click(object sender, EventArgs e)
{
Roles userRole;
string token;
if (VerifLogin(out userRole, out token) != ErrCode.Success)
LvErr userRole;
int token;
short job_id;
if (VerifLogin(out job_id, out userRole, out token) != ErrCode.Success)
return;

switch (userRole)
{
case Roles.Student:
ShowStudentForm(token);
case LvErr.Student:
ShowStudentForm(job_id, token);
break;
default:
MessageBox.Show(userRole.ToString());
@@ -66,18 +67,22 @@ namespace StuMgmClient
}
}

ErrCode VerifLogin(out Roles userRole, out string token)
ErrCode VerifLogin(out short job_id, out LvErr userRole, out int token)
{
ErrCode errcode = SystemCtrl.VerifLogin(txtUserName.Text, txtPassWord.Text, out userRole, out token);
job_id = 01943;
//ErrCode errcode = SystemCtrl.VerifLogin(txtUserName.Text, txtPassWord.Text, out userRole, out token);

ErrCode errcode = SystemCtrl.VerifLogin(job_id, "1", out userRole, out token);
if (errcode != ErrCode.Success)
MessageBox.Show(errcode.ToString());
job_id = 01943;
return errcode;
}
void ShowStudentForm(string token)
void ShowStudentForm(short job_id, int token)
{
this.Hide();
StudentForm stu = new StudentForm(token);
StudentForm stu = new StudentForm(job_id, token);
stu.ShowDialog();
this.Show();
}


+ 12
- 2
StuMgmClient/Properties/Resources.Designer.cs View File

@@ -8,7 +8,7 @@
// </auto-generated>
//------------------------------------------------------------------------------

namespace StuMgmClient.Properties {
namespace StuMgmLib.Properties {
using System;
@@ -39,7 +39,7 @@ namespace StuMgmClient.Properties {
internal static global::System.Resources.ResourceManager ResourceManager {
get {
if (object.ReferenceEquals(resourceMan, null)) {
global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("StuMgmClient.Properties.Resources", typeof(Resources).Assembly);
global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("StuMgmLib.Properties.Resources", typeof(Resources).Assembly);
resourceMan = temp;
}
return resourceMan;
@@ -59,5 +59,15 @@ namespace StuMgmClient.Properties {
resourceCulture = value;
}
}
/// <summary>
/// 查找 System.Drawing.Bitmap 类型的本地化资源。
/// </summary>
internal static System.Drawing.Bitmap 沙漏 {
get {
object obj = ResourceManager.GetObject("沙漏", resourceCulture);
return ((System.Drawing.Bitmap)(obj));
}
}
}
}

+ 10
- 3
StuMgmClient/Properties/Resources.resx View File

@@ -46,7 +46,7 @@
mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
: System.Serialization.Formatters.Binary.BinaryFormatter
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
@@ -60,6 +60,7 @@
: 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">
@@ -68,9 +69,10 @@
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" />
<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">
@@ -85,9 +87,10 @@
<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="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">
@@ -114,4 +117,8 @@
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<assembly alias="System.Windows.Forms" name="System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
<data name="沙漏" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\图片\沙漏.png;System.Drawing.Bitmap, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
</data>
</root>

+ 1
- 1
StuMgmClient/Properties/Settings.Designer.cs View File

@@ -8,7 +8,7 @@
// </auto-generated>
//------------------------------------------------------------------------------

namespace StuMgmClient.Properties {
namespace StuMgmLib.Properties {
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]


+ 1
- 2
StuMgmClient/SelectFrom.designer.cs View File

@@ -88,7 +88,6 @@
//
this.btnSumit.Anchor = System.Windows.Forms.AnchorStyles.None;
this.btnSumit.BackColor = System.Drawing.Color.Transparent;
// this.btnSumit.BackgroundImage = global::StuMgmClient.Properties.Resources.提交_01__1_;
this.btnSumit.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Stretch;
this.btnSumit.FlatAppearance.BorderColor = System.Drawing.Color.FromArgb(((int)(((byte)(0)))), ((int)(((byte)(0)))), ((int)(((byte)(0)))), ((int)(((byte)(0)))));
this.btnSumit.FlatAppearance.BorderSize = 0;
@@ -133,7 +132,7 @@
this.picTime.Anchor = System.Windows.Forms.AnchorStyles.None;
this.picTime.BackColor = System.Drawing.Color.Transparent;
this.picTime.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Stretch;
// this.picTime.Image = global::StuMgmClient.Properties.Resources.沙漏;
this.picTime.Image = ((System.Drawing.Image)(resources.GetObject("picTime.Image")));
this.picTime.Location = new System.Drawing.Point(59, 18);
this.picTime.Name = "picTime";
this.picTime.Size = new System.Drawing.Size(60, 53);


+ 26
- 3
StuMgmClient/SelectFrom.resx View File

@@ -112,12 +112,12 @@
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
<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=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<assembly alias="System.Drawing" name="System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
<assembly alias="System.Drawing" name="System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
<data name="tlpMisson.BackgroundImage" type="System.Drawing.Bitmap, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>
/9j/4AAQSkZJRgABAQEASABIAAD/2wBDAAgGBgcGBQgHBwcJCQgKDBQNDAsLDBkSEw8UHRofHh0aHBwg
@@ -294,6 +294,29 @@
6iigAooooAKbRRQAUUUUAOFLRRQAUUUUAFFFFABRRRQAUUUUAFFFFAFiMYRafRRQAUUUUAFNI4oooAZR
RRQAUUUUAFSCiigBKKKKACiiigAooooAKKKKACnUUUAPooooAbRRRQAUUUUAFFFFABRRRQAlT2x+ZhRR
QBZooooAKgmUDkd6KKAIqKKKACiiigApKKKACiiigAooooAKKKKACiiigAooooAmgctwanoooA//2Q==
</value>
</data>
<data name="picTime.Image" type="System.Drawing.Bitmap, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>
iVBORw0KGgoAAAANSUhEUgAAADAAAAAwCAYAAABXAvmHAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8
YQUAAAPsSURBVGhD7VhBaNRAFO1BBA8ePEgR226SLQoKBdGLeCmCgogHDxUE9SxCRUTQY09KEarWTtJS
tZ5UClYQrIpoD4JWL7XgRVC8KGpLazczu4rYxj/Jz+5PdtKtzWy3h33wsM77+/6fZCbzk4Y66qgCsux3
q2nzToPlulYDM3buAJa2NEDxA0BvNTFr53dieZWhMqg15Z3A8irDYG6PyqSG/NDSz7dheUuDac+2Gdd5
uyQYTBCziXBcK5kYIjk8oy93JtSaerx1WNbyAIZjxHwMh7VCLhGSw5OFo5QesmhiXp+ACtWdAIvsgXc4
rBWGnbtNcvh7AKX0MG3xmZhP47BWGI54RHIAxTGU0gPMnhSNmStwWCvA+1mpeO5lBvKbUEqP2Pr8azg/
DZS0wbD5e5LDw2E9yDju4ZK5mDdZ/hBKWtDkFDaDbyHMYdliFCU9aO6dy5Ym4E/iKUpaAOv/EvgukByd
KOmDLJok8EwndxylVJAtAvhx4Hzg7c5mWaEZZX2QBReLDxK9QSkRsh2p1AbA2ncivoxfQ0k/yu4CHGry
3QHlCEhDmNiIWeXFf4ccbSjrhzQPkpCkcEaoXjhoTLwVDl6YxGMa41PTslwUkKijLDEQruZdevyr7oB8
/MolAmM/wt+FjE+yqoCEyklIWo74IieytXt6fbgHWuy5DaB9iseGXNHiQ5hsbj8kn4wXE9JibreMa+3l
G1U6ksMmPukb1gKmw49AEVOxonzCnRiSMfJuqHRgAdqSy75RLQDJzymKCjlDNzb8n7bjEcrHKIatHOK9
e5EOn4HNe1PGhJ9mwolYjguvjGK87DcBh2XMikBdvJiE/uUshviAg+5GqGf63N04DH1VfkfCBaj+JKJN
XUB4fD7YAs0YhhRBY1RPGcPhp2lMUpw2mIOiEZJ+pAnhql9BuQw0Lqkwk+VO0DhJy84fRFkv4pvWYHwE
JSWisclX1rDFeRoLvIeSXoBx5JmfcfhelJSgsYtNoL3LWwP75S3G+h2p1Z/fhbIe+D0QLcgWt1BKRNIm
VgHPk5K/7r0Qb6WzjrsHpUTEH6OVALHfSjnEOA7rAVzxiyVz/se8KhpR0gbwfU1yeNuHvbUopQccTq9K
5m4Oh7XCsN1ROgGz71cGpfSQJywxr8oEwPclyeFlGD+FUnqAYdmnRWzSBlFbFuUhaGGhcuPCWHECej8t
BgkjE4Bu8wIZWz4Zn5Itd30CiwEMyyZg9ot98PcALIPnlSnkvy9Cot8YLJ+RqiyhwEx8pYa1pXjYOlho
wvIqI/6dcpWwA8urDGjU7igMasr/WlIWE0fhLtyHH/prtdaUHwjkVw4sr4469KGh4R83rROPP3Ze1gAA
AABJRU5ErkJggg==
</value>
</data>
<data name="panHead.BackgroundImage" type="System.Drawing.Bitmap, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">


+ 7
- 2
StuMgmClient/StuMgmClient.csproj View File

@@ -7,7 +7,7 @@
<ProjectGuid>{95FDEE92-6C6E-41F1-A1C3-2FCDB1413781}</ProjectGuid>
<OutputType>WinExe</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>StuMgmClient</RootNamespace>
<RootNamespace>StuMgmLib</RootNamespace>
<AssemblyName>StuMgmClient</AssemblyName>
<TargetFrameworkVersion>v2.0</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
@@ -58,7 +58,6 @@
<Compile Include="SystemComm.cs">
<SubType>Code</SubType>
</Compile>
<Compile Include="Data.cs" />
<Compile Include="SelectFrom.cs">
<SubType>Form</SubType>
</Compile>
@@ -130,6 +129,12 @@
<DesignTimeSharedInput>True</DesignTimeSharedInput>
</Compile>
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\StuMgmLib\StuMgmLib.csproj">
<Project>{34ad3363-1b1c-4f4a-898c-c1a1f215fddd}</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.


+ 6
- 0
StuMgmClient/StuMgmClient.sln View File

@@ -5,6 +5,8 @@ VisualStudioVersion = 12.0.30501.0
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "StuMgmClient", "StuMgmClient.csproj", "{95FDEE92-6C6E-41F1-A1C3-2FCDB1413781}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "StuMgmLib", "..\StuMgmLib\StuMgmLib.csproj", "{34AD3363-1B1C-4F4A-898C-C1A1F215FDDD}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
@@ -15,6 +17,10 @@ Global
{95FDEE92-6C6E-41F1-A1C3-2FCDB1413781}.Debug|Any CPU.Build.0 = Debug|Any CPU
{95FDEE92-6C6E-41F1-A1C3-2FCDB1413781}.Release|Any CPU.ActiveCfg = Release|Any CPU
{95FDEE92-6C6E-41F1-A1C3-2FCDB1413781}.Release|Any CPU.Build.0 = Release|Any CPU
{34AD3363-1B1C-4F4A-898C-C1A1F215FDDD}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{34AD3363-1B1C-4F4A-898C-C1A1F215FDDD}.Debug|Any CPU.Build.0 = Debug|Any CPU
{34AD3363-1B1C-4F4A-898C-C1A1F215FDDD}.Release|Any CPU.ActiveCfg = Release|Any CPU
{34AD3363-1B1C-4F4A-898C-C1A1F215FDDD}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE


+ 5
- 6
StuMgmClient/StudentForm.cs View File

@@ -1,21 +1,20 @@
using System;
using System.Windows.Forms;
using StuMgmLib.MyNameSpace;

namespace StuMgmClient
{
public partial class StudentForm : Form
{
string m_token;
public StudentForm(string token)
int m_token;
public StudentForm(short job_id, int token)
{
InitializeComponent();
m_token = token;
if (SystemCtrl.RefreshUserCourseInfo(token) != ErrCode.Success)
if (SystemCtrl.RefreshUserCourseInfo(job_id, token) != ErrCode.Success)
throw new Exception("获取用户信息异常,请重新启动");

}


void GetStudentData()
{


+ 3
- 3
StuMgmClient/SystemComm.cs View File

@@ -3,13 +3,14 @@ using System.Collections.Generic;
using System.Diagnostics;
using System.Net;
using System.Net.Sockets;
using StuMgmLib.MyNameSpace;

namespace StuMgmClient
{
class SystemComm
{
#region 基本函数
const int bufSize = 1024 * 1024;
const int bufSize = 65535;
static IPEndPoint m_ipEndpoint;
static Socket m_socket;
static byte[] m_buf;
@@ -66,8 +67,7 @@ namespace StuMgmClient
m_socket.Close();
}
#endregion

internal static ErrCode GetData(ClientRequest req,out object o)
internal static ErrCode GetData(ClientRequest req,out ServerResponse o)
{
o = null;



+ 29
- 22
StuMgmClient/SystemCtrl.cs View File

@@ -1,29 +1,32 @@
using System;
using System.Collections.Generic;
using System.Text;
using StuMgmClient;
using StuMgmLib.MyNameSpace;
using System.Diagnostics;

namespace StuMgmClient
{
class SystemCtrl
{
internal static ErrCode VerifLogin(string userName, string pawssword, out Roles role, out string token)
internal static ErrCode VerifLogin(short userName, string pawssword, out LvErr role, out int token)
{
role = Roles.Error;
token = string.Empty;
role = LvErr.Error;
token = 0;

UserInfo cs = new UserInfo(userName, pawssword);
ClientRequest req = new ClientRequest(FuncCode.VerifLogin, cs);
ClientRequest req = new ClientRequest(ClientFunc.VerifLogin, cs);

object o;
ServerResponse o = new ServerResponse(null);
ErrCode err = SystemComm.GetData(req, out o);
if (err != ErrCode.Success)
return err;

if (!(o is UserInfo))
return ErrCode.ErrData;
//if (!(o.Object is UserInfo))
// return ErrCode.ErrData;

role = ((UserInfo)o).UserRole;
token = ((UserInfo)o).Token;
role = o.Lev;
token = o.Token;
return ErrCode.Success;
}

@@ -31,26 +34,26 @@ namespace StuMgmClient
{
courseInfo = null;
//******
ClientRequest req = new ClientRequest(FuncCode.GetCourseInfo, null);
ClientRequest req = new ClientRequest(ClientFunc.GetCourseInfo, null);

object o;
ServerResponse o = new ServerResponse(null);
ErrCode err = SystemComm.GetData(req, out o);
if (err != ErrCode.Success)
return err;

if (!(o is List<CourseInfo>))
if (!(o.Object is List<CourseInfo>))
return ErrCode.ErrData;

courseInfo = (List<CourseInfo>)o;
//courseInfo = (List<CourseInfo>)o;
return ErrCode.Success;
}
internal static ErrCode RefreshUserCourseInfo(string token)
internal static ErrCode RefreshUserCourseInfo(short job_id, int token)
{
UserCourseInfo info;
ErrCode err;

err = GetUserCourseInfo(token, out info);
err = GetUserCourseInfo(job_id, token, out info);
if (err != ErrCode.Success)
return err;

@@ -60,21 +63,25 @@ namespace StuMgmClient

return ErrCode.Success;
}
static ErrCode GetUserCourseInfo(string token ,out UserCourseInfo info)
static ErrCode GetUserCourseInfo(short job_id, int token, out UserCourseInfo info)
{
info = null;
ClientRequest req = new ClientRequest(FuncCode.GetUserCourseInfo, token);
Dictionary<short, int> dic = new Dictionary<short, int>();
dic.Add(job_id, token);
ClientRequest req = new ClientRequest(ClientFunc.GetUserCourseInfo, dic);

object o;
ServerResponse o = new ServerResponse(null);
ErrCode err = SystemComm.GetData(req, out o);
if (err != ErrCode.Success)
return err;

if (!(o is UserCourseInfo))
if (!(o.Object is UserCourseInfo))
return ErrCode.ErrData;

info = (UserCourseInfo)o;

//info = (UserCourseInfo)o;
info = (UserCourseInfo)o.Object;
return ErrCode.Success;
}



+ 23
- 4
StuMgmClient/SystemData.cs View File

@@ -1,7 +1,7 @@
using System;
using System.Collections.Generic;
using System.Text;
using StuMgmLib.MyNameSpace;
namespace StuMgmClient
{
class SystemData
@@ -9,7 +9,6 @@ namespace StuMgmClient
static Dictionary<short, CourseInfo> allCourseInfo;
static Dictionary<short,CourseStatusEnum> allCourseStatus;


internal static ErrCode InitSystemData()
{
ErrCode err;
@@ -25,13 +24,33 @@ namespace StuMgmClient
err = SystemCtrl.GetCourseInfo(out courseInfo);
if (err != ErrCode.Success)
return err;
...//将List<CourseInfo>转为Dictionary<short, CourseInfo>
//将List<CourseInfo>转为Dictionary<short, CourseInfo>
//allCourseInfo = courseInfo.ToDictionary(key => key.Id, value => value);
return ErrCode.Success;
}

internal static ErrCode RefreshUserCourseInfo(UserCourseInfo info)
{
...//将UserCourseInfo转为Dictionary<short,CourseStatusEnum>
//将UserCourseInfo转为Dictionary<short,CourseStatusEnum>
int num = 0;
short oldTem = 0;
//切割字符串
string[] sArray = info.Details.Split(new char[2] { ':', ';' });
foreach (string i in sArray)
{
if (i.Equals("")) { break; }
short tem = Convert.ToInt16(i);
num++;
if (num % 2 != 0)
{
allCourseStatus.Add(tem, CourseStatusEnum.NoStart);
oldTem = tem;
}
else
{
allCourseStatus[oldTem] = (CourseStatusEnum)tem;
}
}
return ErrCode.Success;
}



+ 4
- 3
StuMgmClient/Utility.cs View File

@@ -1,4 +1,5 @@
using System;
using StuMgmLib.MyNameSpace;
using System;
using System.Diagnostics;
using System.IO;
using System.Runtime.Serialization.Formatters.Binary;
@@ -25,13 +26,13 @@ namespace StuMgmClient
}
}

internal static bool BinDeserialize(byte[] data, out object o)
internal static bool BinDeserialize(byte[] data, out ServerResponse o)
{
try
{
MemoryStream ms = new MemoryStream(data);
BinaryFormatter iFormatter = new BinaryFormatter();
o = iFormatter.Deserialize(ms);
o = (ServerResponse)iFormatter.Deserialize(ms);
return true;
}
catch (Exception e)


+ 106
- 0
StuMgmLib/MyNameSpace/CommonData.cs View File

@@ -0,0 +1,106 @@
using System;



namespace StuMgmLib.MyNameSpace
{

public enum ErrCode
{
Success,
FailSerial,
FailDeserial,
FailConnect,
FailSend,
FailReceive,
ErrData,
}

public enum ClientFunc
{
VerifLogin = 1,
GetCourseInfo,
GetUserCourseInfo,
}
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 short Account;
public string Password;
public Int16 Token;
public LvErr UserLev;
public UserInfo(short account, string password)
{
Account = account;
Password = password;
}
}
[Serializable]
public class CourseInfo
{
public short Id;
public short Pid;
public int Time;
public string Name;
public string Content;
}


[Serializable]
public enum CourseStatusEnum
{
NoStart = 0,
Begin,
WaitCheckig,
CheckigSuccess,
CheckigFail,
//
}

[Serializable]
public class UserCourseInfo
{
public short JobId;//工号
public string Name;//姓名
public string Details;//信息描述
}


[Serializable]
public class ServerResponse
{
public LvErr Lev;
public int Token;
public string CourseStatus;
public object Object;
public ServerResponse(object obj)
{
Object = obj;
}
}



}


+ 4
- 1
StuMgmLib/StuMgmLib.csproj View File

@@ -35,9 +35,12 @@
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
<Compile Include="MyNameSpace\CommonData.cs">
<SubType>Code</SubType>
</Compile>
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="MyNameSpace\StuMgmSer.cs" />
</ItemGroup>
<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.


Loading…
Cancel
Save