|
|
using EasyBL.WebApi.Message; using Entity.Sugar; using SqlSugar; using SqlSugar.Base; using System;
namespace EasyBL.WEBAPP.WSM { public class Announcement_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 sAnnouncementID = _fetchString(i_crm, @"AnnouncementID");
var oEntity = db.Queryable<OTB_SYS_Announcement, 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.AnnouncementID == sAnnouncementID) .Select((t1, t2, t3) => new OTB_SYS_Announcement { AnnouncementID = SqlFunc.GetSelfAndAutoFill(t1.AnnouncementID), 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(Announcement_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<OTB_SYS_Announcement>(i_crm); _setEntityBase(oEntity, i_crm); oEntity.AnnouncementID = Guid.NewGuid().ToString(); oEntity.GoTop = false; oEntity.GoTop_Time = DateTime.Now; var oRes = db.Insertable(oEntity).ExecuteReturnEntity(); rm = new SuccessResponseMessage(null, i_crm); rm.DATA.Add(BLWording.REL, oRes); } 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(Announcement_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<OTB_SYS_Announcement>(i_crm); _setEntityBase(oNewEntity, i_crm); var iRel = db.Updateable(oNewEntity) .IgnoreColumns(x => new { x.CreateUser, x.CreateDate, x.GoTop, x.GoTop_Time }).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(Announcement_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 sAnnouncementID = _fetchString(i_crm, @"AnnouncementID"); var iRel = db.Deleteable<OTB_SYS_Announcement>() .Where(x => x.OrgID == i_crm.ORIGID && x.AnnouncementID == sAnnouncementID).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(Announcement_UpdService), @"公告管理編輯", @"Delete(公告管理編輯(刪除))", @"", @"", @""); } finally { if (null != sMsg) { rm = new ErrorResponseMessage(sMsg, i_crm); } } return rm; }
#endregion 公告管理編輯(刪除)
} }
|