migrate to new git

This commit is contained in:
2025-08-29 01:27:25 +08:00
parent 946eb9961e
commit af2c152ef6
8623 changed files with 1000453 additions and 1 deletions

100
web/Global.asax Normal file
View File

@@ -0,0 +1,100 @@
<%@ Application Language="C#" %>
<%@ Import Namespace="System.Web.Routing" %>
<%@ Import Namespace="System.Web.Http" %>
<%@ Import Namespace="System.Web.Optimization" %>
<%@ Import Namespace="System.Linq" %>
<%@ Import Namespace="System.Data" %>
<%@ Import Namespace="System.Web.Configuration" %>
<%@ Import Namespace="System.Web.Http.Dispatcher" %>
<script runat="server">
void Application_Start(object sender, EventArgs e)
{
// Code that runs on application startup
// run static constructor
System.Runtime.CompilerServices.RuntimeHelpers.RunClassConstructor(typeof(Sites).TypeHandle);
//註冊webapi
GlobalConfiguration.Configure(WebApiConfig.Register);
//GlobalConfiguration.Configuration.Services.Replace(
// typeof(IHttpControllerSelector),
// new NamespaceHttpControllerSelector(GlobalConfiguration.Configuration));
GlobalConfiguration.Configuration.Formatters.JsonFormatter.SerializerSettings.ReferenceLoopHandling =
Newtonsoft.Json.ReferenceLoopHandling.Ignore;
GlobalConfiguration.Configuration.Formatters.Remove(GlobalConfiguration.Configuration.Formatters.XmlFormatter);
//GlobalConfiguration.Configuration.Formatters.XmlFormatter.SupportedMediaTypes.Clear();
//註冊自訂路由
RouteConfig.RegisterRoutes(RouteTable.Routes);
InitializeFNumberSerial();//啟動項目的時候查詢出信眾編號的最大值放在記憶體中
//bundle js、css
//BundleConfig.RegisterBundles(BundleTable.Bundles);
}
void Application_End(object sender, EventArgs e)
{
// Code that runs on application shutdown
}
void Application_Error(object sender, EventArgs e)
{
// Code that runs when an unhandled error occurs
}
void Session_Start(object sender, EventArgs e)
{
// Code that runs when a new session is started
}
void Session_End(object sender, EventArgs e)
{
// Code that runs when a session ends.
// Note: The Session_End event is raised only when the sessionstate mode
// is set to InProc in the Web.config file. If session mode is set to StateServer
// or SQLServer, the event is not raised.
}
protected void Application_PostAuthorizeRequest()
{
System.Web.HttpContext.Current.SetSessionStateBehavior(System.Web.SessionState.SessionStateBehavior.Required);
}
private void InitializeFNumberSerial()
{
try
{
using (var _db = new Model.ezEntities())
{
var maxFNumber = _db.followers
.Where(m =>
////m.IsDel == false && ////不確定是否新增欄位? 先註解
m.f_number.Length == 14 &&
(m.f_number.StartsWith("M") || m.f_number.StartsWith("F")))
.OrderByDescending(m => m.reg_time)
.Select(m => m.f_number)
.FirstOrDefault();
int nextSerial = 0;
if (!string.IsNullOrEmpty(maxFNumber))
{
try
{
var serialPart = maxFNumber.Substring(9, 5);
nextSerial = int.Parse(serialPart);
}
catch { }
}
Application["FNumberSerial"] = nextSerial;
}
}
catch (Exception ex)
{
Application["FNumberSerial"] = 0;
}
}
</script>