コード例 #1
0
        private static bool deleteMessageGroup(MessageGroup messageGroup)
        {
            SysDataAccessCredential dac = DAOUtility.GetSysCredentials();
            DataAccess das = new DataAccess();

            using (SqlConnection conn = new SqlConnection(DAOUtility.GetConnectionString(dac)))
            {
                conn.Open();

                SqlCommand command = new SqlCommand();
                command.Connection  = conn;
                command.CommandType = System.Data.CommandType.Text;
                command.CommandText = das.DELETE_MESSAGE_GROUP;
                command.Parameters.AddWithValue(MessageGroupDAO.AT_ID, messageGroup.id);

                try
                {
                    SqlDataReader reader = command.ExecuteReader();

                    if (reader.HasRows)
                    {
                        while (reader.Read())
                        {
                            messageGroup.id = DAOUtility.GetData <int>(reader, MessageGroupDAO.ID);
                        }
                    }
                }
                catch (Exception e)
                {
                    ErrorLogger.LogError(e, "DeleteMessageGroup()", messageGroup.id.ToString());
                }
            }
            return(true);
        }
コード例 #2
0
        private static List <MessageGroup> getSingleMessageGroup(MessageGroup messageGroup)
        {
            List <MessageGroup>     messageGroups = new List <MessageGroup>();
            SysDataAccessCredential dac           = DAOUtility.GetSysCredentials();
            DataAccess das = new DataAccess();

            using (SqlConnection conn = new SqlConnection(DAOUtility.GetConnectionString(dac)))
            {
                conn.Open();
                SqlCommand command = new SqlCommand();
                command.Connection  = conn;
                command.CommandType = System.Data.CommandType.Text;
                command.CommandText = das.GET_SINGLE_MESSAGE_GROUP;
                command.Parameters.AddWithValue(MessageGroupDAO.AT_ID, messageGroup.id);

                try
                {
                    SqlDataReader reader = command.ExecuteReader();

                    if (reader.HasRows)
                    {
                        while (reader.Read())
                        {
                            messageGroups.Add(new MessageGroup(reader));
                        }
                    }
                }
                catch (Exception e)
                {
                    ErrorLogger.LogError(e, "getSingleMessageGroup(MessageGroup MessageGroup)", messageGroup.id.ToString());
                }
            }

            return(messageGroups);
        }
コード例 #3
0
        private static MessageGroup postUpdateMessageGroup(MessageGroup messageGroup)
        {
            SysDataAccessCredential dac = DAOUtility.GetSysCredentials();
            DataAccess das = new DataAccess();

            using (SqlConnection conn = new SqlConnection(DAOUtility.GetConnectionString(dac)))
            {
                conn.Open();

                SqlCommand command = new SqlCommand();
                command.Connection  = conn;
                command.CommandType = System.Data.CommandType.StoredProcedure;
                command.CommandText = das.PUT_MESSAGE_GROUP;
                command.Parameters.AddWithValue(MessageGroupDAO.AT_MESSAGE_GROUP_INSTANCE_ID, messageGroup.messageGroupInstanceId);
                command.Parameters.AddWithValue(MessageGroupDAO.AT_MESSAGE_PART_ID, messageGroup.messagePartId);
                command.Parameters.AddWithValue(MessageGroupDAO.AT_POSITION, messageGroup.position);
                command.Parameters.AddWithValue(MessageGroupDAO.AT_ID, messageGroup.id);

                try
                {
                    SqlDataReader reader = command.ExecuteReader();

                    if (reader.HasRows)
                    {
                        while (reader.Read())
                        {
                            messageGroup.id = DAOUtility.GetData <int>(reader, MessageGroupDAO.ID);
                        }
                    }
                }
                catch (Exception e)
                {
                    ErrorLogger.LogError(e, "postUpdateMessageGroup()", messageGroup.id.ToString());
                }
            }
            return(messageGroup);
        }