コード例 #1
0
        public static async Task GetEventsForDocument(Client.StoreAndForward client)
        {
            // Get events for document with this Id.
            int documentId = 1;

            var httpResponse = await client.GetDocumentEventsWithHttpMessagesAsync(documentId);

            if (httpResponse.Response.StatusCode == HttpStatusCode.OK)
            {
                // Call has been successful.
            }
            else
            {
                // Call has failed - handle errors here.
            }
        }
コード例 #2
0
        public static async Task DeleteDocumentInQueue(Client.StoreAndForward client)
        {
            // Id of document to be removed from the queue. Only documents with a 'Pending' status can be removed.
            int documentId = 1;

            var httpResponse = await client.DeleteDocumentWithHttpMessagesAsync(documentId);

            if (httpResponse.Response.StatusCode == HttpStatusCode.NoContent)
            {
                // Call has been successful.
            }
            else
            {
                // Call has failed - handle errors here.
            }
        }
コード例 #3
0
        public static async Task GetDocumentInQueue(Client.StoreAndForward client)
        {
            // Id of document to be fetched. Document Ids can be obtained using the "GetDocumentsWithHttpMessagesAsync" call.
            int documentId = 1;

            var httpResponse = await client.GetDocumentWithHttpMessagesAsync(documentId);

            if (httpResponse.Response.StatusCode == HttpStatusCode.OK)
            {
                // Call has been successful.
            }
            else
            {
                // Call has failed - handle errors here.
            }
        }
コード例 #4
0
        public static async Task GetEvents(Client.StoreAndForward client)
        {
            // Get events
            var httpResponse = await client.GetEventsWithHttpMessagesAsync(
                DateTime.Now.AddDays(-1),       // Events after this time
                DateTime.Now,                   // Events before this time
                "Success",                      // Event type (Created, Success, Failed, Removed, Deferred)
                0,                              // Offset (number of records to skip)
                10);                            // Limit (number of records to show)


            if (httpResponse.Response.StatusCode == HttpStatusCode.OK)
            {
                // Call has been successful.
            }
            else
            {
                // Call has failed - handle errors here.
            }
        }
コード例 #5
0
        public static async Task GetDocumentsInQueue(Client.StoreAndForward client)
        {
            // Get documents in queue
            // Arguments can be passed in to limit documents added during a certain period, or with certain statuses.
            var httpResponse = await client.GetDocumentsWithHttpMessagesAsync(
                DateTime.Now.AddDays(-1),   // Documents uploaded after this time
                DateTime.Now,               // Documents uploaded before this time
                "Sent",                     // Document status (Pending, Sending, Sent, RetryLimitReached, Removed)
                0,                          // Offset (number of records to skip)
                10);                        // Limit (number of records to return)

            if (httpResponse.Response.StatusCode == HttpStatusCode.OK)
            {
                // Call has been successful.
            }
            else
            {
                // Call has failed - handle errors here.
            }
        }
コード例 #6
0
        public static async Task AddDocumentToQueue(Client.StoreAndForward client)
        {
            DocumentModel document = new DocumentModel();

            // Set required supporting data for the document upload
            document.Data           = File.ReadAllBytes("TestData\\SampleDischargeSummary.zip");
            document.FormatCodeName = "Discharge Summary 3A HPII";
            document.FormatCode     = "1.2.36.1.2001.1006.1.20000.26";
            document.ReplaceId      = null; // Document Id of the document to be superceded

            // Add document to queue
            var httpResponse = await client.AddDocumentWithHttpMessagesAsync(document);

            if (httpResponse.Response.StatusCode == HttpStatusCode.Created)
            {
                // Call has been successful.
            }
            else
            {
                // Call has failed - handle errors here.
            }
        }
コード例 #7
0
        public static async Task Main(string[] args)
        {
            // OPTIONAL - This is to set up logging to the console using Serilog. For this to work, install the following from NuGet:
            // 1. Serilog.Settings.AppSettings
            // 2. Serilog.Sinks.Console
            Log.Logger = new LoggerConfiguration()
                         .WriteTo.Console()
                         .ReadFrom.AppSettings()
                         .CreateLogger();

            // Creates and starts the Store and Forward service.
            // Note: The Store and Forward Service should be hosted in a long-running application, such as a Windows Service.
            var safService = new StoreAndForwardOwinService("http://*:5000/storeandforward");

            safService.Start();
            System.Console.WriteLine("StoreAndForwardService started.");

            // Creates the Store and Forward client, which connects to the service hosted at the same location.
            Client.StoreAndForward storeAndForwardClient = new Client.StoreAndForward(new StoreandForwardAPI(new Uri("http://localhost:5000/storeandforward/")));

            // Add a document to the queue, using the client.
            // Note: The sample document used in this example will fail the upload.
            await AddDocumentToQueue(storeAndForwardClient);

            // These are examples of how to invoke the other operations on the client.
            // await DeleteDocumentInQueue(storeAndForwardClient);
            // await GetDocumentsInQueue(storeAndForwardClient);
            // await GetDocumentInQueue(storeAndForwardClient);
            // await GetEventsForDocument(storeAndForwardClient);
            // await GetEvents(storeAndForwardClient);

            System.Console.WriteLine("Press ENTER to end this sample program...");
            System.Console.ReadLine();

            // Stops the Store and Forward Service.
            safService.Stop();
        }