public static async Task <String> createFilteredQueue(List <Filter> filters, string date)
        {
            PrepareRestCall.postXML();
            string jsonFilter = "[\n";

            for (int i = 0; i < filters.Count; i++)
            {
                if (i != filters.Count - 1)
                {
                    jsonFilter += (filters[i].toJson() + ",\n");
                }
                else
                {
                    jsonFilter += (filters[i].toJson());
                }
            }
            jsonFilter += "\n]";

            Console.WriteLine("Filters in Json format:\n" + jsonFilter);
            var response = await PrepareRestCall.HttpClientInstance.PostAsync("mb/mqs?fromTime=" + date, new StringContent((jsonFilter), Encoding.UTF8, "application/json"));

            string result = response.Content.ReadAsStringAsync().Result;

            response.EnsureSuccessStatusCode();
            return(result);
        }
예제 #2
0
        public static async Task <string> createPCM(portCallMessage pcm)
        {
            PrepareRestCall.postXML();

            string xml = toXML(pcm);

            var response = await PrepareRestCall.HttpClientInstance.PostAsync("mb/mss", new StringContent(xml, Encoding.UTF8, "application/xml"));

            string result = response.ReasonPhrase + " - " + response.Content.ReadAsStringAsync().Result;

            return(result);
        }
예제 #3
0
        public static async Task <string> getPortCallId(string imo, string plannedArrival)
        {
            PrepareRestCall.getText();

            string result = null;

            var response = await PrepareRestCall.HttpClientInstance.GetAsync(String.Format("dmp/port_call_finder/{0}/{1}", imo, plannedArrival));

            if (response.IsSuccessStatusCode)
            {
                result = await response.Content.ReadAsStringAsync();
            }
            return(result);
        }
예제 #4
0
        public static async Task <PortCall> getPortCallById(string id)
        {
            PrepareRestCall.getJson();

            PortCall pc = new PortCall();

            var response = await PrepareRestCall.HttpClientInstance.GetAsync(String.Format("dmp/port_calls/{0}", id));

            if (response.IsSuccessStatusCode)
            {
                pc = await response.Content.ReadAsAsync <PortCall>();
            }

            return(pc);
        }
예제 #5
0
        public static async Task <List <PortLocation> > getLocations()
        {
            PrepareRestCall.getJson();
            List <PortLocation> locations = new List <PortLocation>();

            var response = await PrepareRestCall.HttpClientInstance.GetAsync("/location-registry/locations/?requestType=ALL");

            if (response.IsSuccessStatusCode)
            {
                var responseData = await response.Content.ReadAsAsync <IEnumerable <PortLocation> >();

                locations = responseData.ToList();
            }
            return(locations);
        }
예제 #6
0
        public static async Task <string> createPortCall(string imo)
        {
            PrepareRestCall.postXML();

            string vesselId = "urn:mrn:stm:vessel:IMO:" + imo;

            string body = "{\"vesselId\": \"" + vesselId + "\"}";

            var response = await PrepareRestCall.HttpClientInstance.PostAsync("pcr/port_call", new StringContent(body, Encoding.UTF8, "application/json"));

            string result          = response.ReasonPhrase + " - " + response.Content.ReadAsStringAsync().Result;
            string responseContent = response.Content.ReadAsStringAsync().Result;

            return(result);
        }
예제 #7
0
        public static async Task <List <PortCall> > getPortCalls()
        {
            PrepareRestCall.getJson();

            List <PortCall> pc = null;

            var response = await PrepareRestCall.HttpClientInstance.GetAsync("dmp/port_calls");

            if (response.IsSuccessStatusCode)
            {
                var responseData = await response.Content.ReadAsAsync <IEnumerable <PortCall> >();

                pc = responseData.ToList();
            }
            return(pc);
        }
예제 #8
0
        public static async Task <Vessel> getVesselByImo(string imo)
        {
            PrepareRestCall.getJson();
            string vesselId = "urn:mrn:stm:vessel:IMO:" + imo;

            Vessel v = new Vessel();

            var response = await PrepareRestCall.HttpClientInstance.GetAsync(String.Format("vr/vessel/{0}", vesselId));

            if (response.IsSuccessStatusCode)
            {
                v = await response.Content.ReadAsAsync <Vessel>();
            }

            return(v);
        }
        public static async Task <List <portCallMessage> > pollQueue(string queueId)
        {
            PrepareRestCall.getXML();

            List <portCallMessage> pcm = null;

            var response = await PrepareRestCall.HttpClientInstance.GetAsync(String.Format("mb/mqs/{0}", queueId));

            if (response.IsSuccessStatusCode)
            {
                var responseData = await response.Content.ReadAsStringAsync();

                XmlSerializer    ser  = new XmlSerializer(typeof(portCallMessages));
                StringReader     sr   = new StringReader(responseData);
                portCallMessages pcms = (portCallMessages)ser.Deserialize(sr);

                pcm = pcms.pcms;
            }
            return(pcm);
        }