private void BtnGo_Click(object sender, EventArgs e) { MyDHLAPI api = new MyDHLAPI(Common.CurrentCredentials["Username"] , Common.CurrentCredentials["Password"] , Common.CurrentRestBaseUrl); try { this.Enabled = false; this.UseWaitCursor = true; Cursor.Current = Cursors.WaitCursor; if (string.IsNullOrWhiteSpace(txtPickupCountry.Text) || string.IsNullOrWhiteSpace(txtRequestorName.Text)) { MessageBox.Show(@"Missing data."); return; } txtPickupCountry.Text = txtPickupCountry.Text.Trim(); txtRequestorName.Text = txtRequestorName.Text.Trim(); txtPickupRequestNumber.Text = txtPickupRequestNumber.Text.Trim(); DeletePickupRequest req = new DeletePickupRequest { DeleteRequest = new DeleteRequest { Request = new Request() { ServiceHeader = new ServiceHeader() { ShippingSystemPlatform = "MyDHL API Test App", ShippingSystemPlatformVersion = Application.ProductVersion, Plugin = "MyDHL API C# Library", PluginVersion = api.GetVersion() } }, PickupDate = dtpPickupDate.Value, PickupCountry = txtPickupCountry.Text, RequestorName = txtRequestorName.Text, PickupRequestNumber = txtPickupRequestNumber.Text, Reason = (Enums.DeletePickupRequestReason)cmbReason.SelectedValue } }; DeletePickupResponse resp = api.RequestDeletePickupAsync(req).Result; if (null != resp) { txtResult.Text = Notification.GetAllNotifications(resp.Notifications, Environment.NewLine); } } catch (MyDHLAPIValidationException gvx) { txtResult.Text = MyDHLAPIValidationException.PrintResults(gvx.ExtractValidationResults(), 0); } catch (Exception ex) { txtResult.Text = ex.Message; } finally { this.Enabled = true; this.UseWaitCursor = false; Cursor.Current = Cursors.Default; _lastJsonRequest = api.LastDeletePickupJSONRequest; _lastJsonResponse = api.LastDeletePickupJSONResponse; } }
private void BtnGo_Click(object sender, EventArgs e) { try { this.Enabled = false; this.UseWaitCursor = true; Cursor.Current = Cursors.WaitCursor; if (string.IsNullOrWhiteSpace(txtAccountNumber.Text) || string.IsNullOrWhiteSpace(txtAWBNumber.Text)) { MessageBox.Show(@"Missing data."); return; } txtAccountNumber.Text = txtAccountNumber.Text.Trim(); txtAWBNumber.Text = txtAWBNumber.Text.Trim(); MyDHLAPI api = new MyDHLAPI(Common.CurrentCredentials["Username"] , Common.CurrentCredentials["Password"] , Common.CurrentRestBaseUrl); EPodResponse ePod = api.GetEPod(txtAWBNumber.Text , txtAccountNumber.Text // ReSharper disable once PossibleInvalidCastException , (Enums.EPodType)cmbPODType.SelectedItem); _lastJsonRequest = api.LastEPoDJSONRequest; _lastJsonResponse = api.LastEPoDJSONResponse; if (null != ePod) { string tempFilename = System.IO.Path.GetTempFileName(); switch (ePod.EPod.MimeType) { case "application/pdf": tempFilename += ".pdf"; break; case "image/jpeg": case "image/jpg": tempFilename += ".jpg"; break; case "image/png": tempFilename += ".png"; break; } System.IO.File.WriteAllBytes(tempFilename, ePod.EPod.Image); System.Diagnostics.Process.Start(tempFilename); } } catch (MyDHLAPIValidationException gvx) { txtResult.Text = MyDHLAPIValidationException.PrintResults(gvx.ExtractValidationResults(), 0); } catch (Exception ex) { txtResult.Text = ex.Message; } finally { this.Enabled = true; this.UseWaitCursor = false; Cursor.Current = Cursors.Default; } }