12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022 |
- using Common.system;
- using System;
- using System.Collections.Generic;
- using System.Collections.ObjectModel;
- using System.Configuration;
- using System.Data;
- using System.IO;
- using System.Security.Principal;
- using System.Text;
- using System.Threading;
- using System.Windows;
- using System.Windows.Input;
- using System.Windows.Media;
- using System.Windows.Media.Imaging;
- using XHZB.Desktop.Utils;
- using XHZB.Model;
-
- namespace XHZB.Desktop
- {
- /// <summary>
- /// 登陆
- /// </summary>
- public partial class LoginWindow : Window/*, ZJDownloadUtil.ZJDownloadCallback*/
- {
- #region 字段&属性
- //属性定义
- private Dictionary<int, string> _selGroupList;
- /// <summary>
- /// 分组下拉列表
- /// </summary>
- public Dictionary<int, string> selGroupList
- {
- get => _selGroupList;
- set => _selGroupList = value;//NotifyOfPropertyChange("selGroupList");
- }
- private int _Group;
- /// <summary>
- ///当前分组
- /// </summary>
- public int Group
- {
- get => _Group;
- set => _Group = value;
- }
- /// <summary>
- /// 调用接口
- /// </summary>
- private readonly RegisterController registerController = new RegisterController();
- /// <summary>
- /// 接口返回 0成功 1失败
- /// </summary>
- private int serverReturnCode = 0;
- public DataTable data = new DataTable();
- public DataTable DirectorList = new DataTable();
- internal LoginPageData pageData = new LoginPageData();
- /// <summary>
- /// 记录上次用户的选择的教材
- /// </summary>
- private int lsbids = 0;
- /// <summary>
- /// 记录上次用户的选择的章节
- /// </summary>
- private int directorids = 0;
- #endregion 字段&属性
-
- #region 初始化
- /// <summary>
- /// 初始化
- /// </summary>
- public LoginWindow()
- {
- InitializeComponent();
- if (!APP.CheckScreenCapturerRecorder())
- {
- MessageWindow.Show("首次运行需安装环境,请在确定后依次点击“English-OK-Next>-Next>Install”完成安装!");
- APP.InstallScreenCapturerRecorder();
- }
-
- WindowStartupLocation = WindowStartupLocation.CenterScreen;
-
- string typestr = APP.isDebug ? "测试版" : "正式版";
- bool isAdmin = IsAdministrator();
- string stradmin = isAdmin ? "管理员" : "普通用户";
-
- version_tb.Text = $"{typestr} v{FileToolsCommon.GetConfigValue("VersionName")}(Build{FileToolsCommon.GetConfigValue("VersionCode")}) [{stradmin}]";
-
- if (File.Exists(APP.dataPath + "interfaceAddress.txt")) //若为空
- {
- APP.apiUrl = System.IO.File.ReadAllText(APP.dataPath + "interfaceAddress.txt", Encoding.Default);
- }
- if (File.Exists(APP.dataPath + "imageUploadAddress.txt")) //若为空
- {
- APP.uploadUrl = System.IO.File.ReadAllText(APP.dataPath + "imageUploadAddress.txt", Encoding.Default);
- }
- if (File.Exists(APP.dataPath + "pictureShowsAddress.txt")) //若为空
- {
- APP.showImageUrl = System.IO.File.ReadAllText(APP.dataPath + "pictureShowsAddress.txt", Encoding.Default);
- }
- if (File.Exists(APP.dataPath + "fileStorageAddress.txt")) //若为空
- {
- APP.fileStorageAddress = System.IO.File.ReadAllText(APP.dataPath + "fileStorageAddress.txt", Encoding.Default);
- }
- //APP.AESAccountStr = "9001";
- //APP.AESPassWordStr = "123456";
- //免登录
- if (!string.IsNullOrWhiteSpace(APP.AESAccountStr) && !string.IsNullOrWhiteSpace(APP.AESPassWordStr))
- {
- Dispatcher.Invoke(new Action(() =>
- {
- txbAccountNumber.Text = APP.AESAccountStr;
- pobPassword.Password = APP.AESPassWordStr;
- btnLogin_Click(null, null);
- }));
- }
- }
- //#region 登陆页面验证本地激活码 1.验证成功 可登陆。 2.验证失败 弹出激活窗口。 关闭激活窗口,点击登陆时继续 弹出激活窗口
- ///// <summary>
- ///// 验证激活码
- ///// </summary>
- //void Verification()
- //{
- // //如果本地文件为空,弹出弹窗 输密匙
- // //本地文件不为空, 解析
- // if (!File.Exists(APP.dataPath + "signature.txt"))//上次登陆时间为空 或者签名为空 或者上次登陆时间不是今天 都需要输入密匙验证 ,否则只验证本地的签名
- // {
- // KeyVerification wins = new KeyVerification
- // {
- // Topmost = true,
- // Owner = this
- // };
-
- // wins.ShowDialog();
- // }
- // else
- // {
- // UnderVerification();
- // }
- //}
- ///// <summary>
- ///// 验证中
- ///// </summary>
- //void UnderVerification()
- //{
- // MyApp.myloading.Show();
- // Shared.BackgroundWorkerHelper.RunWorkerAsync(InvokeActivationDecryptServering, InvokeActivationDecryptServerCompate);
- //}
- ///// <summary>
- ///// 激活信息--验证签名是否过期-调用
- ///// </summary>
- ///// <returns></returns>
- //private object InvokeActivationDecryptServering()
- //{
-
- // return Shared.ServerMsg;
- //}
-
- ///// <summary>
- ///// 激活信息--验证签名是否过期-返回结果
- ///// </summary>
- ///// <returns></returns>
- //public void InvokeActivationDecryptServerCompate(object obj)
- //{
- // Dispatcher.Invoke(new Action(() =>
- // {
- // MyApp.myloading.Hide();
- // }));
-
- // //解析
- // try
- // {
- // Shared.Signature = System.IO.File.ReadAllText(ZConfig.dataPath + "signature.txt", Encoding.Default);
- // string decrypt = DataProvider.TripleDESDecrypt(Shared.Signature, ZConfig.secretKey);
- // decrypt = decrypt.Replace("\u0001", "").Trim();
- // Signatures msgBean = ZJsonHelper.JsonToObj<Signatures>(decrypt);
- // long currentTimeTimestamp = DataProvider.TimestampTotalSeconds(); //当前时间 时间戳
- // if (msgBean.endtime > currentTimeTimestamp)//条件成立 解析成功 code 在有效期内
- // {
- // if (File.Exists(ZConfig.dataPath + "signatureTime.txt"))
- // {
- // string signatureTime = System.IO.File.ReadAllText(ZConfig.dataPath + "signatureTime.txt", Encoding.Default);
- // string currentTime = DateTime.Now.ToLongDateString().ToString();//当前时间
- // if (signatureTime != currentTime)
- // {
- // Shared.BackgroundWorkerHelper.RunWorkerAsync(InvokeActivationAddHistoryServering, InvokeActivationAddHistoryServerCompate);
- // }
- // }
- // ZConfig.isActivationSuccessful = true;
- // //Dispatcher.Invoke(new Action(() =>
- // //{
- // // //LoginWindow win = new LoginWindow();
- // // //win.Show();
- // // //Close();
- // //}));
- // }
- // else//时间失效
- // {
- // Dispatcher.Invoke(new Action(() =>
- // {
- // KeyVerification wins = new KeyVerification
- // {
- // Topmost = true,
- // Owner = this
- // };
- // wins.ShowDialog();
- // //Close();
- // }));
- // }
- // }
- // catch (Exception) //解析失败 输code
- // {
- // Dispatcher.Invoke(new Action(() =>
- // {
- // KeyVerification wins = new KeyVerification
- // {
- // Topmost = true,
- // Owner = this
- // };
- // wins.ShowDialog();
- // //Close();
- // }));
- // }
-
- //}
- ///// <summary>
- ///// 激活信息--添加激活历史-调用
- ///// </summary>
- ///// <returns></returns>
- //private object InvokeActivationAddHistoryServering()
- //{
- // serverReturnCode = registerController.ActivationAddHistory(ref Shared.TeachingData);
- // return Shared.ServerMsg;
- //}
-
- ///// <summary>
- ///// 激活信息--添加激活历史-返回结果
- ///// </summary>
- ///// <returns></returns>
- //public void InvokeActivationAddHistoryServerCompate(object obj)
- //{
- // if (!Directory.Exists(APP.dataPath))
- // {
- // Directory.CreateDirectory(APP.dataPath);
- // }
- // string ApplicationData = APP.dataPath + "signatureTime.txt";
- // string currentTime = DateTime.Now.ToLongDateString().ToString();//当前时间
- // System.IO.File.WriteAllText(ApplicationData, currentTime, Encoding.Default);//存放签名验证日期
- //}
- //#endregion
- public bool IsAdministrator()
- {
- WindowsIdentity current = WindowsIdentity.GetCurrent();
- WindowsPrincipal windowsPrincipal = new WindowsPrincipal(current);
- return windowsPrincipal.IsInRole(WindowsBuiltInRole.Administrator);
- }
- /// <summary>
- /// 初始化加载
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void Window_Loaded(object sender, RoutedEventArgs e)
- {
- WindowStartupLocation = WindowStartupLocation.CenterScreen;
-
- btnLogin.Foreground = new SolidColorBrush((Color)ColorConverter.ConvertFromString("#1D8AF4"));
- //imgBrush.ImageSource = new BitmapImage(new Uri("pack://application:,,,/Images/Login/login2_0.png"));
-
- if (GetSettingString("isRemind").Equals("True"))
- {
- ckSaveName.IsChecked = true;
- txbAccountNumber.Text = GetSettingString("userName");
- }
- //if (GetSettingString("OutputInforLog").Equals("1"))
- //{
- // ZConfig.outputInforLog = true;
- //}
- //Verification();
- getNewApp();
- }
- #endregion 初始化
-
- #region 事件
- /// <summary>
- /// 窗体移动事件
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void Window_MouseLeftButtonDown_1(object sender, MouseButtonEventArgs e)
- {
- DragMove();
- }
- /// <summary>
- /// 窗口弧度
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void Window_SizeChanged(object sender, SizeChangedEventArgs e)
- {
- System.Windows.Rect r = new System.Windows.Rect(e.NewSize);
- RectangleGeometry gm = new RectangleGeometry(r, 1, 1);
- ((UIElement)sender).Clip = gm;
- }
- /// <summary>
- /// 登陆事件
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void btnLogin_Click(object sender, RoutedEventArgs e)
- {
- //if (!ZConfig.isActivationSuccessful)
- //{
- // Verification();
- // return;
- //}
-
- if (string.IsNullOrEmpty(txbAccountNumber.Text))
- {
- MessageWindow.Show("账号未输入");
- return;
- }
- if (string.IsNullOrEmpty(pobPassword.Password))
- {
- MessageWindow.Show("密码未输入");
- return;
- }
- APP.myloading.Show();
- APP.BackgroundWorkerHelper.RunWorkerAsync(InvokeServering, InvokeServerCompate);
- }
- /// <summary>
- /// 开始上课
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void btnClassesBegin_Click(object sender, RoutedEventArgs e)
- {
- if (string.IsNullOrWhiteSpace(cmbClass.Text))
- {
- MessageWindow.Show("尚未选择班级");
- return;
- }
- if (string.IsNullOrEmpty(cmbTeachingMaterial.Text))
- {
- MessageWindow.Show("尚未选择章节");
- return;
- }
- APP.myloading.Show();
- APP.classid = Convert.ToInt32(cmbClass.SelectedValue.ToString());
-
- for (int i = 0; i < APP.ClassList.Count; i++)
- {
- if (APP.classid == APP.ClassList[i].classid)
- {
- APP.REQStartClass.classnum = APP.ClassList[i].classnum;
- }
- }
-
- APP.REQStartClass.roomname = DateTime.Now.ToString() + cmbClass.Text;
- APP.REQStartClass.directorid = Convert.ToInt32(cmbTeachingMaterial.SelectedValue.ToString());
- APP.REQStartClass.roomid = TimestampAddRandomNumber();
- APP.roomid = APP.REQStartClass.roomid;
-
- try
- {
- //记录教材 章节 及当前登陆用户id
- string ApplicationData = APP.dataPath + "loginUserid.txt";
- string temp = APP.LoginUser.userid.ToString();
- System.IO.File.WriteAllText(ApplicationData, temp, Encoding.Default);
- ApplicationData = APP.dataPath + "loginLsbid.txt";
- temp = APP.lsbid.ToString();
- System.IO.File.WriteAllText(ApplicationData, temp, Encoding.Default);
- ApplicationData = APP.dataPath + "loginDirectorid.txt";
- temp = APP.REQStartClass.directorid.ToString();
- System.IO.File.WriteAllText(ApplicationData, temp, Encoding.Default);
- }
- catch (Exception ex)
- {
- LogHelper.WriteErrLog("【登陆(LoginWindow)" + ex.Message, ex);
- }
-
-
- APP.BackgroundWorkerHelper.RunWorkerAsync(InvokeClassStudentListServering, InvokeServerClassStudentListCompate);
- }
- /// <summary>
- /// 返回一个时间戳加3位随机数的long型整数
- /// </summary>
- /// <returns></returns>
- public long TimestampAddRandomNumber()
- {
- TimeSpan ts = DateTime.UtcNow - new DateTime(1970, 1, 1, 0, 0, 0, 0);
- string timestr = Convert.ToInt64(ts.TotalMilliseconds).ToString();
- long tick = DateTime.Now.Ticks;
- Random ran = new Random((int)(tick & 0xffffffffL) | (int)(tick >> 32));
- int random = ran.Next(100, 999);
- return Convert.ToInt64(timestr + random.ToString());
- }
- /// <summary>
- /// 关闭
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void btnDown_Click(object sender, RoutedEventArgs e)
- {
- Close();
- Application.Current.Shutdown();
- System.Environment.Exit(0);
- }
- #endregion 事件
-
- #region 方法
- /// <summary>
- /// 读取客户设置
- /// </summary>
- /// <param name="settingName"></param>
- /// <returns></returns>
- public static string GetSettingString(string settingName)
- {
- try
- {
- string settingString = FileToolsCommon.GetConfigValue(settingName);
- return settingString;
- }
- catch (Exception)
- {
- return null;
- }
- }
- /// <summary>
- /// 更新设置
- /// </summary>
- /// <param name="settingName"></param>
- /// <param name="valueName"></param>
- public static void UpdateSettingString(string settingName, string valueName)
- {
- //Configuration config = ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.None);
-
- //if (ConfigurationManager.AppSettings[settingName] != null)
- //{
- // config.AppSettings.Settings.Remove(settingName);
- //}
- //config.AppSettings.Settings.Add(settingName, valueName);
- //config.Save(ConfigurationSaveMode.Modified);
- //ConfigurationManager.RefreshSection("appSettings");
- }
- /// <summary>
- /// 检测APP更新
- /// </summary>
- private void getNewApp()
- {
- //new Thread(o =>
- //{
- // string url = ZConfig.apiUrl + "/appclient/get_new";
-
- // string result = ZHttpUtil.PostAndRespStr(url, "{}");
- // Model.ResultVo<AppModel> resultObj = ZJsonHelper.JsonToObj<Model.ResultVo<AppModel>>(result);
- // if (result != null && resultObj.code == 0)
- // {
- // if (resultObj.obj != null)
- // {
- // int versionCode = resultObj.obj.versioncode;
- // int versionThis = ZConfig.versionCode;
- // if (versionThis < versionCode)
- // {
- // Dispatcher.Invoke(new Action(() =>
- // {
- // appUpdateShow(resultObj.obj);
- // }));
- // }
- // }
- // }
- //}).Start();
- }
- ///// <summary>
- ///// 应用更新
- ///// </summary>
- ///// <param name="app"></param>
- //private void appUpdateShow(AppModel app)
- //{
- // AppUpdateWin win = new AppUpdateWin(app);
- // win.Topmost = true;
- // win.Owner = this;
- // win.ShowDialog();
- //}
- /// <summary>
- /// 登陆服务-调用
- /// </summary>
- /// <returns></returns>
- private object InvokeServering()
- {
- string accountNumber = string.Empty;
- string password = string.Empty;
- Dispatcher.Invoke(new Action(() =>
- {
- accountNumber = txbAccountNumber.Text.Replace(" ", "").Trim();
- password = pobPassword.Password.Replace(" ", "").Trim();
- }));
- serverReturnCode = registerController.Login(accountNumber, password);
- return APP.ErrorMessage;
- }
- /// <summary>
- /// 登陆服务-返回结果
- /// </summary>
- /// <returns></returns>
- public void InvokeServerCompate(object obj)
- {
- APP.myloading.Hide();
- if (serverReturnCode == APP.ServerScuessCode)
- {
- new Thread(o =>
- {
- InvokeLiveBroadcastServering();
- Dispatcher.Invoke(new Action(() =>
- {
- InvokeServerLiveBroadcastCompate();
- }));
-
- }).Start();
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- //grLogin.Visibility = Visibility.Collapsed;
- //grLoginTwo.Visibility = Visibility.Visible;
- //imgBrush.ImageSource = new BitmapImage(new Uri("pack://application:,,,/Images/Login/login2_1.png"));
- //txbHeader.Text = APP.LoginUser.username + "老师,您好!";
- //version_tb.Visibility = Visibility.Collapsed;
- //btnSetUp.Visibility = Visibility.Collapsed;
- //UpdateSettingString("userName", txbAccountNumber.Text);
-
- //new Thread(o =>
- //{
- // InvokeClassListServering();
- // Dispatcher.Invoke(new Action(() =>
- // {
- // InvokeServerClassListCompate();
- // }));
-
- //}).Start();
- //new Thread(o =>
- //{
- // InvokeTsubjectbookListServering();
- // Dispatcher.Invoke(new Action(() =>
- // {
- // InvokeServerTsubjectbookListCompate();
- // }));
-
- //}).Start();
- }
- else
- {
- MessageWindow.Show(APP.ErrorMessage);
- }
- }
- /// <summary>
- /// 开始直播服务-调用
- /// </summary>
- /// <returns></returns>
- private object InvokeLiveBroadcastServering()
- {
- serverReturnCode = registerController.ClassList();
- return APP.ErrorMessage;
- }
- /// <summary>
- /// 开始直播服务-返回结果
- /// </summary>
- /// <returns></returns>
- public void InvokeServerLiveBroadcastCompate()
- {
- if (serverReturnCode == APP.ServerScuessCode)
- {
- string imagepath = APP.classRoomImagePath();
- if (!Directory.Exists(imagepath))
- {
- Directory.CreateDirectory(imagepath);
- }
- ToolbarWindow win = new ToolbarWindow();
-
- Close();
- win.ShowDialog();
- }
- else
- {
- MessageWindow.Show(APP.ErrorMessage);
- }
- }
- /// <summary>
- /// 教师任教班级服务-调用
- /// </summary>
- /// <returns></returns>
- private object InvokeClassListServering()
- {
- serverReturnCode = registerController.ClassList();
- return APP.ErrorMessage;
- }
- /// <summary>
- /// 教师任教班级服务-返回结果
- /// </summary>
- /// <returns></returns>
- public void InvokeServerClassListCompate()
- {
- if (serverReturnCode == APP.ServerScuessCode)
- {
- data.Columns.Add("Value");
- data.Columns.Add("Key");
- for (int i = 0; i < APP.ClassList.Count; i++)
- {
- //创建一行
- DataRow row = data.NewRow();
- //将此行添加到table中
- data.Rows.Add(row);
- if (APP.ClassList[i].gradeid != null)
- {
- switch (APP.ClassList[i].gradeid)
- {
- case 1:
- data.Rows[i]["Value"] = "一年级" + APP.ClassList[i].classname;
- break;
- case 2:
- data.Rows[i]["Value"] = "二年级" + APP.ClassList[i].classname;
- break;
- case 3:
- data.Rows[i]["Value"] = "三年级" + APP.ClassList[i].classname;
- break;
- case 4:
- data.Rows[i]["Value"] = "四年级" + APP.ClassList[i].classname;
- break;
- case 5:
- data.Rows[i]["Value"] = "五年级" + APP.ClassList[i].classname;
- break;
- case 6:
- data.Rows[i]["Value"] = "六年级" + APP.ClassList[i].classname;
- break;
- case 7:
- data.Rows[i]["Value"] = "七年级" + APP.ClassList[i].classname;
- break;
- case 8:
- data.Rows[i]["Value"] = "八年级" + APP.ClassList[i].classname;
- break;
- case 9:
- data.Rows[i]["Value"] = "九年级" + APP.ClassList[i].classname;
- break;
- case 10:
- data.Rows[i]["Value"] = "高一" + APP.ClassList[i].classname;
- break;
- case 11:
- data.Rows[i]["Value"] = "高二" + APP.ClassList[i].classname;
- break;
- case 12:
- data.Rows[i]["Value"] = "高三" + APP.ClassList[i].classname;
- break;
- default:
- data.Rows[i]["Value"] = APP.ClassList[i].classname;
- break;
- }
- }
- else
- {
- data.Rows[i]["Value"] = APP.ClassList[i].classname;
- }
-
- data.Rows[i]["Key"] = APP.ClassList[i].classid;
- }
- dtComponentsUniqueNo = data.DefaultView.ToTable();
- cmbClass.ItemsSource = dtComponentsUniqueNo.DefaultView;
- cmbClass.SelectedIndex = 0;
- //Shared.BackgroundWorkerHelper.RunWorkerAsync(InvokeTsubjectbookListServering, InvokeServerTsubjectbookListCompate);
- }
- else
- {
- MessageWindow.Show(APP.ErrorMessage);
- }
- }
- /// <summary>
- /// 教师教材列表服务-调用
- /// </summary>
- /// <returns></returns>
- private object InvokeTsubjectbookListServering()
- {
- serverReturnCode = registerController.TsubjectbookList();
- return APP.ErrorMessage;
- }
- /// <summary>
- /// 教师教材列表服务-返回结果
- /// </summary>
- /// <returns></returns>
- public void InvokeServerTsubjectbookListCompate()
- {
- if (serverReturnCode == APP.ServerScuessCode)
- {
- try
- {
- if (File.Exists(APP.dataPath + "loginUserid.txt"))
- {
- string userid = System.IO.File.ReadAllText(APP.dataPath + "loginUserid.txt", Encoding.Default);
- if (userid.Equals(APP.LoginUser.userid.ToString()))
- {
- if (File.Exists(APP.dataPath + "loginLsbid.txt"))
- {
- string lsbid = System.IO.File.ReadAllText(APP.dataPath + "loginLsbid.txt", Encoding.Default);
- lsbids = Convert.ToInt32(lsbid);
- if (File.Exists(APP.dataPath + "loginDirectorid.txt"))
- {
- string directorid = System.IO.File.ReadAllText(APP.dataPath + "loginDirectorid.txt", Encoding.Default);
- directorids = Convert.ToInt32(directorid);
- }
- }
- }
- }
- }
- catch (Exception ex)
- {
- LogHelper.WriteErrLog("【登陆(LoginWindow)" + ex.Message, ex);
- }
- int iTemp = 0;
- for (int i = 0; i < APP.TsubjectbookList.Count; i++)
- {
- if (lsbids != 0 && lsbids == APP.TsubjectbookList[i].lsbid)
- {
- iTemp = i;
- }
- pageData.bookList.Add(new ComboBoxBeanModel()
- {
- Key = APP.TsubjectbookList[i].lsbid,
- Value = $"{APP.TsubjectbookList[i].subjectname} {APP.TsubjectbookList[i].bookname}"
- });
- }
- book_list.SelectedIndex = iTemp;
- DataContext = pageData;
- }
- else
- {
- MessageWindow.Show(APP.ErrorMessage);
- }
- }
- /// <summary>
- /// 章节列表服务-调用
- /// </summary>
- /// <returns></returns>
- private string InvokeDirectorListServering(int index)
- {
- int selectIndex = index;
- if (selectIndex != -1)
- {
- APP.lsbid = APP.TsubjectbookList[selectIndex].lsbid;
- APP.REQStartClass.subjectid = APP.TsubjectbookList[selectIndex].subjectid;
- APP.REQStartClass.subjectname = APP.TsubjectbookList[selectIndex].subjectname;
- APP.DirectorList = null;
- serverReturnCode = registerController.DirectorList(APP.TsubjectbookList[selectIndex].lsbid,2,APP.LoginUser.userid);
- }
- return APP.ErrorMessage;
- }
- /// <summary>
- /// 章节列表服务-返回结果
- /// </summary>
- /// <returns></returns>
- public void InvokeServerDirectorListCompate()
- {
- if (serverReturnCode == APP.ServerScuessCode)
- {
- pageData.zhangjieList.Clear();
- for (int i = 0; i < APP.DirectorList.Count; i++)
- {
- DirectorListModel item = APP.DirectorList[i];
- pageData.zhangjieList.Add(new ComboBoxBeanModel()
- {
- Key = item.directorid,
- Value = item.directorname
- });
- addChild(item);
- }
- cmbTeachingMaterial.SelectedIndex = 0;
- for (int i = 0; i < pageData.zhangjieList.Count; i++)
- {
- if (pageData.zhangjieList[i].Key == directorids)
- {
- cmbTeachingMaterial.SelectedIndex = i;
- }
- }
- }
- else
- {
- MessageWindow.Show(APP.ErrorMessage);
- }
- }
- /// <summary>
- /// 子章节递归
- /// </summary>
- /// <param name="directorList"></param>
- private void addChild(DirectorListModel directorList)
- {
- if (directorList.children != null && directorList.children.Count > 0)
- {
- foreach (DirectorListModel child in directorList.children)
- {
- pageData.zhangjieList.Add(new ComboBoxBeanModel()
- {
- Key = child.directorid,
- Value = getSpace(child.directorlevel) + child.directorname
- });
- if (child.children != null && child.children.Count > 0)
- {
- addChild(child);
- }
- }
- }
- }
- /// <summary>
- /// 章节是否加空格符
- /// </summary>
- /// <param name="num"></param>
- /// <returns></returns>
- private string getSpace(int num)
- {
- string str = "";
- for (int i = 0; i < num; i++)
- {
- str += " ";
- }
- return str;
- }
- /// <summary>
- /// 开始课堂服务-调用
- /// </summary>
- /// <returns></returns>
- private object InvokeStartClassServering()
- {
- //Startclass startclass = new Startclass
- //{
- // classid = ZCommonData.classid,
- // roomname = Shared.TeachingData.REQ_StartClass.roomname,
- // subjectid = Shared.TeachingData.REQ_StartClass.subjectid,
- // teacherid = ZCommonData.loginUser.userid,
- // directorid = Shared.TeachingData.REQ_StartClass.directorid,
- // directortype = 1,
- // schoolid = ZCommonData.loginUser.schoolid,
- // roomid = Shared.TeachingData.REQ_StartClass.roomid,
- // lsbid = ZCommonData.lsbid,
- // createtime = DataProvider.TimestampTotalSeconds()
- //};
- //ZSqliteManger.insertClassData(new ClassData()
- //{
- // unix = DataProvider.TimestampTotalSeconds(),
- // roomid = ZCommonData.roomid,
- // api = "startclass",
- // json = ZJsonHelper.ToJson(startclass),
- // askid = DataProvider.TimestampAddRandomNumber()
- //});
- return APP.ErrorMessage;
- }
- /// <summary>
- /// 开始课堂服务-返回结果
- /// </summary>
- /// <returns></returns>
- public void InvokeStartClassCompate(object obj)
- {
- try
- {
- APP.myloading.Hide();
- string imagepath = APP.classRoomImagePath();
- if (!Directory.Exists(imagepath))
- {
- Directory.CreateDirectory(imagepath);
- }
- //Shared.BackgroundWorkerHelper.RunWorkerAsync(InvokeClassStudentListServering, InvokeServerClassStudentListCompate);
- ToolbarWindow win = new ToolbarWindow();
-
- Close();
- win.ShowDialog();
- }
- catch (Exception ex)
- {
-
- LogHelper.WriteErrLog("【LoginWindow】(InvokeStartClassCompate)" + ex.Message, ex);
- }
-
- }
- /// <summary>
- /// 班级学生--列表服务-调用
- /// </summary>
- /// <returns></returns>
- private object InvokeClassStudentListServering()
- {
- //serverReturnCode = registerController.ClassStudentList();
- return APP.ErrorMessage;
- }
- /// <summary>
- /// 班级学生--列表服务服务-返回结果
- /// </summary>
- /// <returns></returns>
- public void InvokeServerClassStudentListCompate(object obj)
- {
- //MyApp.myloading.Hide();
- if (serverReturnCode == APP.ServerScuessCode)
- {
- APP.BackgroundWorkerHelper.RunWorkerAsync(InvokeStartClassServering, InvokeStartClassCompate);
- }
- else
- {
- APP.myloading.Hide();
- MessageWindow.Show(APP.ErrorMessage);
- }
- }
- #endregion 方法
-
- private DataTable dtComponentsUniqueNo;
- public DataTable DtComponentsUniqueNo
- {
- get => dtComponentsUniqueNo;
- set => dtComponentsUniqueNo = value;
- }
- private void txbAccountNumber_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
- {
- txbAccountNumber.Text = "";
- txbAccountNumber.Tag = "";
- }
-
- /// <summary>
- /// 单选框事件
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
-
- private void ckSaveName_Click(object sender, RoutedEventArgs e)
- {
- if (ckSaveName.IsChecked == false)
- {
- UpdateSettingString("isRemind", ckSaveName.IsChecked.ToString());
- }
- else
- {
- UpdateSettingString("isRemind", ckSaveName.IsChecked.ToString());
- }
- }
-
- public void downloadBegin(int position)
- {
- }
-
- public void downloadProgress(int position, int progress)
- {
- }
-
- public void downloadEnd(int position, string filepath)
- {
- Console.WriteLine("下载完成" + filepath + " position:" + position);
- }
-
- /// <summary>
- /// 教材选中事件
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void toolbar_list_SelectionChanged(object sender, System.Windows.Controls.SelectionChangedEventArgs e)
- {
- int SelectedIndex = book_list.SelectedIndex;
- new Thread(o =>
- {
- InvokeDirectorListServering(SelectedIndex);
- Dispatcher.Invoke(new Action(() =>
- {
- InvokeServerDirectorListCompate();
- }));
- }).Start();
- }
-
- /// <summary>
- /// 设置
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void btnSetUp_Click(object sender, RoutedEventArgs e)
- {
- //SetWindow win = new SetWindow
- //{
- // Topmost = true
- //};
- //win.Show();
- }
-
- public void downloadError(int position, string msg)
- {
- MessageWindow.Show(msg);
- }
-
- private void Button_Click(object sender, RoutedEventArgs e)
- {
-
-
- double pwidth = SystemParameters.PrimaryScreenWidth;
- if (APP.W_CameraWindow == null)
- {
- APP.W_CameraWindow = new CameraWindow();
- APP.W_CameraWindow.Topmost = true;
- APP.W_CameraWindow.Left = pwidth - 320;
- APP.W_CameraWindow.Top = 0;
- }
- APP.W_CameraWindow.Show();
- }
- }
-
- public class LoginPageData : NotifyModel
- {
- public ObservableCollection<ComboBoxBeanModel> bookList { get; set; }
-
- public ObservableCollection<ComboBoxBeanModel> zhangjieList { get; set; }
-
- public LoginPageData()
- {
- bookList = new ObservableCollection<ComboBoxBeanModel>();
- zhangjieList = new ObservableCollection<ComboBoxBeanModel>();
- }
- }
- }
|