123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985 |
- 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.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;
- //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;
- //ZSocketServer.getInstance().SendMessage(ZSocketMsgManger.qiangdaEnd());
- 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)
- {
- //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)
- {
- 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
- //});
- //string msg = ZSocketMsgManger.dianmingBegin(ZCommonData.askid, user.userid);
- //ZSocketServer.getInstance().SendMessage(msg);
- //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>();
- }
- }
- }
|