public bool EoMenuPerm_deleteBatch(string[] ids) { var dt = NsDmHelper.EO_MenuPerm .wherepks(ids) .query(); if (dt == null || dt.Count == 0) { return(false); } var dtDetail = NsDmHelper.EO_MenuPermSet .where (t => t.EOMPS_MenuPermId.@in(ids.toConstReq1())) .query(); dt.forEach(x => x.Delete()); dtDetail.forEach(x => x.Delete()); var scope = new FdbTransScope(FdbTransScopeOption.RequiresNew); using (scope.Use) { dt.ns_update(); dtDetail.ns_update(); scope.complete(); } return(true); }
public bool EoMenuFun_deleteBatch(string[] ids) { var dt = NsDmHelper.EO_MenuFun .wherepks(ids) .query(); if (dt == null || dt.Count == 0) { return(false); } var funIds = dt.Select(x => x.EOMF_MenuFunId).ToArray(); var dtFunPermSet = NsDmHelper.EO_FunPermSet .select() .where (t => t.EOFPS_MenuFunId.@in(funIds.toConstReq1())) .query(); dtFunPermSet.forEach(x => x.Delete()); dt.forEach(x => x.Delete()); var scope = new FdbTransScope(FdbTransScopeOption.RequiresNew); using (scope.Use) { dtFunPermSet.ns_update(); dt.ns_update(); scope.complete(); } return(true); }
//[ValidateAntiForgeryToken] public ActionResult Delete(FormCollection collection) { //var token = collection["__RequestVerificationToken"]; var id = collection[AppDataName.EOE_EmployeeId]; var row = EoDataService.Instance.EoEmployee_getById(id).FirstRow; if (row == null) { return(Json(new { Result = jTable_ERROR_CODE, Message = "資料不存在" })); } var login = NsDmHelper.EO_LoginAccount.wherepk(id).queryFirst(); try { if (login != null) { login.Delete(); } row.Delete(); var scope = new FdbTransScope(FdbTransScopeOption.RequiresNew); using (scope.Use) { login.ns_update(); row.ns_update(); scope.complete(); } return(Json(new { Result = jTable_SUCCESS_CODE })); } catch (Exception ex) { return(Json(new { Result = jTable_ERROR_CODE, Message = ex.Message })); } }
public void doWork() { string smtpHost = string.Empty; string smtpUserId = string.Empty; string smtpPasswd = string.Empty; string smtpSender = string.Empty; smtpHost = FtdConfigService.Instance.getAppSettingValue("SmtpHost"); smtpUserId = FtdConfigService.Instance.getAppSettingValue("SmtpUserId"); smtpPasswd = FtdConfigService.Instance.getAppSettingValue("SmtpPasswd"); smtpSender = FtdConfigService.Instance.getAppSettingValue("SmtpSender"); StringBuilder sb = new StringBuilder(); string errorMsg = string.Empty; SY_NewsDataTable dtNews = new SY_NewsDataTable(); SY_NewsObjectDataTable dtNewsObject = new SY_NewsObjectDataTable(); AppAgentLog.writeLog(string.Format("排程開始同步資料[{0}] : {1}", "", DateTime.Now.ToString("yyyy/MM/dd HH:mm:ss"))); DateTime DT = DateTime.Now; try { #region //查詢系統日之前未寄出的通知 var dt = NsDmHelper.SY_MailList .selectAll(t => t.AllPhysical) .where (t => t.SYML_EventTime.tostring(NsDataFormat.DATE_YYYYMMDD) <= DateTime.Now.ToString("yyyyMMdd") & t.SYML_IsSent == "N" & t.SYML_NotifyWay == "A" & t.SYML_Target != null ).query(); foreach (var row in dt.TypeRows) { string email = row.SYML_Target; try { //信件內容控制 StringBuilder sb1 = new StringBuilder(); string tBody = string.Empty; sb1.Append("<font size=3 color=\"black\">" + row.SYML_Message + "</font><br>"); tBody = "<html><body><tr><td>" + sb1.ToString() + "</td></tr></body></html>"; MailMessage message = new MailMessage(smtpSender, email, row.SYML_MsgTypeName_XX, tBody); message.IsBodyHtml = true; SmtpClient client = new SmtpClient(smtpHost); client.Credentials = new NetworkCredential(smtpUserId, smtpPasswd); client.Send(message); row.SYML_IsSent = "Y"; row.SYML_RealSentTime = DateTime.Now; var scope = new FdbTransScope(FdbTransScopeOption.Required); using (scope.Use) { dt.ns_update(); scope.complete(); dt.AcceptChanges(); } } catch (Exception e) { sb.Append("發送mail失敗, 訊息 : " + e.Message + Environment.NewLine); } } #endregion AppAgentLog.writeLog(string.Format("完成同步資料[{0}] : {1}", GetType().Name, DateTime.Now.ToString("yyyy/MM/dd HH:mm:ss"))); string split = new string('-', 30); AppAgentLog.writeLog(split); } catch (Exception ex) { AppAgentLog.writeLog(ex.Message); } finally { } }
public ActionResult Edit(FormCollection collection) { var token = collection["__RequestVerificationToken"]; var mode = collection["ViewMode"]; var id = collection[AppDataName.EOE_EmployeeId]; var msgOK = "OK"; EO_EmployeeDataTable dt = null; EO_EmployeeRow row = null; try { if (mode.equalIgnoreCase("create")) { dt = new EO_EmployeeDataTable(); row = dt.newTypedRow(); row.ns_AssignNewId(); dt.addTypedRow(row); msgOK = FtdStatus.InsertSuccess.ToString(); } else { //找出該筆資料 dt = EoDataService.Instance.EoEmployee_getById(id); if (dt == null || dt.Count == 0) { return(Json(new { Result = jTable_ERROR_CODE, Message = "資料不存在" })); } msgOK = FtdStatus.UpdateSuccess.ToString(); } //將Form sumit的資料更新至DataRow row = dt.FirstRow; var isOK = this.TryUpdateModel(row); //若驗證失敗-->回傳錯誤訊息 if (!ModelState.IsValid) { return(Json(new { Result = jTable_ERROR_CODE, Message = string.Join("<br/>", ModelState.Values) })); } #region //驗證欄位 List <string> lstError = new List <string>(); if (row.EOE_EmployeeId.isNullOrEmpty()) { lstError.Add("人員ID不能為空"); } //if (row.EOE_EmployeeCode.isNullOrEmpty()) //{ // lstError.Add("人員編號不能為空"); //} if (row.EOE_LoginAccount_XX.isNullOrEmpty()) { lstError.Add("帳號不能為空"); } if (row.EOE_EmployeeName.isNullOrEmpty()) { lstError.Add("人員姓名不能為空"); } //if (row.EOE_DepartmentId.isNullOrEmpty()) //{ // lstError.Add("部門ID不能為空"); //} //if (row.EOE_EmployeeTitleId.isNullOrEmpty()) //{ // lstError.Add("職稱ID不能為空"); //} //回傳錯誤訊息 if (lstError.Count > 0) { return(Json(new { Result = jTable_ERROR_CODE, Message = string.Join("<br/>", lstError.ToArray()) })); } //檢查鍵值是否重覆 if (EoDataService.Instance.EoEmployee_checkDuplicate(row.EOE_EmployeeId, row.EOE_DepartmentId, row.EOE_EmployeeCode)) { return(Json(new { Result = jTable_ERROR_CODE, Message = "相同鍵值的資料已存在" })); } #endregion //人員編號=登入帳號 row.EOE_EmployeeCode = row.EOE_LoginAccount_XX; //異動 LoginAccount var dtLoginAccount = NsDmHelper.EO_LoginAccount .selectAll(t => t.AllExt) .where (t => t.EOLA_LoginAccount == row.EOE_EmployeeCode.toConstReq1()) .query(); var rowLoginAccount = dtLoginAccount.FirstRow; if (rowLoginAccount == null) { rowLoginAccount = dtLoginAccount.newTypedRow(); rowLoginAccount.EOLA_LoginAccountId = row.EOE_EmployeeId; rowLoginAccount.EOLA_LoginAccount = row.EOE_EmployeeCode; //預設密碼=帳號 rowLoginAccount.EOLA_LoginPassword = row.EOE_EmployeeCode; dtLoginAccount.addTypedRow(rowLoginAccount); } else { if (rowLoginAccount.EOLA_LoginAccountId != row.EOE_EmployeeId) { return(Json(new { Result = jTable_ERROR_CODE, Message = "帳號已存在" })); } } rowLoginAccount.EOLA_IsEnable = row.EOE_Enabled; if (!row.EOE_LoginPassword_XX.isNullOrEmpty()) { rowLoginAccount.EOLA_LoginPassword = row.EOE_LoginPassword_XX; } var scope = new FdbTransScope(FdbTransScopeOption.RequiresNew); using (scope.Use) { dt.ns_update(); dtLoginAccount.ns_update(); dt.AcceptChanges(); scope.complete(); } return(Json(new { Result = msgOK })); } catch (Exception ex) { return(Json(new { Result = jTable_ERROR_CODE, Message = ex.Message })); } }
public string EoMenuPerm_updatePermSet(EO_MenuPermRow row, List <string> lstItemNos, Dictionary <string, List <string> > dicFuns) { //程式功能清單 var dtMenuFun = NsDmHelper.EO_MenuFun .selectAll() .query(); //程式授權 var dtMenuPermSet = NsDmHelper.EO_MenuPermSet .selectAll() .where (t => t.EOMPS_MenuPermId == row.EOMP_MenuPermId) .query(); var menuPermSetIds = dtMenuPermSet.Select(x => x.EOMPS_MenuPermSetId).ToArray(); //程式功能授權 var dtFunPermSet = NsDmHelper.EO_FunPermSet .selectAll(t => t.AllExt) .where (t => t.EOFPS_MenuPermSetId.batchin(menuPermSetIds.toConstReq1())) .query(); List <string> cmds = null; foreach (var itemNo in lstItemNos) { var menuPermSet = dtMenuPermSet.Where(x => x.EOMPS_MenuItemNo == itemNo).FirstOrDefault(); if (menuPermSet == null) { menuPermSet = dtMenuPermSet.newTypedRow(); menuPermSet.ns_AssignNewId(); menuPermSet.EOMPS_MenuItemNo = itemNo; menuPermSet.EOMPS_MenuPermId = row.EOMP_MenuPermId; dtMenuPermSet.addTypedRow(menuPermSet); } //程式功能 if (!dicFuns.Keys.Contains(itemNo)) { continue; } cmds = dicFuns[itemNo]; foreach (var cmd in cmds) { var menuFun = dtMenuFun.Where(x => x.EOMF_ItemNo == itemNo & x.EOMF_FunctionCode == cmd).FirstOrDefault(); if (menuFun == null) { continue; } var funPermSet = dtFunPermSet.Where(x => x.EOFPS_MenuPermSetId == menuPermSet.EOMPS_MenuPermSetId & x.EOFPS_FunctionCode_XX == cmd ).FirstOrDefault(); if (funPermSet == null) { funPermSet = dtFunPermSet.newTypedRow(); funPermSet.ns_AssignNewId(); funPermSet.EOFPS_MenuFunId = menuFun.EOMF_MenuFunId; funPermSet.EOFPS_MenuPermSetId = menuPermSet.EOMPS_MenuPermSetId; funPermSet.EOFPS_MenuItemNo_XX = itemNo; funPermSet.EOFPS_FunctionCode_XX = menuFun.EOMF_FunctionCode; funPermSet.EOFPS_FunctionName_XX = menuFun.EOMF_FunctionName; dtFunPermSet.addTypedRow(funPermSet); } } } //刪除不存在者 var keyMenus = lstItemNos.Select(x => row.EOMP_MenuPermId + "#" + x).ToArray(); var delMenus = dtMenuPermSet.Where(x => !(x.EOMPS_MenuPermId + "#" + x.EOMPS_MenuItemNo).inAny(keyMenus)).ToArray(); delMenus.forEach(x => x.Delete()); var keyFuns = new List <string>(); foreach (var key in dicFuns.Keys) { var funs = dicFuns[key].Select(x => key + "#" + x).ToArray(); keyFuns.AddRange(funs); } var delFuns = dtFunPermSet.Where(x => !(x.EOFPS_MenuItemNo_XX + "#" + x.EOFPS_FunctionCode_XX).inAny(keyFuns)).ToArray(); delFuns.forEach(x => x.Delete()); var scope = new FdbTransScope(FdbTransScopeOption.RequiresNew); using (scope.Use) { dtMenuPermSet.ns_update(); dtFunPermSet.ns_update(); scope.complete(); } return("OK"); }
public void doWork() { string errorMsg = string.Empty; SY_NewsDataTable dtNews = new SY_NewsDataTable(); SY_NewsObjectDataTable dtNewsObject = new SY_NewsObjectDataTable(); AppAgentLog.writeLog(string.Format("排程開始同步資料[{0}] : {1}", "", DateTime.Now.ToString("yyyy/MM/dd HH:mm:ss"))); DateTime DT = DateTime.Now; try { var dtNotice2 = NsDmHelper.SY_Notice2 .selectAll(t => t.AllPhysical) .where (t => t.SYN2_NewsId == null & t.SYN2_StartTime.tostring(NsDataFormat.DATE_YYYYMMDD) == Convert.ToDateTime(DT).ToString("yyyyMMdd") ) .query(); if (dtNotice2 != null && dtNotice2.Rows.Count > 0) { var drNotice2 = dtNotice2.FirstRow; string year = drNotice2.SYN2_Year; string season = drNotice2.SYN2_Season; string strDT = string.Empty; var dtReportMaster = NsDmHelper.PP_ReportMaster .selectAll(t => t.AllPhysical) .where (t => t.PPRM_Year == year & t.PPRM_Season == season & t.PPRM_ReportDate == null // 尚未送件 ) .query(); #region //有需要公告對象時產生 if (dtReportMaster != null && dtReportMaster.Rows.Count > 0) { #region //公告增加一筆 var drNews = dtNews.newTypedRow(); drNews.ns_AssignNewId(); drNews.SYN_Type = "B"; if (!string.IsNullOrEmpty(drNotice2.SYN2_StartTime)) { strDT = (Convert.ToInt32(drNotice2.SYN2_StartTime.Substring(0, 3)) + 1911).ToString() + "/" + drNotice2.SYN2_StartTime.Substring(3, 2).PadLeft(2, '0') + "/" + drNotice2.SYN2_StartTime.Substring(5, 2).PadLeft(2, '0'); } drNews.SYN_StartTime = Convert.ToDateTime(strDT); if (!string.IsNullOrEmpty(drNotice2.SYN2_EndTime)) { strDT = (Convert.ToInt32(drNotice2.SYN2_EndTime.Substring(0, 3)) + 1911).ToString() + "/" + drNotice2.SYN2_EndTime.Substring(3, 2).PadLeft(2, '0') + "/" + drNotice2.SYN2_EndTime.Substring(5, 2).PadLeft(2, '0'); } drNews.SYN_EndTime = Convert.ToDateTime(strDT); drNews.SYN_Subject = drNotice2.SYN2_Subject; drNews.SYN_Message = drNotice2.SYN2_Content; dtNews.addTypedRow(drNews); #endregion #region //公告明細增加多筆 string newsid = drNews.SYN_NewsId; foreach (var dr in dtReportMaster.TypeRows) { var drNewsObject = dtNewsObject.newTypedRow(); drNewsObject.ns_AssignNewId(); drNewsObject.SYNO_NewsId = newsid; drNewsObject.SYNO_ObjectId = dr.PPRM_ManageOrgId; dtNewsObject.addTypedRow(drNewsObject); } #endregion drNotice2.SYN2_NewsId = newsid; } #endregion //確認無誤一起更新 var scope = new FdbTransScope(FdbTransScopeOption.RequiresNew); using (scope.Use) { drNotice2.ns_update(); dtNews.ns_update(); dtNewsObject.ns_update(); scope.complete(); drNotice2.AcceptChanges(); dtNews.AcceptChanges(); dtNewsObject.AcceptChanges(); } } AppAgentLog.writeLog(string.Format("完成同步資料[{0}] : {1}", GetType().Name, DateTime.Now.ToString("yyyy/MM/dd HH:mm:ss"))); string split = new string('-', 30); AppAgentLog.writeLog(split); } catch (Exception ex) { AppAgentLog.writeLog(ex.Message); } finally { } }