public static ArrayList MergrObj(string strPath) { IList <DirectoryInfo> dir = GetDirectorys(strPath); IList <FileInfo> fi = GetFiles(strPath); ArrayList al = new ArrayList(); foreach (DirectoryInfo d in dir) { if (d.Attributes.HasFlag(FileAttributes.System) || d.Attributes.HasFlag(FileAttributes.Hidden)) { ; } else { string fullname = d.Name;// JsonOper.ReturnSplitBrString(d.Name); string name = JsonOper.GetString(d.Name, 6, ".."); string filetype = d.Attributes.ToString(); string size = Disk.GetFileLength(d.FullName); string lastTime = d.LastWriteTime.ToString("yyyy-MM-dd HH:mm"); al.Add("0|" + name + "|" + fullname + "|文件夹|" + size + "|" + lastTime); } } foreach (FileInfo f in fi) { string fullname = f.Name; //JsonOper.ReturnSplitBrString(f.Name); string name = JsonOper.GetString(f.Name, 6, ".."); string filetype = f.Attributes.ToString(); string size = f.Length + ""; string lastTime = f.LastWriteTime.ToString("yyyy-MM-dd HH:mm"); string extName = fullname.Substring(fullname.LastIndexOf(".") + 1, (fullname.Length - fullname.LastIndexOf(".") - 1)); al.Add("1|" + name + "|" + fullname + "|" + FileType(extName) + "|" + size + "|" + lastTime); } return(al); }
//把全校学生人名添加到本地数据库 public static void addAllStuToLocal(string infor) { SchoolStuInfo g_SchoolStuInfo = JsonOper.DeserializeJsonToObject <SchoolStuInfo>(infor); if (g_SchoolStuInfo == null) { Global.isNetOk = false; return; } g_StudentInfoArray = g_SchoolStuInfo.studentlist; g_Studentlist.Clear(); foreach (StudentInfo s in g_StudentInfoArray) { User u = new User(); u.id = Int32.Parse(s.ID); u.name = s.Name; u.cardid = s.cardid; u.seat = s.SEAT.Replace("-", ""); u.type = 2;//student u.schoolid = m_schoolid; u.imageurl = s.imageurl; string pinying = Util.GetPinyin(s.Name); u.pinying = pinying; s.pinyin = pinying; //u.classname = Global.getClassname(); g_Studentlist.Add(u); } //更新学生信息 if (g_Studentlist.Count > 0) { int nAdd = m_db.addUser(g_Studentlist); } }
public static void setGroup(string ret) { if (ret.Length > 0) { m_grouplist = JsonOper.DeserializeJsonToObject <Grouplist>(ret); } }
public Form2(string questionstr, string id, string numberstr, string classid, string lessonid) { mode = 1; tm_create = DateTime.Now; Log.Info("From2.create, questionstr=" + questionstr + ", id=" + id + ", classid=" + classid + ", lessonid=" + lessonid); al = new ArrayList(); alText = new ArrayList(); clickstate = new ArrayList(); _id = id; InitializeComponent(); SetPanel(numberstr); SetDesktopLocation(0, screenHeight - this.Height); this.Text = "习题[" + id + "]"; this.WindowState = FormWindowState.Maximized; this.TopMost = true; #if DEBUG this.TopMost = false;//Form2.xiti. zzz #endif Xiti xiti = JsonOper.DeserializeJsonToObject <Xiti>(questionstr); m_answer = xiti.answer; string content = xiti.content; string html = "<div style=\"border-top:solid 3px #0B95C8; width:100%; margin-top:30px; padding-top:70px;\"><table align=\"center\"><tr><td style=\"font-family:微软雅黑; font-size:32px;\">" + content + "</td></tr></table></div>"; this.webBrowser1.DocumentText = html; t = new System.Timers.Timer(200); t.Elapsed += new System.Timers.ElapsedEventHandler(Theout); t.Enabled = true; t.AutoReset = true; }
public static string GetHandon() { string result = ""; if (Global.isHDPassive()) { string url = Global.url_recv; string url_param = "action=handon"; url_param += "&classid=0"; url_param += "&courseid=0"; url_param += "&lessonid=0"; string ret = HTTPReq.HttpGet(url + url_param); Log.Debug("HD_Handon: " + url + url_param + ", ret=" + ret); CBInfo cb = JsonOper.DeserializeJsonToObject <CBInfo>(ret.Replace("(", "").Replace(")", "")); if (cb != null && cb.data.Length > 0) { result = cb.data.Replace("-", ""); if (result.EndsWith("|")) { result = result.Substring(0, result.Length - 1); } } } else { result = Httpd.PopMQ_Handon(); } return(result); }
public static string setSeat(int uid, string seat) { g_ClassInfo = JsonOper.DeserializeJsonToObject <ClassInfo>(g_ClassInfoStr); string ret = ""; int i = 0; string uid1 = "", uid0 = ""; string seat1 = "", seat0 = ""; string name1 = "", name0 = ""; foreach (StudentInfo s in g_ClassInfo.Data.Student) { int _uid = Int32.Parse(s.ID); if (s.SEAT == seat) { g_ClassInfo.Data.Student[i].SEAT = ""; g_StudentInfoArray[i].SEAT = ""; ret = g_ClassInfo.Data.Student[i].ID + ":" + g_ClassInfo.Data.Student[i].Name + ":null, "; uid0 = g_ClassInfo.Data.Student[i].ID; seat0 = ""; name0 = g_ClassInfo.Data.Student[i].Name; m_db.setSeat(_uid, ""); /// break; } i++; } i = 0; foreach (StudentInfo s in g_StudentInfoArray) { int _uid = Int32.Parse(s.ID); if (_uid == uid) { g_ClassInfo.Data.Student[i].SEAT = seat; s.SEAT = seat; uid1 = g_ClassInfo.Data.Student[i].ID; name1 = g_ClassInfo.Data.Student[i].Name; seat1 = seat; m_db.setSeat(_uid, seat); ret += g_ClassInfo.Data.Student[i].ID + ":" + g_ClassInfo.Data.Student[i].Name + ":" + seat; break; } i++; } string str = new JavaScriptSerializer().Serialize(g_ClassInfo); g_ClassInfoStr = str; string data = "{\"uid\":\"P1\",\"seat\":\"P2\",\"name\":\"P3\",\"uid0\":\"P4\",\"seat0\":\"P5\",\"name0\":\"P6\"}"; data = data.Replace("P1", uid1 + "").Replace("P2", seat1.Replace("-", "")).Replace("P3", name1.Replace("-", "")); data = data.Replace("P4", uid0 + "").Replace("P5", seat0.Replace("-", "")).Replace("P6", name0.Replace("-", "")); //string str = "{\"ret\":\"P1\",\"msg\":\"P2\",\"data\":\"P3\"}".Replace("P1", ""+ret).Replace("P2", msg).Replace("P3", data); return(data); }
private void button3_Click(object sender, EventArgs e) { string path = ""; string fname = ""; string extname = ""; string ftype = ""; string dir = ""; OpenFileDialog op = new OpenFileDialog(); op.Title = "请选择教学资源文件"; //op.Filter = "All Files(*.*)|*.*|ppt Files(*.ppt)|*.ppt|word 2007 Files(*.doc)|*.doc|excel 2007 Files(*.xls)|*.xls|word Files(*.docx)|*.docx|excel Files(*.xlsx)|*.xlsx"; op.Filter = "课件文件(*.ppt,*.pptx,*.doc,*.docx,*.jpg,*.jpeg,*.bmp,*.png,*.gif,*.mp3,*.mp4,*.wav,*.wma,*.wmv,*.mov,*.swf)|*.ppt;*.pptx;*.doc;*.docx;*.jpg;*.jpeg;*.bmp;*.png;*.gif;*.mp3;*.wav;*.wma;*.mp4;*.wmv;*.mov;*.swf"; //op.Filter = "课件文件(*.ppt,*.pptx,*.doc,*.docx,*.pdf,*.jpg,*.jpeg,*.bmp,*.png,*.gif,*.mp3,*.mp4,*.wav,*.wma,*.wmv,*.mov,*.swf)|*.ppt;*.pptx;*.doc;*.docx;*.pdf;*.jpg;*.jpeg;*.bmp;*.png;*.gif;*.mp3;*.wav;*.wma;*.mp4;*.wmv;*.mov;*.swf"; if (op.ShowDialog() == DialogResult.OK) { path = op.FileName; dir = path.Substring(0, path.LastIndexOf("\\")); fname = op.SafeFileName; extname = fname.Substring(fname.LastIndexOf(".") + 1, (fname.Length - fname.LastIndexOf(".") - 1));; } if (path != "") { Button btn = new Button(); btn.Size = new System.Drawing.Size(70, 70); btn.BackColor = System.Drawing.Color.FromArgb(255, 255, 255); btn.FlatStyle = FlatStyle.Flat; btn.FlatAppearance.BorderColor = System.Drawing.Color.FromArgb(153, 209, 255); btn.FlatAppearance.BorderSize = 0; btn.FlatAppearance.MouseDownBackColor = System.Drawing.Color.FromArgb(204, 232, 255); btn.FlatAppearance.MouseOverBackColor = System.Drawing.Color.FromArgb(229, 243, 255); btn.TextAlign = ContentAlignment.BottomCenter; btn.MouseMove += new System.Windows.Forms.MouseEventHandler(btn_MouseMove); btn.MouseDown += new System.Windows.Forms.MouseEventHandler(btn_MouseDown); btn.AllowDrop = true; string filename = fname; string extName = extname; btn.BackgroundImage = FileICON(extName); btn.Name = "1|" + dir + "|" + fname; btn.Text = JsonOper.GetString(fname, 6, ".."); FileInfo fileInfo = new System.IO.FileInfo(path); string tooltipStr = fname + "\r\n类型:" + Disk.FileType(extName) + "\r\n修改日期:" + fileInfo.LastWriteTime.ToString("yyyy-MM-dd HH:mm") + "\r\n大小:" + fileInfo.Length + "字节"; this.toolTip1.SetToolTip(btn, tooltipStr); btn.MouseDown -= new System.Windows.Forms.MouseEventHandler(btn_MouseDown); btn.MouseDown += new System.Windows.Forms.MouseEventHandler(btnRight_MouseDown); addButtonlist_Right(btn); //添加本地文件 RefreshControls(); //button3_Click sourcePath = btn.Name.Split('|')[1].ToString(); sourceFilename = btn.Name.Split('|')[2].ToString(); System.Threading.Thread thred = new System.Threading.Thread(AsnycCopy);//拖动 thred.Start(); } }
private void Theout(object sender, System.Timers.ElapsedEventArgs e) { if (Interlocked.Exchange(ref inTimer, 1) == 0) { string json = HTTPReq.HttpGet(Global.url_recv + "action=xiti.get&classid=0&lessonid=0&xitiid=0"); if (json.Length > 55) { log.Info("Theout() xiti.get=" + json); } CBInfo cb = JsonOper.DeserializeJsonToObject <CBInfo>(json.Replace("(", "").Replace(")", "")); if (cb != null && cb.data.Length > 0) { string data = cb.data; string context = ""; for (int i = 0; i < data.Split('|').Length - 1; i++) { int num = Convert.ToInt16(data.Split('|')[i].Split(':')[0].ToString().Replace("-", "")); string answer = data.Split('|')[i].Split(':')[1]; int _answerLen = answer.Split(';').Length; string getAnswer = ""; if (_answerLen == 1) { getAnswer = answer.Split(';')[_answerLen - 1].Split(',')[1]; } else { getAnswer = answer.Split(';')[_answerLen - 2].Split(',')[1]; } context = num + ":" + getAnswer; for (int j = 0; j < al.Count; j++) { PictureBox lb = (PictureBox)al[j]; PictureBox text = (PictureBox)alText[j]; if ((num - 1) == j && (int)clickstate[j] == 0) { LabelStateEvent(context, lb, text, j + 1); clickstate[j] = 1; } } } } Interlocked.Exchange(ref inTimer, 0); } }
public void Xiti(string questionstr, string rid) { mode = 2; this.Text = "分组练习"; if (rid != null && rid.Length > 0 && questionstr.Length > 0) { bWithXitiResource = true; Xiti xiti = JsonOper.DeserializeJsonToObject <Xiti>(questionstr); answer = xiti.answer; string content = xiti.content; string html = "<div style=\"border-top:solid 3px #0B95C8; width:100%; margin-top:30px; padding-top:70px;\"><table align=\"center\"><tr><td style=\"font-family:微软雅黑; font-size:32px;\">" + content + "</td></tr></table></div>"; this.webBrowser1.DocumentText = html; } int panelH = SetPanel_Group(); if (bWithXitiResource) { this.Width = screenWidth; this.Height = screenHeight; StartPosition = FormStartPosition.Manual; SetDesktopLocation(0, 0); } else { this.Height = panelH; this.Width = screenWidth; StartPosition = FormStartPosition.Manual; SetDesktopLocation(0, screenHeight - this.Height); } this.Hide(); this.Show(); this.BringToFront(); panel1.Show(); panel1.BringToFront(); t = new System.Timers.Timer(200); t.Elapsed += new System.Timers.ElapsedEventHandler(Theout); t.Enabled = true; t.AutoReset = true; }
/// <summary> /// 刷新控件 /// </summary> public void AddFile(string filepath, bool bCopy) { string fname = Path.GetFileName(filepath); string extName = Path.GetExtension(filepath).Substring(1); string dir = Path.GetDirectoryName(filepath); Button btn = new Button(); btn.Size = new System.Drawing.Size(70, 70); btn.BackColor = System.Drawing.Color.FromArgb(255, 255, 255); btn.FlatStyle = FlatStyle.Flat; btn.FlatAppearance.BorderColor = System.Drawing.Color.FromArgb(153, 209, 255); btn.FlatAppearance.BorderSize = 0; btn.FlatAppearance.MouseDownBackColor = System.Drawing.Color.FromArgb(204, 232, 255); btn.FlatAppearance.MouseOverBackColor = System.Drawing.Color.FromArgb(229, 243, 255); btn.TextAlign = ContentAlignment.BottomCenter; btn.MouseMove += new System.Windows.Forms.MouseEventHandler(btn_MouseMove); btn.MouseDown += new System.Windows.Forms.MouseEventHandler(btn_MouseDown); btn.AllowDrop = true; btn.BackgroundImage = FileICON(extName); btn.Name = "1|" + dir + "|" + fname; btn.Text = JsonOper.GetString(fname, 6, ".."); FileInfo fileInfo = new System.IO.FileInfo(filepath); string tooltipStr = fname + "\r\n类型:" + Disk.FileType(extName) + "\r\n修改日期:" + fileInfo.LastWriteTime.ToString("yyyy-MM-dd HH:mm") + "\r\n大小:" + fileInfo.Length + "字节"; this.toolTip1.SetToolTip(btn, tooltipStr); btn.MouseDown -= new System.Windows.Forms.MouseEventHandler(btn_MouseDown); btn.MouseDown += new System.Windows.Forms.MouseEventHandler(btnRight_MouseDown); addButtonlist_Right(btn);//添加本地文件 RefreshControls(); sourcePath = btn.Name.Split('|')[1].ToString(); sourceFilename = btn.Name.Split('|')[2].ToString(); if (bCopy) { System.Threading.Thread thred = new System.Threading.Thread(AsnycCopy);//拖动 thred.Start(); } }
public static ArrayList getFilelist(string strPath, string[] szType) { IList <FileInfo> fi = GetFiles(strPath); ArrayList al = new ArrayList(); foreach (FileInfo f in fi) { string fullname = f.Name; string name = JsonOper.GetString(f.Name, 6, ".."); string filetype = f.Attributes.ToString(); string size = f.Length + ""; string lastTime = f.LastWriteTime.ToString("yyyy-MM-dd HH:mm"); string extName = fullname.Substring(fullname.LastIndexOf(".") + 1, (fullname.Length - fullname.LastIndexOf(".") - 1)); foreach (string type in szType) { if (fullname.IndexOf("." + type) > 0) { al.Add("1|" + name + "|" + fullname + "|" + FileType(extName) + "|" + size + "|" + lastTime); break; } } } return(al); }
private static int loadSchoolInfo_Local() { string dir = Application.StartupPath + "\\conf\\"; string filename = m_schoolid + ".conf"; FileOper fo = new FileOper(dir, filename); string data = fo.ReadFile(); if (data.Length > 0) { //TODO: 如果文件中有,从文件中获取 //TODO: 如果文件中没有,则从DB中获取 g_SchoolInfoStr = data; SchoolInfo info = JsonOper.DeserializeJsonToObject <SchoolInfo>(data); Global.setSchoolname(info.schoolname); g_szClasses = info.classlist; return(1); } else { return(0); } }
private static void Update() { string versionC = Global.getVersion(); string versionS = ""; string url = "http://" + Global.HOST + "/user.do?action=update&schoolid=" + Global.getSchoolID() + "&classid=" + Global.getClassID() + "&version=" + Global.getVersion(); //string json = HTTPReq.doGet(url,1000); string json = HTTPReq.HttpGet(url); if (json.Length == 0) { return; } Log.Info("Update, ret=" + json); try { UpdateInfo resp = JsonOper.DeserializeJsonToObject <UpdateInfo>(json.Replace("(", "").Replace(")", "")); if (resp == null) { return; } foreach (UpdateItem item in resp.updateinfolist) { Log.Info(item.toJson()); if (item.type == 1)// { versionS = item.version; Log.Info("versionC=" + versionC + ", versionS=" + versionS); string[] szVerS = versionS.Split('.'); string[] szVerC = versionC.Split('.'); string zipurl = item.path; bool bUpdate = false; for (int i = 0; i < szVerS.Length; i++) { int nS = Util.toInt(szVerS[i]); int nC = Util.toInt(szVerC[i]); if (nS > nC) { bUpdate = true; break; } else if (nS < nC) { return; } else { continue; } } if (bUpdate) { string update = Application.StartupPath + "\\RueUpdate.exe"; string update2 = Application.StartupPath + "\\RueUpdate2.exe"; Log.Info(update); Log.Info(update2); if (File.Exists(update2)) { Log.Info("copy..."); KillProcess("RueUpdate.exe"); try { File.Delete(update); File.Copy(update2, update, true); Log.Info("delete update2..."); File.Delete(update2); } catch (Exception e) { Log.Info("File.copy(update2,update) and File.Delete exception. " + e.Message); } } else if (File.Exists(update)) { string param = versionS + " " + zipurl; Log.Info("run update.exe now..." + param); Process.Start(update, param); } } } else if (item.type == 2) { Global.setRyktUpdateInfo(item); } } } catch (Exception e) { Log.Error(e.Message); } }
public static bool loadClassInfo() { if (m_classid == -1) { return(false); } Classes c = m_db.getClassById(m_classid); if (c != null) { Global.setClassID(c.id); Global.setClassname(c.name); Global.setGrade(c.grade); } string dir = Application.StartupPath + "\\conf\\"; string filename = m_schoolid + "-" + m_classid + ".conf"; FileOper fo = new FileOper(dir, filename); string strClassInfo = Common.getClassInfo(); if (strClassInfo.Length > 0) { //更新本地缓存 fo.WriteFile(strClassInfo); g_ClassInfoStr = strClassInfo; Log.Info("Global.loadClassInfo() ...2-ok!"); Log.Debug(g_ClassInfoStr); } else { Log.Error("getClassInfo error."); g_ClassInfoStr = fo.ReadFile(); Log.Error("Global.loadClassInfo() ...2-err..." + g_ClassInfoStr); } if (g_ClassInfoStr.Length > 0) { g_ClassInfo = JsonOper.DeserializeJsonToObject <ClassInfo>(g_ClassInfoStr); g_StudentInfoArray = g_ClassInfo.Data.Student; g_TeacherArray = g_ClassInfo.Data.Teacher; int nClassID = g_ClassInfo.Data.ID; int nGrade = g_ClassInfo.Data.Grade; Global.setGrade(nGrade); Global.setClassID(nClassID); Global.setClassname(g_ClassInfo.Data.Name); Global.setUploadInvalidData(g_ClassInfo.Data.UploadInvalidData); g_Studentlist.Clear(); foreach (StudentInfo s in g_StudentInfoArray) { User u = new User(); u.id = Int32.Parse(s.ID); u.name = s.Name; u.cardid = s.cardid; u.seat = s.SEAT.Replace("-", ""); u.type = 2;//student u.schoolid = m_schoolid; u.classid = nClassID; u.imageurl = s.imageurl; string pinying = Util.GetPinyin(s.Name); u.pinying = pinying; s.pinyin = pinying; //u.classname = Global.getClassname(); g_Studentlist.Add(u); } //write to RueSqlite.db { //更新学生信息 if (g_Studentlist.Count > 0) { int nDel = m_db.delUser(nClassID, 2); int nAdd = m_db.addUser(g_Studentlist); int a = nDel; } } } return(true); }
public static int loadSchoolInfo(int schoolid, string authcode) { int ret = 0; string dir = Application.StartupPath + "\\conf\\"; string filename = schoolid + ".conf"; FileOper fo = new FileOper(dir, filename); string strSchoolInfo = Common.getSchoolInfo(schoolid, authcode); if (strSchoolInfo.Length > 0) { SchoolInfo info = JsonOper.DeserializeJsonToObject <SchoolInfo>(strSchoolInfo); if (info.schoolid > 0) { Global.saveSchoolConfig(schoolid, authcode); g_szAwardType = info.awardtypelist; //更新本地缓存 fo.WriteFile(strSchoolInfo); g_SchoolInfoStr = strSchoolInfo; Log.Info("Global.loadSchoolInfo() ...2-ok!"); Log.Debug(g_SchoolInfoStr); ret = 1; } } else { Log.Info("getSchoolInfo error, load from conf now..."); string data = fo.ReadFile(); if (data.Length > 0) { g_SchoolInfoStr = data; ret = 2; } Log.Info("Global.loadSchoolInfo() ...2-err..." + g_SchoolInfoStr); } //if (strSchoolInfo.Length > 0) if (ret == 1) { SchoolInfo info = JsonOper.DeserializeJsonToObject <SchoolInfo>(g_SchoolInfoStr); User[] si = info.teacherlist; List <User> teacherlist = new List <User>(); foreach (User u in si) { teacherlist.Add(u); } int nDel = m_db.delTeachers(m_schoolid); int nAdd = m_db.addUser(teacherlist); int a = nDel; Global.setSchoolID(schoolid); Global.setSchoolname(info.schoolname); m_db.delSchool(info.schoolid); m_db.addSchool(info.schoolid, info.schoolname); g_szClasses = info.classlist; int nClassDel = m_db.delClassBySchoolid(m_schoolid); int nClassAdd = 0; foreach (Classes c in g_szClasses) { nClassAdd += m_db.addClass(c); } Log.Info("Global.loadSchoolInfo() nClassDel=" + nClassDel + ", nClassAdd=" + nClassAdd); string coursetimes = info.coursetime; m_db.delCourseTime(); m_db.addCourseTime(coursetimes); Log.Info("Global.loadSchoolInfo() Over."); g_SchoolInfoStr = strSchoolInfo; } else if (ret == 2) { Log.Info("getSchoolInfo error."); SchoolInfo info = JsonOper.DeserializeJsonToObject <SchoolInfo>(g_SchoolInfoStr); User[] si = info.teacherlist; List <User> teacherlist = new List <User>(); foreach (User u in si) { teacherlist.Add(u); } Global.setSchoolID(schoolid); Global.setSchoolname(info.schoolname); g_szClasses = info.classlist; } if (g_SchoolInfoStr.Length == 0) { return(-1); } else { return(1); } }
/// <summary> /// 采集器----GetXiti /// </summary> public static string GetXitiResult(bool bClear = false) { Log.Debug("GetXitiResult()_1 "); string ret = ""; if (Global.isHDPassive()) { Log.Info("GetXitiResult()_2 "); string url = Global.url_recv; string url_param = "action=xiti.get"; url_param += "&classid=0"; url_param += "&courseid=0"; url_param += "&lessonid=0"; if (bClear) { Thread thread = new Thread(delegate() { ret = HTTPReq.HttpGet(url + url_param); Log.Info("HD_Async_Xiti: " + url + url_param + ", ret=" + ret); }); thread.Start(); } else { string json = HTTPReq.HttpGet(url + url_param); Log.Info("HD_Xiti_Passive: " + url + url_param + ", json=" + json); CBInfo cb = JsonOper.DeserializeJsonToObject <CBInfo>(json.Replace("(", "").Replace(")", "")); if (cb != null && cb.data.Length > 0) { string data = cb.data; for (int i = 0; i < data.Split('|').Length - 1; i++) { int num = Convert.ToInt16(data.Split('|')[i].Split(':')[0].ToString().Replace("-", "")); string answer = data.Split('|')[i].Split(':')[1]; //57A299E5,A;57A299E5,B;57A299E6,C;57A299E6,D;57A299E6,S string[] szKey = answer.Split(';'); SortedSet <string> keySet = new SortedSet <string>(); for (int k = 0; k < szKey.Length; k++) { string _answer = szKey[k].Split(',')[1]; if (_answer == "S") { continue; } if (!keySet.Contains(_answer)) { keySet.Add(_answer); } } string keys = ""; foreach (string key in keySet) { keys += key; } if (keys.Length == 0) { continue; } string context = num + ":" + keys; ret += (ret.Length > 0 ? "|" : "") + context; } } } } else { if (bClear) { Log.Debug("GetXitiResult()_2, Clear..."); string data = Httpd.ClearMQ_Xiti(); if (data.Length > 0) { Common.uploadInvalidXitiResult(data); } } else { Log.Debug("GetXitiResult()_3_1, Pop..."); ret = Httpd.PopMQ_Xiti(); Log.Debug("GetXitiResult()_3_2, Pop..." + ret); } } return(ret); }
/// <summary> /// 设置答题结果显示界面 /// </summary> /// <param name="numberstr"></param> /// <param name="selectAnswer"></param> public void SetPanel(string numberstr, string selectAnswer) { string answerStr = ReturnResult(); int answered = 0; ClassInfo ci = JsonOper.DeserializeJsonToObject <ClassInfo>(numberstr); peopleValues[peopleValues.Length - 2] = ci.Data.StudentCount; if (answerStr != "") { _answerList = new List <AnswerInfo>(); for (int i = 0; i < answerStr.Split(',').Length; i++) { if (answerStr.Split(',')[i] != "") { AnswerInfo ai = new AnswerInfo(); ai.CBID = Convert.ToInt16(answerStr.Split(',')[i].Split(':')[0]); ai.CBAnswer = answerStr.Split(',')[i].Split(':')[1]; _answerList.Add(ai); answered++; } } } else { this.panel1.Visible = false; } int _firstAnswerCount = 0; List <AnswerInfo> _firstAnswerList = null; if (_answerList != null) { for (int i = 0; i < answerList.Length; i++) { List <AnswerInfo> result; if (answerList[i] == "未答") { result = (from x in _answerList where x.CBAnswer == "S" select x).ToList <AnswerInfo>(); countValues[i] = (decimal)(result.Count + (ci.Data.StudentCount - answered)) / (decimal)ci.Data.StudentCount; peopleValues[i] = result.Count + ci.Data.StudentCount - answered; } else if (answerList[i] == "其它") { if (answerList.Length == 6) { result = (from x in _answerList where x.CBAnswer == "R" || x.CBAnswer == "W" select x).ToList <AnswerInfo>(); } else { result = (from x in _answerList where x.CBAnswer == "A" || x.CBAnswer == "B" || x.CBAnswer == "C" || x.CBAnswer == "D" select x).ToList <AnswerInfo>(); } countValues[i] = (decimal)result.Count / (decimal)ci.Data.StudentCount; peopleValues[i] = result.Count; } else { if (answerList.Length == 6) { result = (from x in _answerList where x.CBAnswer == answerList[i] select x).ToList <AnswerInfo>(); } else { string _temp = "W"; if (answerList[i].ToString() == "✔") { _temp = "R"; } result = (from x in _answerList where x.CBAnswer == _temp select x).ToList <AnswerInfo>(); } countValues[i] = (decimal)result.Count / (decimal)ci.Data.StudentCount; peopleValues[i] = result.Count; } string _aConver = selectAnswer; if (answerList.Length == 4) { if (selectAnswer == "W") { _aConver = "✘"; } else { _aConver = "✔"; } } if (answerList[i] == _aConver) { List <AnswerInfo> selectResult = null; if (selectAnswer == "未答") { selectResult = new List <AnswerInfo>(); List <AnswerInfo> _temp = (from x in _answerList where x.CBAnswer != "S" select x).ToList <AnswerInfo>(); for (int j = 1; j <= ci.Data.StudentCount; j++) { if (_temp.Count == 0) { AnswerInfo ai = new AnswerInfo(); ai.CBID = j; ai.CBAnswer = "S"; selectResult.Add(ai); } else { bool ishas = true; for (int k = 0; k < _temp.Count; k++) { if (j == _temp[k].CBID) { ishas = false; break; } } if (ishas) { AnswerInfo ai = new AnswerInfo(); ai.CBID = j; ai.CBAnswer = "S"; selectResult.Add(ai); } } } } else if (selectAnswer == "其它") { if (answerList.Length == 6) { selectResult = (from x in _answerList where x.CBAnswer == "R" || x.CBAnswer == "W" select x).ToList <AnswerInfo>(); } else { selectResult = (from x in _answerList where x.CBAnswer == "A" || x.CBAnswer == "B" || x.CBAnswer == "C" || x.CBAnswer == "D" select x).ToList <AnswerInfo>(); } } else { selectResult = (from x in _answerList where x.CBAnswer == selectAnswer select x).ToList <AnswerInfo>(); } _firstAnswerCount = selectResult.Count; _firstAnswerList = selectResult; } } } int _count = screenWidth / 51; int _line = _firstAnswerCount % _count > 0 ? _firstAnswerCount / _count + 1 : _firstAnswerCount / _count; int panelHeight = _line * 50 + 10; int panelLH = this.screenHeight - panelHeight; this.panel2.Height = panelLH; this.panel1.Location = new System.Drawing.Point(0, panelLH); this.panel1.Size = new System.Drawing.Size(screenWidth, panelHeight); this.panel1.BringToFront(); int _lw = 0; int _br = 1; int _locationWidth = 0; int _locationHeight = 40; int _tpi = 1; if (_firstAnswerList != null) { if (_firstAnswerList.Count > 0) { this.panel1.Controls.Clear(); this.panel1.Visible = true; } foreach (AnswerInfo rl in _firstAnswerList) { _locationHeight = (_lw * 40) + ((_lw + 1) * 10); if (_tpi == 1 || _br % 2 == 0) { _locationWidth = (screenWidth - _count * 51) / 2 + 5; } else { _locationWidth += 51; } if (_tpi % _count == 0) { _br *= 2; if (_lw <= _line) { _lw++; } } else { _br = 1; } Label label = new Label(); label.Font = new System.Drawing.Font("微软雅黑", 15.75F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(134))); label.ForeColor = System.Drawing.Color.White; Image lbimg = global::RueHelper.Properties.Resources.select; label.Image = lbimg; label.Location = new System.Drawing.Point(_locationWidth, _locationHeight); label.Name = "click_" + _tpi; label.Size = new System.Drawing.Size(41, 40); label.TabIndex = 0; label.Text = rl.CBID + ""; label.TextAlign = System.Drawing.ContentAlignment.MiddleCenter; this.panel1.Controls.Add(label); _tpi++; } } }
public Form10(string studentinfo, string data, int id, string name) { InitializeComponent(); al = new ArrayList(); this.Text = "点名"; this.WindowState = FormWindowState.Maximized; this.TopMost = true; #if DEBUG this.TopMost = false;//Form10 CallName,zzz #endif if (Global.getGrade() > 6) { bHighSchool = true; } if (bHighSchool) { //点名提问 姓名框 this.label1.Size = new System.Drawing.Size(401, 174);//394,167 this.label1.Image = global::RueHelper.Properties.Resources.nameshow; this.label1.Location = new System.Drawing.Point((screenWidth - this.label1.Width) / 2, (screenHeight - this.label1.Height) / 2 + 30); //this.label1.ForeColor = System.Drawing.Color.Black; //this.label1.ForeColor = System.Drawing.ColorTranslator.FromHtml("#5748A5"); //this.label1.Font = new System.Drawing.Font("微软雅黑", 42F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); //点名提问图片框 this.pictureBox1.Visible = false; this.pictureBox1.Location = new System.Drawing.Point((screenWidth - this.pictureBox1.Width) / 2 - 10, label1.Top - pictureBox1.Height - 20); //点名提问文本框 this.label3.Visible = true; this.label3.Location = new System.Drawing.Point((screenWidth - 219) / 2, label1.Top - 90); this.label3.Text = "点 名 提 问"; this.label3.Font = new System.Drawing.Font("微软雅黑", 30F); this.label2.Visible = false; } else { //点名提问图片框 this.pictureBox1.Visible = true; this.pictureBox1.Location = new System.Drawing.Point((screenWidth - this.pictureBox1.Width) / 2 - 10, label1.Top - pictureBox1.Height - 20); this.label1.Size = new System.Drawing.Size(408, 179);//401,172 this.label1.Location = new System.Drawing.Point((screenWidth - this.label1.Width) / 2, (screenHeight - this.label1.Height) / 2 + 50); this.label2.Location = new System.Drawing.Point(label1.Left, label1.Top); this.pictureBox2.Location = new System.Drawing.Point((screenWidth - this.pictureBox2.Width) / 2, (screenHeight - this.pictureBox2.Height) / 2 - 200); this.label3.Size = new System.Drawing.Size(288, 50); this.label3.Location = new System.Drawing.Point((screenWidth - this.label3.Width) / 2 + 10, pictureBox1.Top + 30); this.label1.Image = global::RueHelper.Properties.Resources.nameshow; } ClassInfo ci = JsonOper.DeserializeJsonToObject <ClassInfo>(studentinfo); si = ci.Data.Student; if (name.Length == 0 && data.Length > 0)//随机点名 { for (int i = 0; i < data.Split('|').Length - 1; i++) { int num = Convert.ToInt16(data.Split('|')[i].Split(':')[0].ToString().Replace("-", "")); string answer = data.Split('|')[i].Split(':')[1]; int _answerLen = answer.Split(';').Length; string getAnswer = ""; if (_answerLen == 1) { getAnswer = answer.Split(';')[_answerLen - 1].Split(',')[1]; } else { getAnswer = answer.Split(';')[_answerLen - 2].Split(',')[1]; } al.Add(num + ":" + getAnswer); } Random rd = new Random(); ArrayList _tempAl = new ArrayList(); for (int i = 0; i < al.Count; i++) { int _num = Convert.ToInt16(al[i].ToString().Split(':')[0].ToString()); string s1 = si[_num - 1].Name; if (CheckAL(s1)) { _tempAl.Add(al[i].ToString()); } } bool insert = true; if (_tempAl.Count == 0) { insert = false; _tempAl = al; } int r = rd.Next(_tempAl.Count); string temp = _tempAl[r].ToString(); int number = Convert.ToInt16(temp.Split(':')[0].ToString());//No. string stname = si[number - 1].Name; this.label1.Text = stname; STName = stname; STID = temp.Split(':')[0].ToString(); if (insert) { StudentInfo newSI = new StudentInfo(); newSI.Name = stname; studentResult.Add(newSI); } } else//制定点名 { STName = name; STID = id + ""; } this.label1.Text = STName; //this.Show(); //this.BringToFront(); //3秒显示,自动隐藏 System.Windows.Forms.Timer t = new System.Windows.Forms.Timer(); t.Interval = 2000;//2秒 t.Tick += new EventHandler(t_Tick); t.Start(); }
private int SetPanel(string numberstr) { ClassInfo ci = JsonOper.DeserializeJsonToObject <ClassInfo>(numberstr); si = ci.Data.Student; int _count = screenWidth / 51; int _line = ci.Data.StudentCount % _count > 0 ? ci.Data.StudentCount / _count + 1 : ci.Data.StudentCount / _count; int panelHeight = _line * 50 + 10;/////////////////////// if (_line == 2) { panelHeight = _line * 50 + 60; } else if (_line == 1) { panelHeight = _line * 50 + 110; } int panelLH = this.screenHeight - panelHeight; this.panel1.Location = new System.Drawing.Point(0, 0);//panelLH this.panel1.Size = new System.Drawing.Size(this.screenWidth, panelHeight); this.panel2.Location = new System.Drawing.Point(0, 0);//panelLH this.panel2.Size = new System.Drawing.Size(this.screenWidth, panelHeight); this.panel1.BringToFront(); this.panel2.Hide(); label_top3_1.Text = ""; label_top3_2.Text = ""; label_top3_3.Text = ""; int top3_top = (panelHeight - label_top3_1.Size.Height) / 2 - 10; label_top3_1.Text = " "; label_top3_2.Text = " "; label_top3_3.Text = " "; label_top3_1.Top = top3_top; label_top3_2.Top = top3_top; label_top3_3.Top = top3_top; int highInterval = 10;//三行的行间距 if (_line == 2) { highInterval = 25;//两行变三行,两行的行间距 } else if (_line == 1) { highInterval = 55; } int _lw = 0; int _br = 1; int _locationWidth = 0; int _locationHeight = 40; int nStudentCount = ci.Data.StudentCount; for (int i = 1; i <= nStudentCount; i++) { _locationHeight = (_lw * 40) + ((_lw + 1) * highInterval); if (i == 1 || _br % 2 == 0) { _locationWidth = (screenWidth - _count * 51) / 2 + 5; } else { _locationWidth += 51; } if (i % _count == 0) { _br *= 2; if (_lw <= _line) { _lw++; } } else { _br = 1; } PictureBox pic = new PictureBox(); AnswerCount ac = new AnswerCount(); ac.ImageWidth = 40; ac.ImagesHeight = 40; ac.FontStyle = System.Drawing.FontStyle.Bold; ac.AnswerFamily = "微软雅黑"; ac.AnswerFontSize = 15.75F; Image lbimg = ac.DrawingArcFill(1, 1, System.Drawing.Color.FromArgb(254, 80, 79), 0, 41, System.Drawing.Color.FromArgb(254, 80, 79)); Image textimg = ac.DrawingString(Brushes.White, i + ""); bool ishasnum = false; for (int j = 0; j < nStudentCount; j++) { string seat0 = ci.Data.Student[j].SEAT.Replace("-", ""); if (seat0 == "") { seat0 = "0"; } int nSeat0 = Util.toInt(seat0); if (i == nSeat0) { ishasnum = true; break; } } if (ishasnum) { textimg = ac.DrawingString(Brushes.DimGray, i + ""); lbimg = ac.DrawingArcFill(1, 1, System.Drawing.Color.FromArgb(204, 204, 204), 2, 41, System.Drawing.Color.White); } pic.Location = new System.Drawing.Point(_locationWidth, _locationHeight); pic.Name = "click_" + i; pic.Size = new System.Drawing.Size(41, 41); pic.TabIndex = 0; pic.Image = lbimg; PictureBox text = new PictureBox(); text.BackColor = System.Drawing.Color.Transparent; text.Location = new System.Drawing.Point(0, 0); text.Name = "text_" + i; text.Size = new System.Drawing.Size(41, 41); text.TabIndex = 0; text.Image = textimg; pic.Controls.Add(text); al.Add(pic); alText.Add(text); clickstate.Add(0); this.panel1.Controls.Add(pic); } return(panelHeight); }
private int SetPanel(string numberstr) { ClassInfo ci = JsonOper.DeserializeJsonToObject <ClassInfo>(numberstr); si = ci.Data.Student; int _count = screenWidth / 51; int _line = ci.Data.StudentCount % _count > 0 ? ci.Data.StudentCount / _count + 1 : ci.Data.StudentCount / _count; int panelHeight = _line * 50 + 10;/////////////////////// if (_line == 2) { panelHeight = _line * 50 + 60; } else if (_line == 1) { panelHeight = _line * 50 + 110; } int panelLH = this.screenHeight - panelHeight; this.webBrowser1.Size = new System.Drawing.Size(screenWidth, screenHeight - panelHeight - 80); ///this.panel1.Location = new System.Drawing.Point(0, 0);//panelLH /// this.panel1.Size = new System.Drawing.Size(this.screenWidth, panelHeight); this.panel2.Location = new System.Drawing.Point(0, 0); this.panel2.Size = new System.Drawing.Size(this.screenWidth, panelHeight); //"✔", "✘" int picWidth = 200; double picHightRatio = 0.12; pictureBox_A.Top = (int)(panelHeight * picHightRatio); pictureBox_B.Top = (int)(panelHeight * picHightRatio); pictureBox_C.Top = (int)(panelHeight * picHightRatio); pictureBox_D.Top = (int)(panelHeight * picHightRatio); pictureBox_R.Top = (int)(panelHeight * picHightRatio); pictureBox_W.Top = (int)(panelHeight * picHightRatio); double picLeft = 0.08; pictureBox_A.Left = (int)(screenWidth * (picLeft + 0.15 * 0)); pictureBox_B.Left = (int)(screenWidth * (picLeft + 0.15 * 1)); pictureBox_C.Left = (int)(screenWidth * (picLeft + 0.15 * 2)); pictureBox_D.Left = (int)(screenWidth * (picLeft + 0.15 * 3)); pictureBox_R.Left = (int)(screenWidth * (picLeft + 0.15 * 4)); pictureBox_W.Left = (int)(screenWidth * (picLeft + 0.15 * 5)); if (screenWidth <= 1024) { pictureBox_A.Left = 50; pictureBox_B.Left = 210; pictureBox_C.Left = 370; pictureBox_D.Left = 530; pictureBox_R.Left = 690; pictureBox_W.Left = 850; } int textLeftBias = 20; label_A.Left = pictureBox_A.Left - textLeftBias; label_B.Left = pictureBox_B.Left - textLeftBias; label_C.Left = pictureBox_C.Left - textLeftBias; label_D.Left = pictureBox_D.Left - textLeftBias; label_R.Left = pictureBox_R.Left - textLeftBias; label_W.Left = pictureBox_W.Left - textLeftBias; int textTopBias = 3; label_A.Top = textTopBias; label_B.Top = textTopBias; label_C.Top = textTopBias; label_D.Top = textTopBias; label_R.Top = textTopBias; label_W.Top = textTopBias; int text2LeftBias = 78; label_Ar.Left = pictureBox_A.Left + text2LeftBias; label_Br.Left = pictureBox_B.Left + text2LeftBias; label_Cr.Left = pictureBox_C.Left + text2LeftBias; label_Dr.Left = pictureBox_D.Left + text2LeftBias; label_Rr.Left = pictureBox_R.Left + text2LeftBias; label_Wr.Left = pictureBox_W.Left + text2LeftBias; label_Ar.BackColor = CircleBackgroundColor; label_Br.BackColor = CircleBackgroundColor; label_Cr.BackColor = CircleBackgroundColor; label_Dr.BackColor = CircleBackgroundColor; label_Rr.BackColor = CircleBackgroundColor; label_Wr.BackColor = CircleBackgroundColor; int text2TopBias = 60; label_Ar.Top = text2TopBias; label_Br.Top = text2TopBias; label_Cr.Top = text2TopBias; label_Dr.Top = text2TopBias; label_Rr.Top = text2TopBias; label_Wr.Top = text2TopBias; this.pictureBox_A.Size = new System.Drawing.Size(160, 160); this.pictureBox_B.Size = new System.Drawing.Size(160, 160); this.pictureBox_C.Size = new System.Drawing.Size(160, 160); this.pictureBox_D.Size = new System.Drawing.Size(160, 160); this.pictureBox_R.Size = new System.Drawing.Size(160, 160); this.pictureBox_W.Size = new System.Drawing.Size(160, 160); //pictureBox_A.Location = new System.Drawing.Point(picWidth, panelLH + 39); //pictureBox_B.Location = new System.Drawing.Point(picWidth * 2, panelLH + 39); //pictureBox_C.Location = new System.Drawing.Point(picWidth * 3, panelLH + 39); //pictureBox_D.Location = new System.Drawing.Point(picWidth * 4, panelLH + 39); //pictureBox_R.Location = new System.Drawing.Point(picWidth * 5, panelLH + 39); //pictureBox_W.Location = new System.Drawing.Point(picWidth * 6, panelLH + 39); statisticABCD(); int highInterval = 10;//三行的行间距 if (_line == 2) { highInterval = 25;//两行变三行,两行的行间距 } else if (_line == 1) { highInterval = 55; } int _lw = 0; int _br = 1; int _locationWidth = 0; int _locationHeight = 40; for (int i = 1; i <= ci.Data.StudentCount; i++) { _locationHeight = (_lw * 40) + ((_lw + 1) * highInterval); if (i == 1 || _br % 2 == 0) { _locationWidth = (screenWidth - _count * 51) / 2 + 5; } else { _locationWidth += 51; } if (i % _count == 0) { _br *= 2; if (_lw <= _line) { _lw++; } } else { _br = 1; } PictureBox pic = new PictureBox(); AnswerCount ac = new AnswerCount(); ac.ImageWidth = 40; ac.ImagesHeight = 40; ac.FontStyle = System.Drawing.FontStyle.Bold; ac.AnswerFamily = "微软雅黑"; ac.AnswerFontSize = 15.75F; Image lbimg = ac.DrawingArcFill(1, 1, System.Drawing.Color.FromArgb(254, 80, 79), 0, 41, System.Drawing.Color.FromArgb(254, 80, 79)); Image textimg = ac.DrawingString(Brushes.White, i + ""); bool ishasnum = false; int nStudentCount = ci.Data.Student.Length; for (int j = 0; j < nStudentCount; j++) { string seat0 = ci.Data.Student[j].SEAT.Replace("-", ""); if (seat0 == "") { seat0 = "0"; } int nSeat0 = Util.toInt(seat0); if (i == nSeat0) { ishasnum = true; break; } } if (ishasnum) { textimg = ac.DrawingString(Brushes.DimGray, i + ""); lbimg = ac.DrawingArcFill(1, 1, System.Drawing.Color.FromArgb(204, 204, 204), 2, 41, System.Drawing.Color.White); } pic.Location = new System.Drawing.Point(_locationWidth, _locationHeight); pic.Name = "click_" + i; pic.Size = new System.Drawing.Size(41, 41); pic.TabIndex = 0; pic.Image = lbimg; PictureBox text = new PictureBox(); text.BackColor = System.Drawing.Color.Transparent; text.Location = new System.Drawing.Point(0, 0); text.Name = "text_" + i; text.Size = new System.Drawing.Size(41, 41); text.TabIndex = 0; text.Image = textimg; pic.Controls.Add(text); al.Add(pic); alText.Add(text); clickstate.Add(0); this.panel1.Controls.Add(pic); } return(panelHeight); }
private void SetPanel(string numberstr) { ClassInfo ci = JsonOper.DeserializeJsonToObject <ClassInfo>(numberstr); si = ci.Data.Student; int _count = screenWidth / 51; int _line = ci.Data.StudentCount % _count > 0 ? ci.Data.StudentCount / _count + 1 : ci.Data.StudentCount / _count; int panelHeight = _line * 50 + 10; int panelLH = this.screenHeight - panelHeight; this.panel1.Location = new System.Drawing.Point(0, panelLH); this.panel1.Size = new System.Drawing.Size(this.screenWidth, panelHeight); int _lw = 0; int _br = 1; int _locationWidth = 0; int _locationHeight = 40; for (int i = 1; i <= ci.Data.StudentCount; i++) { _locationHeight = (_lw * 40) + ((_lw + 1) * 10); if (i == 1 || _br % 2 == 0) { _locationWidth = (screenWidth - _count * 51) / 2 + 5; } else { _locationWidth += 51; } if (i % _count == 0) { _br *= 2; if (_lw <= _line) { _lw++; } } else { _br = 1; } PictureBox pic = new PictureBox(); AnswerCount ac = new AnswerCount(); ac.ImageWidth = 40; ac.ImagesHeight = 40; ac.FontStyle = System.Drawing.FontStyle.Bold; ac.AnswerFamily = "微软雅黑"; ac.AnswerFontSize = 15.75F; Image lbimg = ac.DrawingArcFill(1, 1, System.Drawing.Color.FromArgb(254, 80, 79), 0, 41, System.Drawing.Color.FromArgb(254, 80, 79)); Image textimg = ac.DrawingString(Brushes.White, i + ""); bool ishasnum = false; string[] szStudentNumber = ci.Data.StudentNumbers.Split(','); int nStudent = szStudentNumber.Length; for (int j = 1; j <= nStudent; j++) { if (i == j) { ishasnum = true; break; } } if (ishasnum) { textimg = ac.DrawingString(Brushes.DimGray, i + ""); lbimg = ac.DrawingArcFill(1, 1, System.Drawing.Color.FromArgb(204, 204, 204), 2, 41, System.Drawing.Color.White); } pic.Location = new System.Drawing.Point(_locationWidth, _locationHeight); pic.Name = "click_" + i; pic.Size = new System.Drawing.Size(41, 41); pic.TabIndex = 0; pic.Image = lbimg; PictureBox text = new PictureBox(); text.BackColor = System.Drawing.Color.Transparent; text.Location = new System.Drawing.Point(0, 0); text.Name = "text_" + i; text.Size = new System.Drawing.Size(41, 41); text.TabIndex = 0; text.Image = textimg; pic.Controls.Add(text); al.Add(pic); alText.Add(text); clickstate.Add(0); this.panel1.Controls.Add(pic); } }