Beispiel #1
0
        /// <summary>
        /// Get with transaction
        /// </summary>
        public PM_ALT_CRITERION Get(object entityId, DbTransaction transaction)
        {
            ArgumentValidator.CheckForNullArgument(entityId, "entityId");
            ArgumentValidator.CheckForNullArgument(transaction, "transaction");

            PM_ALT_CRITERION PM_ALT_CRITERIONEntity = null;

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

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

            return(PM_ALT_CRITERIONEntity);
        }
 //
 public void SaveBatch(Guid alertID, IList <PM_ALT_CRITERION> entities, out string returnMessage)
 {
     returnMessage = string.Empty;
     //
     try
     {
         //1.
         _PM_ALT_CRITERIONDAO.SetDeletedByAlert(alertID);
         //2.
         foreach (PM_ALT_CRITERION entity in entities)
         {
             PM_ALT_CRITERION entityExisted = this.GetEntity(entity.CriterionID.Value);
             if (null == entityExisted)
             {
                 this.Insert(entity);
             }
             else
             {
                 entity.RowDeleted = false;
                 this.UpdateSome(entity);
             }
         }
         //3.
         _PM_ALT_CRITERIONDAO.ClearDeletedByAlert(alertID);
     }
     catch (Exception ex)
     {
         returnMessage = ex.Message;
         return;
     }
 }
Beispiel #3
0
 public void Update(PM_ALT_CRITERION entity, bool updateAll, DbTransaction transaction)
 {
     if (!updateAll)
     {
         UpdateSome(entity, transaction);
     }
     else
     {
         UpdateAll(entity, transaction);
     }
 }
Beispiel #4
0
 public void Update(PM_ALT_CRITERION entity, bool updateAll)
 {
     if (!updateAll)
     {
         UpdateSome(entity);
     }
     else
     {
         UpdateAll(entity);
     }
 }
        public void UpdateSome(PM_ALT_CRITERION entity)
        {
            try
            {
                ArgumentValidator.CheckForNullArgument(entity, "PM_ALT_CRITERION Entity");

                _PM_ALT_CRITERIONDAO.Update(entity, false);
            }
            catch (Exception ex)
            {
                ExceptionPolicy.HandleException(ex, ExceptionPolicy.BusinessLogicDefaultPolicy);
            }
        }
        public void Delete(PM_ALT_CRITERION entity)
        {
            try
            {
                ArgumentValidator.CheckForNullArgument(entity, "PM_ALT_CRITERION Entity");

                _PM_ALT_CRITERIONDAO.Delete(entity.CriterionID);
            }
            catch (Exception ex)
            {
                ExceptionPolicy.HandleException(ex, ExceptionPolicy.BusinessLogicDefaultPolicy);
            }
        }
        public PM_ALT_CRITERION GetEntity(Guid entityGuid)
        {
            PM_ALT_CRITERION entity = null;

            try
            {
                ArgumentValidator.CheckForNullArgument(entityGuid, "PM_ALT_CRITERION Guid");

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

            return(entity);
        }
        public PM_ALT_CRITERION Insert(PM_ALT_CRITERION entity)
        {
            PM_ALT_CRITERION newEntity = null;

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

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

            return(newEntity);
        }
Beispiel #9
0
        private void UpdateAll(PM_ALT_CRITERION entity, DbTransaction transaction)
        {
            ArgumentValidator.CheckForNullArgument(entity, "entity");
            ArgumentValidator.CheckForNullArgument(transaction, "transaction");

            PersistentPM_ALT_CRITERION PM_ALT_CRITERIONEntity = entity as PersistentPM_ALT_CRITERION;

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

                db.AddInParameter(dbCommand, "@CriterionID", DbType.Guid, PM_ALT_CRITERIONEntity.CriterionID);
                db.AddInParameter(dbCommand, "@AlertID", DbType.Guid, PM_ALT_CRITERIONEntity.AlertID);
                db.AddInParameter(dbCommand, "@Relation", DbType.String, PM_ALT_CRITERIONEntity.Relation);
                db.AddInParameter(dbCommand, "@Element", DbType.String, PM_ALT_CRITERIONEntity.Element);
                db.AddInParameter(dbCommand, "@Alias", DbType.String, PM_ALT_CRITERIONEntity.Alias);
                db.AddInParameter(dbCommand, "@Operator", DbType.String, PM_ALT_CRITERIONEntity.Operator);
                db.AddInParameter(dbCommand, "@Value", DbType.String, PM_ALT_CRITERIONEntity.Value);
                db.AddInParameter(dbCommand, "@ScaleType", DbType.Int32, PM_ALT_CRITERIONEntity.ScaleType);
                db.AddInParameter(dbCommand, "@Action", DbType.Int32, PM_ALT_CRITERIONEntity.Action);
                db.AddInParameter(dbCommand, "@Sequence", DbType.Int32, PM_ALT_CRITERIONEntity.Sequence);
                db.AddInParameter(dbCommand, "@ParentID", DbType.Guid, PM_ALT_CRITERIONEntity.ParentID);
                db.AddInParameter(dbCommand, "@CritLevel", DbType.Int32, PM_ALT_CRITERIONEntity.CritLevel);
                db.AddInParameter(dbCommand, "@IsActive", DbType.Boolean, PM_ALT_CRITERIONEntity.IsActive);
                db.AddInParameter(dbCommand, "@RowDeleted", DbType.Boolean, PM_ALT_CRITERIONEntity.RowDeleted);
                db.AddInParameter(dbCommand, "@CreatedBy", DbType.String, PM_ALT_CRITERIONEntity.CreatedBy);
                db.AddInParameter(dbCommand, "@CreatedOn", DbType.DateTime, PM_ALT_CRITERIONEntity.CreatedOn);
                db.AddInParameter(dbCommand, "@ModifiedBy", DbType.String, PM_ALT_CRITERIONEntity.ModifiedBy);
                db.AddInParameter(dbCommand, "@ModifiedOn", DbType.DateTime, PM_ALT_CRITERIONEntity.ModifiedOn);
                int result = db.ExecuteNonQuery(dbCommand, transaction);

                if (result == 0)
                {
                    throw new EntityNotFoundException();
                }
            }
            catch (Exception ex)
            {
                ExceptionPolicy.HandleException(ex, ExceptionPolicy.DataAccessDefaultPolicy);
            }
        }
Beispiel #10
0
        private static PM_ALT_CRITERION ReadEntity(IDataReader dataReader)
        {
            PM_ALT_CRITERION PM_ALT_CRITERIONEntity = new PM_ALT_CRITERION();
            object           value;


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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

            return(PM_ALT_CRITERIONEntity);
        }
Beispiel #11
0
        private void UpdateSome(PM_ALT_CRITERION entity, DbTransaction transaction)
        {
            ArgumentValidator.CheckForNullArgument(entity, "entity");
            ArgumentValidator.CheckForNullArgument(transaction, "transaction");

            PersistentPM_ALT_CRITERION PM_ALT_CRITERIONEntity = entity as PersistentPM_ALT_CRITERION;

            StringBuilder sqlUpdateSome = new StringBuilder();

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

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

            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);
            }
        }
Beispiel #12
0
        /// <summary>
        /// Update with transaction
        /// </summary>

        public void Update(PM_ALT_CRITERION entity, DbTransaction transaction)
        {
            Update(entity, true, transaction);
        }
Beispiel #13
0
        /// <summary>
        /// Update
        /// </summary>

        public void Update(PM_ALT_CRITERION entity)
        {
            Update(entity, true);
        }