コード例 #1
0
        /// <summary>
        /// Get with transaction
        /// </summary>
        public PM_ALT_LOG Get(object entityId, DbTransaction transaction)
        {
            ArgumentValidator.CheckForNullArgument(entityId, "entityId");
            ArgumentValidator.CheckForNullArgument(transaction, "transaction");

            PM_ALT_LOG PM_ALT_LOGEntity = null;

            try
            {
                Database  db        = GetDatabaseInstance();
                DbCommand dbCommand = db.GetSqlStringCommand(PM_ALT_LOGDAO.SqlGet);

                db.AddInParameter(dbCommand, "@LogPK", DbType.Int64, entityId);
                using (IDataReader dataReader = db.ExecuteReader(dbCommand, transaction))
                {
                    if (dataReader.Read())
                    {
                        PM_ALT_LOGEntity = ReadEntity(dataReader);
                    }
                }
            }
            catch (Exception ex)
            {
                ExceptionPolicy.HandleException(ex, ExceptionPolicy.DataAccessDefaultPolicy);
            }

            return(PM_ALT_LOGEntity);
        }
コード例 #2
0
 public void Update(PM_ALT_LOG entity, bool updateAll, DbTransaction transaction)
 {
     if (!updateAll)
     {
         UpdateSome(entity, transaction);
     }
     else
     {
         UpdateAll(entity, transaction);
     }
 }
コード例 #3
0
 public void Update(PM_ALT_LOG entity, bool updateAll)
 {
     if (!updateAll)
     {
         UpdateSome(entity);
     }
     else
     {
         UpdateAll(entity);
     }
 }
コード例 #4
0
        public void UpdateSome(PM_ALT_LOG entity)
        {
            try
            {
                ArgumentValidator.CheckForNullArgument(entity, "PM_ALT_LOG Entity");

                _PM_ALT_LOGDAO.Update(entity, false);
            }
            catch (Exception ex)
            {
                ExceptionPolicy.HandleException(ex, ExceptionPolicy.BusinessLogicDefaultPolicy);
            }
        }
コード例 #5
0
        public PM_ALT_LOG Insert(PM_ALT_LOG entity)
        {
            PM_ALT_LOG newEntity = null;

            try
            {
                ArgumentValidator.CheckForNullArgument(entity, "PM_ALT_LOG Entity");

                newEntity = _PM_ALT_LOGDAO.Insert(entity);
            }
            catch (Exception ex)
            {
                ExceptionPolicy.HandleException(ex, ExceptionPolicy.BusinessLogicDefaultPolicy);
            }

            return(newEntity);
        }
コード例 #6
0
        public PM_ALT_LOG GetEntity(Int64 entityPK)
        {
            PM_ALT_LOG entity = null;

            try
            {
                ArgumentValidator.CheckForNullArgument(entityPK, "PM_ALT_LOG Int64");

                entity = _PM_ALT_LOGDAO.Get(entityPK);
            }
            catch (Exception ex)
            {
                ExceptionPolicy.HandleException(ex, ExceptionPolicy.BusinessLogicDefaultPolicy);
            }

            return(entity);
        }
コード例 #7
0
        private void UpdateAll(PM_ALT_LOG entity, DbTransaction transaction)
        {
            ArgumentValidator.CheckForNullArgument(entity, "entity");
            ArgumentValidator.CheckForNullArgument(transaction, "transaction");

            PersistentPM_ALT_LOG PM_ALT_LOGEntity = entity as PersistentPM_ALT_LOG;

            try
            {
                Database  db        = GetDatabaseInstance();
                DbCommand dbCommand = db.GetSqlStringCommand(PM_ALT_LOGDAO.SqlUpdate);

                db.AddInParameter(dbCommand, "@LogPK", DbType.Int64, PM_ALT_LOGEntity.LogPK);
                db.AddInParameter(dbCommand, "@AlertID", DbType.Guid, PM_ALT_LOGEntity.AlertID);
                db.AddInParameter(dbCommand, "@LogTitle", DbType.String, PM_ALT_LOGEntity.LogTitle);
                db.AddInParameter(dbCommand, "@LogContent", DbType.String, PM_ALT_LOGEntity.LogContent);
                db.AddInParameter(dbCommand, "@NotifiedCnt", DbType.Int32, PM_ALT_LOGEntity.NotifiedCnt);
                db.AddInParameter(dbCommand, "@IsClosed", DbType.Boolean, PM_ALT_LOGEntity.IsClosed);
                db.AddInParameter(dbCommand, "@RespondedBy", DbType.String, PM_ALT_LOGEntity.RespondedBy);
                db.AddInParameter(dbCommand, "@RespondedOn", DbType.DateTime, PM_ALT_LOGEntity.RespondedOn);
                db.AddInParameter(dbCommand, "@ResponseAction", DbType.String, PM_ALT_LOGEntity.ResponseAction);
                db.AddInParameter(dbCommand, "@ResponseCause", DbType.String, PM_ALT_LOGEntity.ResponseCause);
                db.AddInParameter(dbCommand, "@ResponseNotes", DbType.String, PM_ALT_LOGEntity.ResponseNotes);
                db.AddInParameter(dbCommand, "@AuditedBy", DbType.String, PM_ALT_LOGEntity.AuditedBy);
                db.AddInParameter(dbCommand, "@AuditedOn", DbType.DateTime, PM_ALT_LOGEntity.AuditedOn);
                db.AddInParameter(dbCommand, "@RowDeleted", DbType.Boolean, PM_ALT_LOGEntity.RowDeleted);
                db.AddInParameter(dbCommand, "@CreatedBy", DbType.String, PM_ALT_LOGEntity.CreatedBy);
                db.AddInParameter(dbCommand, "@CreatedOn", DbType.DateTime, PM_ALT_LOGEntity.CreatedOn);
                db.AddInParameter(dbCommand, "@NotifiedBy", DbType.String, PM_ALT_LOGEntity.NotifiedBy);
                db.AddInParameter(dbCommand, "@NotifiedOn", DbType.DateTime, PM_ALT_LOGEntity.NotifiedOn);
                int result = db.ExecuteNonQuery(dbCommand, transaction);

                if (result == 0)
                {
                    throw new EntityNotFoundException();
                }
            }
            catch (Exception ex)
            {
                ExceptionPolicy.HandleException(ex, ExceptionPolicy.DataAccessDefaultPolicy);
            }
        }
コード例 #8
0
        public void Respond(PM_ALT_LOG log, out string returnMessage)
        {
            returnMessage = string.Empty;
            //
            DateTime?datetime = UtilDAO.GetDatabaseUtcDatetime().Value.AddHours(8);

            //
            try
            {
                if (log == null)
                {
                    returnMessage = "Parameter [ALERT_LOG log] can not be null.";
                    return;
                }
                if (!log.LogPK.HasValue)
                {
                    returnMessage = "Parameter [LogPK] can not be null.";
                    return;
                }
                //
                #region check security
                SSIdentity identity = SSAuthentication.CurrentIdentity as SSIdentity;
                if (identity == null)
                {
                    returnMessage = "[Authentication.Identity] is required.";
                    return;
                }
                #endregion
                //
                log.RespondedOn = datetime;
                this.UpdateSome(log);
            }
            catch (Exception ex)
            {
                returnMessage = ex.Message;
                return;
            }
        }
コード例 #9
0
        /// <summary>
        /// Insert
        /// </summary>
        public PM_ALT_LOG Insert(PM_ALT_LOG entity)
        {
            ArgumentValidator.CheckForNullArgument(entity, "entity");
            PersistentPM_ALT_LOG PM_ALT_LOGEntity = entity as PersistentPM_ALT_LOG;

            try
            {
                Database  db        = GetDatabaseInstance();
                DbCommand dbCommand = db.GetSqlStringCommand(PM_ALT_LOGDAO.SqlInsert);

                db.AddInParameter(dbCommand, "@AlertID", DbType.Guid, PM_ALT_LOGEntity.AlertID);
                db.AddInParameter(dbCommand, "@LogTitle", DbType.String, PM_ALT_LOGEntity.LogTitle);
                db.AddInParameter(dbCommand, "@LogContent", DbType.String, PM_ALT_LOGEntity.LogContent);
                db.AddInParameter(dbCommand, "@NotifiedCnt", DbType.Int32, PM_ALT_LOGEntity.NotifiedCnt);
                db.AddInParameter(dbCommand, "@IsClosed", DbType.Boolean, PM_ALT_LOGEntity.IsClosed);
                db.AddInParameter(dbCommand, "@RespondedBy", DbType.String, PM_ALT_LOGEntity.RespondedBy);
                db.AddInParameter(dbCommand, "@RespondedOn", DbType.DateTime, PM_ALT_LOGEntity.RespondedOn);
                db.AddInParameter(dbCommand, "@ResponseAction", DbType.String, PM_ALT_LOGEntity.ResponseAction);
                db.AddInParameter(dbCommand, "@ResponseCause", DbType.String, PM_ALT_LOGEntity.ResponseCause);
                db.AddInParameter(dbCommand, "@ResponseNotes", DbType.String, PM_ALT_LOGEntity.ResponseNotes);
                db.AddInParameter(dbCommand, "@AuditedBy", DbType.String, PM_ALT_LOGEntity.AuditedBy);
                db.AddInParameter(dbCommand, "@AuditedOn", DbType.DateTime, PM_ALT_LOGEntity.AuditedOn);
                db.AddInParameter(dbCommand, "@RowDeleted", DbType.Boolean, PM_ALT_LOGEntity.RowDeleted);
                db.AddInParameter(dbCommand, "@CreatedBy", DbType.String, PM_ALT_LOGEntity.CreatedBy);
                db.AddInParameter(dbCommand, "@CreatedOn", DbType.DateTime, PM_ALT_LOGEntity.CreatedOn);
                db.AddInParameter(dbCommand, "@NotifiedBy", DbType.String, PM_ALT_LOGEntity.NotifiedBy);
                db.AddInParameter(dbCommand, "@NotifiedOn", DbType.DateTime, PM_ALT_LOGEntity.NotifiedOn);

                int result = db.ExecuteNonQuery(dbCommand);
            }
            catch (Exception ex)
            {
                ExceptionPolicy.HandleException(ex, ExceptionPolicy.DataAccessDefaultPolicy);
            }

            return(PM_ALT_LOGEntity as PM_ALT_LOG);
        }
コード例 #10
0
        protected override bool Execute(object readyData)
        {
            try
            {
                if (readyData == null)
                {
                    return(false);
                }
                //
                DataTable dtAll = readyData as DataTable;

                IList <PM_ALT_LOG>     logs     = new List <PM_ALT_LOG>();
                IList <PM_ALT_MESSAGE> messages = new List <PM_ALT_MESSAGE>();
                if (_alert.Format == "TABLE" || _alert.Format == "IMAGE")
                {
                    //fill Log Subject & Content
                    string logSubject = _alert.AlertContent;
                    if (!string.IsNullOrEmpty(logSubject))
                    {
                        logSubject = logSubject.Replace("@日期$", DateTime.Now.ToString("yyyy-MM-dd"));
                    }

                    string logContent = _alert.AlertDesc;
                    if (!string.IsNullOrEmpty(logContent))
                    {
                        logContent = _PM_ALT_BASEBO.BuildTable(_alert.AlertDesc, dtAll);
                    }

                    PM_ALT_MESSAGE msg = new PM_ALT_MESSAGE();
                    msg.MsgSubject = logSubject;
                    msg.MsgContent = logContent;
                    msg.MsgFrom    = "MESAdmin";
                    msg.MsgTo      = _MessageToMembers;
                    msg.Category   = _alert.AlertName;
                    msg.MsgType    = _alert.AlertType;
                    msg.Format     = _alert.Format;
                    msg.ObjectID   = _alert.AlertID;
                    msg.SentCnt    = 0;
                    msg.RowDeleted = false;

                    messages.Add(msg);

                    PM_ALT_LOG log = new PM_ALT_LOG();
                    log.AlertID     = _alert.AlertID;
                    log.LogTitle    = logSubject; //_alert.AlertAlias;
                    log.LogContent  = logContent;
                    log.NotifiedCnt = 1;
                    log.IsClosed    = false;
                    log.RowDeleted  = false;

                    logs.Add(log);
                }
                else
                {
                    for (int z = 0; z < dtAll.Rows.Count; z++)
                    {
                        //fill Log Subject & Content
                        string logSubject = _alert.AlertContent;

                        if (!string.IsNullOrEmpty(logSubject))
                        {
                            logSubject = logSubject.Replace("@日期$", DateTime.Now.ToString("yyyy-MM-dd"));
                        }


                        if (!string.IsNullOrEmpty(logSubject))
                        {
                            for (int i = 0; i < dtAll.Columns.Count; i++)
                            {
                                logSubject = logSubject.Replace("@" + dtAll.Columns[i].ColumnName + "$", dtAll.Rows[z][i].ToString());
                            }
                        }

                        string logURL = _alert.URL;
                        if (!string.IsNullOrEmpty(logURL))
                        {
                            for (int i = 0; i < dtAll.Columns.Count; i++)
                            {
                                logURL = logURL.Replace("@" + dtAll.Columns[i].ColumnName + "$", dtAll.Rows[z][i].ToString());
                            }
                        }

                        string logContent = _alert.AlertDesc;
                        if (!string.IsNullOrEmpty(logContent))
                        {
                            logContent = _PM_ALT_BASEBO.BuildContent(_alert.AlertDesc, dtAll, z);
                        }

                        PM_ALT_MESSAGE msg = new PM_ALT_MESSAGE();
                        msg.MsgSubject = logSubject; //_alert.AlertAlias;
                        msg.MsgContent = logContent;
                        msg.MsgFrom    = "MESAdmin";
                        msg.MsgTo      = _MessageToMembers;
                        msg.Category   = _alert.AlertName;
                        msg.MsgType    = _alert.AlertType;
                        msg.Format     = _alert.Format;
                        msg.ObjectID   = _alert.AlertID;
                        msg.SentCnt    = 0;
                        msg.RowDeleted = false;
                        msg.URL        = logURL;

                        messages.Add(msg);
                        //
                        //create log
                        PM_ALT_LOG log = new PM_ALT_LOG();
                        log.AlertID     = _alert.AlertID;
                        log.LogTitle    = logSubject; //_alert.AlertAlias;
                        log.LogContent  = logContent;
                        log.NotifiedCnt = 1;
                        log.IsClosed    = false;
                        log.RowDeleted  = false;

                        logs.Add(log);
                    }
                }
                //
                string returnMessage = string.Empty;
                if (!string.IsNullOrEmpty(returnMessage))
                {
                    log.Error("Exception: " + returnMessage + this.Name + ".SaveLogs()");
                    return(false);
                }

                //
                _PM_ALT_MESSAGEBO.SaveBatch(messages, out returnMessage);
                if (!string.IsNullOrEmpty(returnMessage))
                {
                    log.Error("Exception: " + returnMessage + this.Name + ".SaveMessages()");
                    return(false);
                }
                //
                if (!string.IsNullOrEmpty(_alert.PostProcedure))
                {
                    try
                    {
                        _PM_ALT_BASEBO.CallProcedure(_alert.PostProcedure);
                    }
                    catch (Exception ex)
                    {
                        log.Error(this.Name + ".CallPostProcedure()", ex);
                        return(false);
                    }
                }
                //
                if (_alert != null)
                {
                    PM_ALT_BASE alert = new PM_ALT_BASE();
                    alert.AlertID         = _alert.AlertID;
                    alert.LastAlertedTime = Siemens.Simatic.Util.Utilities.DAO.UtilDAO.GetDatabaseUtcDatetime().Value.AddHours(8);
                    _PM_ALT_BASEBO.UpdateSome(alert);
                }
            }
            catch (Exception ex)
            {
                log.Error(this.Name + ".Execute()", ex);
                return(false);
            }
            //
            return(true);
        }
コード例 #11
0
        private static PM_ALT_LOG ReadEntity(IDataReader dataReader)
        {
            PM_ALT_LOG PM_ALT_LOGEntity = new PM_ALT_LOG();
            object     value;


            value = dataReader["LogPK"];
            if (value != DBNull.Value)
            {
                PM_ALT_LOGEntity.LogPK = (Int64?)value;
            }

            value = dataReader["AlertID"];
            if (value != DBNull.Value)
            {
                PM_ALT_LOGEntity.AlertID = (Guid?)value;
            }

            value = dataReader["LogTitle"];
            if (value != DBNull.Value)
            {
                PM_ALT_LOGEntity.LogTitle = (String)value;
            }

            value = dataReader["LogContent"];
            if (value != DBNull.Value)
            {
                PM_ALT_LOGEntity.LogContent = (String)value;
            }

            value = dataReader["NotifiedCnt"];
            if (value != DBNull.Value)
            {
                PM_ALT_LOGEntity.NotifiedCnt = (Int32?)value;
            }

            value = dataReader["IsClosed"];
            if (value != DBNull.Value)
            {
                PM_ALT_LOGEntity.IsClosed = (Boolean?)value;
            }

            value = dataReader["RespondedBy"];
            if (value != DBNull.Value)
            {
                PM_ALT_LOGEntity.RespondedBy = (String)value;
            }

            value = dataReader["RespondedOn"];
            if (value != DBNull.Value)
            {
                PM_ALT_LOGEntity.RespondedOn = (DateTime?)value;
            }

            value = dataReader["ResponseAction"];
            if (value != DBNull.Value)
            {
                PM_ALT_LOGEntity.ResponseAction = (String)value;
            }

            value = dataReader["ResponseCause"];
            if (value != DBNull.Value)
            {
                PM_ALT_LOGEntity.ResponseCause = (String)value;
            }

            value = dataReader["ResponseNotes"];
            if (value != DBNull.Value)
            {
                PM_ALT_LOGEntity.ResponseNotes = (String)value;
            }

            value = dataReader["AuditedBy"];
            if (value != DBNull.Value)
            {
                PM_ALT_LOGEntity.AuditedBy = (String)value;
            }

            value = dataReader["AuditedOn"];
            if (value != DBNull.Value)
            {
                PM_ALT_LOGEntity.AuditedOn = (DateTime?)value;
            }

            value = dataReader["RowDeleted"];
            if (value != DBNull.Value)
            {
                PM_ALT_LOGEntity.RowDeleted = (Boolean?)value;
            }

            value = dataReader["CreatedBy"];
            if (value != DBNull.Value)
            {
                PM_ALT_LOGEntity.CreatedBy = (String)value;
            }

            value = dataReader["CreatedOn"];
            if (value != DBNull.Value)
            {
                PM_ALT_LOGEntity.CreatedOn = (DateTime?)value;
            }

            value = dataReader["NotifiedBy"];
            if (value != DBNull.Value)
            {
                PM_ALT_LOGEntity.NotifiedBy = (String)value;
            }

            value = dataReader["NotifiedOn"];
            if (value != DBNull.Value)
            {
                PM_ALT_LOGEntity.NotifiedOn = (DateTime?)value;
            }

            return(PM_ALT_LOGEntity);
        }
コード例 #12
0
        private void UpdateSome(PM_ALT_LOG entity, DbTransaction transaction)
        {
            ArgumentValidator.CheckForNullArgument(entity, "entity");
            ArgumentValidator.CheckForNullArgument(transaction, "transaction");

            PersistentPM_ALT_LOG PM_ALT_LOGEntity = entity as PersistentPM_ALT_LOG;

            StringBuilder sqlUpdateSome = new StringBuilder();

            sqlUpdateSome.Append("UPDATE dbo.PM_ALT_LOG SET ");

            PropertyInfo[] propertyInfos        = PM_ALT_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_LOGEntity, null);
                    ORProperty property      = EntityMapping[propertyInfo.Name];
                    if (!property.IsPrimaryKey)
                    {
                        if (!PM_ALT_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 LogPK = @LogPK ");

            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);
            }
        }
コード例 #13
0
        /// <summary>
        /// Update with transaction
        /// </summary>

        public void Update(PM_ALT_LOG entity, DbTransaction transaction)
        {
            Update(entity, true, transaction);
        }
コード例 #14
0
        /// <summary>
        /// Update
        /// </summary>

        public void Update(PM_ALT_LOG entity)
        {
            Update(entity, true);
        }
コード例 #15
0
        /// <summary>
        /// 插入消息表
        /// </summary>
        /// <returns></returns>
        public string Trigger(DataTable dtTrigger, PM_ALT_BASE alertEntity)
        {
            try
            {
                if (dtTrigger == null || dtTrigger.Rows.Count == 0)
                {
                    return("没有执行内容");
                }

                IList <PM_ALT_LOG>     logs     = new List <PM_ALT_LOG>();
                IList <PM_ALT_MESSAGE> messages = new List <PM_ALT_MESSAGE>();
                if (alertEntity.Format == "TABLE" || alertEntity.Format == "IMAGE")
                {
                    //fill Log Subject & Content
                    string logSubject = alertEntity.AlertContent;
                    if (!string.IsNullOrEmpty(logSubject))
                    {
                        logSubject = logSubject.Replace("@日期$", DateTime.Now.ToString("yyyy-MM-dd"));
                    }

                    string logContent = alertEntity.AlertDesc;
                    if (!string.IsNullOrEmpty(logContent))
                    {
                        logContent = this.BuildTable(alertEntity.AlertDesc, dtTrigger);
                    }

                    PM_ALT_MESSAGE msg = new PM_ALT_MESSAGE();
                    msg.MsgSubject = logSubject;
                    msg.MsgContent = logContent;
                    msg.MsgFrom    = "MESAdmin";
                    msg.MsgTo      = this.GetEmailToList(alertEntity.AlertID.ToString());
                    msg.Category   = alertEntity.AlertName;
                    msg.MsgType    = alertEntity.AlertType;
                    msg.Format     = alertEntity.Format;
                    msg.ObjectID   = alertEntity.AlertID;
                    msg.SentCnt    = 0;
                    msg.RowDeleted = false;

                    messages.Add(msg);

                    PM_ALT_LOG log = new PM_ALT_LOG();
                    log.AlertID     = alertEntity.AlertID;
                    log.LogTitle    = logSubject; //_alert.AlertAlias;
                    log.LogContent  = logContent;
                    log.NotifiedCnt = 1;
                    log.IsClosed    = false;
                    log.RowDeleted  = false;

                    logs.Add(log);
                }
                else
                {
                    for (int z = 0; z < dtTrigger.Rows.Count; z++)
                    {
                        //fill Log Subject & Content
                        string logSubject = alertEntity.AlertContent;

                        if (!string.IsNullOrEmpty(logSubject))
                        {
                            logSubject = logSubject.Replace("@日期$", DateTime.Now.ToString("yyyy-MM-dd"));
                        }


                        if (!string.IsNullOrEmpty(logSubject))
                        {
                            for (int i = 0; i < dtTrigger.Columns.Count; i++)
                            {
                                logSubject = logSubject.Replace("@" + dtTrigger.Columns[i].ColumnName + "$", dtTrigger.Rows[z][i].ToString());
                            }
                        }

                        string logContent = alertEntity.AlertDesc;
                        if (!string.IsNullOrEmpty(logContent))
                        {
                            logContent = this.BuildContent(alertEntity.AlertDesc, dtTrigger, z);
                        }

                        string logURL = alertEntity.URL;
                        if (!string.IsNullOrEmpty(logURL))
                        {
                            for (int i = 0; i < dtTrigger.Columns.Count; i++)
                            {
                                logURL = logURL.Replace("@" + dtTrigger.Columns[i].ColumnName + "$", dtTrigger.Rows[z][i].ToString());
                            }
                        }

                        PM_ALT_MESSAGE msg = new PM_ALT_MESSAGE();
                        msg.MsgSubject = logSubject; //_alert.AlertAlias;
                        msg.MsgContent = logContent;
                        msg.MsgFrom    = "MESAdmin";
                        msg.MsgTo      = this.GetEmailToList(alertEntity.AlertID.ToString());
                        msg.Category   = alertEntity.AlertName;
                        msg.MsgType    = alertEntity.AlertType;
                        msg.Format     = alertEntity.Format;
                        msg.ObjectID   = alertEntity.AlertID;
                        msg.URL        = logURL;
                        msg.SentCnt    = 0;
                        msg.RowDeleted = false;

                        messages.Add(msg);
                        //
                        //create log
                        PM_ALT_LOG log = new PM_ALT_LOG();
                        log.AlertID     = alertEntity.AlertID;
                        log.LogTitle    = logSubject; //_alert.AlertAlias;
                        log.LogContent  = logContent;
                        log.NotifiedCnt = 1;
                        log.IsClosed    = false;
                        log.RowDeleted  = false;

                        logs.Add(log);
                    }
                }
                //
                string returnMessage = string.Empty;
                if (!string.IsNullOrEmpty(returnMessage))
                {
                    return("Exception: " + returnMessage + ".SaveLogs()");
                }

                //
                pm_ALT_MESSAGEBO.SaveBatch(messages, out returnMessage);
                if (!string.IsNullOrEmpty(returnMessage))
                {
                    return("Exception: " + returnMessage + ".SaveEmails()");
                }

                //
                if (alertEntity != null)
                {
                    PM_ALT_BASE alert = new PM_ALT_BASE();
                    alert.AlertID         = alertEntity.AlertID;
                    alert.LastAlertedTime = Siemens.Simatic.Util.Utilities.DAO.UtilDAO.GetDatabaseUtcDatetime().Value.AddHours(8);
                    this.UpdateSome(alert);
                }
                return("生成预警成功");
            }
            catch (Exception ex) {
                return("生成预警失败");
            }
        }