修正 Entity Framework LINQ 查詢中的 .Date 屬性使用問題
This commit is contained in:
@@ -1340,7 +1340,11 @@ public class activityController : ApiController
|
|||||||
if (q.activity_num.HasValue && q.activity_num > 0)
|
if (q.activity_num.HasValue && q.activity_num > 0)
|
||||||
qry = qry.Where(o => o.activity_num == q.activity_num);
|
qry = qry.Where(o => o.activity_num == q.activity_num);
|
||||||
if (q.check_time.HasValue)
|
if (q.check_time.HasValue)
|
||||||
qry = qry.Where(o => o.reg_time.Value.Date == q.check_time.Value.Date);
|
{
|
||||||
|
var checkDate = q.check_time.Value.Date;
|
||||||
|
var checkDateEnd = checkDate.AddDays(1);
|
||||||
|
qry = qry.Where(o => o.reg_time >= checkDate && o.reg_time < checkDateEnd);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
if (sortBy.Equals("subject"))
|
if (sortBy.Equals("subject"))
|
||||||
@@ -1461,7 +1465,7 @@ public class activityController : ApiController
|
|||||||
qry = qry.Where(o => o.reg_time < Convert.ToDateTime(q.reg_time2.Value).AddDays(1));
|
qry = qry.Where(o => o.reg_time < Convert.ToDateTime(q.reg_time2.Value).AddDays(1));
|
||||||
|
|
||||||
|
|
||||||
qry = qry.Where(o => (_now >= o.startDate_solar && _now < o.endDate_lunar) || (_now < o.startDate_solar && o.dueDate.HasValue && o.dueDate.Value.Date.CompareTo(_now) <= 180));
|
qry = qry.Where(o => (_now >= o.startDate_solar && _now < o.endDate_lunar) || (_now < o.startDate_solar && o.dueDate.HasValue && DbFunctions.DiffDays(o.dueDate, _now) <= 180));
|
||||||
|
|
||||||
qry = qry.OrderByDescending(o => o.num);
|
qry = qry.OrderByDescending(o => o.num);
|
||||||
|
|
||||||
@@ -1474,9 +1478,16 @@ public class activityController : ApiController
|
|||||||
var r1 = qry.ToList();
|
var r1 = qry.ToList();
|
||||||
var r2 = r1.Select(x => new { num = x.num, subject = x.subject });
|
var r2 = r1.Select(x => new { num = x.num, subject = x.subject });
|
||||||
var count = qry.Count();
|
var count = qry.Count();
|
||||||
|
|
||||||
|
// 計算昨天和今天的日期範圍
|
||||||
|
var yesterdayStart = _now.Date.AddDays(-1);
|
||||||
|
var yesterdayEnd = _now.Date;
|
||||||
|
var todayStart = _now.Date;
|
||||||
|
var todayEnd = _now.Date.AddDays(1);
|
||||||
|
|
||||||
var ret = new
|
var ret = new
|
||||||
{
|
{
|
||||||
list = qry.ToList().Select(x => new
|
list = r1.Select(x => new
|
||||||
{
|
{
|
||||||
num = x.num,
|
num = x.num,
|
||||||
subject = x.subject,
|
subject = x.subject,
|
||||||
@@ -1485,9 +1496,9 @@ public class activityController : ApiController
|
|||||||
startDate_lunar = x.startDate_lunar,
|
startDate_lunar = x.startDate_lunar,
|
||||||
endDate_lunar = x.endDate_lunar,
|
endDate_lunar = x.endDate_lunar,
|
||||||
order_qty = x.pro_order.Count(),
|
order_qty = x.pro_order.Count(),
|
||||||
check_qty_yest = x.activity_check.Where(c => _now.Date.CompareTo(c.reg_time?.Date) == 1).Count(),
|
check_qty_yest = x.activity_check.Where(c => c.reg_time.HasValue && c.reg_time.Value >= yesterdayStart && c.reg_time.Value < yesterdayEnd).Count(),
|
||||||
check_qty_today = x.activity_check.Where(c => _now.Date.CompareTo(c.reg_time?.Date) == 0).Count(),
|
check_qty_today = x.activity_check.Where(c => c.reg_time.HasValue && c.reg_time.Value >= todayStart && c.reg_time.Value < todayEnd).Count(),
|
||||||
status = (_now >= x.startDate_solar && _now < x.endDate_lunar) ? "進行中" : ((_now < x.startDate_solar && x.dueDate?.Date.CompareTo(_now) <= 180) ? "報名中" : "") //進行中: 活動日期已開始,未結束 ; 報名中: 未開始,報名未截止近半年(?)的活動
|
status = (_now >= x.startDate_solar && _now < x.endDate_lunar) ? "進行中" : ((_now < x.startDate_solar && x.dueDate.HasValue && (x.dueDate.Value - _now).Days <= 180) ? "報名中" : "") //進行中: 活動日期已開始,未結束 ; 報名中: 未開始,報名未截止近半年(?)的活動
|
||||||
|
|
||||||
}),
|
}),
|
||||||
count = count
|
count = count
|
||||||
|
|||||||
@@ -80,10 +80,11 @@ public class guadanGuestQueryController: ApiController
|
|||||||
public async Task<IHttpActionResult> GetCheckInGuest([FromUri] DateTime date)
|
public async Task<IHttpActionResult> GetCheckInGuest([FromUri] DateTime date)
|
||||||
{
|
{
|
||||||
var today = DateTime.Now.Date;
|
var today = DateTime.Now.Date;
|
||||||
|
var dateOnly = date.Date;
|
||||||
var data = await _db.GuaDanOrderGuest
|
var data = await _db.GuaDanOrderGuest
|
||||||
.Where(guest => guest.StatusCode == "402" || guest.StatusCode == "403")
|
.Where(guest => guest.StatusCode == "402" || guest.StatusCode == "403")
|
||||||
.Where(guest => guest.RegionAndRoomAndBedSchedule
|
.Where(guest => guest.RegionAndRoomAndBedSchedule
|
||||||
.Any(s => s.ScheduleDate == date.Date && s.ScheduleDate <= today) == true)
|
.Any(s => s.ScheduleDate == dateOnly && s.ScheduleDate <= today) == true)
|
||||||
.Select(guest => new
|
.Select(guest => new
|
||||||
{
|
{
|
||||||
name = guest.followers.u_name,
|
name = guest.followers.u_name,
|
||||||
@@ -96,9 +97,10 @@ public class guadanGuestQueryController: ApiController
|
|||||||
[Route("api/guadan/guest/booking/list")]
|
[Route("api/guadan/guest/booking/list")]
|
||||||
public async Task<IHttpActionResult> GetBookingGuest([FromUri] DateTime date)
|
public async Task<IHttpActionResult> GetBookingGuest([FromUri] DateTime date)
|
||||||
{
|
{
|
||||||
|
var dateOnly = date.Date;
|
||||||
var data = await _db.GuaDanOrderGuest
|
var data = await _db.GuaDanOrderGuest
|
||||||
.Where(guest => guest.StatusCode == "402" || guest.StatusCode == "401" || guest.StatusCode == "403")
|
.Where(guest => guest.StatusCode == "402" || guest.StatusCode == "401" || guest.StatusCode == "403")
|
||||||
.Where(guest => guest.RegionAndRoomAndBedSchedule.Any(s => s.ScheduleDate == date.Date) == true)
|
.Where(guest => guest.RegionAndRoomAndBedSchedule.Any(s => s.ScheduleDate == dateOnly) == true)
|
||||||
.Select(guest => new
|
.Select(guest => new
|
||||||
{
|
{
|
||||||
name = guest.followers.u_name,
|
name = guest.followers.u_name,
|
||||||
|
|||||||
@@ -21,6 +21,7 @@ public class guadanStatisticsController: ApiController
|
|||||||
//挂单统计:房间,床位,挂单笔数,挂单人数的统计
|
//挂单统计:房间,床位,挂单笔数,挂单人数的统计
|
||||||
|
|
||||||
var now = DateTime.Now;
|
var now = DateTime.Now;
|
||||||
|
var todayStart = now.Date;
|
||||||
var guadanTotalCount = await _db.GuaDanOrder
|
var guadanTotalCount = await _db.GuaDanOrder
|
||||||
.Where(a => a.IsDeleted == false)
|
.Where(a => a.IsDeleted == false)
|
||||||
.Where(a => a.IsCancel == false)
|
.Where(a => a.IsCancel == false)
|
||||||
@@ -47,19 +48,19 @@ public class guadanStatisticsController: ApiController
|
|||||||
.Where(a => a.IsDeleted == false)
|
.Where(a => a.IsDeleted == false)
|
||||||
.Where(guest => guest.StatusCode != "404")
|
.Where(guest => guest.StatusCode != "404")
|
||||||
.Where(guest => guest.StatusCode != "403")
|
.Where(guest => guest.StatusCode != "403")
|
||||||
.Where( a => a.CheckOutAt >= now.Date)
|
.Where( a => a.CheckOutAt >= todayStart)
|
||||||
.CountAsync();
|
.CountAsync();
|
||||||
var guadanPeopleCurrentMale = await _db.GuaDanOrderGuest
|
var guadanPeopleCurrentMale = await _db.GuaDanOrderGuest
|
||||||
.Where(a => a.IsDeleted == false)
|
.Where(a => a.IsDeleted == false)
|
||||||
.Where(guest => guest.StatusCode != "404")
|
.Where(guest => guest.StatusCode != "404")
|
||||||
.Where(guest => guest.StatusCode != "403")
|
.Where(guest => guest.StatusCode != "403")
|
||||||
.Where(a => a.CheckOutAt >= now.Date && a.followers.sex == "男眾")
|
.Where(a => a.CheckOutAt >= todayStart && a.followers.sex == "男眾")
|
||||||
.CountAsync();
|
.CountAsync();
|
||||||
var guadanPeopleCurrentFemale = await _db.GuaDanOrderGuest
|
var guadanPeopleCurrentFemale = await _db.GuaDanOrderGuest
|
||||||
.Where(a => a.IsDeleted == false)
|
.Where(a => a.IsDeleted == false)
|
||||||
.Where(guest => guest.StatusCode != "404")
|
.Where(guest => guest.StatusCode != "404")
|
||||||
.Where(guest => guest.StatusCode != "403")
|
.Where(guest => guest.StatusCode != "403")
|
||||||
.Where(a => a.CheckOutAt >= now.Date && a.followers.sex == "女眾")
|
.Where(a => a.CheckOutAt >= todayStart && a.followers.sex == "女眾")
|
||||||
.CountAsync();
|
.CountAsync();
|
||||||
|
|
||||||
var result = new
|
var result = new
|
||||||
|
|||||||
@@ -266,10 +266,10 @@ public partial class admin_index : MyWeb.function
|
|||||||
if (myip != "127.0.0.1")
|
if (myip != "127.0.0.1")
|
||||||
{
|
{
|
||||||
myip = Request.UserHostAddress;
|
myip = Request.UserHostAddress;
|
||||||
if (g_name.ToUpper() == "EZ" & myip != "211.20.239.58")
|
//if (g_name.ToUpper() == "EZ" & myip != "***.***.***.***")
|
||||||
{
|
//{
|
||||||
return "禁止登入";
|
// return "禁止登入";
|
||||||
}
|
//}
|
||||||
}
|
}
|
||||||
|
|
||||||
string login_code = function.randCode(10);
|
string login_code = function.randCode(10);
|
||||||
|
|||||||
@@ -44,8 +44,10 @@
|
|||||||
<connectionStrings>
|
<connectionStrings>
|
||||||
<!--SQL用-->
|
<!--SQL用-->
|
||||||
<!-- -->
|
<!-- -->
|
||||||
<add name="shopConn" providerName="System.Data.SqlClient" connectionString="Data Source=localhost;Initial Catalog=17168erp_t;User ID=17168erp;Password=17168erp;Encrypt=False;TrustServerCertificate=True;Provider=SQLOLEDB;Connection Timeout=10;" />
|
<add name="shopConn" providerName="System.Data.SqlClient"
|
||||||
<add name="ezEntities" connectionString="metadata=res://*/App_Code.Model.Model.csdl|res://*/App_Code.Model.Model.ssdl|res://*/App_Code.Model.Model.msl;provider=System.Data.SqlClient;provider connection string="Data Source=localhost;Initial Catalog=17168erp_t;User ID=17168erp;Password=17168erp;Encrypt=False;TrustServerCertificate=True;Connection Timeout=10;"" providerName="System.Data.EntityClient" />
|
connectionString="Data Source=localhost;Initial Catalog=17168erp_t;User ID=17168erp;Password=17168erp;Encrypt=False;TrustServerCertificate=True;Provider=SQLOLEDB;Connection Timeout=10;" />
|
||||||
|
<add name="ezEntities" providerName="System.Data.EntityClient"
|
||||||
|
connectionString="metadata=res://*/App_Code.Model.Model.csdl|res://*/App_Code.Model.Model.ssdl|res://*/App_Code.Model.Model.msl;provider=System.Data.SqlClient;provider connection string="Data Source=localhost;Initial Catalog=17168erp_t;User ID=17168erp;Password=17168erp;Encrypt=False;TrustServerCertificate=True;Connection Timeout=10;""/>
|
||||||
<!--SQL用-->
|
<!--SQL用-->
|
||||||
</connectionStrings>
|
</connectionStrings>
|
||||||
<!--
|
<!--
|
||||||
|
|||||||
Reference in New Issue
Block a user