private async void ExecuteUploadVPCommand(object obj) { string vpbody = null; bool sendAck = false; string callbackEndpoint = string.Empty; var dlg = new NewSTMMessageDialog(); dlg.ViewModel.ShowAcknowledgement = true; dlg.ViewModel.ShowCallbackEndpoint = true; if (dlg.ShowDialog() == true) { var newMsg = new PublishedMessageContract { Message = dlg.ViewModel.StmMsg, //MessageID = dlg.ViewModel.Id }; sendAck = dlg.ViewModel.Acknowledgement; vpbody = newMsg.Message; callbackEndpoint = Uri.EscapeDataString(dlg.ViewModel.CallbackEndpoint ?? string.Empty); } if (!string.IsNullOrEmpty(vpbody)) { Busy = true; BusyContent = "Uploading voyageplan"; await Task.Factory.StartNew(() => { var visService = new VisService(); if (sendAck) { string myAck = ConfigurationManager.AppSettings.Get("VisPublicUrl").Replace("{database}", VisService.DbName); string endpointUri = SelectedService.EndpointUri; if (!string.IsNullOrEmpty(callbackEndpoint)) { endpointUri = WebRequestHelper.CombineUrl(endpointUri, string.Format("/voyagePlans?callbackEndpoint={0}", Uri.EscapeDataString(callbackEndpoint)) + string.Format("&deliveryAckEndPoint={0}", Uri.EscapeDataString(myAck))); } else { endpointUri = WebRequestHelper.CombineUrl(endpointUri, string.Format("/voyagePlans?deliveryAckEndPoint={0}", Uri.EscapeDataString(myAck ?? string.Empty))); } var result = visService.CallService(vpbody, endpointUri, "POST", "text/xml; charset=utf-8"); MessageBox.Show(result); } else { string endpointUri = WebRequestHelper.CombineUrl(SelectedService.EndpointUri, "/voyagePlans"); if (!string.IsNullOrEmpty(callbackEndpoint)) { endpointUri += string.Format("?callbackEndpoint={0}", Uri.EscapeDataString(callbackEndpoint)); } var result = visService.CallService(vpbody, endpointUri, "POST", "text/xml; charset=utf-8"); MessageBox.Show(result); } }); Busy = false; } }
public void ExecuteCreateNewMessageCommand(object parameter) { var dlg = new NewSTMMessageDialog(); dlg.ViewModel.ShowUvid = true; if (dlg.ShowDialog() == true) { var newVp = new PublishedMessageContract { Message = dlg.ViewModel.StmMsg, MessageID = dlg.ViewModel.Id }; Messages.Add(newVp); SelectedMessage = newVp; } }