星火直播PC
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

RollCallWindow.xaml.cs 37KB

пре 3 година
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985
  1. using Common.system;
  2. using Newtonsoft.Json;
  3. using System;
  4. using System.Collections.Generic;
  5. using System.Collections.ObjectModel;
  6. using System.IO;
  7. using System.Linq;
  8. using System.Text;
  9. using System.Threading;
  10. using System.Windows;
  11. using System.Windows.Input;
  12. using System.Windows.Threading;
  13. using XHZB.Desktop.Utils;
  14. using XHZB.Model;
  15. namespace XHZB.Desktop
  16. {
  17. /// <summary>
  18. /// 点名抢答
  19. /// </summary>
  20. public partial class RollCallWindow : Window/*, ZSocketCallback*/
  21. {
  22. #region 值初始化
  23. /// <summary>
  24. /// 服务返回 0成功
  25. /// </summary>
  26. private readonly int serverReturnCode = 0;
  27. internal RollCallPageData pageData = new RollCallPageData();
  28. private readonly RegisterController registerController = new RegisterController();
  29. internal string backgroundOpacity = "0.5";
  30. private readonly Random rd = new Random();
  31. private readonly int[] iArrty = new int[3] { 201314, 201314, 201314 };
  32. private static string userids = string.Empty;
  33. private static string useridss = string.Empty;
  34. private static string useridsss = string.Empty;
  35. private static int ranNum = 201314;
  36. private readonly int[] iArray = new int[1];
  37. private static int returnNum = 0;
  38. //private bool isSjdm = false;
  39. internal double pwidth = SystemParameters.PrimaryScreenWidth;
  40. internal double pHeight = SystemParameters.PrimaryScreenHeight;
  41. private RollCallPerfectionWindow rollCallPerfectionWindow;
  42. /// <summary>
  43. /// 随机点名
  44. /// </summary>
  45. private bool isRollCall = false;
  46. /// <summary>
  47. /// 抢答
  48. /// </summary>
  49. private bool isRushToAnswer = false;
  50. public string BackgroundOpacity
  51. {
  52. get => backgroundOpacity;
  53. set => backgroundOpacity = value;
  54. }
  55. /// <summary>
  56. /// 随机几率 1高 2中 3低
  57. /// </summary>
  58. string flag = "1";
  59. int rNum = 999;
  60. #endregion 值初始化
  61. /// <summary>
  62. /// 课堂点名
  63. /// </summary>
  64. public RollCallWindow()
  65. {
  66. InitializeComponent();
  67. WindowStartupLocation = WindowStartupLocation.CenterScreen;
  68. if (!File.Exists(APP.dataPath + "randomProbability.txt")) //若为空
  69. {
  70. flag = "1";
  71. }
  72. else
  73. {
  74. flag = System.IO.File.ReadAllText(APP.dataPath + "randomProbability.txt", Encoding.Default);
  75. }
  76. Initialize();
  77. //ZSocketServer.getInstance().addWin(this);
  78. }
  79. /// <summary>
  80. /// 初始化
  81. /// </summary>
  82. public void Initialize()
  83. {
  84. userids = string.Empty;
  85. useridss = string.Empty;
  86. useridsss = string.Empty;
  87. returnNum = 0;
  88. rNum = 999;
  89. APP.RollCallList = new System.Collections.Generic.List<RollCallModel>();
  90. imgRandomRollCall.Visibility = Visibility.Visible;
  91. imgRandomRollCallTwo.Visibility = Visibility.Collapsed;
  92. imgAnswer.Visibility = Visibility.Visible;
  93. imgAnswerTwo.Visibility = Visibility.Collapsed;
  94. stpAnswer.Visibility = Visibility.Collapsed;
  95. //ToolbarWindow.IsNotOperation = true;
  96. IsRandomRollCallButton = false;
  97. //初始化配置文件
  98. //ZJConfigUtil.init();
  99. initPageData();
  100. //ZSocketServer.getInstance().addWin(this);
  101. }
  102. public void userListChange()
  103. {
  104. Console.WriteLine("本节考勤-渲染用户列表");
  105. Dispatcher.BeginInvoke(DispatcherPriority.Normal,
  106. new Action(() =>
  107. {
  108. receiveWsMsg(null);
  109. }));
  110. }
  111. public void receiveWsMsg(ZWsMsgVo msg)
  112. {
  113. if (!isRollCall && !isRushToAnswer)
  114. {
  115. initPageData();
  116. }
  117. if (msg != null && msg.type == 402 && isRushToAnswer && msg.body.asktid == APP.askid)
  118. {
  119. Console.WriteLine(msg);
  120. #region 去重
  121. for (int i = 0; i < pageData.userList.Count; i++)
  122. {
  123. if (msg.body.userid.ToString().Equals(pageData.userList[i].ID))
  124. {
  125. return;
  126. }
  127. }
  128. #endregion
  129. //Askstudent askstudent = new Askstudent
  130. //{
  131. // roomid = ZCommonData.roomid,
  132. // studentid = msg.body.userid
  133. //};
  134. //askstudent.asktid = ZCommonData.askid;
  135. //askstudent.schoolid = ZCommonData.loginUser.schoolid;
  136. //askstudent.createtime = DataProvider.TimestampTotalSeconds();
  137. //askstudent.studentselected = 0;
  138. //askstudent.radiocorrect = 0;
  139. //askstudent.classid = msg.body.classid;
  140. //ZSqliteManger.insertClassData(new ClassData()
  141. //{
  142. // unix = DataProvider.TimestampTotalSeconds(),
  143. // roomid = ZCommonData.roomid,
  144. // api = "askstudent",
  145. // json = ZJsonHelper.ToJson(askstudent),
  146. // askid = ZCommonData.askid
  147. //});
  148. System.Collections.Generic.List<RollCallModel> callList = APP.RollCallList;
  149. bool isUserid = true;
  150. //if (TeachingDataStatic.RollCallStatisticsList.Count > 0)//统计抢答
  151. //{
  152. // for (int i = 0; i < TeachingDataStatic.RollCallStatisticsList.Count; i++)
  153. // {
  154. // if (TeachingDataStatic.RollCallStatisticsList[i].userid == msg.body.userid)
  155. // {
  156. // TeachingDataStatic.RollCallStatisticsList[i].replies += 1;
  157. // isUserid = false;
  158. // break;
  159. // }
  160. // }
  161. //}
  162. if (isUserid)
  163. {//统计
  164. //Shared.TeachingData.rollCall = new RollCall
  165. //{
  166. // usertype = msg.usertype,
  167. // userid = msg.body.userid,
  168. // username = msg.body.username,
  169. // userpic = msg.body.userpic,
  170. // replies = 1
  171. //};
  172. //TeachingDataStatic.RollCallStatisticsList.Add(Shared.TeachingData.rollCall);
  173. //Shared.TeachingData.rollCall = new RollCall();
  174. }
  175. Dispatcher.Invoke(DispatcherPriority.Normal,
  176. new Action(() =>
  177. {
  178. try
  179. {
  180. if (pageData.userList.Count > 0)
  181. {
  182. if (pageData.userList[pageData.userList.Count - 1].askid != msg.body.asktid)
  183. {
  184. pageData.userList.Clear();
  185. }
  186. }
  187. }
  188. catch (Exception ex)
  189. {
  190. LogHelper.WriteErrLog("【抢答】(receiveWsMsg)socket移除askid不一致用户," + ex.Message, ex);
  191. }
  192. //renderView();
  193. returnNum++;
  194. if (returnNum <= 18)
  195. {
  196. string medal = "../Images/RollCall/02log-1.png";
  197. string attendance = "../Images/RollCall/attendance_3.png";
  198. if (returnNum == 1)
  199. {
  200. medal = "../Images/RollCall/rollCall_7.png";
  201. attendance = "../Images/RollCall/attendance_33.png";
  202. }
  203. else if (returnNum == 2)
  204. {
  205. medal = "../Images/RollCall/rollCall_5.png";
  206. attendance = "../Images/RollCall/attendance_33.png";
  207. }
  208. else if (returnNum == 3)
  209. {
  210. medal = "../Images/RollCall/rollCall_6.png";
  211. attendance = "../Images/RollCall/attendance_33.png";
  212. }
  213. string userpic = msg.body.userpic;
  214. if (ZCache.headDic.ContainsKey(userpic.Replace("/", "")))
  215. {
  216. userpic = ZCache.headDic[userpic.Replace("/", "")];
  217. }
  218. else
  219. {
  220. userpic = "../Images/RollCall/attendance_1.png";
  221. }
  222. pageData.userList.Add(new RollCallPageData()
  223. {
  224. Name = msg.body.username,
  225. Attendance_33 = "Collapsed",
  226. Attendance_3 = "Visible",
  227. Pic = userpic,
  228. ID = msg.body.userid.ToString(),
  229. Attendance = attendance,
  230. Medal = medal,
  231. askid = msg.body.asktid
  232. });
  233. stpAnswer.Visibility = Visibility.Visible;
  234. }
  235. txbNumberOfReplies.Text = returnNum.ToString();
  236. }));
  237. }
  238. }
  239. System.Collections.Generic.List<OnlineUserModel> raduser = new System.Collections.Generic.List<OnlineUserModel>();
  240. System.Collections.Generic.List<OnlineUserModel> userListNew = new System.Collections.Generic.List<OnlineUserModel>();
  241. private void initPageData()
  242. {
  243. Dispatcher.Invoke(DispatcherPriority.Normal,
  244. new Action(() =>
  245. {
  246. if (pageData.userList.Count > 0)
  247. {
  248. pageData.userList.Clear();
  249. }
  250. List<OnlineUserModel> userList = APP.OnlineUserList;
  251. userListNew = new List<OnlineUserModel>();
  252. string userlistStr = JsonHelper.ToJson(userList);
  253. userListNew = JsonToList<OnlineUserModel>(userlistStr);
  254. List<ClassStudentListModel> classStudentList = APP.ClassStudentList;
  255. for (int i = 0; i < classStudentList.Count; i++)
  256. {
  257. classStudentList[i].status = 0;
  258. for (int j = 0; j < userListNew.Count; j++)
  259. {
  260. if (classStudentList[i].studentid == userListNew[j].userid)
  261. {
  262. userListNew[j].num = classStudentList[i].num;
  263. }
  264. }
  265. }
  266. if (userListNew.Count > 0)
  267. {
  268. //OrderbyDescending 倒叙 OrderBy 顺序
  269. raduser = userListNew.OrderBy(x => x.num).ToList();
  270. }
  271. foreach (OnlineUserModel user in userListNew)
  272. {
  273. string userpic = user.userpic;
  274. if (ZCache.headDic.ContainsKey(userpic.Replace("/", "")))
  275. {
  276. userpic = ZCache.headDic[userpic.Replace("/", "")];
  277. }
  278. else
  279. {
  280. userpic = "../Images/RollCall/attendance_1.png";
  281. }
  282. pageData.userList.Add(new RollCallPageData()
  283. {
  284. Name = user.username,
  285. Attendance_33 = "Collapsed",
  286. Attendance_3 = "Visible",
  287. Pic = userpic,
  288. ID = user.userid.ToString(),
  289. Attendance = "../Images/RollCall/attendance_3.png"
  290. });
  291. foreach (ClassStudentListModel cl in classStudentList)
  292. {
  293. if (cl.studentid == user.userid)
  294. {
  295. cl.status = 1;
  296. }
  297. }
  298. }
  299. string notOnline = string.Empty;
  300. foreach (ClassStudentListModel cl in classStudentList)
  301. {
  302. if (cl.status == 0)
  303. {
  304. notOnline += cl.studentname + " ";
  305. }
  306. }
  307. if (!string.IsNullOrWhiteSpace(notOnline))
  308. {
  309. txbNotOnline.Text = notOnline;
  310. }
  311. else
  312. {
  313. txbNotOnline.Text = "暂无";
  314. }
  315. toolbar_list.DataContext = pageData;
  316. }));
  317. }
  318. internal static List<T> JsonToList<T>(string respstr)
  319. {
  320. JsonSerializer serializer = new JsonSerializer();
  321. StringReader sr = new StringReader(respstr);
  322. object o = serializer.Deserialize(new JsonTextReader(sr), typeof(List<T>));
  323. List<T> list = o as List<T>;
  324. return list;
  325. }
  326. /// <summary>
  327. /// 是否已经按下按钮
  328. /// </summary>
  329. public bool IsRandomRollCallButton = false;
  330. /// <summary>
  331. /// 随机点名
  332. /// </summary>
  333. /// <param name="sender"></param>
  334. /// <param name="e"></param>
  335. private void btnRandomRollCall_Click(object sender, RoutedEventArgs e)
  336. {
  337. if (!IsRandomRollCallButton)
  338. {
  339. IsRandomRollCallButton = true;
  340. userids = string.Empty;
  341. useridss = string.Empty;
  342. useridsss = string.Empty;
  343. returnNum = 0;
  344. APP.RollCallList = new System.Collections.Generic.List<Model.RollCallModel>();
  345. stpAnswer.Visibility = Visibility.Collapsed;
  346. imgRandomRollCall.Visibility = Visibility.Collapsed;
  347. imgRandomRollCallTwo.Visibility = Visibility.Visible;
  348. imgAnswer.Visibility = Visibility.Visible;
  349. imgAnswerTwo.Visibility = Visibility.Collapsed;
  350. initPageData();
  351. if (isRushToAnswer)//如果抢答没有结束 先结束抢答
  352. {
  353. //ZSocketServer.getInstance().SendMessage(ZSocketMsgManger.qiangdaEnd());
  354. isRushToAnswer = false;
  355. }
  356. if (APP.OnlineUserList.Count > 0)//判断当前在线人数大于0 点击才有效 ceshi=
  357. {
  358. isRollCall = true;
  359. Thread.Sleep(500);
  360. APP.BackgroundWorkerHelper.RunWorkerAsync(InvokeRandomRollCallServering, InvokeRandomRollCallServerCompate);
  361. }
  362. else
  363. {
  364. IsRandomRollCallButton = false;
  365. }
  366. }
  367. }
  368. /// <summary>
  369. /// 点名抽奖效果
  370. /// </summary>
  371. /// <returns></returns>
  372. private object InvokeRandomRollCallServering()
  373. {
  374. try
  375. {
  376. if (ranNum != 201314 && ranNum != 0)
  377. {
  378. if (ranNum < pageData.userList.Count)
  379. {
  380. pageData.userList[ranNum].Attendance_33 = "Collapsed";
  381. pageData.userList[ranNum].Attendance_3 = "Visible";
  382. Thread.Sleep(500);
  383. }
  384. }
  385. int randomTimes = 0;//随机次数
  386. ranNum = 0;//随机到用户的下标
  387. if (pageData.userList.Count == 1)//当前在线1人直接选中
  388. {
  389. pageData.userList[0].Attendance_33 = "Collapsed";
  390. pageData.userList[0].Attendance_3 = "Visible";
  391. Thread.Sleep(500);
  392. pageData.userList[0].Attendance_33 = "Visible";
  393. pageData.userList[0].Attendance_3 = "Collapsed";
  394. }
  395. else
  396. {
  397. randomTimes = 10;
  398. //if (TeachingDataStatic.OnlineUserList.Count > 0)
  399. //{
  400. // //OrderbyDescending 倒叙 OrderBy 顺序
  401. // raduser = raduser.OrderBy(x => x.num).ToList();
  402. //}
  403. int ranNumberOfPeople = 999;
  404. if ("1".Equals(flag) && raduser.Count > 5)
  405. {
  406. do
  407. {
  408. long tick = DateTime.Now.Ticks;
  409. Random ran = new Random((int)(tick & 0xffffffffL) | (int)(tick >> 32));
  410. ranNumberOfPeople = ran.Next(5);
  411. for (int i = 0; i < userListNew.Count; i++)
  412. {
  413. if (userListNew[i].userid == raduser[ranNumberOfPeople].userid)
  414. {
  415. ranNumberOfPeople = i;
  416. break;
  417. }
  418. }
  419. } while (ranNumberOfPeople == rNum);
  420. raduser[ranNumberOfPeople].num += 1;
  421. }
  422. else if ("2".Equals(flag) && raduser.Count > 15)
  423. {
  424. do
  425. {
  426. long tick = DateTime.Now.Ticks;
  427. Random ran = new Random((int)(tick & 0xffffffffL) | (int)(tick >> 32));
  428. ranNumberOfPeople = ran.Next(15);
  429. for (int i = 0; i < userListNew.Count; i++)
  430. {
  431. if (userListNew[i].userid == raduser[ranNumberOfPeople].userid)
  432. {
  433. ranNumberOfPeople = i;
  434. break;
  435. }
  436. }
  437. } while (ranNumberOfPeople == rNum);
  438. raduser[ranNumberOfPeople].num += 1;
  439. }
  440. else if (raduser.Count > 30)
  441. {
  442. do
  443. {
  444. long tick = DateTime.Now.Ticks;
  445. Random ran = new Random((int)(tick & 0xffffffffL) | (int)(tick >> 32));
  446. ranNumberOfPeople = ran.Next(30);
  447. for (int i = 0; i < userListNew.Count; i++)
  448. {
  449. if (userListNew[i].userid == raduser[ranNumberOfPeople].userid)
  450. {
  451. ranNumberOfPeople = i;
  452. break;
  453. }
  454. }
  455. raduser[ranNumberOfPeople].num += 1;
  456. } while (ranNumberOfPeople == rNum);
  457. }
  458. else
  459. {
  460. ranNumberOfPeople = 999;
  461. }
  462. //if (APP.outputInforLog)
  463. //{
  464. // 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);
  465. //}
  466. int ranNums = 0;//记录上一次随机的下标
  467. for (int i = 0; i < randomTimes; i++)
  468. {
  469. Thread.Sleep(200);
  470. if (i > 0)
  471. {
  472. pageData.userList[ranNum].Attendance_33 = "Collapsed";
  473. pageData.userList[ranNum].Attendance_3 = "Visible";
  474. }
  475. while (ranNums == ranNum)//保证这次随机的下标和上次不相同
  476. {
  477. long tick = DateTime.Now.Ticks;
  478. Random ran = new Random((int)(tick & 0xffffffffL) | (int)(tick >> 32));
  479. ranNum = ran.Next(pageData.userList.Count);
  480. if (i == 9 && ranNumberOfPeople != 999)
  481. {
  482. ranNum = ranNumberOfPeople;
  483. break;
  484. }
  485. if (pageData.userList.Count < 3)
  486. {
  487. break;
  488. }
  489. }
  490. ranNums = ranNum;
  491. rNum = ranNum;
  492. pageData.userList[ranNum].Attendance_33 = "Visible";
  493. pageData.userList[ranNum].Attendance_3 = "Collapsed";
  494. }
  495. }
  496. }
  497. catch (Exception ex)
  498. {
  499. LogHelper.WriteErrLog("【抢答点名(RollCallWindow)" + ex.Message, ex);
  500. }
  501. return APP.ErrorMessage;
  502. }
  503. /// <summary>
  504. /// 点名抽奖效果-返回结果
  505. /// </summary>
  506. /// <returns></returns>
  507. public void InvokeRandomRollCallServerCompate(object obj)
  508. {
  509. APP.BackgroundWorkerHelper.RunWorkerAsync(InvokeInteractiveLaunchsServering, InvokeInteractiveLaunchsServerCompate);
  510. }
  511. private void frm_ChangeTextEvent(string text)
  512. {
  513. if ("重新点名".Equals(text))
  514. {
  515. returnNum = 0;
  516. //ZSocketServer.getInstance().SendMessage(ZSocketMsgManger.qiangdaEnd());
  517. initPageData();
  518. IsRandomRollCallButton = true;
  519. if (APP.OnlineUserList.Count > 0)//判断当前在线人数大于0 点击才有效
  520. {
  521. isRollCall = true;
  522. APP.BackgroundWorkerHelper.RunWorkerAsync(InvokeRandomRollCallServering, InvokeRandomRollCallServerCompate);
  523. }
  524. }
  525. else if ("关闭窗口".Equals(text))
  526. {
  527. returnNum = 0;
  528. userids = string.Empty;
  529. useridss = string.Empty;
  530. useridsss = string.Empty;
  531. isRollCall = false;
  532. isRushToAnswer = false;
  533. //ZSocketServer.getInstance().SendMessage(ZSocketMsgManger.qiangdaEnd());
  534. IsRandomRollCallButton = false;
  535. //ToolbarWindow.IsOpenRollCallWindow = false;
  536. Hide();
  537. }
  538. }
  539. private void Window_MouseLeftButtonDown_1(object sender, MouseButtonEventArgs e)
  540. {
  541. DragMove();
  542. }
  543. /// <summary>
  544. /// 关闭
  545. /// </summary>
  546. /// <param name="sender"></param>
  547. /// <param name="e"></param>
  548. private void btnDown_Click(object sender, RoutedEventArgs e)
  549. {
  550. //ToolbarWindow.IsNotOperation = false;
  551. APP.myloading.Show();
  552. new Thread(o =>
  553. {
  554. returnNum = 0;
  555. userids = string.Empty;
  556. useridss = string.Empty;
  557. useridsss = string.Empty;
  558. isRollCall = false;
  559. isRushToAnswer = false;
  560. APP.RollCallList = new System.Collections.Generic.List<Model.RollCallModel>();
  561. //string msg = ZSocketMsgManger.qiangdaEnd();
  562. //ZSocketServer.getInstance().SendMessage(msg);
  563. //ZSqliteManger.insertClassAction(new ClassAction()
  564. //{
  565. // unix = DataProvider.TimestampTotalSeconds(),
  566. // roomid = ZCommonData.roomid,
  567. // type = 403,
  568. // json = msg,
  569. // askid = ZCommonData.askid
  570. //});
  571. Dispatcher.Invoke(new Action(() =>
  572. {
  573. //ToolbarWindow.IsOpenRollCallWindow = false;
  574. APP.myloading.Hide();
  575. Hide();
  576. }));
  577. }).Start();
  578. }
  579. /// <summary>
  580. /// 抢答
  581. /// </summary>
  582. /// <param name="sender"></param>
  583. /// <param name="e"></param>
  584. private void btnAnswer_Click(object sender, RoutedEventArgs e)
  585. {
  586. if (!IsRandomRollCallButton)
  587. {
  588. returnNum = 0;
  589. userids = string.Empty;
  590. useridss = string.Empty;
  591. useridsss = string.Empty;
  592. APP.RollCallList = new System.Collections.Generic.List<RollCallModel>();
  593. imgRandomRollCall.Visibility = Visibility.Visible;
  594. imgRandomRollCallTwo.Visibility = Visibility.Collapsed;
  595. imgAnswer.Visibility = Visibility.Collapsed;
  596. imgAnswerTwo.Visibility = Visibility.Visible;
  597. //initPageData();
  598. if (isRollCall)//如果随机点名没有结束 发送结束随机点名消息
  599. {
  600. //ZSocketServer.getInstance().SendMessage(ZSocketMsgManger.qiangdaEnd());
  601. isRollCall = false;
  602. }
  603. if (APP.OnlineUserList.Count > 0)//判断当前在线人数大于0 点击才有效
  604. {
  605. if (pageData.userList.Count > 0)
  606. {
  607. pageData.userList.Clear();
  608. }
  609. //TeachingDataStatic.rollCallNum += 1;
  610. txbNumberOfReplies.Text = "0";
  611. isRushToAnswer = true;
  612. APP.BackgroundWorkerHelper.RunWorkerAsync(InvokeInteractiveLaunchServering, InvokeInteractiveLaunchServerCompate);
  613. }
  614. else
  615. {
  616. isRushToAnswer = false;
  617. }
  618. }
  619. }
  620. /// <summary>
  621. /// 互动 抢答服务-调用
  622. /// </summary>
  623. /// <returns></returns>
  624. private object InvokeInteractiveLaunchServering()
  625. {
  626. //Askteacher askteacher = new Askteacher
  627. //{
  628. // roomid = ZCommonData.roomid,
  629. // asktype = 20,
  630. // schoolid = ZCommonData.loginUser.schoolid,
  631. // asktid = DataProvider.TimestampAddRandomNumber(),
  632. // createtime = DataProvider.TimestampTotalSeconds(),
  633. // asktnum = 0
  634. //};
  635. //ZCommonData.askid = askteacher.asktid;
  636. //ZSqliteManger.insertClassData(new ClassData()
  637. //{
  638. // unix = DataProvider.TimestampTotalSeconds(),
  639. // roomid = ZCommonData.roomid,
  640. // api = "askteacher",
  641. // json = ZJsonHelper.ToJson(askteacher),
  642. // askid = askteacher.asktid
  643. //});
  644. //string msg = ZSocketMsgManger.qiangdaBegin(ZCommonData.askid);
  645. //ZSocketServer.getInstance().SendMessage(msg);
  646. //ZSqliteManger.insertClassAction(new ClassAction()
  647. //{
  648. // unix = DataProvider.TimestampTotalSeconds(),
  649. // roomid = ZCommonData.roomid,
  650. // type = 401,
  651. // json = msg,
  652. // askid = ZCommonData.askid
  653. //});
  654. return APP.ErrorMessage;
  655. }
  656. /// <summary>
  657. /// 互动 抢答服务-返回结果
  658. /// </summary>
  659. /// <returns></returns>
  660. public void InvokeInteractiveLaunchServerCompate(object obj)
  661. {
  662. }
  663. /// <summary>
  664. /// 互动 随机点名 服务-调用
  665. /// </summary>
  666. /// <returns></returns>
  667. private object InvokeInteractiveLaunchsServering()
  668. {
  669. //Askteacher askteacher = new Askteacher
  670. //{
  671. // roomid = ZCommonData.roomid,
  672. // asktype = 21,
  673. // schoolid = ZCommonData.loginUser.schoolid,
  674. // asktid = DataProvider.TimestampAddRandomNumber(),
  675. // createtime = DataProvider.TimestampTotalSeconds(),
  676. // asktnum = 0
  677. //};
  678. //ZCommonData.askid = askteacher.asktid;
  679. //ZSqliteManger.insertClassData(new ClassData()
  680. //{
  681. // unix = DataProvider.TimestampTotalSeconds(),
  682. // roomid = ZCommonData.roomid,
  683. // api = "askteacher",
  684. // json = ZJsonHelper.ToJson(askteacher),
  685. // askid = askteacher.asktid
  686. //});
  687. OnlineUserModel user = APP.OnlineUserList[ranNum];
  688. Console.WriteLine("ranNum:" + ranNum.ToString() + @user.username + "Ci" + user.num.ToString());
  689. //Askstudent askstudent = new Askstudent
  690. //{
  691. // roomid = ZCommonData.roomid,
  692. // studentid = user.userid,
  693. // asktid = ZCommonData.askid,
  694. // classid = ZCommonData.classid,
  695. // schoolid = ZCommonData.loginUser.schoolid,
  696. // createtime = DataProvider.TimestampTotalSeconds(),
  697. // studentselected = 1,
  698. // radiocorrect = 0
  699. //};
  700. //ZSqliteManger.insertClassData(new ClassData()
  701. //{
  702. // unix = DataProvider.TimestampTotalSeconds(),
  703. // roomid = ZCommonData.roomid,
  704. // api = "askstudent",
  705. // json = ZJsonHelper.ToJson(askstudent),
  706. // askid = askteacher.asktid
  707. //});
  708. //string msg = ZSocketMsgManger.dianmingBegin(ZCommonData.askid, user.userid);
  709. //ZSocketServer.getInstance().SendMessage(msg);
  710. //ZSqliteManger.insertClassAction(new ClassAction()
  711. //{
  712. // unix = DataProvider.TimestampTotalSeconds(),
  713. // roomid = ZCommonData.roomid,
  714. // type = 411,
  715. // json = msg,
  716. // askid = ZCommonData.askid
  717. //});
  718. return APP.ErrorMessage;
  719. }
  720. /// <summary>
  721. /// 互动 随机点名服务-返回结果
  722. /// </summary>
  723. /// <returns></returns>
  724. public void InvokeInteractiveLaunchsServerCompate(object obj)
  725. {
  726. if (serverReturnCode == APP.ServerScuessCode)
  727. {
  728. OnlineUserModel user = APP.OnlineUserList[ranNum];
  729. string userpic = user.userpic;
  730. string userpicPath = "../Images/RollCall/attendance_1.png";
  731. if (ZCache.headDic.ContainsKey(userpic.Replace("/", "")))
  732. {
  733. userpicPath = ZCache.headDic[userpic.Replace("/", "")];
  734. }
  735. try
  736. {
  737. #region 随机次数增加
  738. for (int i = 0; i < APP.ClassStudentList.Count; i++)
  739. {
  740. if (APP.ClassStudentList[i].studentid == user.userid)
  741. {
  742. APP.ClassStudentList[i].num += 1;
  743. break;
  744. }
  745. }
  746. #endregion
  747. bool isUserid = true;
  748. //if (TeachingDataStatic.RandomRollCallStatisticsList.Count > 0)
  749. //{
  750. // for (int i = 0; i < TeachingDataStatic.RandomRollCallStatisticsList.Count; i++)
  751. // {
  752. // if (TeachingDataStatic.RandomRollCallStatisticsList[i].userid == user.userid)
  753. // {
  754. // TeachingDataStatic.RandomRollCallStatisticsList[i].replies += 1;
  755. // isUserid = false;
  756. // break;
  757. // }
  758. // }
  759. //}
  760. if (isUserid)
  761. {
  762. //RandomRollCallStatistics randomRollCallStatistics = new RandomRollCallStatistics
  763. //{
  764. // username = user.username,
  765. // userid = user.userid,
  766. // userpicPath = userpicPath,
  767. // replies = 1
  768. //};
  769. //TeachingDataStatic.RandomRollCallStatisticsList.Add(randomRollCallStatistics);
  770. //randomRollCallStatistics = new RandomRollCallStatistics();
  771. }
  772. }
  773. catch (Exception ex)
  774. {
  775. LogHelper.WriteErrLog("【课堂点名(RollCallWindow)】错误日志:" + ex.Message, ex);
  776. }
  777. try
  778. {
  779. if (rollCallPerfectionWindow == null)
  780. {
  781. rollCallPerfectionWindow = new RollCallPerfectionWindow(
  782. user.username,
  783. userpicPath
  784. )
  785. {
  786. Topmost = true,
  787. Width = pwidth,
  788. Height = pHeight,
  789. Left = 0,
  790. Top = 0
  791. };
  792. //订阅事件
  793. rollCallPerfectionWindow.ChangeTextEvent += new ChangeTextHandler(frm_ChangeTextEvent);
  794. rollCallPerfectionWindow.Owner = this;
  795. }
  796. else
  797. {
  798. rollCallPerfectionWindow.Name(user.username);
  799. }
  800. rollCallPerfectionWindow.Show();
  801. }
  802. catch (Exception ex)
  803. {
  804. LogHelper.WriteErrLog("【课堂点名(RollCallWindow)】错误日志:" + ex.Message, ex);
  805. }
  806. }
  807. }
  808. /// <summary>
  809. /// 页面关闭
  810. /// </summary>
  811. /// <param name="sender"></param>
  812. /// <param name="e"></param>
  813. private void Window_Closed(object sender, EventArgs e)
  814. {
  815. //ToolbarWindow.IsNotOperation = false;
  816. click_closeClick();
  817. //ZSocketServer.getInstance().removedWin(this);
  818. }
  819. #region 关闭委托
  820. /// <summary>
  821. /// 关闭委托 结束页面 创建人:赵耀 创建时间:2020年8月13日
  822. /// </summary>
  823. /// <param name="sender"></param>
  824. /// <param name="e"></param>
  825. public delegate void CloseClick();
  826. /// <summary>
  827. /// 关闭委托 结束页面 创建人:赵耀 创建时间:2020年8月13日
  828. /// </summary>
  829. public event CloseClick click_closeClick;
  830. #endregion 关闭委托
  831. }
  832. public class RollCallPageData : NotifyModel
  833. {
  834. public ObservableCollection<RollCallPageData> userList { get; set; }
  835. internal string _name;
  836. public string Name
  837. {
  838. get => _name;
  839. set { _name = value; OnPropertyChanged("Name"); }
  840. }
  841. internal string _id;
  842. public string ID
  843. {
  844. get => _id;
  845. set { _id = value; OnPropertyChanged("ID"); }
  846. }
  847. internal string _Pic;
  848. public string Pic
  849. {
  850. get => _Pic;
  851. set { _Pic = value; OnPropertyChanged("Pic"); }
  852. }
  853. internal string _attendance = "";
  854. public string Attendance
  855. {
  856. get => _attendance;
  857. set { _attendance = value; OnPropertyChanged("Attendance"); }
  858. }
  859. internal string _attendance_3 = "Visible";
  860. public string Attendance_3
  861. {
  862. get => _attendance_3;
  863. set { _attendance_3 = value; OnPropertyChanged("Attendance_3"); }
  864. }
  865. internal string _attendance_33 = "Visible";
  866. public string Attendance_33
  867. {
  868. get => _attendance_33;
  869. set { _attendance_33 = value; OnPropertyChanged("Attendance_33"); }
  870. }
  871. internal string _medal = "../Images/noting.png";
  872. public string Medal
  873. {
  874. get => _medal;
  875. set { _medal = value; OnPropertyChanged("Medal"); }
  876. }
  877. public long askid { get; set; }
  878. public RollCallPageData()
  879. {
  880. userList = new ObservableCollection<RollCallPageData>();
  881. }
  882. }
  883. }