private void DeletedSignUp(SignUpInfo signUpInfo) { SignUpControl oneSignUpItem = null; for (int loop = 0; loop < signUpList.Children.Count; loop++) { if (signUpList.Children[loop].GetType().ToString() == "SignInApp.SignUpControl") { oneSignUpItem = signUpList.Children[loop] as SignUpControl; if (oneSignUpItem.mSignUpInfo.Id == signUpInfo.Id) { //删除 string outMessage = ""; string response = RESTClient.SignOut(signUpInfo.Id, ref outMessage); if (response == null || response == "") { if (outMessage == "") { outMessage = "删除签到失败,服务器错误"; } broder_back.Visibility = Visibility.Collapsed; _loading.Visibility = Visibility.Collapsed; WarningTipWindow tipDialog = new WarningTipWindow(outMessage); tipDialog.ShowDialog(); return; } try { JObject jResp = (JObject)JsonConvert.DeserializeObject(response); String status = (String)jResp.SelectToken("status", true); if (status != "success") { string message = (String)jResp.SelectToken("message", true); broder_back.Visibility = Visibility.Collapsed; _loading.Visibility = Visibility.Collapsed; WarningTipWindow tipDialog = new WarningTipWindow("删除签到失败:" + message); tipDialog.ShowDialog(); LogHelper.WriteWarnLog("删除签到失败:" + message); return; } LogHelper.WriteInfoLog("查询签到成功"); broder_back.Visibility = Visibility.Collapsed; _loading.Visibility = Visibility.Collapsed; signUpList.Children.RemoveAt(loop); return; } catch (Exception err) { broder_back.Visibility = Visibility.Collapsed; _loading.Visibility = Visibility.Collapsed; WarningTipWindow tipDialog = new WarningTipWindow("查询签到失败," + err.Message); tipDialog.ShowDialog(); return; } } } } }
public SignUpControl(int index, SignUpInfo signUpInfo) { InitializeComponent(); mSignUpInfo = signUpInfo; mSignUpInfo.Size18 = CommDef.Size18; mSignUpInfo.Size50 = CommDef.Size50; mSignUpInfo.Size60 = CommDef.Size60; mSignUpInfo.Size100 = CommDef.Size100; mSignUpInfo.Size200 = CommDef.Size200; int width = (int)SystemParameters.WorkArea.Width; this.Width = width - CommDef.Size380 - 24 - CommDef.Size24; this.DataContext = signUpInfo; }
private void QuerySignUp() { if (mClassCourse != null) { string outMessage = ""; string response = RESTClient.QuerySignUp(mClassCourse, ref outMessage); if (response == null || response == "") { if (outMessage == "") { outMessage = "查询签到失败,服务器错误"; } this.Dispatcher.Invoke(() => { broder_back.Visibility = Visibility.Collapsed; _loading.Visibility = Visibility.Collapsed; WarningTipWindow tipDialog = new WarningTipWindow(outMessage); tipDialog.ShowDialog(); }); LogHelper.WriteWarnLog(outMessage); return; } try { JObject jResp = (JObject)JsonConvert.DeserializeObject(response); String status = (String)jResp.SelectToken("status", true); if (status != "success") { string message = (String)jResp.SelectToken("message", true); this.Dispatcher.Invoke(() => { broder_back.Visibility = Visibility.Collapsed; _loading.Visibility = Visibility.Collapsed; WarningTipWindow tipDialog = new WarningTipWindow("查询签到失败:" + message); tipDialog.ShowDialog(); }); LogHelper.WriteWarnLog("查询签到失败:" + message); return; } JArray jArray = (JArray)jResp.SelectToken("data", true); LogHelper.WriteInfoLog("查询签到成功"); this.Dispatcher.Invoke(() => { broder_back.Visibility = Visibility.Collapsed; _loading.Visibility = Visibility.Collapsed; signUpList.Children.Clear(); int index = 0; foreach (var item in jArray) { JToken jToken = item; SignUpInfo signUpInfo = new SignUpInfo(); try { signUpInfo.Id = (String)jToken.SelectToken("id"); signUpInfo.StudentName = (String)jToken.SelectToken("studentName"); signUpInfo.CheckTime = (String)jToken.SelectToken("checkTime"); if ((String)jToken.SelectToken("inOut") == "1") { signUpInfo.Type = "上课"; } else { signUpInfo.Type = "下课"; } signUpInfo.IdCardNum = (String)jToken.SelectToken("idCardNum"); if ((String)jToken.SelectToken("sex") == "1") { signUpInfo.Sex = "男"; } else { signUpInfo.Sex = "女"; } signUpInfo.CourseName = (String)jToken.SelectToken("courseName"); SignUpControl signUpControl = new SignUpControl(index++, signUpInfo); signUpControl.DeletedSignUp += DeletedSignUp; signUpList.Children.Add(signUpControl); } catch (Exception err) { LogHelper.WriteWarnLog(err.Message); continue; } } }); return; } catch (Exception err) { this.Dispatcher.Invoke(() => { broder_back.Visibility = Visibility.Collapsed; _loading.Visibility = Visibility.Collapsed; WarningTipWindow tipDialog = new WarningTipWindow("查询签到失败," + err.Message); tipDialog.ShowDialog(); }); return; } } }