コード例 #1
0
        /// <summary>
        /// Executes a FileMaker Request to a JSON string.
        /// </summary>
        /// <param name="method">The http method to use for the request.</param>
        /// <param name="requestUri"></param>
        /// <param name="req">The request to execute.</param>
        /// <returns>The JSON string returned from FMS.</returns>
        public async Task <HttpResponseMessage> ExecuteRequestAsync(
            HttpMethod method,
            string requestUri,
            IFileMakerRequest req)
        {
            var str         = req.SerializeRequest();
            var httpContent = new StringContent(str, Encoding.UTF8, "application/json");

            // do not pass character set.
            // this is due to fms 18 returning Bad Request when specified
            // this hack is backward compatible for FMS17
            httpContent.Headers.ContentType.CharSet = null;

            var httpRequest = new HttpRequestMessage(method, requestUri)
            {
                Content = httpContent
            };

            // we're about to use the token so update date used, and refresh if needed.
            await UpdateTokenDateAsync();

            // run and return the action
            var response = await _client.SendAsync(httpRequest);

            return(response);
        }
コード例 #2
0
 public static IFileMakerRequest SetScript(
     this IFileMakerRequest request,
     string scriptName,
     string scriptParameter = null)
 {
     request.Script = scriptName;
     if (!string.IsNullOrEmpty(scriptParameter))
     {
         request.ScriptParameter = scriptParameter;
     }
     return(request);
 }
コード例 #3
0
        /// <summary>
        /// Execute the POST request to FMS XML
        /// </summary>
        /// <param name="req">The Request To Execute.</param>
        /// <returns>The HttpResponseMessage From The Request.</returns>
        private async Task <HttpResponseMessage> ExecuteRequestAsync(IFileMakerRequest req)
        {
            var url = _fmsUri + "/fmi/xml/fmresultset.xml";

            var requestContent = req.SerializeRequest();

            var globals = string.Join("", _globalsToAdd);

            _globalsToAdd.Clear();

            // append fileName to request since thats not represented in the request itself
            // append globals
            var sContent = requestContent + globals + $"&-db={_fileName}";

            var httpRequestContent = new StringContent(sContent);

            var response = await _client.PostAsync(url, httpRequestContent);

            return(response);
        }
コード例 #4
0
        /// <summary>
        /// Executes a FileMaker Request to a JSON string.
        /// </summary>
        /// <param name="method">The http method to use for the request.</param>
        /// <param name="requestUri"></param>
        /// <param name="req">The request to execute.</param>
        /// <returns>The JSON string returned from FMS.</returns>
        public async Task <HttpResponseMessage> ExecuteRequestAsync(
            HttpMethod method,
            string requestUri,
            IFileMakerRequest req)
        {
            var str         = req.SerializeRequest();
            var httpContent = new StringContent(str, Encoding.UTF8, "application/json");
            var httpRequest = new HttpRequestMessage(method, requestUri)
            {
                Content = httpContent
            };

            // we're about to use the token so update date used, and refresh if needed.
            await UpdateTokenDateAsync();

            // run and return the action
            var response = await _client.SendAsync(httpRequest);

            return(response);
        }
コード例 #5
0
 public RequestQueryInstanceConverter(IFileMakerRequest parentRequest)
 {
     _parentRequest = parentRequest;
 }