Exemple #1
0
        /// <summary>
        /// List requests
        /// </summary>
        /// <param name="StatusIn"></param>
        /// <returns></returns>
        public static List <ProcessRequestArguments> List(int requestID)
        {
            var result = new List <ProcessRequestArguments>();

            using (var connection = new MySqlConnection(ConnString.ConnectionStringFramework))
            {
                var commandString = string.Format(
                    " SELECT " +
                    FieldString() +
                    "   FROM     ProcessRequestArguments " +
                    "  WHERE  " +
                    "    FKRequestUID = '" + requestID.ToString() + "'" +
                    "  "
                    );

                using (var command = new MySqlCommand(
                           commandString, connection))
                {
                    connection.Open();
                    using (MySqlDataReader reader = command.ExecuteReader())
                    {
                        while (reader.Read())
                        {
                            var _ProcessRequestArguments = new ProcessRequestArguments();
                            ProcessRequestArguments.LoadFromReader(_ProcessRequestArguments, reader);

                            result.Add(_ProcessRequestArguments);
                        }
                    }
                }
            }

            return(result);
        }
Exemple #2
0
        /// <summary>
        /// Load from Reader
        /// </summary>
        /// <param name="processRequest"></param>
        /// <param name="tablePrefix"></param>
        /// <param name="reader"></param>
        public static void LoadFromReader(
            ProcessRequestArguments processRequest,
            MySqlDataReader reader)
        {
            processRequest.FKRequestUID = Convert.ToInt32(reader[FieldName.FKRequestUID].ToString());
            processRequest.Code         = reader[FieldName.Code].ToString();
            processRequest.ValueType    = reader[FieldName.ValueType].ToString();
            processRequest.Value        = reader[FieldName.Value].ToString();

            return;
        }
Exemple #3
0
        /// <summary>
        /// Add New Process Request Argument
        /// </summary>
        public ResponseStatus Add()
        {
            ResponseStatus responseSuccessful = new ResponseStatus();
            ResponseStatus responseError      = new ResponseStatus(messageType: MessageType.Error);

            // Check if request has already been added
            //
            if (ProcessRequestArguments.Exists(this.FKRequestUID, this.Code))
            {
                responseError.Message  = "Request Argument already exists " + this.Code;
                responseError.Contents = this;
                return(responseError);
            }

            DateTime _now = DateTime.Today;

            using (var connection = new MySqlConnection(ConnString.ConnectionStringFramework))
            {
                var commandString =
                    (
                        "INSERT INTO ProcessRequestArguments " +
                        "( " +
                        FieldString() +
                        ")" +
                        " VALUES " +
                        "( " +
                        "  @" + FieldName.FKRequestUID +
                        ", @" + FieldName.Code +
                        ", @" + FieldName.ValueType +
                        ", @" + FieldName.Value +

                        " )"

                    );

                using (var command = new MySqlCommand(
                           commandString, connection))
                {
                    command.Parameters.Add("@FKRequestUID", MySqlDbType.Int32).Value = FKRequestUID;
                    command.Parameters.Add("@Code", MySqlDbType.VarChar).Value       = Code;
                    command.Parameters.Add("@ValueType", MySqlDbType.VarChar).Value  = ValueType;
                    command.Parameters.Add("@Value", MySqlDbType.VarChar).Value      = Value;

                    connection.Open();
                    command.ExecuteNonQuery();
                }
            }
            return(responseSuccessful);
        }
Exemple #4
0
        /// <summary>
        /// List requests
        /// </summary>
        /// <param name="StatusIn"></param>
        /// <returns></returns>
        public static List <ProcessRequest> List(ProcessRequest.StatusValue StatusIn)
        {
            var result = new List <ProcessRequest>();

            var checktype = " WHERE  Status = '" + StatusIn.ToString() + "'";

            if (StatusIn == ProcessRequest.StatusValue.ALL)
            {
                checktype = "";
            }

            using (var connection = new MySqlConnection(ConnString.ConnectionString))
            {
                var commandString = string.Format(
                    " SELECT " +
                    FieldString() +
                    "   FROM    ProcessRequest " +
                    checktype +
                    "  ORDER BY 1 DESC "
                    );

                using (var command = new MySqlCommand(
                           commandString, connection))
                {
                    connection.Open();
                    using (MySqlDataReader reader = command.ExecuteReader())
                    {
                        while (reader.Read())
                        {
                            var _ProcessRequest = new ProcessRequest();
                            ProcessRequest.LoadFromReader(_ProcessRequest, reader);

                            // Load Arguments
                            //
                            _ProcessRequest.argumentList = ProcessRequestArguments.List(_ProcessRequest.UID);

                            result.Add(_ProcessRequest);
                        }
                    }
                }
            }

            return(result);
        }