12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001 |
- using Common.system;
- using Newtonsoft.Json;
- using System;
- using System.Collections.Generic;
- using System.Collections.ObjectModel;
- using System.IO;
- using System.Linq;
- using System.Text;
- using System.Threading;
- using System.Windows;
- using System.Windows.Input;
- using System.Windows.Threading;
- using XHZB.Desktop.Utils;
- using XHZB.Desktop.WebSocket;
- using XHZB.Model;
-
- namespace XHZB.Desktop
- {
- /// <summary>
- /// 点名抢答
- /// </summary>
- public partial class RollCallWindow : Window/*, ZSocketCallback*/
- {
- #region 值初始化
-
- /// <summary>
- /// 服务返回 0成功
- /// </summary>
- private readonly int serverReturnCode = 0;
-
- internal RollCallPageData pageData = new RollCallPageData();
- private readonly RegisterController registerController = new RegisterController();
- internal string backgroundOpacity = "0.5";
- private readonly Random rd = new Random();
- private readonly int[] iArrty = new int[3] { 201314, 201314, 201314 };
- private static string userids = string.Empty;
- private static string useridss = string.Empty;
- private static string useridsss = string.Empty;
-
- private static int ranNum = 201314;
- private readonly int[] iArray = new int[1];
-
- private static int returnNum = 0;
- //private bool isSjdm = false;
- internal double pwidth = SystemParameters.PrimaryScreenWidth;
-
- internal double pHeight = SystemParameters.PrimaryScreenHeight;
- private RollCallPerfectionWindow rollCallPerfectionWindow;
-
- /// <summary>
- /// 随机点名
- /// </summary>
- private bool isRollCall = false;
-
- /// <summary>
- /// 抢答
- /// </summary>
- private bool isRushToAnswer = false;
-
- public string BackgroundOpacity
- {
- get => backgroundOpacity;
- set => backgroundOpacity = value;
- }
- /// <summary>
- /// 随机几率 1高 2中 3低
- /// </summary>
- string flag = "1";
- int rNum = 999;
- #endregion 值初始化
-
- /// <summary>
- /// 课堂点名
- /// </summary>
- public RollCallWindow()
- {
- InitializeComponent();
- WindowStartupLocation = WindowStartupLocation.CenterScreen;
- if (!File.Exists(APP.dataPath + "randomProbability.txt")) //若为空
- {
- flag = "1";
- }
- else
- {
- flag = System.IO.File.ReadAllText(APP.dataPath + "randomProbability.txt", Encoding.Default);
- }
- Initialize();
-
- //ZSocketServer.getInstance().addWin(this);
- }
-
- /// <summary>
- /// 初始化
- /// </summary>
- public void Initialize()
- {
- userids = string.Empty;
- useridss = string.Empty;
- useridsss = string.Empty;
- returnNum = 0;
- rNum = 999;
- APP.RollCallList = new System.Collections.Generic.List<RollCallModel>();
-
- imgRandomRollCall.Visibility = Visibility.Visible;
- imgRandomRollCallTwo.Visibility = Visibility.Collapsed;
- imgAnswer.Visibility = Visibility.Visible;
- imgAnswerTwo.Visibility = Visibility.Collapsed;
-
- stpAnswer.Visibility = Visibility.Collapsed;
- //ToolbarWindow.IsNotOperation = true;
- IsRandomRollCallButton = false;
- //初始化配置文件
- //ZJConfigUtil.init();
- initPageData();
- //ZSocketServer.getInstance().addWin(this);
- }
- public void userListChange()
- {
- Console.WriteLine("本节考勤-渲染用户列表");
- Dispatcher.BeginInvoke(DispatcherPriority.Normal,
- new Action(() =>
- {
- receiveWsMsg(null);
- }));
- }
- public void receiveWsMsg(ZWsMsgVo msg)
- {
- if (!isRollCall && !isRushToAnswer)
- {
- initPageData();
- }
- if (msg != null && msg.type == 402 && isRushToAnswer && msg.body.asktid == APP.askid)
- {
- Console.WriteLine(msg);
-
-
- #region 去重
- for (int i = 0; i < pageData.userList.Count; i++)
- {
- if (msg.body.userid.ToString().Equals(pageData.userList[i].ID))
- {
- return;
- }
- }
- #endregion
-
- //Askstudent askstudent = new Askstudent
- //{
- // roomid = ZCommonData.roomid,
- // studentid = msg.body.userid
- //};
-
- //askstudent.asktid = ZCommonData.askid;
- //askstudent.schoolid = ZCommonData.loginUser.schoolid;
- //askstudent.createtime = DataProvider.TimestampTotalSeconds();
- //askstudent.studentselected = 0;
- //askstudent.radiocorrect = 0;
- //askstudent.classid = msg.body.classid;
- //ZSqliteManger.insertClassData(new ClassData()
- //{
- // unix = DataProvider.TimestampTotalSeconds(),
- // roomid = ZCommonData.roomid,
- // api = "askstudent",
- // json = ZJsonHelper.ToJson(askstudent),
- // askid = ZCommonData.askid
- //});
-
- System.Collections.Generic.List<RollCallModel> callList = APP.RollCallList;
- bool isUserid = true;
- //if (TeachingDataStatic.RollCallStatisticsList.Count > 0)//统计抢答
- //{
- // for (int i = 0; i < TeachingDataStatic.RollCallStatisticsList.Count; i++)
- // {
- // if (TeachingDataStatic.RollCallStatisticsList[i].userid == msg.body.userid)
- // {
- // TeachingDataStatic.RollCallStatisticsList[i].replies += 1;
- // isUserid = false;
- // break;
- // }
- // }
- //}
-
- if (isUserid)
- {//统计
- //Shared.TeachingData.rollCall = new RollCall
- //{
- // usertype = msg.usertype,
- // userid = msg.body.userid,
- // username = msg.body.username,
- // userpic = msg.body.userpic,
- // replies = 1
- //};
- //TeachingDataStatic.RollCallStatisticsList.Add(Shared.TeachingData.rollCall);
- //Shared.TeachingData.rollCall = new RollCall();
- }
-
- Dispatcher.Invoke(DispatcherPriority.Normal,
- new Action(() =>
- {
- try
- {
- if (pageData.userList.Count > 0)
- {
- if (pageData.userList[pageData.userList.Count - 1].askid != msg.body.asktid)
- {
- pageData.userList.Clear();
- }
- }
- }
- catch (Exception ex)
- {
- LogHelper.WriteErrLog("【抢答】(receiveWsMsg)socket移除askid不一致用户," + ex.Message, ex);
- }
-
- //renderView();
- returnNum++;
- if (returnNum <= 18)
- {
- string medal = "../Images/RollCall/02log-1.png";
- string attendance = "../Images/RollCall/attendance_3.png";
- if (returnNum == 1)
- {
- medal = "../Images/RollCall/rollCall_7.png";
- attendance = "../Images/RollCall/attendance_33.png";
- }
- else if (returnNum == 2)
- {
- medal = "../Images/RollCall/rollCall_5.png";
- attendance = "../Images/RollCall/attendance_33.png";
- }
- else if (returnNum == 3)
- {
- medal = "../Images/RollCall/rollCall_6.png";
- attendance = "../Images/RollCall/attendance_33.png";
- }
- string userpic = msg.body.userpic;
- if (ZCache.headDic.ContainsKey(userpic.Replace("/", "")))
- {
- userpic = ZCache.headDic[userpic.Replace("/", "")];
- }
- else
- {
- userpic = "../Images/RollCall/attendance_1.png";
- }
- pageData.userList.Add(new RollCallPageData()
- {
- Name = msg.body.username,
- Attendance_33 = "Collapsed",
- Attendance_3 = "Visible",
- Pic = userpic,
- ID = msg.body.userid.ToString(),
- Attendance = attendance,
- Medal = medal,
- askid = msg.body.asktid
-
- });
- stpAnswer.Visibility = Visibility.Visible;
- }
- txbNumberOfReplies.Text = returnNum.ToString();
- }));
- }
- }
-
-
- System.Collections.Generic.List<OnlineUserModel> raduser = new System.Collections.Generic.List<OnlineUserModel>();
- System.Collections.Generic.List<OnlineUserModel> userListNew = new System.Collections.Generic.List<OnlineUserModel>();
- private void initPageData()
- {
- Dispatcher.Invoke(DispatcherPriority.Normal,
- new Action(() =>
- {
- if (pageData.userList.Count > 0)
- {
- pageData.userList.Clear();
- }
- List<OnlineUserModel> userList = APP.OnlineUserList;
- userListNew = new List<OnlineUserModel>();
- string userlistStr = JsonHelper.ToJson(userList);
- userListNew = JsonToList<OnlineUserModel>(userlistStr);
- List<ClassStudentListModel> classStudentList = APP.ClassStudentList;
-
-
- for (int i = 0; i < classStudentList.Count; i++)
- {
- classStudentList[i].status = 0;
- for (int j = 0; j < userListNew.Count; j++)
- {
- if (classStudentList[i].studentid == userListNew[j].userid)
- {
- userListNew[j].num = classStudentList[i].num;
- }
- }
- }
- if (userListNew.Count > 0)
- {
- //OrderbyDescending 倒叙 OrderBy 顺序
- raduser = userListNew.OrderBy(x => x.num).ToList();
- }
-
- foreach (OnlineUserModel user in userListNew)
- {
- string userpic = user.userpic;
- if (ZCache.headDic.ContainsKey(userpic.Replace("/", "")))
- {
- userpic = ZCache.headDic[userpic.Replace("/", "")];
- }
- else
- {
- userpic = "../Images/RollCall/attendance_1.png";
- }
-
- pageData.userList.Add(new RollCallPageData()
- {
- Name = user.username,
- Attendance_33 = "Collapsed",
- Attendance_3 = "Visible",
- Pic = userpic,
- ID = user.userid.ToString(),
- Attendance = "../Images/RollCall/attendance_3.png"
- });
- foreach (ClassStudentListModel cl in classStudentList)
- {
- if (cl.studentid == user.userid)
- {
- cl.status = 1;
- }
- }
- }
- string notOnline = string.Empty;
- foreach (ClassStudentListModel cl in classStudentList)
- {
- if (cl.status == 0)
- {
- notOnline += cl.studentname + " ";
- }
- }
- if (!string.IsNullOrWhiteSpace(notOnline))
- {
- txbNotOnline.Text = notOnline;
- }
- else
- {
- txbNotOnline.Text = "暂无";
- }
- toolbar_list.DataContext = pageData;
- }));
- }
- internal static List<T> JsonToList<T>(string respstr)
- {
- JsonSerializer serializer = new JsonSerializer();
- StringReader sr = new StringReader(respstr);
- object o = serializer.Deserialize(new JsonTextReader(sr), typeof(List<T>));
- List<T> list = o as List<T>;
- return list;
- }
- /// <summary>
- /// 是否已经按下按钮
- /// </summary>
- public bool IsRandomRollCallButton = false;
- /// <summary>
- /// 随机点名
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void btnRandomRollCall_Click(object sender, RoutedEventArgs e)
- {
-
-
-
-
-
-
- if (!IsRandomRollCallButton)
- {
- IsRandomRollCallButton = true;
- userids = string.Empty;
- useridss = string.Empty;
- useridsss = string.Empty;
- returnNum = 0;
- APP.RollCallList = new System.Collections.Generic.List<Model.RollCallModel>();
- stpAnswer.Visibility = Visibility.Collapsed;
-
- imgRandomRollCall.Visibility = Visibility.Collapsed;
- imgRandomRollCallTwo.Visibility = Visibility.Visible;
- imgAnswer.Visibility = Visibility.Visible;
- imgAnswerTwo.Visibility = Visibility.Collapsed;
-
- initPageData();
- if (isRushToAnswer)//如果抢答没有结束 先结束抢答
- {
- //ZSocketServer.getInstance().SendMessage(ZSocketMsgManger.qiangdaEnd());
- isRushToAnswer = false;
- }
- if (APP.OnlineUserList.Count > 0)//判断当前在线人数大于0 点击才有效 ceshi=
- {
- isRollCall = true;
- Thread.Sleep(500);
- APP.BackgroundWorkerHelper.RunWorkerAsync(InvokeRandomRollCallServering, InvokeRandomRollCallServerCompate);
- }
- else
- {
- IsRandomRollCallButton = false;
- }
- }
- }
-
- /// <summary>
- /// 点名抽奖效果
- /// </summary>
- /// <returns></returns>
- private object InvokeRandomRollCallServering()
- {
- try
- {
- if (ranNum != 201314 && ranNum != 0)
- {
- if (ranNum < pageData.userList.Count)
- {
- pageData.userList[ranNum].Attendance_33 = "Collapsed";
- pageData.userList[ranNum].Attendance_3 = "Visible";
- Thread.Sleep(500);
- }
- }
- int randomTimes = 0;//随机次数
- ranNum = 0;//随机到用户的下标
- if (pageData.userList.Count == 1)//当前在线1人直接选中
- {
- pageData.userList[0].Attendance_33 = "Collapsed";
- pageData.userList[0].Attendance_3 = "Visible";
- Thread.Sleep(500);
- pageData.userList[0].Attendance_33 = "Visible";
- pageData.userList[0].Attendance_3 = "Collapsed";
- }
- else
- {
- randomTimes = 10;
-
-
-
- //if (TeachingDataStatic.OnlineUserList.Count > 0)
- //{
- // //OrderbyDescending 倒叙 OrderBy 顺序
- // raduser = raduser.OrderBy(x => x.num).ToList();
- //}
-
- int ranNumberOfPeople = 999;
- if ("1".Equals(flag) && raduser.Count > 5)
- {
-
-
- do
- {
- long tick = DateTime.Now.Ticks;
- Random ran = new Random((int)(tick & 0xffffffffL) | (int)(tick >> 32));
- ranNumberOfPeople = ran.Next(5);
-
-
- for (int i = 0; i < userListNew.Count; i++)
- {
- if (userListNew[i].userid == raduser[ranNumberOfPeople].userid)
- {
- ranNumberOfPeople = i;
- break;
- }
- }
- } while (ranNumberOfPeople == rNum);
-
-
- raduser[ranNumberOfPeople].num += 1;
- }
- else if ("2".Equals(flag) && raduser.Count > 15)
- {
- do
- {
- long tick = DateTime.Now.Ticks;
- Random ran = new Random((int)(tick & 0xffffffffL) | (int)(tick >> 32));
- ranNumberOfPeople = ran.Next(15);
-
- for (int i = 0; i < userListNew.Count; i++)
- {
- if (userListNew[i].userid == raduser[ranNumberOfPeople].userid)
- {
- ranNumberOfPeople = i;
- break;
- }
- }
- } while (ranNumberOfPeople == rNum);
- raduser[ranNumberOfPeople].num += 1;
- }
- else if (raduser.Count > 30)
- {
- do
- {
- long tick = DateTime.Now.Ticks;
- Random ran = new Random((int)(tick & 0xffffffffL) | (int)(tick >> 32));
- ranNumberOfPeople = ran.Next(30);
-
- for (int i = 0; i < userListNew.Count; i++)
- {
- if (userListNew[i].userid == raduser[ranNumberOfPeople].userid)
- {
- ranNumberOfPeople = i;
- break;
- }
- }
- raduser[ranNumberOfPeople].num += 1;
- } while (ranNumberOfPeople == rNum);
- }
- else
- {
- ranNumberOfPeople = 999;
- }
-
-
- //if (APP.outputInforLog)
- //{
- // LogHelper.WriteInfoLog("ranNum:" + TeachingDataStatic.OnlineUserList[ranNum].username + "&" + raduser[0].username + raduser[1].username + raduser[2].username + raduser[3].username + raduser[4].username + raduser[5].username);
- //}
-
-
-
-
-
-
-
- int ranNums = 0;//记录上一次随机的下标
- for (int i = 0; i < randomTimes; i++)
- {
- Thread.Sleep(200);
- if (i > 0)
- {
-
- pageData.userList[ranNum].Attendance_33 = "Collapsed";
- pageData.userList[ranNum].Attendance_3 = "Visible";
-
- }
- while (ranNums == ranNum)//保证这次随机的下标和上次不相同
- {
- long tick = DateTime.Now.Ticks;
- Random ran = new Random((int)(tick & 0xffffffffL) | (int)(tick >> 32));
- ranNum = ran.Next(pageData.userList.Count);
- if (i == 9 && ranNumberOfPeople != 999)
- {
- ranNum = ranNumberOfPeople;
- break;
- }
- if (pageData.userList.Count < 3)
- {
- break;
- }
- }
- ranNums = ranNum;
- rNum = ranNum;
- pageData.userList[ranNum].Attendance_33 = "Visible";
- pageData.userList[ranNum].Attendance_3 = "Collapsed";
- }
- }
- }
- catch (Exception ex)
- {
- LogHelper.WriteErrLog("【抢答点名(RollCallWindow)" + ex.Message, ex);
- }
-
- return APP.ErrorMessage;
- }
-
- /// <summary>
- /// 点名抽奖效果-返回结果
- /// </summary>
- /// <returns></returns>
- public void InvokeRandomRollCallServerCompate(object obj)
- {
- APP.BackgroundWorkerHelper.RunWorkerAsync(InvokeInteractiveLaunchsServering, InvokeInteractiveLaunchsServerCompate);
- }
-
- private void frm_ChangeTextEvent(string text)
- {
- if ("重新点名".Equals(text))
- {
- returnNum = 0;
- WSocketClient.getInstance().SendMessage(SocketMsgManger.RandomRollCallEndMsg());
- //ZSocketServer.getInstance().SendMessage(ZSocketMsgManger.qiangdaEnd());
- initPageData();
- IsRandomRollCallButton = true;
- if (APP.OnlineUserList.Count > 0)//判断当前在线人数大于0 点击才有效
- {
- isRollCall = true;
- APP.BackgroundWorkerHelper.RunWorkerAsync(InvokeRandomRollCallServering, InvokeRandomRollCallServerCompate);
- }
- }
- else if ("关闭窗口".Equals(text))
- {
- returnNum = 0;
- userids = string.Empty;
- useridss = string.Empty;
- useridsss = string.Empty;
- isRollCall = false;
- isRushToAnswer = false;
- WSocketClient.getInstance().SendMessage(SocketMsgManger.RandomRollCallEndMsg());
- IsRandomRollCallButton = false;
- //ToolbarWindow.IsOpenRollCallWindow = false;
- Hide();
- }
- }
-
- private void Window_MouseLeftButtonDown_1(object sender, MouseButtonEventArgs e)
- {
- DragMove();
- }
-
- /// <summary>
- /// 关闭
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void btnDown_Click(object sender, RoutedEventArgs e)
- {
- WSocketClient.getInstance().SendMessage(SocketMsgManger.RushToAnswerEndMsg());
-
-
-
-
- //ToolbarWindow.IsNotOperation = false;
- APP.myloading.Show();
- new Thread(o =>
- {
- returnNum = 0;
- userids = string.Empty;
- useridss = string.Empty;
- useridsss = string.Empty;
- isRollCall = false;
- isRushToAnswer = false;
- APP.RollCallList = new System.Collections.Generic.List<Model.RollCallModel>();
- //string msg = ZSocketMsgManger.qiangdaEnd();
- //ZSocketServer.getInstance().SendMessage(msg);
- //ZSqliteManger.insertClassAction(new ClassAction()
- //{
- // unix = DataProvider.TimestampTotalSeconds(),
- // roomid = ZCommonData.roomid,
- // type = 403,
- // json = msg,
- // askid = ZCommonData.askid
- //});
-
- Dispatcher.Invoke(new Action(() =>
- {
- //ToolbarWindow.IsOpenRollCallWindow = false;
- APP.myloading.Hide();
- Hide();
- }));
- }).Start();
-
- }
-
- /// <summary>
- /// 抢答
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void btnAnswer_Click(object sender, RoutedEventArgs e)
- {
- WSocketClient.getInstance().SendMessage(SocketMsgManger.RushToAnswerMsg());
-
-
-
- if (!IsRandomRollCallButton)
- {
- returnNum = 0;
- userids = string.Empty;
- useridss = string.Empty;
- useridsss = string.Empty;
- APP.RollCallList = new System.Collections.Generic.List<RollCallModel>();
-
- imgRandomRollCall.Visibility = Visibility.Visible;
- imgRandomRollCallTwo.Visibility = Visibility.Collapsed;
- imgAnswer.Visibility = Visibility.Collapsed;
- imgAnswerTwo.Visibility = Visibility.Visible;
- //initPageData();
- if (isRollCall)//如果随机点名没有结束 发送结束随机点名消息
- {
- //ZSocketServer.getInstance().SendMessage(ZSocketMsgManger.qiangdaEnd());
- isRollCall = false;
- }
-
- if (APP.OnlineUserList.Count > 0)//判断当前在线人数大于0 点击才有效
- {
- if (pageData.userList.Count > 0)
- {
- pageData.userList.Clear();
- }
- //TeachingDataStatic.rollCallNum += 1;
- txbNumberOfReplies.Text = "0";
- isRushToAnswer = true;
-
- APP.BackgroundWorkerHelper.RunWorkerAsync(InvokeInteractiveLaunchServering, InvokeInteractiveLaunchServerCompate);
- }
- else
- {
- isRushToAnswer = false;
- }
- }
- }
-
- /// <summary>
- /// 互动 抢答服务-调用
- /// </summary>
- /// <returns></returns>
- private object InvokeInteractiveLaunchServering()
- {
- //Askteacher askteacher = new Askteacher
- //{
- // roomid = ZCommonData.roomid,
- // asktype = 20,
- // schoolid = ZCommonData.loginUser.schoolid,
- // asktid = DataProvider.TimestampAddRandomNumber(),
- // createtime = DataProvider.TimestampTotalSeconds(),
- // asktnum = 0
- //};
- //ZCommonData.askid = askteacher.asktid;
- //ZSqliteManger.insertClassData(new ClassData()
- //{
- // unix = DataProvider.TimestampTotalSeconds(),
- // roomid = ZCommonData.roomid,
- // api = "askteacher",
- // json = ZJsonHelper.ToJson(askteacher),
- // askid = askteacher.asktid
- //});
-
- //string msg = ZSocketMsgManger.qiangdaBegin(ZCommonData.askid);
- //ZSocketServer.getInstance().SendMessage(msg);
-
-
- //ZSqliteManger.insertClassAction(new ClassAction()
- //{
- // unix = DataProvider.TimestampTotalSeconds(),
- // roomid = ZCommonData.roomid,
- // type = 401,
- // json = msg,
- // askid = ZCommonData.askid
- //});
- return APP.ErrorMessage;
- }
-
- /// <summary>
- /// 互动 抢答服务-返回结果
- /// </summary>
- /// <returns></returns>
- public void InvokeInteractiveLaunchServerCompate(object obj)
- {
- }
-
- /// <summary>
- /// 互动 随机点名 服务-调用
- /// </summary>
- /// <returns></returns>
- private object InvokeInteractiveLaunchsServering()
- {
- //Askteacher askteacher = new Askteacher
- //{
- // roomid = ZCommonData.roomid,
- // asktype = 21,
- // schoolid = ZCommonData.loginUser.schoolid,
- // asktid = DataProvider.TimestampAddRandomNumber(),
- // createtime = DataProvider.TimestampTotalSeconds(),
- // asktnum = 0
- //};
- //ZCommonData.askid = askteacher.asktid;
- //ZSqliteManger.insertClassData(new ClassData()
- //{
- // unix = DataProvider.TimestampTotalSeconds(),
- // roomid = ZCommonData.roomid,
- // api = "askteacher",
- // json = ZJsonHelper.ToJson(askteacher),
- // askid = askteacher.asktid
- //});
-
- OnlineUserModel user = APP.OnlineUserList[ranNum];
-
-
-
- Console.WriteLine("ranNum:" + ranNum.ToString() + @user.username + "Ci" + user.num.ToString());
- //Askstudent askstudent = new Askstudent
- //{
- // roomid = ZCommonData.roomid,
- // studentid = user.userid,
- // asktid = ZCommonData.askid,
- // classid = ZCommonData.classid,
- // schoolid = ZCommonData.loginUser.schoolid,
- // createtime = DataProvider.TimestampTotalSeconds(),
- // studentselected = 1,
- // radiocorrect = 0
- //};
- //ZSqliteManger.insertClassData(new ClassData()
- //{
- // unix = DataProvider.TimestampTotalSeconds(),
- // roomid = ZCommonData.roomid,
- // api = "askstudent",
- // json = ZJsonHelper.ToJson(askstudent),
- // askid = askteacher.asktid
- //});
- WSocketClient.getInstance().SendMessage(SocketMsgManger.RandomRollCallMsg(user.userid));
- //ZSqliteManger.insertClassAction(new ClassAction()
- //{
- // unix = DataProvider.TimestampTotalSeconds(),
- // roomid = ZCommonData.roomid,
- // type = 411,
- // json = msg,
- // askid = ZCommonData.askid
- //});
- return APP.ErrorMessage;
- }
-
- /// <summary>
- /// 互动 随机点名服务-返回结果
- /// </summary>
- /// <returns></returns>
- public void InvokeInteractiveLaunchsServerCompate(object obj)
- {
- if (serverReturnCode == APP.ServerScuessCode)
- {
- OnlineUserModel user = APP.OnlineUserList[ranNum];
- string userpic = user.userpic;
- string userpicPath = "../Images/RollCall/attendance_1.png";
- if (ZCache.headDic.ContainsKey(userpic.Replace("/", "")))
- {
- userpicPath = ZCache.headDic[userpic.Replace("/", "")];
- }
-
- try
- {
- #region 随机次数增加
- for (int i = 0; i < APP.ClassStudentList.Count; i++)
- {
- if (APP.ClassStudentList[i].studentid == user.userid)
- {
- APP.ClassStudentList[i].num += 1;
- break;
- }
- }
- #endregion
-
-
- bool isUserid = true;
- //if (TeachingDataStatic.RandomRollCallStatisticsList.Count > 0)
- //{
- // for (int i = 0; i < TeachingDataStatic.RandomRollCallStatisticsList.Count; i++)
- // {
- // if (TeachingDataStatic.RandomRollCallStatisticsList[i].userid == user.userid)
- // {
- // TeachingDataStatic.RandomRollCallStatisticsList[i].replies += 1;
- // isUserid = false;
- // break;
- // }
- // }
- //}
- if (isUserid)
- {
- //RandomRollCallStatistics randomRollCallStatistics = new RandomRollCallStatistics
- //{
- // username = user.username,
- // userid = user.userid,
- // userpicPath = userpicPath,
- // replies = 1
- //};
- //TeachingDataStatic.RandomRollCallStatisticsList.Add(randomRollCallStatistics);
- //randomRollCallStatistics = new RandomRollCallStatistics();
- }
- }
- catch (Exception ex)
- {
- LogHelper.WriteErrLog("【课堂点名(RollCallWindow)】错误日志:" + ex.Message, ex);
- }
- try
- {
- if (rollCallPerfectionWindow == null)
- {
- rollCallPerfectionWindow = new RollCallPerfectionWindow(
- user.username,
- userpicPath
- )
- {
- Topmost = true,
- Width = pwidth,
- Height = pHeight,
- Left = 0,
- Top = 0
- };
-
- //订阅事件
- rollCallPerfectionWindow.ChangeTextEvent += new ChangeTextHandler(frm_ChangeTextEvent);
- rollCallPerfectionWindow.Owner = this;
- }
- else
- {
- rollCallPerfectionWindow.Name(user.username);
- }
- rollCallPerfectionWindow.Show();
- }
- catch (Exception ex)
- {
- LogHelper.WriteErrLog("【课堂点名(RollCallWindow)】错误日志:" + ex.Message, ex);
- }
- }
- }
-
- /// <summary>
- /// 页面关闭
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void Window_Closed(object sender, EventArgs e)
- {
- //ToolbarWindow.IsNotOperation = false;
- click_closeClick();
- //ZSocketServer.getInstance().removedWin(this);
- }
-
- #region 关闭委托
-
- /// <summary>
- /// 关闭委托 结束页面 创建人:赵耀 创建时间:2020年8月13日
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- public delegate void CloseClick();
-
- /// <summary>
- /// 关闭委托 结束页面 创建人:赵耀 创建时间:2020年8月13日
- /// </summary>
- public event CloseClick click_closeClick;
-
- #endregion 关闭委托
- }
-
- public class RollCallPageData : NotifyModel
- {
- public ObservableCollection<RollCallPageData> userList { get; set; }
- internal string _name;
-
- public string Name
- {
- get => _name;
- set { _name = value; OnPropertyChanged("Name"); }
- }
-
- internal string _id;
-
- public string ID
- {
- get => _id;
- set { _id = value; OnPropertyChanged("ID"); }
- }
-
- internal string _Pic;
-
- public string Pic
- {
- get => _Pic;
- set { _Pic = value; OnPropertyChanged("Pic"); }
- }
-
- internal string _attendance = "";
-
- public string Attendance
- {
- get => _attendance;
- set { _attendance = value; OnPropertyChanged("Attendance"); }
- }
-
- internal string _attendance_3 = "Visible";
-
- public string Attendance_3
- {
- get => _attendance_3;
- set { _attendance_3 = value; OnPropertyChanged("Attendance_3"); }
- }
-
- internal string _attendance_33 = "Visible";
-
- public string Attendance_33
- {
- get => _attendance_33;
- set { _attendance_33 = value; OnPropertyChanged("Attendance_33"); }
- }
-
- internal string _medal = "../Images/noting.png";
-
- public string Medal
- {
- get => _medal;
- set { _medal = value; OnPropertyChanged("Medal"); }
- }
-
- public long askid { get; set; }
-
- public RollCallPageData()
- {
- userList = new ObservableCollection<RollCallPageData>();
- }
- }
- }
|