public string SaveBase(PM_ALT_BASE entity, IList <PM_ALT_NOTI> notis, AlertSaveOptions saveOptions) { string message = "添加成功"; try { PM_ALT_BASE exist = pm_ALT_BASEBO.GetEntity(entity.AlertName); if (exist == null || exist.AlertID == null) { pm_ALT_BASEBO.Save(entity, notis, saveOptions, out message); } else { message = "预警名称已存在"; } return(message); } catch (Exception e) { return("添加失败"); throw e; } }
public void Save(PM_ALT_BASE entity, IList <PM_ALT_NOTI> notis, AlertSaveOptions saveOptions, out string returnMessage) { returnMessage = string.Empty; // try { DateTime?datetime = UtilDAO.GetDatabaseUtcDatetime().Value.AddHours(8); // #region check #region check basic if (saveOptions == null) { returnMessage = "Parameter [SaveOptions saveOptions] can not be null."; return; } if (entity == null) { returnMessage = "Input parameter [ALERT entity] can not be null."; return; } if (!entity.AlertID.HasValue) { returnMessage = "Input parameter [ALERT.AlertID] can not be null."; return; } if (saveOptions.IsChangeNoti) { if (notis == null) { returnMessage = "Input parameter [IList<ALERT_NOTI> notis] can not be null."; return; } } // SSIdentity identity = SSAuthentication.CurrentIdentity as SSIdentity; if (identity == null) { returnMessage = "[Authentication.Identity] is required."; return; } #endregion // #region check alert if (saveOptions.IsChangeAlert) { if (string.IsNullOrEmpty(entity.AlertName)) { returnMessage = "[ALERT Name] is required."; return; } if (string.IsNullOrEmpty(entity.AlertAlias)) { returnMessage = "[ALERT Alias] is required."; return; } if (string.IsNullOrEmpty(entity.AlertObject)) { returnMessage = "[ALERT Object] is required."; return; } if (!_PM_ALT_BASEDAO.CheckDatabaseObject(entity.AlertObject)) { returnMessage = "[ALERT Object] is invalid."; return; } // if (!entity.AlertID.HasValue) { entity.AlertID = Guid.NewGuid(); entity.CreatedBy = identity.Name; entity.CreatedOn = datetime; } else { entity.ModifiedBy = identity.Name; entity.ModifiedOn = datetime; } // if (!entity.RowDeleted.HasValue) { entity.RowDeleted = false; } if (string.IsNullOrEmpty(entity.CreatedBy)) { entity.CreatedBy = identity.Name; } if (!entity.CreatedOn.HasValue) { entity.CreatedOn = datetime; } } #endregion // #region check noti if (saveOptions.IsChangeNoti) { } #endregion #endregion // #region save // #region save alert if (saveOptions.IsChangeAlert) { PM_ALT_BASE entityExisted = this.GetEntity(entity.AlertID.Value); if (entityExisted == null) { if (null != this.GetEntity(entity.AlertName)) { returnMessage = "The item with the same code has existed."; return; } // entity.ModifiedBy = null; entity.ModifiedOn = null; // this.Insert(entity); } else { this.UpdateSome(entity); } } #endregion // #region save noti if (saveOptions.IsChangeNoti) { _PM_ALT_NOTIBO.SaveBatch(entity.AlertID.Value, notis, out returnMessage); // if (!string.IsNullOrEmpty(returnMessage)) { return; } } #endregion #endregion } catch (Exception ex) { returnMessage = ex.Message; return; } }