/// <summary> /// Get with transaction /// </summary> public PM_ALT_EVENT_LOG Get(object entityId, DbTransaction transaction) { ArgumentValidator.CheckForNullArgument(entityId, "entityId"); ArgumentValidator.CheckForNullArgument(transaction, "transaction"); PM_ALT_EVENT_LOG PM_ALT_EVENT_LOGEntity = null; try { Database db = GetDatabaseInstance(); DbCommand dbCommand = db.GetSqlStringCommand(PM_ALT_EVENT_LOGDAO.SqlGet); db.AddInParameter(dbCommand, "@EventLogID", DbType.Guid, entityId); using (IDataReader dataReader = db.ExecuteReader(dbCommand, transaction)) { if (dataReader.Read()) { PM_ALT_EVENT_LOGEntity = ReadEntity(dataReader); } } } catch (Exception ex) { ExceptionPolicy.HandleException(ex, ExceptionPolicy.DataAccessDefaultPolicy); } return(PM_ALT_EVENT_LOGEntity); }
private void UpdateAll(PM_ALT_EVENT_LOG entity, DbTransaction transaction) { ArgumentValidator.CheckForNullArgument(entity, "entity"); ArgumentValidator.CheckForNullArgument(transaction, "transaction"); PersistentPM_ALT_EVENT_LOG PM_ALT_EVENT_LOGEntity = entity as PersistentPM_ALT_EVENT_LOG; try { Database db = GetDatabaseInstance(); DbCommand dbCommand = db.GetSqlStringCommand(PM_ALT_EVENT_LOGDAO.SqlUpdate); db.AddInParameter(dbCommand, "@EventLogID", DbType.Guid, PM_ALT_EVENT_LOGEntity.EventLogID); db.AddInParameter(dbCommand, "@EventTypeID", DbType.Guid, PM_ALT_EVENT_LOGEntity.EventTypeID); db.AddInParameter(dbCommand, "@EventBrief", DbType.String, PM_ALT_EVENT_LOGEntity.EventBrief); db.AddInParameter(dbCommand, "@EventContent", DbType.String, PM_ALT_EVENT_LOGEntity.EventContent); db.AddInParameter(dbCommand, "@Attachments", DbType.String, PM_ALT_EVENT_LOGEntity.Attachments); db.AddInParameter(dbCommand, "@NotifiedCnt", DbType.Int32, PM_ALT_EVENT_LOGEntity.NotifiedCnt); db.AddInParameter(dbCommand, "@IsFinished", DbType.Boolean, PM_ALT_EVENT_LOGEntity.IsFinished); db.AddInParameter(dbCommand, "@CreatedBy", DbType.String, PM_ALT_EVENT_LOGEntity.CreatedBy); db.AddInParameter(dbCommand, "@CreatedOn", DbType.DateTime, PM_ALT_EVENT_LOGEntity.CreatedOn); db.AddInParameter(dbCommand, "@NotifiedBy", DbType.String, PM_ALT_EVENT_LOGEntity.NotifiedBy); db.AddInParameter(dbCommand, "@NotifiedOn", DbType.DateTime, PM_ALT_EVENT_LOGEntity.NotifiedOn); int result = db.ExecuteNonQuery(dbCommand, transaction); if (result == 0) { throw new EntityNotFoundException(); } } catch (Exception ex) { ExceptionPolicy.HandleException(ex, ExceptionPolicy.DataAccessDefaultPolicy); } }
/// <summary> /// Insert /// </summary> public PM_ALT_EVENT_LOG Insert(PM_ALT_EVENT_LOG entity) { ArgumentValidator.CheckForNullArgument(entity, "entity"); PersistentPM_ALT_EVENT_LOG PM_ALT_EVENT_LOGEntity = entity as PersistentPM_ALT_EVENT_LOG; try { Database db = GetDatabaseInstance(); DbCommand dbCommand = db.GetSqlStringCommand(PM_ALT_EVENT_LOGDAO.SqlInsert); db.AddInParameter(dbCommand, "@EventLogID", DbType.Guid, PM_ALT_EVENT_LOGEntity.EventLogID); db.AddInParameter(dbCommand, "@EventTypeID", DbType.Guid, PM_ALT_EVENT_LOGEntity.EventTypeID); db.AddInParameter(dbCommand, "@EventBrief", DbType.String, PM_ALT_EVENT_LOGEntity.EventBrief); db.AddInParameter(dbCommand, "@EventContent", DbType.String, PM_ALT_EVENT_LOGEntity.EventContent); db.AddInParameter(dbCommand, "@Attachments", DbType.String, PM_ALT_EVENT_LOGEntity.Attachments); db.AddInParameter(dbCommand, "@NotifiedCnt", DbType.Int32, PM_ALT_EVENT_LOGEntity.NotifiedCnt); db.AddInParameter(dbCommand, "@IsFinished", DbType.Boolean, PM_ALT_EVENT_LOGEntity.IsFinished); db.AddInParameter(dbCommand, "@CreatedBy", DbType.String, PM_ALT_EVENT_LOGEntity.CreatedBy); db.AddInParameter(dbCommand, "@CreatedOn", DbType.DateTime, PM_ALT_EVENT_LOGEntity.CreatedOn); db.AddInParameter(dbCommand, "@NotifiedBy", DbType.String, PM_ALT_EVENT_LOGEntity.NotifiedBy); db.AddInParameter(dbCommand, "@NotifiedOn", DbType.DateTime, PM_ALT_EVENT_LOGEntity.NotifiedOn); int result = db.ExecuteNonQuery(dbCommand); } catch (Exception ex) { ExceptionPolicy.HandleException(ex, ExceptionPolicy.DataAccessDefaultPolicy); } return(PM_ALT_EVENT_LOGEntity as PM_ALT_EVENT_LOG); }
public void Update(PM_ALT_EVENT_LOG entity, bool updateAll, DbTransaction transaction) { if (!updateAll) { UpdateSome(entity, transaction); } else { UpdateAll(entity, transaction); } }
public void Update(PM_ALT_EVENT_LOG entity, bool updateAll) { if (!updateAll) { UpdateSome(entity); } else { UpdateAll(entity); } }
// public void Notified(Guid eventLogID, int notifiedCnt, bool isFinished) { PM_ALT_EVENT_LOG log = new PM_ALT_EVENT_LOG(); log.EventLogID = eventLogID; log.NotifiedCnt = notifiedCnt; log.IsFinished = isFinished; log.NotifiedBy = "MESEmailSystem"; log.NotifiedOn = SSGlobalConfig.Now; this.UpdateSome(log); }
public void UpdateSome(PM_ALT_EVENT_LOG entity) { try { ArgumentValidator.CheckForNullArgument(entity, "PM_ALT_EVENT_LOG Entity"); _PM_ALT_EVENT_LOGDAO.Update(entity, false); } catch (Exception ex) { ExceptionPolicy.HandleException(ex, ExceptionPolicy.BusinessLogicDefaultPolicy); } }
// #region base interface impl public PM_ALT_EVENT_LOG Insert(PM_ALT_EVENT_LOG entity) { PM_ALT_EVENT_LOG newEntity = null; try { ArgumentValidator.CheckForNullArgument(entity, "PM_ALT_EVENT_LOG Entity"); newEntity = _PM_ALT_EVENT_LOGDAO.Insert(entity); } catch (Exception ex) { ExceptionPolicy.HandleException(ex, ExceptionPolicy.BusinessLogicDefaultPolicy); } return(newEntity); }
public PM_ALT_EVENT_LOG GetEntity(Guid entityGuid) { PM_ALT_EVENT_LOG entity = null; try { ArgumentValidator.CheckForNullArgument(entityGuid, "PM_ALT_EVENT_LOG Guid"); entity = _PM_ALT_EVENT_LOGDAO.Get(entityGuid); } catch (Exception ex) { ExceptionPolicy.HandleException(ex, ExceptionPolicy.BusinessLogicDefaultPolicy); } return(entity); }
/// <summary> /// MES 发送邮件 /// </summary> /// <param name="em">事件模块</param> /// <param name="brief">邮件标题</param> /// <param name="content">邮件内容</param> public void Send(string em, string brief, string content, string attachments, string optor) { CV_PM_ALT_EVENT_TYPE type = _CV_PM_ALT_EVENT_TYPEBO.GetEntity(SafeConvert.ToString(em)); try { PM_ALT_EVENT_LOG log = new PM_ALT_EVENT_LOG { EventLogID = Guid.NewGuid(), CreatedBy = optor, CreatedOn = SSGlobalConfig.Now, EventBrief = string.Format(type.EventBrief, brief), EventContent = string.Format(type.EventContent, brief, content), Attachments = attachments, EventTypeID = type.EventTypeID, IsFinished = false, NotifiedCnt = 0 }; this.Insert(log); } catch { PM_ALT_EVENT_LOG log = new PM_ALT_EVENT_LOG { EventLogID = Guid.NewGuid(), CreatedBy = optor, CreatedOn = SSGlobalConfig.Now, EventBrief = string.Format(brief), EventContent = string.Format(content), Attachments = attachments, EventTypeID = type.EventTypeID, IsFinished = false, NotifiedCnt = 0 }; this.Insert(log); } }
private static PM_ALT_EVENT_LOG ReadEntity(IDataReader dataReader) { PM_ALT_EVENT_LOG PM_ALT_EVENT_LOGEntity = new PM_ALT_EVENT_LOG(); object value; value = dataReader["EventLogID"]; if (value != DBNull.Value) { PM_ALT_EVENT_LOGEntity.EventLogID = (Guid?)value; } value = dataReader["EventTypeID"]; if (value != DBNull.Value) { PM_ALT_EVENT_LOGEntity.EventTypeID = (Guid?)value; } value = dataReader["EventBrief"]; if (value != DBNull.Value) { PM_ALT_EVENT_LOGEntity.EventBrief = (String)value; } value = dataReader["EventContent"]; if (value != DBNull.Value) { PM_ALT_EVENT_LOGEntity.EventContent = (String)value; } value = dataReader["Attachments"]; if (value != DBNull.Value) { PM_ALT_EVENT_LOGEntity.Attachments = (String)value; } value = dataReader["NotifiedCnt"]; if (value != DBNull.Value) { PM_ALT_EVENT_LOGEntity.NotifiedCnt = (Int32?)value; } value = dataReader["IsFinished"]; if (value != DBNull.Value) { PM_ALT_EVENT_LOGEntity.IsFinished = (Boolean?)value; } value = dataReader["CreatedBy"]; if (value != DBNull.Value) { PM_ALT_EVENT_LOGEntity.CreatedBy = (String)value; } value = dataReader["CreatedOn"]; if (value != DBNull.Value) { PM_ALT_EVENT_LOGEntity.CreatedOn = (DateTime?)value; } value = dataReader["NotifiedBy"]; if (value != DBNull.Value) { PM_ALT_EVENT_LOGEntity.NotifiedBy = (String)value; } value = dataReader["NotifiedOn"]; if (value != DBNull.Value) { PM_ALT_EVENT_LOGEntity.NotifiedOn = (DateTime?)value; } return(PM_ALT_EVENT_LOGEntity); }
private void UpdateSome(PM_ALT_EVENT_LOG entity, DbTransaction transaction) { ArgumentValidator.CheckForNullArgument(entity, "entity"); ArgumentValidator.CheckForNullArgument(transaction, "transaction"); PersistentPM_ALT_EVENT_LOG PM_ALT_EVENT_LOGEntity = entity as PersistentPM_ALT_EVENT_LOG; StringBuilder sqlUpdateSome = new StringBuilder(); sqlUpdateSome.Append("UPDATE dbo.PM_ALT_EVENT_LOG SET "); PropertyInfo[] propertyInfos = PM_ALT_EVENT_LOGEntity.GetType().GetProperties(); Hashtable propertyValues = new System.Collections.Hashtable(); int columnCountForUpdate = 0; foreach (PropertyInfo propertyInfo in propertyInfos) { if (EntityMapping.ContainsProperty(propertyInfo.Name)) { object propertyValue = propertyInfo.GetValue(PM_ALT_EVENT_LOGEntity, null); ORProperty property = EntityMapping[propertyInfo.Name]; if (!property.IsPrimaryKey) { if (!PM_ALT_EVENT_LOGEntity.IsDefaultValue(propertyInfo.Name)) { propertyValues[propertyInfo.Name] = propertyValue; sqlUpdateSome.Append(" " + property.ColumnName + " = @" + property.ColumnName + ","); columnCountForUpdate++; } } else { propertyValues[propertyInfo.Name] = propertyValue; } } } if (columnCountForUpdate == 0) { return; } sqlUpdateSome.Remove(sqlUpdateSome.Length - 1, 1); sqlUpdateSome.Append(" WHERE 1 = 1 "); sqlUpdateSome.Append(" AND EventLogID = @EventLogID "); try { Database db = GetDatabaseInstance(); DbCommand dbCommand = db.GetSqlStringCommand(sqlUpdateSome.ToString()); foreach (DictionaryEntry de in propertyValues) { ORProperty property = EntityMapping[de.Key.ToString()]; db.AddInParameter(dbCommand, "@" + property.ColumnName, property.DatabaseType, de.Value); } int result = db.ExecuteNonQuery(dbCommand, transaction); if (result == 0) { throw new EntityNotFoundException(); } } catch (Exception ex) { ExceptionPolicy.HandleException(ex, ExceptionPolicy.DataAccessDefaultPolicy); } }
/// <summary> /// Update with transaction /// </summary> public void Update(PM_ALT_EVENT_LOG entity, DbTransaction transaction) { Update(entity, true, transaction); }
/// <summary> /// Update /// </summary> public void Update(PM_ALT_EVENT_LOG entity) { Update(entity, true); }