You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
478 lines
20 KiB
478 lines
20 KiB
using EasyBL.WebApi.Message;
|
|
using EasyBL.WEBAPP.SYS;
|
|
using Entity.Sugar;
|
|
using Entity.ViewModels;
|
|
using SqlSugar;
|
|
using SqlSugar.Base;
|
|
using System;
|
|
|
|
namespace EasyBL.WEBAPP.WSM
|
|
{
|
|
public class VenueMaintain_UpdService : ServiceBase
|
|
{
|
|
#region 展館管理(單筆查詢)
|
|
|
|
/// <summary>
|
|
/// 展館管理(單筆查詢)
|
|
/// </summary>
|
|
/// <param name="i_crm"></param>
|
|
/// <returns></returns>
|
|
public ResponseMessage QueryOne(RequestMessage i_crm)
|
|
{
|
|
ResponseMessage rm = null;
|
|
string sMsg = null;
|
|
var db = SugarBase.GetIntance();
|
|
try
|
|
{
|
|
do
|
|
{
|
|
var sArgumentClassID = _fetchString(i_crm, @"VenueID");
|
|
var oEntity = db.Queryable<SETB_ORG_Venue, OTB_SYS_Members, OTB_SYS_Members, SETB_UTL_City, SETB_SYS_Country>
|
|
((t1, t2, t3, t4, t5) =>
|
|
new object[] {
|
|
JoinType.Left, t1.OrgID == t2.OrgID && t1.CreateUser == t2.MemberID,
|
|
JoinType.Left, t1.OrgID == t3.OrgID && t1.ModifyUser == t3.MemberID,
|
|
JoinType.Left, t1.OrgID == t4.OrgID && t1.CityID == t4.CityID,
|
|
JoinType.Left, t1.OrgID == t5.OrgID && t4.CountryID == t5.CountryID,
|
|
}
|
|
)
|
|
.Where((t1, t2, t3, t4, t5) => t1.OrgID == i_crm.ORIGID && t1.VenueID == sArgumentClassID)
|
|
.Select((t1, t2, t3, t4, t5) => new View_ORG_Venue
|
|
{
|
|
VenueID = SqlFunc.GetSelfAndAutoFill(t1.VenueID),
|
|
CreateUserName = t2.MemberName,
|
|
ModifyUserName = t3.MemberName,
|
|
CountryID = t4.CountryID,
|
|
RegionID = t5.RegionID
|
|
})
|
|
.Single();
|
|
|
|
rm = new SuccessResponseMessage(null, i_crm);
|
|
rm.DATA.Add(BLWording.REL, oEntity);
|
|
} while (false);
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
sMsg = Util.GetLastExceptionMsg(ex);
|
|
LogAndSendEmail(sMsg + "Params:" + JsonToString(i_crm), ex, i_crm.ORIGID, i_crm.USERID, nameof(VenueMaintain_UpdService), "", "QueryOne(參數類別管理(單筆查詢))", "", "", "");
|
|
}
|
|
finally
|
|
{
|
|
if (null != sMsg)
|
|
{
|
|
rm = new ErrorResponseMessage(sMsg, i_crm);
|
|
}
|
|
}
|
|
return rm;
|
|
}
|
|
|
|
#endregion 展館管理(單筆查詢)
|
|
|
|
#region 展館管理(新增)
|
|
|
|
/// <summary>
|
|
/// 展館管理(新增)
|
|
/// </summary>
|
|
/// <param name="i_crm">todo: describe i_crm parameter on UpdImportCustomers</param>
|
|
/// <returns></returns>
|
|
public ResponseMessage Insert(RequestMessage i_crm)
|
|
{
|
|
ResponseMessage rm = null;
|
|
string sMsg = null;
|
|
try
|
|
{
|
|
rm = SugarBase.ExecTran(db =>
|
|
{
|
|
do
|
|
{
|
|
var oEntity = _fetchEntity<SETB_ORG_Venue>(i_crm);
|
|
_setEntityBase(oEntity, i_crm);
|
|
oEntity.DelStatus = "N";
|
|
var iOldCout = db.Queryable<SETB_ORG_Venue>().Count(x => x.OrgID == i_crm.ORIGID && x.DelStatus == "N"); //排序變數,取得所有展館筆數
|
|
//V00001,V0002....,V12345
|
|
var sMaxNO = "00001";
|
|
var sMaxVenueID = db.Queryable<SETB_ORG_Venue>().Where(x => x.OrgID == i_crm.ORIGID).Max(x => x.VenueID); //取得VenueID為最大值的展館編號
|
|
if (!string.IsNullOrEmpty(sMaxVenueID)) //若不是第一筆資料
|
|
{
|
|
sMaxNO = ((int.Parse(sMaxVenueID.Substring(1, 5)) + 1).ToString()).PadLeft(5, '0'); //取得字串
|
|
}
|
|
oEntity.VenueID = "V" + sMaxNO; //流水號前加V
|
|
if (oEntity.OrderByValue <= iOldCout)
|
|
{
|
|
var iRelUp = db.Updateable<SETB_ORG_Venue>()
|
|
.UpdateColumns(x => new SETB_ORG_Venue { OrderByValue = x.OrderByValue + 1 })
|
|
.Where(x => x.OrgID == i_crm.ORIGID && x.OrderByValue >= oEntity.OrderByValue)
|
|
.ExecuteCommand();
|
|
}
|
|
var iRel = db.Insertable(oEntity).ExecuteCommand();
|
|
rm = new SuccessResponseMessage(null, i_crm);
|
|
rm.DATA.Add(BLWording.REL, iRel);
|
|
} while (false);
|
|
return rm;
|
|
});
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
sMsg = Util.GetLastExceptionMsg(ex);
|
|
LogAndSendEmail(sMsg + @"Param:" + JsonToString(i_crm), ex, i_crm.ORIGID, i_crm.USERID, nameof(VenueMaintain_UpdService), @"參數類別管理", @"Add(參數類別管理(新增))", @"", @"", @"");
|
|
}
|
|
finally
|
|
{
|
|
if (null != sMsg)
|
|
{
|
|
rm = new ErrorResponseMessage(sMsg, i_crm);
|
|
}
|
|
}
|
|
return rm;
|
|
}
|
|
|
|
#endregion 展館管理(新增)
|
|
|
|
#region 展館管理(修改)
|
|
|
|
/// <summary>
|
|
/// 展館管理(修改)
|
|
/// </summary>
|
|
/// <param name="i_crm">todo: describe i_crm parameter on UpdImportCustomers</param>
|
|
/// <returns></returns>
|
|
public ResponseMessage Update(RequestMessage i_crm)
|
|
{
|
|
ResponseMessage rm = null;
|
|
string sMsg = null;
|
|
try
|
|
{
|
|
rm = SugarBase.ExecTran(db =>
|
|
{
|
|
do
|
|
{
|
|
var oNewEntity = _fetchEntity<SETB_ORG_Venue>(i_crm);
|
|
_setEntityBase(oNewEntity, i_crm);
|
|
oNewEntity.DelStatus = "N";
|
|
var oOldEntity = db.Queryable<SETB_ORG_Venue>().Single(x => x.OrgID == i_crm.ORIGID && x.VenueID == oNewEntity.VenueID);
|
|
|
|
if (oNewEntity.OrderByValue > oOldEntity.OrderByValue)
|
|
{
|
|
var iRelUp = db.Updateable<SETB_ORG_Venue>()
|
|
.UpdateColumns(x => new SETB_ORG_Venue { OrderByValue = x.OrderByValue - 1 })
|
|
.Where(x => x.OrgID == oNewEntity.OrgID && x.OrderByValue <= oNewEntity.OrderByValue && x.OrderByValue > oOldEntity.OrderByValue).ExecuteCommand();
|
|
}
|
|
else
|
|
{
|
|
var iRelDown = db.Updateable<SETB_ORG_Venue>()
|
|
.UpdateColumns(x => new SETB_ORG_Venue { OrderByValue = x.OrderByValue + 1 })
|
|
.Where(x => x.OrgID == oNewEntity.OrgID && x.OrderByValue >= oNewEntity.OrderByValue && x.OrderByValue < oOldEntity.OrderByValue).ExecuteCommand();
|
|
}
|
|
|
|
var iRel = db.Updateable(oNewEntity)
|
|
.IgnoreColumns(x => new
|
|
{
|
|
x.CreateUser,
|
|
x.CreateDate
|
|
}).ExecuteCommand();
|
|
rm = new SuccessResponseMessage(null, i_crm);
|
|
rm.DATA.Add(BLWording.REL, iRel);
|
|
} while (false);
|
|
|
|
return rm;
|
|
});
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
sMsg = Util.GetLastExceptionMsg(ex);
|
|
LogAndSendEmail(sMsg + @"Param:" + JsonToString(i_crm), ex, i_crm.ORIGID, i_crm.USERID, nameof(VenueMaintain_UpdService), @"參數類別管理", @"Update(參數類別管理(修改))", @"", @"", @"");
|
|
}
|
|
finally
|
|
{
|
|
if (null != sMsg)
|
|
{
|
|
rm = new ErrorResponseMessage(sMsg, i_crm);
|
|
}
|
|
}
|
|
return rm;
|
|
}
|
|
|
|
#endregion 展館管理(修改)
|
|
|
|
#region 展館管理(刪除)
|
|
|
|
/// <summary>
|
|
/// 展館管理(刪除)
|
|
/// </summary>
|
|
/// <param name="i_crm">todo: describe i_crm parameter on UpdImportCustomers</param>
|
|
/// <returns></returns>
|
|
public ResponseMessage Delete(RequestMessage i_crm)
|
|
{
|
|
ResponseMessage rm = null;
|
|
string sMsg = null;
|
|
try
|
|
{
|
|
rm = SugarBase.ExecTran(db =>
|
|
{
|
|
do
|
|
{
|
|
var sVenueID = _fetchString(i_crm, @"VenueID");
|
|
|
|
var iExsitChild = db.Queryable<SETB_ORG_Venue>().Count(x => x.OrgID == i_crm.ORIGID && x.VenueID == sVenueID);
|
|
var oEntity = db.Queryable<SETB_ORG_Venue>().Single(x => x.OrgID == i_crm.ORIGID && x.VenueID == sVenueID);
|
|
//var iRel = db.Updateable<SETB_ORG_Venue>().Where(x => x.OrgID == i_crm.ORIGID && x.VenueID == iVenueID).ExecuteCommand();
|
|
var iRel = db.Updateable<SETB_ORG_Venue>().UpdateColumns(x => new SETB_ORG_Venue { DelStatus = "Y" }).Where(x => x.OrgID == i_crm.ORIGID && x.VenueID == sVenueID).ExecuteCommand();
|
|
var iRelUp = db.Updateable<SETB_ORG_Venue>()
|
|
.UpdateColumns(x => new SETB_ORG_Venue { OrderByValue = x.OrderByValue - 1 })
|
|
.Where(x => x.OrgID == oEntity.OrgID && x.OrderByValue > oEntity.OrderByValue)
|
|
.ExecuteCommand();
|
|
rm = new SuccessResponseMessage(null, i_crm);
|
|
rm.DATA.Add(BLWording.REL, iRel);
|
|
} while (false);
|
|
|
|
return rm;
|
|
});
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
sMsg = Util.GetLastExceptionMsg(ex);
|
|
LogAndSendEmail(sMsg + @"Param:" + JsonToString(i_crm), ex, i_crm.ORIGID, i_crm.USERID, nameof(VenueMaintain_UpdService), @"參數類別管理", @"Delete(參數類別管理(刪除))", @"", @"", @"");
|
|
}
|
|
finally
|
|
{
|
|
if (null != sMsg)
|
|
{
|
|
rm = new ErrorResponseMessage(sMsg, i_crm);
|
|
}
|
|
}
|
|
return rm;
|
|
}
|
|
|
|
#endregion 展館管理(刪除)
|
|
|
|
#region 展館管理(查詢筆數)
|
|
|
|
/// <summary>
|
|
/// 展館管理(查詢筆數)
|
|
/// </summary>
|
|
/// <param name="i_crm"></param>
|
|
/// <returns></returns>
|
|
public ResponseMessage QueryCout(RequestMessage i_crm)
|
|
{
|
|
ResponseMessage rm = null;
|
|
string sMsg = null;
|
|
var db = SugarBase.GetIntance();
|
|
try
|
|
{
|
|
do
|
|
{
|
|
var iVenue = _fetchString(i_crm, @"VenueID");
|
|
var iCityID = _fetchInt(i_crm, @"CityID");
|
|
var iCountryID = _fetchInt(i_crm, @"CountryID");
|
|
var sVenueName_EN = _fetchString(i_crm, @"VenueName_EN");
|
|
var sVenueName = _fetchString(i_crm, @"VenueName");
|
|
var iCout = db.Queryable<SETB_ORG_Venue>()
|
|
.Where(x => x.OrgID == i_crm.ORIGID && x.DelStatus == "N")
|
|
.WhereIF(!string.IsNullOrEmpty(iVenue), x => x.VenueID == iVenue)
|
|
.WhereIF(iCityID != -1, x => x.CityID == iCityID)
|
|
.WhereIF(iCountryID != -1, x => x.CountryID == iCountryID)
|
|
//.WhereIF(iVenue != -1 , x => x.VenueID == iVenue)
|
|
.WhereIF(!String.IsNullOrEmpty(sVenueName_EN) , x => x.VenueName_EN == sVenueName_EN)
|
|
.WhereIF(!String.IsNullOrEmpty(sVenueName), x => x.VenueName == sVenueName)
|
|
.Count();
|
|
|
|
rm = new SuccessResponseMessage(null, i_crm);
|
|
rm.DATA.Add(BLWording.REL, iCout);
|
|
} while (false);
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
sMsg = Util.GetLastExceptionMsg(ex);
|
|
LogAndSendEmail(sMsg + "Params:" + JsonToString(i_crm), ex, i_crm.ORIGID, i_crm.USERID, nameof(VenueMaintain_UpdService), "", "QueryCout(參數類別管理(查詢筆數))", "", "", "");
|
|
}
|
|
finally
|
|
{
|
|
if (null != sMsg)
|
|
{
|
|
rm = new ErrorResponseMessage(sMsg, i_crm);
|
|
}
|
|
}
|
|
return rm;
|
|
}
|
|
|
|
#endregion 展館管理(查詢筆數)
|
|
|
|
#region 洲別下拉選單
|
|
|
|
/// <summary>
|
|
/// 洲別(多筆)
|
|
/// </summary>
|
|
/// <param name="i_crm"></param>
|
|
/// <returns></returns>
|
|
public ResponseMessage GetRegion(RequestMessage i_crm)
|
|
{
|
|
ResponseMessage rm = null;
|
|
string sMsg = null;
|
|
var db = SugarBase.GetIntance();
|
|
try
|
|
{
|
|
do
|
|
{
|
|
var saRegion = db.Queryable<SETB_SYS_Region>()
|
|
.Where(x => x.OrgID == i_crm.ORIGID && x.Effective == "Y" && x.DelStatus == "N")
|
|
.ToList();
|
|
rm = new SuccessResponseMessage(null, i_crm);
|
|
rm.DATA.Add(BLWording.REL, saRegion);
|
|
} while (false);
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
sMsg = Util.GetLastExceptionMsg(ex);
|
|
LogAndSendEmail(sMsg + "Params:" + JsonToString(i_crm), ex, i_crm.ORIGID, i_crm.USERID, nameof(VenueMaintain_UpdService), "", "QueryList(參數類別(多筆))", "", "", "");
|
|
}
|
|
finally
|
|
{
|
|
if (null != sMsg)
|
|
{
|
|
rm = new ErrorResponseMessage(sMsg, i_crm);
|
|
}
|
|
}
|
|
return rm;
|
|
}
|
|
|
|
#endregion 洲別下拉選單
|
|
|
|
#region 國別下拉選單
|
|
|
|
/// <summary>
|
|
/// 國別(多筆)
|
|
/// </summary>
|
|
/// <param name="i_crm"></param>
|
|
/// <returns></returns>
|
|
public ResponseMessage GetCountry(RequestMessage i_crm)
|
|
{
|
|
ResponseMessage rm = null;
|
|
string sMsg = null;
|
|
var db = SugarBase.GetIntance();
|
|
try
|
|
{
|
|
do
|
|
{
|
|
var iRegionID = _fetchInt(i_crm, @"RegionID");
|
|
var saCountry = db.Queryable<SETB_SYS_Country>()
|
|
//搜尋條件
|
|
.Where(x => x.OrgID == i_crm.ORIGID && x.Effective == "Y" && x.DelStatus == "N")
|
|
.WhereIF(iRegionID != -1, x => x.RegionID == iRegionID)
|
|
.ToList();
|
|
rm = new SuccessResponseMessage(null, i_crm);
|
|
rm.DATA.Add(BLWording.REL, saCountry);
|
|
|
|
} while (false);
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
sMsg = Util.GetLastExceptionMsg(ex);
|
|
LogAndSendEmail(sMsg + "Params:" + JsonToString(i_crm), ex, i_crm.ORIGID, i_crm.USERID, nameof(VenueMaintain_UpdService), "", "QueryList(參數類別(多筆))", "", "", "");
|
|
}
|
|
finally
|
|
{
|
|
if (null != sMsg)
|
|
{
|
|
rm = new ErrorResponseMessage(sMsg, i_crm);
|
|
}
|
|
}
|
|
return rm;
|
|
}
|
|
|
|
#endregion 國別下拉選單
|
|
|
|
#region 城市下拉選單
|
|
|
|
/// <summary>
|
|
/// 城市查詢(多筆)
|
|
/// </summary>
|
|
/// <param name="i_crm"></param>
|
|
/// <returns></returns>
|
|
public ResponseMessage GetCity(RequestMessage i_crm)
|
|
{
|
|
ResponseMessage rm = null;
|
|
string sMsg = null;
|
|
var db = SugarBase.GetIntance();
|
|
try
|
|
{
|
|
do
|
|
{
|
|
var iCountryID = _fetchInt(i_crm, @"CountryID");
|
|
var saCity = db.Queryable<SETB_UTL_City>()
|
|
//搜尋條件
|
|
.Where(x => x.OrgID == i_crm.ORIGID && x.Effective == "Y" && x.DelStatus == "N")
|
|
.WhereIF(iCountryID != -1, x => x.CountryID == iCountryID)
|
|
.ToList();
|
|
rm = new SuccessResponseMessage(null, i_crm);
|
|
rm.DATA.Add(BLWording.REL, saCity);
|
|
} while (false);
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
sMsg = Util.GetLastExceptionMsg(ex);
|
|
LogAndSendEmail(sMsg + "Params:" + JsonToString(i_crm), ex, i_crm.ORIGID, i_crm.USERID, nameof(VenueMaintain_UpdService), "", "QueryList(參數類別(多筆))", "", "", "");
|
|
}
|
|
finally
|
|
{
|
|
if (null != sMsg)
|
|
{
|
|
rm = new ErrorResponseMessage(sMsg, i_crm);
|
|
}
|
|
}
|
|
return rm;
|
|
}
|
|
|
|
#endregion 城市下拉選單
|
|
|
|
#region 所有區域(多筆)
|
|
|
|
/// <summary>
|
|
/// 所有區域(多筆)
|
|
/// </summary>
|
|
/// <param name="i_crm"></param>
|
|
/// <returns></returns>
|
|
public ResponseMessage getLocation(RequestMessage i_crm)
|
|
{
|
|
ResponseMessage rm = null;
|
|
string sMsg = null;
|
|
var db = SugarBase.GetIntance();
|
|
try
|
|
{
|
|
do
|
|
{
|
|
var saRegion = db.Queryable<SETB_SYS_Region>()
|
|
.Where(x => x.OrgID == i_crm.ORIGID && x.Effective == "Y" && x.DelStatus == "N")
|
|
.OrderBy(x => x.OrderByValue)
|
|
.ToList();
|
|
var saCountry = db.Queryable<SETB_SYS_Country>()
|
|
.Where(x => x.OrgID == i_crm.ORIGID && x.Effective == "Y" && x.DelStatus == "N")
|
|
.OrderBy(x => x.OrderByValue)
|
|
.ToList();
|
|
var saCity = db.Queryable<SETB_UTL_City>()
|
|
.Where(x => x.OrgID == i_crm.ORIGID && x.Effective == "Y" && x.DelStatus == "N")
|
|
.OrderBy(x => x.OrderByValue)
|
|
.ToList();
|
|
rm = new SuccessResponseMessage(null, i_crm);
|
|
rm.DATA.Add("region", saRegion);
|
|
rm.DATA.Add("country", saCountry);
|
|
rm.DATA.Add("city", saCity);
|
|
} while (false);
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
sMsg = Util.GetLastExceptionMsg(ex);
|
|
LogAndSendEmail(sMsg + "Params:" + JsonToString(i_crm), ex, i_crm.ORIGID, i_crm.USERID, nameof(VenueMaintain_UpdService), "", "QueryList(參數類別(多筆))", "", "", "");
|
|
}
|
|
finally
|
|
{
|
|
if (null != sMsg)
|
|
{
|
|
rm = new ErrorResponseMessage(sMsg, i_crm);
|
|
}
|
|
}
|
|
return rm;
|
|
}
|
|
|
|
#endregion 所有區域(多筆)
|
|
|
|
}
|
|
}
|