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.
 
 
 
 
 

350 lines
13 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.ShowEasy
{
public class OrganizerMaintain_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 sOrganizerID = _fetchString(i_crm, @"OrganizerID");
var sLangType = _fetchString(i_crm, @"LangType");
var oEntity = db.Queryable<SETB_ORG_Organizer, OTB_SYS_Members, OTB_SYS_Members>
((t1, t2, t3) =>
new object[] {
JoinType.Left, t1.OrgID == t2.OrgID && t1.CreateUser == t2.MemberID,
JoinType.Left, t1.OrgID == t3.OrgID && t1.ModifyUser == t3.MemberID
}
)
.Where((t1, t2, t3) => t1.OrgID == i_crm.ORIGID && t1.OrganizerID == sOrganizerID && t1.LangType == sLangType)
.Select((t1, t2, t3) => new View_ORG_Organizer
{
OrganizerID = SqlFunc.GetSelfAndAutoFill(t1.OrganizerID),
CreateUserName = t2.MemberName,
ModifyUserName = t3.MemberName
})
.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(OrganizerMaintain_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_Organizer>(i_crm);
_setEntityBase(oEntity, i_crm);
string sOrganizerGUID = Guid.NewGuid().ToString();
oEntity.OrganizerID = sOrganizerGUID;
var iRel = 0;
var LanguageList = db.Queryable<OTB_SYS_Arguments>()
.Where(x => x.OrgID == i_crm.ORIGID && x.Effective == "Y" && x.DelStatus == "N" && x.ArgumentClassID == "LanCountry" && x.LevelOfArgument == 0)
.OrderBy(x => x.OrderByValue)
.ToList();
foreach (var Argument in LanguageList)
{
oEntity.LangType = Argument.ArgumentID;
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(OrganizerMaintain_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_Organizer>(i_crm);
_setEntityBase(oNewEntity, i_crm);
var oOldEntity = db.Queryable<SETB_ORG_Organizer>().Single(x => x.OrgID == i_crm.ORIGID && x.OrganizerID == oNewEntity.OrganizerID && x.LangType == oNewEntity.LangType);
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(OrganizerMaintain_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 sOrganizerID = _fetchString(i_crm, @"OrganizerID");
var sLangType = _fetchString(i_crm, @"LangType");
var iRel = db.Deleteable<SETB_ORG_Organizer>().Where(x => x.OrgID == i_crm.ORIGID && x.OrganizerID == sOrganizerID).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(OrganizerMaintain_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 sOrganizerID = _fetchString(i_crm, @"OrganizerID");
var sOrganizerName = _fetchString(i_crm, @"OrganizerName");
var sLangType = _fetchString(i_crm, @"LangType");
var iCout = db.Queryable<SETB_ORG_Organizer>()
.Where(x => x.OrgID == i_crm.ORIGID && x.LangType == sLangType)
.WhereIF(!string.IsNullOrEmpty(sOrganizerID), x => x.OrganizerID == sOrganizerID)
.WhereIF(!string.IsNullOrEmpty(sOrganizerName), x => x.OrganizerName == sOrganizerName)
.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(OrganizerMaintain_UpdService), "", "QueryCout(主辦單位值(查詢筆數))", "", "", "");
}
finally
{
if (null != sMsg)
{
rm = new ErrorResponseMessage(sMsg, i_crm);
}
}
return rm;
}
#endregion 主辦單位值(查詢筆數)
#region 語言管理 (List 查詢)
public ResponseMessage GetLanguage(RequestMessage i_crm)
{
ResponseMessage rm = null;
string sMsg = null;
var db = SugarBase.GetIntance();
try
{
do
{
var sArgumentClassID = "LanCountry";
var saLanguage = db.Queryable<OTB_SYS_Arguments>()
.Where(x => x.OrgID == i_crm.ORIGID && x.Effective == "Y" && x.DelStatus == "N")
.WhereIF(!string.IsNullOrEmpty(sArgumentClassID), t1 => t1.ArgumentClassID == sArgumentClassID)
.Select((t1) => new SETB_SYS_Language
{
LanguageID = t1.ArgumentID,
LanguageName = t1.ArgumentValue
})
.ToList();
rm = new SuccessResponseMessage(null, i_crm);
rm.DATA.Add(BLWording.REL, saLanguage);
} while (false);
}
catch (Exception ex)
{
sMsg = Util.GetLastExceptionMsg(ex);
LogAndSendEmail(sMsg + "Params:" + JsonToString(i_crm), ex, i_crm.ORIGID, i_crm.USERID, nameof(OrganizerMaintain_UpdService), "", "QueryList 語言管理 (List 查詢)", "", "", "");
}
finally
{
if (null != sMsg)
{
rm = new ErrorResponseMessage(sMsg, i_crm);
}
}
return rm;
}
#endregion 語言管理 (List 查詢)
#region 洲別選單
/// <summary>
/// 城市類別管理(查詢筆數)
/// </summary>
/// <param name="i_crm"></param>
/// <returns></returns>
public ResponseMessage QueryRegionList(RequestMessage i_crm)
{
RegionMaintain_QryService cm_upd = new RegionMaintain_QryService();
ResponseMessage rm = cm_upd.QueryRegionList(i_crm);
return rm;
}
#endregion 洲別選單
#region 以國家當作搜尋條件
/// <summary>
/// 城市類別管理(查詢筆數)
/// </summary>
/// <param name="i_crm"></param>
/// <returns></returns>
public ResponseMessage QueryCountryList(RequestMessage i_crm)
{
CountryMaintain_QryService cm_upd = new CountryMaintain_QryService();
ResponseMessage rm = cm_upd.QueryCountryList(i_crm);
return rm;
}
#endregion 以國家當作搜尋條件
}
}