コード例 #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 SqlConnection(ConnString.ConnectionString))
            {
                var commandString = string.Format(
                    " SELECT " +
                    FieldString() +
                    "   FROM     [ProcessRequestArguments] " +
                    "  WHERE  " +
                    "    [FKRequestUID] = '" + requestID.ToString() + "'" +
                    "  "
                    );

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

                            result.Add(_ProcessRequestArguments);
                        }
                    }
                }
            }

            return(result);
        }
コード例 #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,
            SqlDataReader 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;
        }
コード例 #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 SqlConnection(ConnString.ConnectionString))
            {
                var commandString =
                    (
                        "INSERT INTO [ProcessRequestArguments] " +
                        "( " +
                        FieldString() +
                        ")" +
                        " VALUES " +
                        "( " +
                        "  @" + FieldName.FKRequestUID +
                        ", @" + FieldName.Code +
                        ", @" + FieldName.ValueType +
                        ", @" + FieldName.Value +

                        " )"

                    );

                using (var command = new SqlCommand(
                           commandString, connection))
                {
                    command.Parameters.Add("@FKRequestUID", SqlDbType.BigInt).Value = FKRequestUID;
                    command.Parameters.Add("@Code", SqlDbType.VarChar).Value        = Code;
                    command.Parameters.Add("@ValueType", SqlDbType.VarChar).Value   = ValueType;
                    command.Parameters.Add("@Value", SqlDbType.VarChar).Value       = Value;

                    connection.Open();
                    command.ExecuteNonQuery();
                }
            }
            return(responseSuccessful);
        }
コード例 #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 SqlConnection(ConnString.ConnectionString))
            {
                var commandString = string.Format(
                    " SELECT " +
                    FieldString() +
                    "   FROM     [ProcessRequest] " +
                    checktype
                    );

                using (var command = new SqlCommand(
                           commandString, connection))
                {
                    connection.Open();
                    using (SqlDataReader 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);
        }