buildRequest() private method

private buildRequest ( ) : MdoQuery
return MdoQuery
Beispiel #1
0
        /// <summary>
        /// Create a new record entry in a Vista file
        /// </summary>
        /// <param name="fieldsAndValues">The field number and value dictionary</param>
        /// <param name="vistaFile">The Vista file number</param>
        /// <param name="iens">If creating a record in a subfile, the IENS string of the parent record</param>
        /// <returns>The IEN of the new record</returns>
        public CrudOperation create(Dictionary <String, String> fieldsAndValues, String vistaFile, String iens = null)
        {
            Dictionary <String, String> wpFieldsAndValues = findWpFields(fieldsAndValues);
            DdrFiler request      = buildCreateRequest(fieldsAndValues, vistaFile, iens);
            DateTime startRequest = DateTime.Now;
            String   response     = request.execute();
            DateTime endRequest   = DateTime.Now;
            String   parsed       = toCreateUpdateDeleteRecordResponse(response);

            // if we get this far, create succeeded! to make the API easier to use, enable user to pass WP fields in dictionary
            foreach (String key in wpFieldsAndValues.Keys)
            {
                addWordProcessing(vistaFile, key, String.Concat(parsed, ",", iens), wpFieldsAndValues[key]);
            }

            //return result;
            CrudOperation result = new CrudOperation()
            {
                RPC = new RPC()
                {
                    Name           = request.buildRequest().RpcName,
                    RequestString  = request.buildRequest().buildMessage(),
                    ResponseString = response,
                    RequestTime    = startRequest,
                    ResponseTime   = endRequest
                },
                Result = parsed,
                Type   = CrudOperationType.CREATE
            };

            return(result);
        }
Beispiel #2
0
        public CrudOperation update(Dictionary <String, String> fieldsAndValues, String ien, String vistaFile)
        {
            CrudOperation result = null;

            Dictionary <String, String> wpFieldsAndValues = findWpFields(fieldsAndValues);

            if (fieldsAndValues.Count > 0) // need to check this in case we were only updating WP fields
            {
                DdrFiler request      = buildUpdateRequest(fieldsAndValues, ien, vistaFile);
                DateTime startRequest = DateTime.Now;
                String   response     = request.execute();
                DateTime endRequest   = DateTime.Now;
                String   parsed       = toCreateUpdateDeleteRecordResponse(response); // should throw exception on failure

                result = new CrudOperation()
                {
                    RPC = new RPC()
                    {
                        Name           = request.buildRequest().RpcName,
                        RequestString  = request.buildRequest().buildMessage(),
                        ResponseString = response,
                        RequestTime    = startRequest,
                        ResponseTime   = endRequest
                    },
                    Result = parsed,
                    Type   = CrudOperationType.UPDATE
                };
            }
            // if we get this far, create succeeded! to make the API easier to use, enable user to pass WP fields in dictionary
            foreach (String key in wpFieldsAndValues.Keys)
            {
                addWordProcessing(vistaFile, key, ien, wpFieldsAndValues[key]);
                fieldsAndValues.Add(key, wpFieldsAndValues[key]); // want to add this back to original dict so that we don't permanently change it's state
            }


            return(result);
        }
Beispiel #3
0
        public CrudOperation delete(String recordIen, String vistaFile)
        {
            DdrFiler request      = buildDeleteRequest(recordIen, vistaFile);
            DateTime startRequest = DateTime.Now;
            String   response     = request.execute();
            DateTime endRequest   = DateTime.Now;
            String   parsed       = toCreateUpdateDeleteRecordResponse(response);

            CrudOperation result = new CrudOperation()
            {
                RPC = new RPC()
                {
                    Name           = request.buildRequest().RpcName,
                    RequestString  = request.buildRequest().buildMessage(),
                    ResponseString = response,
                    RequestTime    = startRequest,
                    ResponseTime   = endRequest
                },
                Result = parsed,
                Type   = CrudOperationType.DELETE
            };

            return(result);
        }