public static void Main(string[] args) { const string username = ""; const string password = ""; var client = new RestClient("https://api.esendex.com") { Authenticator = new HttpBasicAuthenticator(username, password) }; var dispatcherRequest = new DispatcherRequest { AccountReference = "", Messages = new[] { new DispatcherMessage { Body = "", Recipient = "" } } }; var jsonString = JsonConvert.SerializeObject(dispatcherRequest); var restRequest = new RestRequest("/v1.0/messagedispatcher", Method.POST); restRequest.AddParameter("application/json", jsonString, ParameterType.RequestBody); var response = client.Execute <DispatcherResponse>(restRequest); Console.WriteLine(response.StatusCode); Console.ReadLine(); }
internal void HandleCallbackRequest(string receivedMessage) { DispatcherRequest dispatcherRequest = JsonConvert.DeserializeObject <DispatcherRequest>(receivedMessage); if (_callbackHandlers.TryGetValue(dispatcherRequest.command, out CallbackRequestHandler handler)) { handler(this, dispatcherRequest); } else { string errorMessage = String.Format(CultureInfo.CurrentCulture, "Received unhandled callback command '{0}'", dispatcherRequest.command); throw new DARException(errorMessage); } }
public static string GenerateRequestBody(DispatcherRequest dispatcherRequest) { var ns = new XmlSerializerNamespaces(); const string defaultNamespace = "http://api.esendex.com/ns/"; ns.Add(string.Empty, defaultNamespace); var builder = new StringBuilder(); using (var writer = new StringWriter(builder)) using (var xmlTextWriter = new XmlTextWriter(writer)) { var xmlSerializer = new XmlSerializer(typeof(DispatcherRequest), defaultNamespace); xmlSerializer.Serialize(xmlTextWriter, dispatcherRequest, ns); } return(builder.ToString()); }
protected override void ChildGrid_OnModified(Container entity) { if (entity.ID > 0 && entity.TransferBooking != null && entity.TransferBooking.ID > 0 && entity.Booking.ID != entity.TransferBooking.ID) { // Update dispatcher booking Id DispatcherRequestLibrary dispathLib = new DispatcherRequestLibrary(ConfigurationHelper.GetsmARTDBContextConnectionString()); IEnumerable <DispatcherRequest> dispatcherReqs = dispathLib.GetDispatcherByBookingAndContainerNo(entity.TransferBooking.ID, entity.Container_No, new string[] { "TruckingCompany", "Driver", "Booking_Ref_No", "Purchase_Order_No", "Party", "Location", "Shipper", "Sales_Order_No", "Asset", "Container" }); DispatcherRequest dispatcherReq = dispatcherReqs.FirstOrDefault(); if (dispatcherReq != null) { dispatcherReq.Booking_Ref_No.ID = entity.Booking.ID; dispathLib.Modify(dispatcherReq, new string[] { "TruckingCompany", "Driver", "Booking_Ref_No", "Purchase_Order_No", "Party", "Location", "Shipper", "Sales_Order_No", "Asset" }); } entity.Booking.ID = entity.TransferBooking.ID; } }
private string CreateDispatcherRequest(DebugAdapterRunner runner) { DispatcherRequest request = new DispatcherRequest(runner.GetNextSequenceNumber(), this.Name, this.args); return(runner.SerializeMessage(request)); }