⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 wsendtime.asmx

📁 用asp写的程序,在线考试系统,功能齐全,是一个非常好用的系统
💻 ASMX
字号:
<%@ WebService Language="C#" Class="ExamOnline.WSEndTime" %>

using System;
using System.Web;
using System.Web.Services;
using System.Web.Services.Protocols;
using System.Web.Script.Services;

namespace ExamOnline
{
    [WebService(Namespace = "http://tempuri.org/")]
    [WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
    [ScriptService]
    public class WSEndTime : System.Web.Services.WebService
    {
        [WebMethod]
        public string getEndTime()
        {
            DateTime dt;
            if(HttpContext.Current.Application["EndTime"] != null)
            {
                dt =Convert.ToDateTime(HttpContext.Current.Application["EndTime"]);
            }
            else 
            {
                dt = (new ExamOnline.Exam()).getEndTime();
                HttpContext.Current.Application["EndTime"] = dt;
            }
            TimeSpan ts = dt - DateTime.Now;
            
            string hours = "";
            string minutes = "";
            if(ts.Hours < 10)
            {
                hours =  "0" + ts.Hours.ToString();
            }
            else
            {
                hours = ts.Hours.ToString();
            }
            if (ts.Minutes < 10)
            {
                minutes = "0" + ts.Minutes.ToString();
            }
            else
            {
                minutes = ts.Minutes.ToString();
            }
            return hours + ":" + minutes;
        }
    }
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -