温馨提示:代码在线浏览功能只能做为源码浏览参考,如果想更进一步了解该代码请下载:Asp.net在线考试系统源码及毕业设计论文
当前文件:
ExamOnline/Students/WSEndTime.asmx[1K,2009-6-12 11:42:06],打开代码结构图
ExamOnline/Students/WSEndTime.asmx[1K,2009-6-12 11:42:06],打开代码结构图1<%@ WebService Language="C#" Class="ExamOnline.WSEndTime" %> 2
3
using System; 4
using System.Web; 5
using System.Web.Services; 6
using System.Web.Services.Protocols; 7
using System.Web.Script.Services; 8
9
namespace ExamOnline 10
{ 11
[WebService(Namespace = "http://tempuri.org/")] 12
[WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)] 13
[ScriptService] 14
public class WSEndTime : System.Web.Services.WebService 15
{ 16
[WebMethod] 17
public string getEndTime() 18
{ 19
DateTime dt; 20
if(HttpContext.Current.Application["EndTime"] != null) 21
{ 22
dt =Convert.ToDateTime(HttpContext.Current.Application["EndTime"]); 23
} 24
else 25
{ 26
dt = (new ExamOnline.Exam()).getEndTime(); 27
HttpContext.Current.Application["EndTime"] = dt; 28
} 29
TimeSpan ts = dt - DateTime.Now; 30
31
string hours = ""; 32
string minutes = ""; 33
if(ts.Hours < 10) 34
{ 35
hours = "0" + ts.Hours.ToString(); 36
} 37
else 38
{ 39
hours = ts.Hours.ToString(); 40
} 41
if (ts.Minutes < 10) 42
{ 43
minutes = "0" + ts.Minutes.ToString(); 44
} 45
else 46
{ 47
minutes = ts.Minutes.ToString(); 48
} 49
return hours + ":" + minutes; 50
} 51
} 52
}





[WebService(Namespace 
}
}