MVC自定义验证Authorize,总括结余数

有三个网络朋友问及,在SQL中,总计每一笔的盈余数。他提供的截图注脚:
997755.com澳门葡京 1

后天Insus.NET有在数据库达成过对某一字段进展加密码与解密《利用EncryptByPass布莱顿沙滩se和DecryptByPass阿蒙森湾滩se对MS
SQLServer某一字段时行加密和解密》[

Ticks是贰个周期,存款和储蓄的是一百皮秒,换算为秒,一千卓殊之一秒。
咱们需求总计2个日子里面,经过多少Ticks,能够运用上面包车型大巴章程来实现,使用2个日子相减。

Ticks是二个周期,存款和储蓄的是一百皮秒,换算为秒,壹仟极度之一秒。
我们须求计算2个时辰之间,经过多少Ticks,能够运用下边的法子来兑现,使用2个日子相减。

 

](
MVC完成自定义验证Authorize Attribute。

获取结果为正数,是使用较晚的时日减去较早的日子。反之为负数,便是使用较早的时光减去较晚的年华。

获得结果为正数,是采取较晚的时日减去较早的日子。反之为负数,正是使用较早的光阴减去较晚的时光。

997755.com澳门葡京 2

兑现以前,Insus.NET对usp_Users_VeryLoginVerify修改一下,改为更加好驾驭与应用:
997755.com澳门葡京 3

始建一个对象:
997755.com澳门葡京 4

创制三个目的:
997755.com澳门葡京 5

 

 

 

 

贯彻那么些作用,关键是获取前一笔记录eqty字段的值。

997755.com澳门葡京 6997755.com澳门葡京 7

997755.com澳门葡京 8997755.com澳门葡京 9

997755.com澳门葡京 10997755.com澳门葡京 11

上边Insus.NET尝试写一下。使用最简易的法子,正是循环每一笔记录。然后能够计算qty加上前一笔的eqty。

SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
ALTER PROCEDURE [dbo].[usp_Users_VeryLoginVerify]
(
    @U_nbr NVARCHAR(20),
    @pwd NVARCHAR(100)
)
AS
BEGIN    
    DECLARE @errmsg NVARCHAR(50) = N'用户名或密码错误。'

    IF NOT EXISTS(SELECT TOP 1 1 FROM [dbo].[Users] WHERE [U_nbr] = @U_nbr)
    BEGIN    
        RAISERROR(@errmsg,16,1)
        RETURN
    END

    SELECT [U_nbr] AS [Account] FROM [dbo].[Users] WHERE [U_nbr] = @U_nbr AND CONVERT(NVARCHAR(100),DECRYPTBYPASSPHRASE('insus#sec!%y',[Pwd]))  = @pwd  

    IF @@ROWCOUNT <= 0
    BEGIN    
        RAISERROR(@errmsg,16,1)
        RETURN
    END
END
 class Ag
    {
        private DateTime _StartDate;

        public DateTime StartDate
        {
            get { return _StartDate; }
            set { _StartDate = value; }
        }
        private DateTime _EndDate;

        public DateTime EndDate
        {
            get { return _EndDate; }
            set { _EndDate = value; }
        }

        public Ag(DateTime startDate, DateTime endDate)
        {
            this._StartDate = startDate;
            this._EndDate = endDate;
        }

        public void DurationTicks()
        {           
            TimeSpan ts = (_EndDate - _StartDate).Duration();
            Console.WriteLine(ts.Ticks);
        }
    }
 class Ag
    {
        private DateTime _StartDate;

        public DateTime StartDate
        {
            get { return _StartDate; }
            set { _StartDate = value; }
        }
        private DateTime _EndDate;

        public DateTime EndDate
        {
            get { return _EndDate; }
            set { _EndDate = value; }
        }

        public Ag(DateTime startDate, DateTime endDate)
        {
            this._StartDate = startDate;
            this._EndDate = endDate;
        }

        public void DurationTicks()
        {           
            TimeSpan ts = (_EndDate - _StartDate).Duration();
            Console.WriteLine(ts.Ticks);
        }
    }

开创三个不时表存款和储蓄原数:
997755.com澳门葡京 12

Source Code

Source Code

Source Code

997755.com澳门葡京 13997755.com澳门葡京 14

 

在调节台应用程序运维方面写好的次序:
997755.com澳门葡京 15

在调整台应用程序运转方面写好的主次:
997755.com澳门葡京 16MVC自定义验证Authorize,总括结余数。

CREATE TABLE #tt
(
  [empid] char(3),
  [fdate] date,
  [qty] int
)

INSERT INTO #tt([empid],[fdate],[qty]) VALUES('100','2018-01-01',100)
INSERT INTO #tt([empid],[fdate],[qty]) VALUES('100','2018-01-01',100)
INSERT INTO #tt([empid],[fdate],[qty]) VALUES('100','2018-01-01',120)
INSERT INTO #tt([empid],[fdate],[qty]) VALUES('100','2018-01-01',145)
INSERT INTO #tt([empid],[fdate],[qty]) VALUES('100','2018-01-02',30)
INSERT INTO #tt([empid],[fdate],[qty]) VALUES('100','2018-01-02',150)
INSERT INTO #tt([empid],[fdate],[qty]) VALUES('100','2018-01-02',160)
INSERT INTO #tt([empid],[fdate],[qty]) VALUES('100','2018-01-02',170)
INSERT INTO #tt([empid],[fdate],[qty]) VALUES('100','2018-01-02',121)
INSERT INTO #tt([empid],[fdate],[qty]) VALUES('100','2018-01-02',106)

OK,上边是数据库方面。
摄取你要求在ASP.NET MVC写程序:

 
当今来了,实际情状而不是都是计量2个日子里面包车型地铁Ticks,而是有十分的大恐怕须求总计2个时间之间的秒,分钟,小时,天等。
为了落到实处地点的渴求,大家得询问部分基础知识:
1天= 24;
1小时= 60分钟;
1分钟= 60秒;
1秒= 10000000Ticks;

 
这段时间来了,实际景况实际不是都以测算2个时间里面包车型大巴Ticks,而是有异常的大希望须要总结2个日子之间的秒,分钟,时辰,天等。
为了兑现地点的渴求,我们得询问部分基础知识:
1天= 24;
1小时= 60分钟;
1分钟= 60秒;
1秒= 10000000Ticks;

Source Code

动用Cookie来积存登陆以及表明消息,写一个Cookie体系:
997755.com澳门葡京 17

之所以,遵照上边包车型大巴测算结果(Ticks)和公式可以计算出2个时刻之内的秒,分钟,小时,天等。

之所以,分局方的推断结果(Ticks)和公式能够测算出2个小时里面的秒,分钟,时辰,天等。

 

 

大家在品种中,加多上边4个办法:

咱俩在档案的次序中,加多上面4个艺术:

笔者们初叶拍卖,创制别的叁个有的时候表,原始表相似,但是要求加多2个字段,id和eqty。其中id是本来增进的identity(1,1)。

997755.com澳门葡京 18997755.com澳门葡京 19

997755.com澳门葡京 20

997755.com澳门葡京 21

还亟需把原本数据搬到此新建的有的时候表中:
997755.com澳门葡京 22

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;

namespace Insus.NET.Utilities
{
    public abstract class CookieBase
    {
        private static HttpResponse Response
        {
            get
            {
                return HttpContext.Current.Response;
            }
        }

        private static HttpRequest Request
        {
            get
            {
                return HttpContext.Current.Request;
            }
        }

        public static HttpCookie Cookie
        {
            get
            {
                return Request.Cookies["CookieBase"] as HttpCookie;
            }
            set
            {
                if (Request.Cookies["CookieBase"] != null)
                {
                    Request.Cookies.Remove("CookieBase");
                }
                Response.Cookies.Add(value);
            }
        }

        public static HttpCookie NewCookie
        {
            get
            {
                return new HttpCookie("CookieBase");
            }
        }

        public static void RemoveCookie()
        {
            if (Cookie == null)
                Response.Cookies.Remove("CookieBase");
            else
                Response.Cookies["CookieBase"].Expires = DateTime.Now.AddDays(-1);
        }       
    }
}

997755.com澳门葡京 23997755.com澳门葡京 24

997755.com澳门葡京 25997755.com澳门葡京 26

 

Source Code

 public void DurationSeconds()
        {
            TimeSpan ts = (_EndDate - _StartDate).Duration();
            Console.WriteLine("Duraction Seconds: {0}", ts.Ticks / 10000000L);
        }

        public void DurationMinutes()
        {
            TimeSpan ts = (_EndDate - _StartDate).Duration();
            Console.WriteLine("Duraction Minutes: {0}",ts.Ticks / (10000000L * 60));
        }

        public void DurationHours()
        {
            TimeSpan ts = (_EndDate - _StartDate).Duration();
            Console.WriteLine("Duraction Hours: {0}", ts.Ticks / (10000000L * 60 * 60));
        }

        public void DurationDays()
        {
            TimeSpan ts = (_EndDate - _StartDate).Duration();
            Console.WriteLine("Duraction Days: {0}", ts.Ticks / (10000000L * 60 * 60 * 24));
        }
 public void DurationSeconds()
        {
            TimeSpan ts = (_EndDate - _StartDate).Duration();
            Console.WriteLine("Duraction Seconds: {0}", ts.Ticks / 10000000L);
        }

        public void DurationMinutes()
        {
            TimeSpan ts = (_EndDate - _StartDate).Duration();
            Console.WriteLine("Duraction Minutes: {0}",ts.Ticks / (10000000L * 60));
        }

        public void DurationHours()
        {
            TimeSpan ts = (_EndDate - _StartDate).Duration();
            Console.WriteLine("Duraction Hours: {0}", ts.Ticks / (10000000L * 60 * 60));
        }

        public void DurationDays()
        {
            TimeSpan ts = (_EndDate - _StartDate).Duration();
            Console.WriteLine("Duraction Days: {0}", ts.Ticks / (10000000L * 60 * 60 * 24));
        }

997755.com澳门葡京 27997755.com澳门葡京 28

 
事实上下边那几个CookeBase.cs是一个能储存多指标的集结类。在真的的次序中,你想囤积什么音讯,可以写一个如下边包车型大巴类来操作:
997755.com澳门葡京 29

Source Code

Source Code

CREATE TABLE #ttt
(
    [id] int identity(1,1),
    [empid] char(3),
    [fdate] date,
    [qty] int, 
    [eqty] int
)

INSERT INTO #ttt([empid],[fdate],[qty]) SELECT  [empid],[fdate],[qty]  FROM #tt

 

 

 

Source Code

997755.com澳门葡京 30997755.com澳门葡京 31

主意写完,在调节台测验一下方面包车型大巴主意:
997755.com澳门葡京 32

办法写完,在调节台测量检验一下方面包车型地铁格局:
997755.com澳门葡京 33

 

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Web;

namespace Insus.NET.Utilities
{
   public class SecurityBase
    {
        public static bool IsAuthorized
        {
            get
            {
                return CookieBase.Cookie == null ? false : bool.Parse(CookieBase.Cookie.Values["IsAuthorized"]);
            }
            set
            {
                HttpCookie httpCookie = CookieBase.Cookie == null ? CookieBase.NewCookie : CookieBase.Cookie;
                httpCookie.Values["IsAuthorized"] = value.ToString();
                CookieBase.Cookie = httpCookie;
            }
        }

        public static string UserName
        {
            get
            {
                return CookieBase.Cookie == null ? string.Empty : CookieBase.Cookie.Values["UserName"];
            }
            set
            {
                HttpCookie httpCookie = CookieBase.Cookie == null ? CookieBase.NewCookie : CookieBase.Cookie;
                httpCookie.Values["UserName"] = value;
                CookieBase.Cookie = httpCookie;
            }
        }

        public static void RemoveCooke()
        {
            CookieBase.RemoveCookie();
        }
    }
}

 

 

接下去,Insus.NET写了二个仓库储存进程,方法如下:
997755.com澳门葡京 34

Source Code

 上边的总结办法某些原始,MSDN已经交由相应的办法,就能够计算出2个时刻里面包车型地铁秒,分钟,小时,天等。如:
TotalSeconds(),TotalMinutes(),TotalHours(),TotalDays();
为了演示与测量试验,Insus.NET再成立别的4个方法:

 上边的乘除方法某些原始,MSDN已经付出相应的不二等秘书诀,就能够总括出2个小时里面包车型客车秒,分钟,小时,天等。如:
TotalSeconds(),TotalMinutes(),TotalHours(),TotalDays();
为了演示与测量检验,Insus.NET再成立别的4个方法:

 

接下去,我们要求创设三个认证过滤器:
997755.com澳门葡京 35

997755.com澳门葡京 36

997755.com澳门葡京 37

997755.com澳门葡京 38997755.com澳门葡京 39

997755.com澳门葡京 40997755.com澳门葡京 41

997755.com澳门葡京 42997755.com澳门葡京 43

997755.com澳门葡京 44997755.com澳门葡京 45

DECLARE @r int = 1,@rs INT = 0
SELECT @rs = MAX([empid]) FROM #ttt

WHILE @r <= @rs 
BEGIN    
    IF (@r = 1 )
        UPDATE #ttt SET [eqty] = [qty] WHERE [id] = @r --处理第一笔记录
    ELSE
    BEGIN
        DECLARE @eqty INT 
        SELECT @eqty = [eqty] FROM #ttt WHERE [id] = @r - 1  --获取前一笔的结余数

        UPDATE #ttt SET [eqty] = [qty] + @eqty  WHERE [id] = @r  --计算后更新当前记录的eqty字段值。
    END    

    SET @r = @r+ 1
END
GO
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Web;
using System.Web.Mvc;
using Insus.NET.Utilities;
using System.Web.Routing;

namespace Insus.NET.Attributes
{
    public class SecurityAuthorizeAttribute : AuthorizeAttribute
    {
        protected override bool AuthorizeCore(HttpContextBase httpContext)
        {
            return SecurityBase.IsAuthorized;
        }

        public override void OnAuthorization(AuthorizationContext filterContext)
        {
            string controllerName = filterContext.ActionDescriptor.ControllerDescriptor.ControllerName;
            string actionName = filterContext.ActionDescriptor.ActionName;           
            base.OnAuthorization(filterContext);
        }

        protected override void HandleUnauthorizedRequest(AuthorizationContext filterContext)
        {
            var routeValue = new RouteValueDictionary {
                { "Controller", "Home"},
                { "Action", "Index"}
            };
            filterContext.Result = new RedirectToRouteResult(routeValue);
        }
    }
}
  public void TotalSeconds()
        {
            TimeSpan ts = (_EndDate - _StartDate).Duration();
            Console.WriteLine("Duraction Seconds: {0}", ts.TotalSeconds);
        }

        public void TotalMinutes()
        {
            TimeSpan ts = (_EndDate - _StartDate).Duration();
            Console.WriteLine("Duraction Minutes: {0}", ts.TotalMinutes);
        }

        public void TotalHours()
        {
            TimeSpan ts = (_EndDate - _StartDate).Duration();
            Console.WriteLine("Duraction Hours: {0}", ts.TotalHours);
        }

        public void TotalDays()
        {
            TimeSpan ts = (_EndDate - _StartDate).Duration();
            Console.WriteLine("Duraction Days: {0}", ts.TotalDays);
        }
  public void TotalSeconds()
        {
            TimeSpan ts = (_EndDate - _StartDate).Duration();
            Console.WriteLine("Duraction Seconds: {0}", ts.TotalSeconds);
        }

        public void TotalMinutes()
        {
            TimeSpan ts = (_EndDate - _StartDate).Duration();
            Console.WriteLine("Duraction Minutes: {0}", ts.TotalMinutes);
        }

        public void TotalHours()
        {
            TimeSpan ts = (_EndDate - _StartDate).Duration();
            Console.WriteLine("Duraction Hours: {0}", ts.TotalHours);
        }

        public void TotalDays()
        {
            TimeSpan ts = (_EndDate - _StartDate).Duration();
            Console.WriteLine("Duraction Days: {0}", ts.TotalDays);
        }

Source Code

Source Code

Source Code

Source Code

 

 
其一过滤器SecurityAuthorizeAttribute.cs,稍后大家会在调节器中动用到它。

 

 

管理结果:
997755.com澳门葡京 46

收受你须要写调控器了,不,大家就如少写了有个别物件,如model和Entity:

 

 

 

997755.com澳门葡京 47

997755.com澳门葡京 ,再运维程序:

再运营程序:

 

997755.com澳门葡京 48

997755.com澳门葡京 49

Models写好,还差贰个Entity,这些实体是与数码连接的物件:
997755.com澳门葡京 50

 

 

 

末段的现有的主意,它曾经封装好单位转变与公式计算。

末段的现存的方法,它早就封装好单位转变与公式总括。

在ASP.NET
MVC中,完结登入验证的示范,最少须求八个调整器,三个是给佚名用户访问的,它包括普通的页面和部分着力的操作。另贰个控制器是经过认证通过之后技能访问的页面。
997755.com澳门葡京 51

紧密的用户有能够窥见,2种结果有些不等同,未有小数和有小数。其实能够化解的,把一千格外之一秒那些基数转变为double数据类型就能够。也等于说把能来的L–>D:

留意的用户有能够窥见,2种结出有个别不相同样,未有小数和有小数。其实能够缓慢解决的,把一千非常之一秒这些基数调换为double数据类型就可以。也正是说把能来的L–>D:

另一个调节器:
997755.com澳门葡京 52

997755.com澳门葡京 53

997755.com澳门葡京 54

 

997755.com澳门葡京 55997755.com澳门葡京 56

997755.com澳门葡京 57997755.com澳门葡京 58

终极是创建视图了:
997755.com澳门葡京 59

 public void DurationSeconds()
        {
            TimeSpan ts = (_EndDate - _StartDate).Duration();
            // Console.WriteLine("Duraction Seconds: {0}", ts.Ticks / 10000000L);
            Console.WriteLine("Duraction Seconds: {0}", ts.Ticks / 10000000D);
        }

        public void DurationMinutes()
        {
            TimeSpan ts = (_EndDate - _StartDate).Duration();
            //  Console.WriteLine("Duraction Minutes: {0}", ts.Ticks / (10000000L * 60));
            Console.WriteLine("Duraction Minutes: {0}", ts.Ticks / (10000000D * 60));
        }

        public void DurationHours()
        {
            TimeSpan ts = (_EndDate - _StartDate).Duration();
            // Console.WriteLine("Duraction Hours: {0}", ts.Ticks / (10000000L * 60 * 60));  
            Console.WriteLine("Duraction Hours: {0}", ts.Ticks / (10000000D * 60 * 60));
        }

        public void DurationDays()
        {
            TimeSpan ts = (_EndDate - _StartDate).Duration();
            // Console.WriteLine("Duraction Days: {0}", ts.Ticks / (10000000L * 60 * 60 * 24));   
            Console.WriteLine("Duraction Days: {0}", ts.Ticks / (10000000D * 60 * 60 * 24));
        }
 public void DurationSeconds()
        {
            TimeSpan ts = (_EndDate - _StartDate).Duration();
            // Console.WriteLine("Duraction Seconds: {0}", ts.Ticks / 10000000L);
            Console.WriteLine("Duraction Seconds: {0}", ts.Ticks / 10000000D);
        }

        public void DurationMinutes()
        {
            TimeSpan ts = (_EndDate - _StartDate).Duration();
            //  Console.WriteLine("Duraction Minutes: {0}", ts.Ticks / (10000000L * 60));
            Console.WriteLine("Duraction Minutes: {0}", ts.Ticks / (10000000D * 60));
        }

        public void DurationHours()
        {
            TimeSpan ts = (_EndDate - _StartDate).Duration();
            // Console.WriteLine("Duraction Hours: {0}", ts.Ticks / (10000000L * 60 * 60));  
            Console.WriteLine("Duraction Hours: {0}", ts.Ticks / (10000000D * 60 * 60));
        }

        public void DurationDays()
        {
            TimeSpan ts = (_EndDate - _StartDate).Duration();
            // Console.WriteLine("Duraction Days: {0}", ts.Ticks / (10000000L * 60 * 60 * 24));   
            Console.WriteLine("Duraction Days: {0}", ts.Ticks / (10000000D * 60 * 60 * 24));
        }

 

Source Code

Source Code

997755.com澳门葡京 60997755.com澳门葡京 61

 

 

@{
    Layout = null;
}

<!DOCTYPE html>

<html>
<head>
    <meta name="viewport" content="width=device-width" />
    <title>Index</title>

    <style type="text/css">
        #logincontact label {
            display: inline-block;
            width: 100px;
            text-align: right;
        }

        #logincontact_submit {
            padding-left: 100px;
        }

        #logincontact div {
            margin-top: 1em;
        }

        .error {
            display: none;
            margin-left: 10px;
        }

        .error_show {
            color: red;
            margin-left: 10px;
        }

        input.invalid {
            border: 2px solid red;
        }

        input.valid {
            border: 2px solid green;
        }
    </style>

    <script src="~/Scripts/jquery-2.2.1.js"></script>

    <script type="text/javascript">
        ////<![CDATA[
        $(document).ready(function () {
            $('#logincontact_Account').on('input', function () {
                var input = $(this);
                var is_Account = input.val();
                if (is_Account) {
                    input.removeClass("invalid").addClass("valid");
                }
                else {
                    input.removeClass("valid").addClass("invalid");
                }
            });


            $('#logincontact_Password').on('input', function () {
                var input = $(this);
                var is_Password = input.val();
                if (is_Password) {
                    input.removeClass("invalid").addClass("valid");
                }
                else {
                    input.removeClass("valid").addClass("invalid");
                }
            });


            $('#ButtonSignIn').click(function (event) {
                var form_data = $("#logincontact").serializeArray();
                var error_free = true;
                for (var input in form_data) {
                    var element = $("#logincontact_" + form_data[input]['name']);
                    var valid = element.hasClass("valid");
                    var error_element = $("span", element.parent());

                    if (!valid) {
                        error_element.removeClass("error").addClass("error_show");
                        error_free = false;
                    }
                    else {
                        error_element.removeClass("error_show").addClass("error");
                    }
                }

                if (!error_free) {
                    event.preventDefault();
                }
                else {
                    var obj = {};
                    obj.Account = $('#logincontact_Account').val(),
                    obj.Password = $('#logincontact_Password').val()

                    $.ajax({
                        type: 'POST',
                        url: '/Home/LoginVerify',
                        dataType: 'json',
                        data: JSON.stringify(obj),
                        contentType: 'application/json; charset=utf-8',
                        success: function (data, textStatus) {
                            alert("登录成功。");
                            window.location.href = "/User/Index";
                        },
                        error: function (XMLHttpRequest, textStatus, errorThrown) {
                            alert(errorThrown);
                        },
                    });
                }
            });
        });
        //]]>
    </script>
</head>
<body>
    <form id="logincontact" method="post" action="">
        <div>
            <label for="logincontact_Account">Account:</label>
            <input type="text" id="logincontact_Account" name="Account" />
            This account field is required.
        </div>
        <div>
            <label for="logincontact_Password">Password:</label>
            <input type="password" id="logincontact_Password" name="Password" />
            This password field is required.
        </div>
        <div id="logincontact_submit">
            <input id="ButtonSignIn" type="button" value="Sign In" />
        </div>
    </form>
</body>
</html>

这一次,大家再次运转程序,看看结果是还是不是与自带的诀要总计的结果同样:
997755.com澳门葡京 62

此番,我们重国民党的新生活运动行程序,看看结果是还是不是与自带的办法总括的结果一致:
997755.com澳门葡京 63

Source Code

OK,就那规范,你可以行使自带现有的方式,可以本人写。

OK,就那样子,你能够运用自带现存的章程,能够团结写。

 

写到这里应该是结果了,然则回过头来看看本人写的代码,有一句:

写到这里应该是结果了,可是回过头来看看自身写的代码,有一句:

再有三个:
997755.com澳门葡京 64

TimeSpan ts = (_EndDate - _StartDate).Duration();
TimeSpan ts = (_EndDate - _StartDate).Duration();

 

每二个方法里均有,代码冗余了,我们得以简化它,写三个主意也许属性:
997755.com澳门葡京 65

每多个主意里均有,代码冗余了,我们得以简化它,写贰个艺术恐怕属性:
997755.com澳门葡京 66

997755.com澳门葡京 67997755.com澳门葡京 68

997755.com澳门葡京 69997755.com澳门葡京 70

997755.com澳门葡京 71997755.com澳门葡京 72

@{
    Layout = null;
}

<!DOCTYPE html>
<html>
<head>
    <meta name="viewport" content="width=device-width" />
    <title>Index</title>
    <script src="~/Scripts/jquery-2.2.1.js"></script>

    <script type="text/javascript">
        ////<![CDATA[
        $(document).ready(function () {

            $('#ButtonSignOut').click(function (event) {
                $.ajax({
                    type: 'POST',
                    url: '/Home/SignOut',                                  
                    contentType: 'application/json; charset=utf-8',
                    success: function (data, textStatus) {
                        alert("已经安全退出网站。");
                        window.location.href = "/Home/Index";
                    },
                    error: function (XMLHttpRequest, textStatus, errorThrown) {
                        alert(errorThrown);
                    },
                });
            });
        });
        //]]>
    </script>
</head>
<body>
    <div>
        Hi @ViewBag.UserName
        <br />
        <input id="ButtonSignOut" type="button" value="Sign Out" />
    </div>
</body>
</html>
public TimeSpan Ts
        {
            get
            {
                return (_EndDate - _StartDate).Duration();
            }
        }

        public long Ticks
        {
            get
            {
                return Ts.Ticks;
            }
        }
public TimeSpan Ts
        {
            get
            {
                return (_EndDate - _StartDate).Duration();
            }
        }

        public long Ticks
        {
            get
            {
                return Ts.Ticks;
            }
        }

Source Code

Source Code

Source Code

终止了,来二个实时演示吧:
997755.com澳门葡京 73

 

 

 

因此一遍重构,8个办法里,只供给一句代码就行了:

透过一回重构,8个方法里,只须求一句代码就行了:

997755.com澳门葡京 74

997755.com澳门葡京 75

 

 

相关文章

发表评论

电子邮件地址不会被公开。 必填项已用*标注

*
*
Website