private void ShowIpWorkDone() { string Sname = Request.Cookies[LearnSite.Common.CookieHelp.stuCookieNname].Values["Sname"].ToString(); string Snum = Request.Cookies[LearnSite.Common.CookieHelp.stuCookieNname].Values["Snum"].ToString(); string Wcid = Request.QueryString["Cid"].ToString(); string Wmid = Request.QueryString["Mid"].ToString(); VoteLink.NavigateUrl = "~/Student/myevaluate.aspx?Mid=" + Wmid + "&Cid=" + Wcid; LearnSite.BLL.Works bll = new LearnSite.BLL.Works(); LearnSite.Model.Works work = new LearnSite.Model.Works(); work = bll.GetModelByStu(Int32.Parse(Wmid), Snum); BtnScratch.Text = "开始编写"; Thumbnail.ImageUrl = "~/Images/thumbnail.png"; if (work != null) { string Wurl = work.Wurl; string Wthumbnail = work.Wthumbnail; if (!string.IsNullOrEmpty(Wthumbnail)) { Thumbnail.ImageUrl = Wthumbnail + "?temp=" + DateTime.Now.Millisecond.ToString(); Wtitle.Text = HttpUtility.HtmlDecode(work.Wtitle); string urlid = work.Wid.ToString(); Thumbnail.Attributes["OnClick"] = "scratchShare(" + urlid + ")"; } bool IsCheck = work.Wcheck; if (IsCheck) { Labelmsg.Text = "您的作品已评分!<br/>您不可以重新编写!"; BtnScratch.Visible = false; } else { Labelmsg.Text = "您的作品还未评分!<br/>您可以重新修改提交!"; BtnScratch.Text = "继续编写"; } } if (Snum.StartsWith("s")) { BtnBegin.Visible = true; } else { BtnBegin.Visible = false; } }
private void ShowMission() { if (Request.QueryString["id"] != null) { int wid = Int32.Parse(Request.QueryString["id"].ToString()); LearnSite.BLL.Works wbll = new LearnSite.BLL.Works(); LearnSite.Model.Works model = new LearnSite.Model.Works(); string ipwid = "ip" + LearnSite.Common.Computer.MyIp().Replace('.', 'a') + "_" + wid.ToString(); if (Session[ipwid] == null) { wbll.UpdateWhit(wid); Session[ipwid] = wid; } model = wbll.GetModel(wid); Id = wid.ToString(); Owner = model.Wname; Titles = model.Wtitle; this.Page.Title = Titles + " " + Owner; int Wcid = model.Wcid.Value; int Wgrade = model.Wgrade.Value; if (Request.Cookies[LearnSite.Common.CookieHelp.stuCookieNname] != null) { LearnSite.Model.Cook cook = new LearnSite.Model.Cook(); LearnSite.BLL.Room rbll = new LearnSite.BLL.Room(); string result = rbll.GetRcid(cook.Sgrade, cook.Sclass); if (!string.IsNullOrEmpty(result)) { int cid = Int32.Parse(result); if (cid == Wcid && cook.Sgrade == Wgrade) { //如果是正在上的课节内容,则不显示作品的脚本 ViewMode = "true"; } if (Request.Cookies[LearnSite.Common.CookieHelp.teaCookieNname] != null) { ViewMode = "false"; } } } } }
protected void showScratch() { if (Request.QueryString["id"] != null) { int wid = Int32.Parse(Request.QueryString["id"].ToString()); LearnSite.BLL.Works wbll = new LearnSite.BLL.Works(); LearnSite.Model.Works model = new LearnSite.Model.Works(); model = wbll.GetModel(wid); Id = wid.ToString(); LabelTitle.Text = model.Wtitle + " 作者:" + model.Wname; Owner = Owner + " 作者:" + model.Wname; Pic = "http://" + Request.Url.Host + model.Wthumbnail.Replace("~", ""); Titles = model.Wtitle; } else { Pic = Request.ApplicationPath + "Images/thumbnail.png"; } }
private void ShowMission() { if (Request.QueryString["id"] != null) { int wid = Int32.Parse(Request.QueryString["id"].ToString()); LearnSite.BLL.Works wbll = new LearnSite.BLL.Works(); LearnSite.Model.Works model = new LearnSite.Model.Works(); string ipwid = "ip" + LearnSite.Common.Computer.MyIp().Replace('.', 'a') + "_" + wid.ToString(); if (Session[ipwid] == null) { wbll.UpdateWhit(wid); Session[ipwid] = wid; } model = wbll.GetModel(wid); Id = wid.ToString(); Owner = model.Wname; Titles = model.Wtitle; } }
private void ShowWork() { string Wfiletype, Wurl; string Wid = Request.QueryString["Wid"].ToString(); if (LearnSite.Common.WordProcess.IsNum(Wid)) { LearnSite.Model.Works wmodel = new LearnSite.Model.Works(); LearnSite.BLL.Works ws = new LearnSite.BLL.Works(); wmodel = ws.GetModel(Int32.Parse(Wid)); string workfilename = wmodel.Wfilename; WorkSnum = wmodel.Wnum; Wurl = wmodel.Wurl; Wfiletype = wmodel.Wtype; int worklength = wmodel.Wlength.Value; decimal kblen = worklength / 1024; LbWscore.Text = wmodel.Wscore.ToString(); LbWfscore.Text = wmodel.Wfscore.ToString(); LabelWdate.Text = wmodel.Wdate.ToString(); LbWself.Text = HttpUtility.HtmlDecode(wmodel.Wself); LbWdscore.Text = wmodel.Wdscore.ToString(); bool Wflash = wmodel.Wflash.Value; DateTime workdate = wmodel.Wdate.Value; TimeSpan ts = DateTime.Now - workdate; int days = Int32.Parse(LearnSite.Common.XmlHelp.GetWorkDowntime());//获取作品查看天数 int wgrade = wmodel.Wgrade.Value; int wterm = wmodel.Wterm.Value; string Wip = wmodel.Wip; ShowSelf(Int32.Parse(Wid), WorkSnum); ShowFeedback(Int32.Parse(Wid)); ShowGauge(wmodel.Wmid.Value); LearnSite.BLL.Students stbll = new LearnSite.BLL.Students(); string mySname = stbll.GetSnameBySnum(WorkSnum); if (mySname != "") { HLfile.Text = mySname + "." + Wfiletype; } else { HLfile.Text = "模拟学生" + WorkSnum + "." + Wfiletype; } Labelsize.Text = kblen.ToString("N2") + "kb"; Labelgood.Text = "推荐" + LearnSite.Common.WordProcess.StrCountNew(MyFeedback, "T,").ToString() + "次"; Labelwid.Text = Wid; Labeltype.Text = Wfiletype; Labelwurl.Text = Wurl; if (isOffice(Wfiletype)) { if (ws.ExistsMyMissonWork(wmodel.Wmid.Value, cook.Snum)) { Buttonpreview.Visible = true;//是office文档则显示预览查看按钮,以防止因为控件下载而卡页面 } else { Buttonpreview.Visible = false;//如果未交作品的,则无法查看 } } else { Buttonpreview.Visible = false;//不是office文档则直接预览 Literal1.Text = LearnSite.Common.WordProcess.SelectEvaluateShow(Wid, Wfiletype, Wurl, false); } ImageType.ImageUrl = "~/Images/FileType/" + Wfiletype.ToLower() + ".gif"; if (ts.Days < days) { int waitdays = days - ts.Days; if (LearnSite.Common.XmlHelp.GetWorkIpLimit())///如果作品提交IP限制 { if (cook.Snum == WorkSnum && cook.LoginIp == Wip) { HLfile.Visible = true; } else { HLfile.Visible = false; Labelmsg.Text = waitdays.ToString() + "天后可下载"; } } else { if (cook.Snum == WorkSnum) { HLfile.Visible = true; } else { HLfile.Visible = false;//否则 IP没限制或IP不同则限制几天后下载 Labelmsg.Text = waitdays.ToString() + "天后可下载"; } } } else { if (cook.Sgrade == wgrade && cook.ThisTerm == wterm) { if (cook.Snum == WorkSnum) { HLfile.Visible = true;//本学期的作品自己可见,别人不可下载 } else { HLfile.Visible = false;//如果是本学期的作品,则无法下载,呵呵 Labelmsg.Text = "隐藏下载"; Labelmsg.ToolTip = "该作品在版权保护期内,暂时无法下载."; } } else { HLfile.Visible = true;//超过,都可下载 } } HLfile.NavigateUrl = "~/Plugins/download.aspx?Id=" + LearnSite.Common.EnDeCode.Encrypt(Wurl, "ls"); LearnSite.BLL.Mission mbll = new LearnSite.BLL.Mission(); Labelmission.Text = mbll.GetMissionTitle(wmodel.Wmid.Value); } }
/// <summary> /// 显示信息 /// </summary> private void ShowInfo() { string Studentnum = Request.Cookies[LearnSite.Common.CookieHelp.stuCookieNname].Values["Snum"].ToString(); int MySgrade = Int32.Parse(Request.Cookies[LearnSite.Common.CookieHelp.stuCookieNname].Values["Sgrade"].ToString()); int MySclass = Int32.Parse(Request.Cookies[LearnSite.Common.CookieHelp.stuCookieNname].Values["Sclass"].ToString()); int MySyear = Int32.Parse(Request.Cookies[LearnSite.Common.CookieHelp.stuCookieNname].Values["Syear"].ToString()); int MySgroup = Int32.Parse(Request.Cookies[LearnSite.Common.CookieHelp.stuCookieNname].Values["Sgroup"].ToString()); if (MySgroup == 0) { Labelscope.Text = "全班"; } else { Labelscope.Text = "组内"; } string Mid = Request.QueryString["Mid"].ToString(); if (LearnSite.Common.WordProcess.IsNum(Mid)) { LearnSite.Model.Works wmodel = new LearnSite.Model.Works(); LearnSite.BLL.Works ws = new LearnSite.BLL.Works(); LearnSite.BLL.Mission mbll = new LearnSite.BLL.Mission(); LearnSite.Model.Mission mModel = new LearnSite.Model.Mission(); mModel = mbll.GetModel(Int32.Parse(Mid)); ImageWtype.ImageUrl = "~/Images/FileType/" + mModel.Mfiletype + ".gif"; Labelmtitle.Text = "〖" + mModel.Mtitle + "〗"; LabelMgid.Text = mModel.Mgid.ToString(); Labelwmid.Text = Mid; LabelWtype.Text = mModel.Mfiletype; wmodel = ws.GetModelByStu(Int32.Parse(Mid), Studentnum); if (wmodel != null) { DataListvote.DataSource = ws.ShowMissionWorksGroup(MySgrade, MySclass, Int32.Parse(Mid), MySgroup); DataListvote.DataBind(); Labelhow.Text = DataListvote.Items.Count.ToString(); Labelme.Text = wmodel.Wvote.ToString(); string workIp = wmodel.Wip; string worknum = wmodel.Wnum; DateTime workdate = wmodel.Wdate.Value; DateTime nowdate = DateTime.Now; bool worklimit = LearnSite.Common.XmlHelp.GetWorkIpLimit(); Labelegg.Text = wmodel.Wegg.ToString(); Labelwfscore.Text = wmodel.Wfscore.ToString(); TimeSpan ts = nowdate - workdate; int lastday = ts.Days; Labelwdate.Text = lastday.ToString();///取短日期 if (lastday < 30) { if (showRgaugeSet()) { LimitVote();//限制为可预览的投票 } else { Labelmsg.Text = "当前作品互评暂停!"; BtnVote.Enabled = false; } } else { Labelmsg.Text = "一个月前的作品不能再投票了!"; BtnVote.Enabled = false; } } else { if (Studentnum.StartsWith("s")) { DataListvote.DataSource = ws.ShowMissionWorksGroup(MySgrade, MySclass, Int32.Parse(Mid), MySgroup); DataListvote.DataBind(); Labelhow.Text = DataListvote.Items.Count.ToString(); BtnVote.Enabled = true; } else { Labelmsg.Text = "您未提交作品,无法互评!"; BtnVote.Enabled = false; } } } }
/// <summary> /// 显示信息 /// </summary> private void ShowInfo() { string Studentnum = Request.Cookies["StudentCookies"].Values["Snum"].ToString(); int MySgrade = Int32.Parse(Request.Cookies["StudentCookies"].Values["Sgrade"].ToString()); int MySclass = Int32.Parse(Request.Cookies["StudentCookies"].Values["Sclass"].ToString()); string Wid = Request.QueryString["Wid"].ToString(); string Wcid = Request.QueryString["Wcid"].ToString(); if (LearnSite.Common.WordProcess.IsNum(Wid) && LearnSite.Common.WordProcess.IsNum(Wcid)) { LearnSite.Model.Works wmodel = new LearnSite.Model.Works(); LearnSite.BLL.Works ws = new LearnSite.BLL.Works(); wmodel = ws.GetModel(Int32.Parse(Wid)); Labelsort.Text = wmodel.Wmsort.ToString(); Labelegg.Text = wmodel.Wegg.ToString(); LabelCtitle.Text = "〖" + ws.GetCtitle(Int32.Parse(Wid)) + "〗"; Labelme.Text = wmodel.Wvote.ToString(); Labelegg.Text = wmodel.Wegg.ToString(); Labelhow.Text = ws.HowWorks(Int32.Parse(Wcid), MySgrade, MySclass, Int32.Parse(Labelsort.Text)); string workIp = wmodel.Wip; string worknum = wmodel.Wnum; string loginIp = Request.Cookies["StudentCookies"].Values["LoginIp"].ToString(); bool worklimit = LearnSite.Common.XmlHelp.GetWorkIpLimit(); if (workIp == loginIp && Studentnum == worknum) //如果作品提交IP和学号跟登录IP学号一致,则显示所有作品 { DataListvote.DataSource = ws.ShowMissionWorks(Int32.Parse(Wcid), MySgrade, MySclass, Int32.Parse(Labelsort.Text), Studentnum); DataListvote.DataBind(); Session[Studentnum] = workIp;//设置IP } else { Labelmsg.Text = "你提交作品的Ip与登录投票的Ip不同,不能投票!"; } } }
private void uploadthiswork() { if (Request.Files["Filedata"] != null) { try { HttpPostedFile work_upload = Request.Files["Filedata"]; string Wmid = Request.QueryString["mid"].ToString(); string Wnum = Request.QueryString["num"].ToString(); string info = HttpUtility.UrlDecode(Request.QueryString["info"].ToString()); LearnSite.BLL.Mission mbll = new LearnSite.BLL.Mission(); LearnSite.Model.Mission mmodel = new LearnSite.Model.Mission(); mmodel = mbll.GetModel(Int32.Parse(Wmid)); string Wcid = mmodel.Mcid.ToString(); string Wmsort = mmodel.Msort.ToString(); string Wfiletype = work_upload.FileName.Substring(work_upload.FileName.LastIndexOf(".") + 1).ToLower(); // string Wextention = mmodel.Mfiletype; int Wlength = work_upload.ContentLength; //Syear | Sgrade | Sclass | Sid | Sname | Wip | Sterm | LoginTime string[] infoarray = info.Split('|'); string Syear = infoarray[0]; string Sgrade = infoarray[1]; string Sclass = infoarray[2]; string Wsid = infoarray[3]; string Sname = infoarray[4]; string Wip = infoarray[5]; string Wterm = infoarray[6]; string Logintime = infoarray[7]; DateTime Wdate = DateTime.Now; bool checkcan = true; LearnSite.BLL.Works ws = new LearnSite.BLL.Works(); string Wid = ws.WorkDone(Wnum, Int32.Parse(Wcid), Int32.Parse(Wmid));//返回空字符表示不存在该记录 if (Wid != "") { if (!ws.IsChecked(Int32.Parse(Wid))) { //如果未评价,则重新提交修改作品 string MySavePath = LearnSite.Common.WorkUpload.GetWurl(Syear, Sgrade, Sclass, Wcid, Wmid);//获得作品保存路径(如果不存在,自动创建) string RndTime = LearnSite.Common.WordProcess.GetRandomNum(99).ToString(); string OnlyFileName = Wnum + "_" + Wcid + "_" + Wmid + "_" + RndTime; string NewFileName = OnlyFileName + "." + Wfiletype; string Wurl = MySavePath + "/" + NewFileName; string resaveFilename = Server.MapPath(Wurl); try { ws.UpdateWorkUp(Int32.Parse(Wid), Wurl, NewFileName, Wlength, Wdate, checkcan, "");//更新Wfilename, Wurl,Wlength, Wdate //LearnSite.BLL.Signin sn = new LearnSite.BLL.Signin(); //sn.UpdateQwork(Int32.Parse(Wsid), Int32.Parse(Wcid));//更新今天签到表中的作品数量 work_upload.SaveAs(resaveFilename);//保存提交作品 Response.StatusCode = 200; Response.Write(NewFileName); } catch (Exception ex) { Response.StatusCode = 200; Response.Write(ex); } finally { Response.End(); } } else { Response.StatusCode = 200; Response.Write("老师已经评价了!"); Response.End(); } } else { //如果作品未提交,提交作品(Wnum, Wcid,Wmid,Wmsort, Wfilename, Wurl,Wlength, Wdate, Wip, Wtime) string MySavePath = LearnSite.Common.WorkUpload.GetWurl(Syear, Sgrade, Sclass, Wcid, Wmid);//获得作品保存路径(如果不存在,自动创建) string RndTime = LearnSite.Common.WordProcess.GetRandomNum(99).ToString(); string OnlyFileName = Wnum + "_" + Wcid + "_" + Wmid + "_" + RndTime; string NewFileName = OnlyFileName + "." + Wfiletype; string Wurl = MySavePath + "/" + NewFileName; string Wtime = LearnSite.Common.Computer.TimePassed(Logintime).ToString(); LearnSite.Model.Works wmodel = new LearnSite.Model.Works(); wmodel.Wnum = Wnum; wmodel.Wcid = Int32.Parse(Wcid); wmodel.Wmid = Int32.Parse(Wmid); wmodel.Wmsort = Int32.Parse(Wmsort); wmodel.Wfilename = NewFileName; wmodel.Wtype = Wfiletype; wmodel.Wurl = Wurl; wmodel.Wlength = Wlength; wmodel.Wdate = Wdate; wmodel.Wip = Wip; wmodel.Wtime = Wtime; wmodel.Wcan = checkcan; wmodel.Wcheck = false; wmodel.Wegg = 12;//设定票数为12张 wmodel.Whit = 0; wmodel.Wgrade = Int32.Parse(Sgrade); wmodel.Wterm = Int32.Parse(Wterm); wmodel.Wsid = Int32.Parse(Wsid); wmodel.Wclass = Int32.Parse(Sclass); wmodel.Wname = HttpUtility.UrlDecode(Sname); wmodel.Wyear = Int32.Parse(Syear); switch (Wfiletype) { case "doc": case "ppt": case "xls": case "docx": case "pptx": case "xlsx": case "wps": case "dps": case "et": wmodel.Woffice = true; break; default: wmodel.Woffice = false; break; } wmodel.Wflash = false; wmodel.Werror = false; string saveFilename = Server.MapPath(Wurl); try { ws.AddWorkUp(wmodel); //添加作品提交记录 LearnSite.BLL.Signin sn = new LearnSite.BLL.Signin(); sn.UpdateQwork(Int32.Parse(Wsid), Int32.Parse(Wcid)); //更新今天签到表中的作品数量 work_upload.SaveAs(saveFilename); //保存提交作品 Response.StatusCode = 200; Response.Write(NewFileName); } catch (Exception ex) { Response.StatusCode = 200; Response.Write(ex); } finally { Response.End(); } } } catch (Exception ex) { Response.StatusCode = 200; Response.Write(ex); } finally { Response.End(); } } }
protected void Btnupload_Click(object sender, EventArgs e) { if (IsValid) { string Wmid = Request.QueryString["Mid"].ToString(); if (LearnSite.Common.WordProcess.IsNum(Wmid)) { string Sname = Request.Cookies["StudentCookies"].Values["Sname"].ToString(); string Syear = Request.Cookies["StudentCookies"].Values["Syear"].ToString(); string Sgrade = Request.Cookies["StudentCookies"].Values["Sgrade"].ToString(); string Sclass = Request.Cookies["StudentCookies"].Values["Sclass"].ToString(); string Wnum = Request.Cookies["StudentCookies"].Values["Snum"].ToString(); string Wip = Request.Cookies["StudentCookies"].Values["LoginIp"].ToString(); string LoginTime = Request.Cookies["StudentCookies"].Values["LoginTime"].ToString(); string Wcid = LabelMcid.Text; string Mfiletype = LabelMfiletype.Text; string Wmsort = LabelMsort.Text; DateTime Wdate = DateTime.Now; string iplast = Wip.Substring(Wip.LastIndexOf(".") + 1); if (CheckBoxMupload.Checked)//是否可上传 { string postfilename = this.AttachFile.FileName; int Wlength = Convert.ToInt32(this.AttachFile.ContentLength); if (postfilename != "" && postfilename != null) { if (LearnSite.Common.WorkUpload.CheckType(postfilename, Mfiletype)) //上传类型是否正确 { LearnSite.BLL.Works ws = new LearnSite.BLL.Works(); string Wid = ws.WorkDone(Wnum, Int32.Parse(Wcid), Int32.Parse(Wmid));//返回空字符表示不存在该记录 if (Wid != "") { //重新提交修改作品 string MySavePath = LearnSite.Common.WorkUpload.GetWurl(Syear, Sgrade, Sclass, Wcid, Wmid);//获得作品保存路径(如果不存在,自动创建) string RndTime = (DateTime.Parse(LoginTime)).Minute.ToString(); string NewFileName = Server.UrlDecode(Sname) + Wcid + "_" + Wmid + "_" + RndTime + iplast + "." + Mfiletype; string Wurl = MySavePath + "/" + NewFileName; string saveFilename = Server.MapPath(Wurl); try { this.AttachFile.MoveTo(saveFilename, Brettle.Web.NeatUpload.MoveToOptions.Overwrite);//保存提交作品 ws.UpdateWorkUp(Int32.Parse(Wid), Wurl, NewFileName, Wlength, Wdate,CheckBoxCan.Checked);//更新Wfilename, Wurl,Wlength, Wdate string ch = "课程活动" + Wmsort + "重新提交作品成功!"; Labelmsg.Text = ch; LearnSite.Common.WordProcess.Alert(ch, this.Page); } catch (Exception ex) { throw ex; } } else { //如果作品未提交,提交作品(Wnum, Wcid,Wmid,Wmsort, Wfilename, Wurl,Wlength, Wdate, Wip, Wtime) string MySavePath = LearnSite.Common.WorkUpload.GetWurl(Syear, Sgrade, Sclass, Wcid, Wmid);//获得作品保存路径(如果不存在,自动创建) string RndTime = (DateTime.Parse(LoginTime)).Minute.ToString(); string NewFileName = Server.UrlDecode(Sname) + Wcid + "_" + Wmid + "_" + RndTime + iplast + "." + Mfiletype; string Wurl = MySavePath + "/" + NewFileName; string Wtime = LearnSite.Common.Computer.TimePassed().ToString(); LearnSite.Model.Works wmodel = new LearnSite.Model.Works(); wmodel.Wnum = Wnum; wmodel.Wcid = Int32.Parse(Wcid); wmodel.Wmid = Int32.Parse(Wmid); wmodel.Wmsort = Int32.Parse(Wmsort); wmodel.Wfilename = NewFileName; wmodel.Wurl = Wurl; wmodel.Wlength = Wlength; wmodel.Wdate = Wdate; wmodel.Wip = Wip; wmodel.Wtime = Wtime; wmodel.Wcan = CheckBoxCan.Checked; string saveFilename = Server.MapPath(Wurl); try { this.AttachFile.MoveTo(saveFilename, Brettle.Web.NeatUpload.MoveToOptions.Overwrite);//保存提交作品 ws.AddWorkUp(wmodel);//添加作品提交记录 string worknums = ws.HowCidWorks(Int32.Parse(Wcid), Wnum); if (worknums != "") { LearnSite.BLL.Signin sn = new LearnSite.BLL.Signin(); sn.UpdateQwork(Wnum, Int32.Parse(worknums));//更新今天签到表中的作品数量 } string ch = "课程活动"+Wmsort+"提交作品成功!"; Labelmsg.Text = ch; LearnSite.Common.WordProcess.Alert(ch, this.Page); ShowWorked(); } catch (Exception ex) { throw ex; } } } else { Labelmsg.Text = "提交类型错误!"; string ch = "提交作品类型错误!"; LearnSite.Common.WordProcess.Alert(ch, this.Page); } } else { Labelmsg.Text = "你没有选择提交作品!"; string ch = "你没有浏览选择你的作品,请再选择一遍!"; LearnSite.Common.WordProcess.Alert(ch, this.Page); } } else { Labelmsg.Text = "本任务无作品!"; } } } }
private void uploadthiswork() { HttpPostedFile work_upload = Request.Files["imgFile"]; int maxSize = 104857600;//定义上传最大值为100MB if (work_upload != null) { string Wmid = Request.QueryString["mid"].ToString(); string Wnum = Request.QueryString["num"].ToString(); LearnSite.BLL.Mission mbll = new LearnSite.BLL.Mission(); LearnSite.Model.Mission mmodel = new LearnSite.Model.Mission(); mmodel = mbll.GetModel(Int32.Parse(Wmid)); string Wcid = mmodel.Mcid.ToString(); string Wmsort = mmodel.Msort.ToString(); string Wfiletype = work_upload.FileName.Substring(work_upload.FileName.LastIndexOf(".") + 1).ToLower(); string Wextention = mmodel.Mfiletype; string limitext = Wextention;//初始化,随意 switch (Wextention) { case "doc": limitext = "*.doc;*.docx"; break; case "ppt": limitext = "*.ppt;*.pptx"; break; case "xls": limitext = "*.xls;*.xlsx"; break; case "office": limitext = "*.doc;*.docx;*.ppt;*.pptx;*.xls;*.xlsx"; break; case "sb": limitext = "*.sb;*.sb2"; break; default: limitext = "*." + Wextention; break; } if (Wfiletype == Wextention || limitext.Contains(Wfiletype)) { if (work_upload.InputStream != null || work_upload.InputStream.Length < maxSize) { int Wlength = work_upload.ContentLength; string Syear = Request.Cookies[LearnSite.Common.CookieHelp.stuCookieNname].Values["Syear"].ToString(); string Sgrade = Request.Cookies[LearnSite.Common.CookieHelp.stuCookieNname].Values["Sgrade"].ToString(); string Sclass = Request.Cookies[LearnSite.Common.CookieHelp.stuCookieNname].Values["Sclass"].ToString(); string Wsid = Request.Cookies[LearnSite.Common.CookieHelp.stuCookieNname].Values["Sid"].ToString(); string Wip = Request.Cookies[LearnSite.Common.CookieHelp.stuCookieNname].Values["LoginIp"].ToString(); string Sname = Request.Cookies[LearnSite.Common.CookieHelp.stuCookieNname].Values["Sname"].ToString(); string Wterm = Request.Cookies[LearnSite.Common.CookieHelp.stuCookieNname].Values["ThisTerm"].ToString(); DateTime Wdate = DateTime.Now; bool checkcan = true; LearnSite.BLL.Works ws = new LearnSite.BLL.Works(); string Wid = ws.WorkDone(Wnum, Int32.Parse(Wcid), Int32.Parse(Wmid));//返回空字符表示不存在该记录 if (Wid != "") { if (!ws.IsChecked(Int32.Parse(Wid))) { //如果未评价,则重新提交修改作品 string MySavePath = LearnSite.Common.WorkUpload.GetWurl(Syear, Sgrade, Sclass, Wcid, Wmid);//获得作品保存路径(如果不存在,自动创建) string RndTime = LearnSite.Common.WordProcess.GetRandomNum(99).ToString(); string OnlyFileName = Wnum + "_" + Wcid + "_" + Wmid + "_" + RndTime; string NewFileName = OnlyFileName + "." + Wfiletype; string Wurl = MySavePath + "/" + NewFileName; string resaveFilename = Server.MapPath(Wurl); ws.UpdateWorkUp(Int32.Parse(Wid), Wurl, NewFileName, Wlength, Wdate, checkcan, ""); //更新Wfilename, Wurl,Wlength, Wdate LearnSite.BLL.Signin sn = new LearnSite.BLL.Signin(); sn.UpdateQwork(Int32.Parse(Wsid), Int32.Parse(Wcid)); //更新今天签到表中的作品数量 work_upload.SaveAs(resaveFilename); //保存提交作品 Hashtable hash = new Hashtable(); hash["error"] = 0; Response.AddHeader("Content-Type", "text/html; charset=UTF-8"); Response.Write(JsonMapper.ToJson(hash)); Response.End(); } else { showError("老师已经评价了!"); } } else { //如果作品未提交,提交作品(Wnum, Wcid,Wmid,Wmsort, Wfilename, Wurl,Wlength, Wdate, Wip, Wtime) string MySavePath = LearnSite.Common.WorkUpload.GetWurl(Syear, Sgrade, Sclass, Wcid, Wmid);//获得作品保存路径(如果不存在,自动创建) string RndTime = LearnSite.Common.WordProcess.GetRandomNum(99).ToString(); string OnlyFileName = Wnum + "_" + Wcid + "_" + Wmid + "_" + RndTime; string NewFileName = OnlyFileName + "." + Wfiletype; string Wurl = MySavePath + "/" + NewFileName; string Wtime = LearnSite.Common.Computer.TimePassed().ToString(); LearnSite.Model.Works wmodel = new LearnSite.Model.Works(); wmodel.Wnum = Wnum; wmodel.Wcid = Int32.Parse(Wcid); wmodel.Wmid = Int32.Parse(Wmid); wmodel.Wmsort = Int32.Parse(Wmsort); wmodel.Wfilename = NewFileName; wmodel.Wtype = Wextention; wmodel.Wurl = Wurl; wmodel.Wlength = Wlength; wmodel.Wdate = Wdate; wmodel.Wip = Wip; wmodel.Wtime = Wtime; wmodel.Wcan = checkcan; wmodel.Wcheck = false; wmodel.Wegg = 12;//设定票数为12张 wmodel.Whit = 0; wmodel.Wgrade = Int32.Parse(Sgrade); wmodel.Wterm = Int32.Parse(Wterm); wmodel.Wsid = Int32.Parse(Wsid); wmodel.Wclass = Int32.Parse(Sclass); wmodel.Wname = HttpUtility.UrlDecode(Sname); wmodel.Wyear = Int32.Parse(Syear); switch (Wfiletype) { case "doc": case "ppt": case "xls": case "docx": case "pptx": case "xlsx": case "wps": case "dps": case "et": wmodel.Woffice = true; break; default: wmodel.Woffice = false; break; } wmodel.Wflash = false; wmodel.Werror = false; string saveFilename = Server.MapPath(Wurl); ws.AddWorkUp(wmodel); //添加作品提交记录 LearnSite.BLL.Signin sn = new LearnSite.BLL.Signin(); sn.UpdateQwork(Int32.Parse(Wsid), Int32.Parse(Wcid)); //更新今天签到表中的作品数量 work_upload.SaveAs(saveFilename); //保存提交作品 Hashtable hash = new Hashtable(); hash["error"] = 0; Response.AddHeader("Content-Type", "text/html; charset=UTF-8"); Response.Write(JsonMapper.ToJson(hash)); Response.End(); } } else { showError("选择的文件大小超过限制!(最大为100MB)"); } } else { showError("选择的文件类型错误!"); } } else { showError("请选择文件!"); } }
private void updatescore(string Wid, int Wscore) { LearnSite.Model.Works work = new LearnSite.Model.Works(); work.Wid =Int32.Parse( Wid); work.Wscore = Wscore; work.Wcheck = true; LearnSite.BLL.Works workbll = new LearnSite.BLL.Works(); if (Wscore == 12) { workbll.WgoodBest(Int32.Parse(Wid)); } else { workbll.WgoodNormal(Int32.Parse(Wid)); } workbll.ScoreOneWork(work); System.Threading.Thread.Sleep(500); Labelmsg.Text = "编号为" + Wid + "的作品评分为" + Wscore + "分"; showscore(); GridViewScore.DataBind(); }
private void ShowWork() { string Studentnum = Request.Cookies["StudentCookies"].Values["Snum"].ToString(); string Wfilename, Wfiletype, Wurl, Wip; string Wid = Request.QueryString["Wid"].ToString(); if (LearnSite.Common.WordProcess.IsNum(Wid)) { LearnSite.Model.Works wmodel=new LearnSite.Model.Works(); LearnSite.BLL.Works ws = new LearnSite.BLL.Works(); wmodel=ws.GetModel(Int32.Parse(Wid)); LabelWnum.Text = wmodel.Wnum; Wfilename = wmodel.Wfilename; Wurl = wmodel.Wurl; Wfiletype = LearnSite.Common.FileDown.FileNameExtension(Wurl); string typestr = Wfiletype.Substring(1, Wfiletype.Length - 1); ImageType.ImageUrl = "~/Images/FileType/" + typestr.ToLower() + ".gif"; Labelself.Text = HttpUtility.HtmlDecode(wmodel.Wself); Labelsdate.Text = wmodel.Wdate.ToString(); Labellength.Text = wmodel.Wlength.ToString() + "字节"; Labelfilename.Text = wmodel.Wfilename; LabelWscore.Text = wmodel.Wscore.ToString()+"分"; Wip = wmodel.Wip; TimeSpan ts = DateTime.Now - DateTime.Parse(Labelsdate.Text); Labelspan.Text = ts.Days.ToString() + " 天 "; Session[Studentnum+"Wurl"] = Wurl; string worknum = wmodel.Wnum; string LoginIp = Request.Cookies["StudentCookies"].Values["LoginIp"].ToString(); int days =Int32.Parse( LearnSite.Common.XmlHelp.GetWorkDowntime());//获取作品查看天数 HyperLinkreturn.NavigateUrl = "~/Student/myvote.aspx?Wid=" + Wid + "&Wcid=" + wmodel.Wcid.ToString() + "&Wmsort="+wmodel.Wmsort.ToString(); LearnSite.BLL.Mission mbll = new LearnSite.BLL.Mission(); Labelmission.Text = mbll.GetMissionTitle(wmodel.Wmid.Value); if (Wip == LoginIp && worknum==Studentnum) { LBtnfile.Visible = true; if (Labelself.Text != "") { Btnword.Text = "修改自评"; } else { Btnword.Text = "添加自评"; } } else { if (ts.Days > days) { Btnword.Text = "添加互评"; LBtnfile.Visible = true; } else { Labelmsg.Text = days.ToString()+"天后可查看"; LBtnfile.Visible = false; } } //Labelmsg.Text = Wurl; } }
/// <summary> /// ��������б� /// </summary> public List<LearnSite.Model.Works> DataTableToList(DataTable dt) { List<LearnSite.Model.Works> modelList = new List<LearnSite.Model.Works>(); int rowsCount = dt.Rows.Count; if (rowsCount > 0) { LearnSite.Model.Works model; for (int n = 0; n < rowsCount; n++) { model = new LearnSite.Model.Works(); if (dt.Rows[n]["Wid"].ToString() != "") { model.Wid = int.Parse(dt.Rows[n]["Wid"].ToString()); } model.Wnum = dt.Rows[n]["Wnum"].ToString(); if (dt.Rows[n]["Wcid"].ToString() != "") { model.Wcid = int.Parse(dt.Rows[n]["Wcid"].ToString()); } if (dt.Rows[n]["Wmid"].ToString() != "") { model.Wmid = int.Parse(dt.Rows[n]["Wmid"].ToString()); } if (dt.Rows[n]["Wmsort"].ToString() != "") { model.Wmsort = int.Parse(dt.Rows[n]["Wmsort"].ToString()); } model.Wfilename = dt.Rows[n]["Wfilename"].ToString(); model.Wurl = dt.Rows[n]["Wurl"].ToString(); if (dt.Rows[n]["Wlength"].ToString() != "") { model.Wlength = int.Parse(dt.Rows[n]["Wlength"].ToString()); } if (dt.Rows[n]["Wscore"].ToString() != "") { model.Wscore = int.Parse(dt.Rows[n]["Wscore"].ToString()); } if (dt.Rows[n]["Wdate"].ToString() != "") { model.Wdate = DateTime.Parse(dt.Rows[n]["Wdate"].ToString()); } model.Wip = dt.Rows[n]["Wip"].ToString(); model.Wtime = dt.Rows[n]["Wtime"].ToString(); if (dt.Rows[n]["Wvote"].ToString() != "") { model.Wvote = int.Parse(dt.Rows[n]["Wvote"].ToString()); } if (dt.Rows[n]["Wegg"].ToString() != "") { model.Wegg = int.Parse(dt.Rows[n]["Wegg"].ToString()); } if (dt.Rows[n]["Wcheck"].ToString() != "") { if ((dt.Rows[n]["Wcheck"].ToString() == "1") || (dt.Rows[n]["Wcheck"].ToString().ToLower() == "true")) { model.Wcheck = true; } else { model.Wcheck = false; } } model.Wself = dt.Rows[n]["Wself"].ToString(); if (dt.Rows[n]["Wcan"].ToString() != "") { if ((dt.Rows[n]["Wcan"].ToString() == "1") || (dt.Rows[n]["Wcan"].ToString().ToLower() == "true")) { model.Wcan = true; } else { model.Wcan = false; } } if (dt.Rows[n]["Wgood"].ToString() != "") { if ((dt.Rows[n]["Wgood"].ToString() == "1") || (dt.Rows[n]["Wgood"].ToString().ToLower() == "true")) { model.Wgood = true; } else { model.Wgood = false; } } modelList.Add(model); } } return modelList; }