从通用实体类CommonEntity中移除Membership相关代码,Membership将有XCode支持。 升级Web为.Net 4.0,该模版不再支持.Net 2.0,页面aspx.cs代码将可以使用C# 4.0语法
nnhy authored at 2015-05-08 15:59:01
2.42 KiB
X
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Web;
using System.Web.UI.WebControls;
using NewLife.CommonEntity;
using NewLife.Reflection;
using XCode.Membership;

public partial class Pages_Main : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        if (ManageProvider.Provider.Current == null)
        {
            Response.Write("无权访问!");
            Response.End();
            return;
        }

        if (Request["Act"] == "Restart")
        {
            HttpRuntime.UnloadAppDomain();
            Response.Redirect(Path.GetFileName(Request.Path));
            return;
        }

        if (!IsPostBack)
        {
            gv.DataSource = AssemblyX.GetMyAssemblies();
            gv.DataBind();
        }
    }

    protected void gv_Sorting(object sender, GridViewSortEventArgs e)
    {
        List<AssemblyX> list = AssemblyX.GetMyAssemblies();
        list.Sort(delegate(AssemblyX item1, AssemblyX item2)
        {
            Int32 d = e.SortDirection == SortDirection.Ascending ? 1 : -1;
            if (e.SortExpression == "Compile")
                return d * item1.Compile.CompareTo(item2.Compile);
            else if (e.SortExpression == "Title")
                return d * item1.Title.CompareTo(item2.Title);
            else if (e.SortExpression == "FileVersion")
                return d * item1.FileVersion.CompareTo(item2.FileVersion);
            else if (e.SortExpression == "Version")
                return d * item1.Version.CompareTo(item2.Version);
            else if (e.SortExpression == "Name")
                return d * item1.Name.CompareTo(item2.Name);
            else
                return d * item1.Name.CompareTo(item2.Name);
        });

        gv.DataSource = list;
        gv.DataBind();
    }

    protected String GetWebServerName()
    {
        String name = Request.ServerVariables["Server_SoftWare"];
        if (String.IsNullOrEmpty(name)) name = Process.GetCurrentProcess().ProcessName;

        // 检测集成管道,低版本.Net不支持,请使用者根据情况自行注释
        try
        {
            if (UsingIntegratedPipeline()) name += " [集成管道]";
        }
        catch { }

        return name;
    }

    Boolean UsingIntegratedPipeline()
    {
        return HttpRuntime.UsingIntegratedPipeline;
    }
}