public ShipmentResponse Create(ShipmentViewModel Shipment) { ShipmentResponse response = new ShipmentResponse(); using (SqliteConnection db = new SqliteConnection("Filename=SirmiumERPGFC.db")) { db.Open(); SqliteCommand insertCommand = db.CreateCommand(); insertCommand.CommandText = SqlCommandInsertPart; try { insertCommand = AddCreateParameters(insertCommand, Shipment); insertCommand.ExecuteNonQuery(); } catch (SqliteException error) { MainWindow.ErrorMessage = error.Message; response.Success = false; response.Message = error.Message; return(response); } db.Close(); response.Success = true; return(response); } }
public ShipmentResponse Delete(Guid identifier) { ShipmentResponse response = new ShipmentResponse(); using (SqliteConnection db = new SqliteConnection("Filename=SirmiumERPGFC.db")) { db.Open(); SqliteCommand insertCommand = new SqliteCommand(); insertCommand.Connection = db; //Use parameterized query to prevent SQL injection attacks insertCommand.CommandText = "DELETE FROM Shipments WHERE Identifier = @Identifier"; insertCommand.Parameters.AddWithValue("@Identifier", identifier); try { insertCommand.ExecuteNonQuery(); } catch (SqliteException error) { MainWindow.ErrorMessage = error.Message; response.Success = false; response.Message = error.Message; return(response); } db.Close(); response.Success = true; return(response); } }
public void CreateInvoiceForm(ShipmentResponse resp, RatesForm form) { var pdf = PdfDocument.FromFile($"{_paths.Value.Forms}\\InvoiceForm.pdf"); //pdf.Form.GetFieldByName("TaxID").Value = "718272719RM0001"; //pdf.Form.GetFieldByName("FromContactName").Value = form.NameFrom; //pdf.Form.GetFieldByName("FromName").Value = form.NameFrom; //pdf.Form.GetFieldByName("FromAddress").Value = form.AddressFrom; //pdf.Form.GetFieldByName("FromRestOfAddress").Value = $"{form.CityFrom}, {form.ZipFrom}, {form.StateFrom}"; //pdf.Form.GetFieldByName("FromPhone").Value = form.PhoneFrom; //pdf.Form.GetFieldByName("WaybillNumber").Value = resp.ShipmentResponse.ShipmentResults.ShipmentIdentificationNumber; //pdf.Form.GetFieldByName("ShipmentID").Value = resp.ShipmentResponse.ShipmentResults.ShipmentIdentificationNumber; //pdf.Form.GetFieldByName("Date").Value = DateTime.Now.ToString("dd/MMM/yyyy"); //pdf.Form.GetFieldByName("ShipToContactName").Value = form.NameTo; //pdf.Form.GetFieldByName("ShipToName").Value = form.NameTo; //pdf.Form.GetFieldByName("ShipToAddress").Value = form.AddressTo; //pdf.Form.GetFieldByName("ShipToRestOfAddress").Value = $"{form.CityTo}, {form.ZipTo}, {form.StateTo}"; //pdf.Form.GetFieldByName("ShipToPhone").Value = form.PhoneTo; //newPdf.SaveAs($"{_paths.Value.Forms}\\{resp.ShipmentResponse.ShipmentResults.ShipmentIdentificationNumber}.pdf"); }
public ShipmentResponse Create(ShipmentViewModel re) { ShipmentResponse response = new ShipmentResponse(); try { // Backup documents List <ShipmentDocumentViewModel> shipmentDocuments = re.ShipmentDocuments?.ToList(); re.ShipmentDocuments = null; Shipment createdShipment = unitOfWork.GetShipmentRepository().Create(re.ConvertToShipment()); // Update documents if (shipmentDocuments != null && shipmentDocuments.Count > 0) { // Items for create or update foreach (var shipmentDocument in shipmentDocuments .Where(x => x.ItemStatus == ItemStatus.Added || x.ItemStatus == ItemStatus.Edited)?.ToList() ?? new List <ShipmentDocumentViewModel>()) { shipmentDocument.Shipment = new ShipmentViewModel() { Id = createdShipment.Id }; shipmentDocument.ItemStatus = ItemStatus.Submited; ShipmentDocument createdShipmentDocument = unitOfWork.GetShipmentDocumentRepository() .Create(shipmentDocument.ConvertToShipmentDocument()); } foreach (var item in shipmentDocuments .Where(x => x.ItemStatus == ItemStatus.Deleted)?.ToList() ?? new List <ShipmentDocumentViewModel>()) { item.Shipment = new ShipmentViewModel() { Id = createdShipment.Id }; unitOfWork.GetShipmentDocumentRepository().Create(item.ConvertToShipmentDocument()); unitOfWork.GetShipmentDocumentRepository().Delete(item.Identifier); } } unitOfWork.Save(); response.Shipment = createdShipment.ConvertToShipmentViewModel(); response.Success = true; } catch (Exception ex) { response.Shipment = new ShipmentViewModel(); response.Success = false; response.Message = ex.Message; } return(response); }
private ShipmentResponse Map(ShipmentNote shipmentNote) { var response = new ShipmentResponse { IsDelivered = shipmentNote.IsDelivered, ConfirmationNumber = shipmentNote.ConfirmationNumber }; return(response); }
public async Task CanCreateShipmentWithOnlyRequiredFields() { // the order needs to be autorized to do a shipment on. this can only be done by waiting. string validOrderId = "XXXXX"; ShipmentRequest shipmentRequest = this.CreateShipmentWithOnlyRequiredFields(); ShipmentResponse result = await this._shipmentClient.CreateShipmentAsync(validOrderId, shipmentRequest); // Then: Make sure we get a valid shipment response Assert.IsNotNull(result); Assert.IsTrue(result.CreatedAt >= DateTime.Now); }
public JsonResult ProcessShipment(ShipmentRequestRootObject model, string requestUrl = _shipRequestUriCIE) { try { var accountNbr = "132R1V"; ShipmentRequestElements.Shipper shipper = new ShipmentRequestElements.Shipper { Name = model.ShipmentRequest.Shipment.ShipFrom.Name, ShipperNumber = accountNbr, AttentionName = model.ShipmentRequest.Shipment.ShipFrom.AttentionName, Phone = new ShipmentRequestElements.Phone { Number = model.ShipmentRequest.Shipment.ShipFrom.Phone.Number }, FaxNumber = model.ShipmentRequest.Shipment.ShipFrom.FaxNumber, Address = new ShipmentRequestElements.ShipperAddress { AddressLine = model.ShipmentRequest.Shipment.ShipFrom.Address.AddressLine, City = model.ShipmentRequest.Shipment.ShipFrom.Address.City, CountryCode = model.ShipmentRequest.Shipment.ShipFrom.Address.CountryCode, StateProvinceCode = model.ShipmentRequest.Shipment.ShipFrom.Address.StateProvinceCode, PostalCode = model.ShipmentRequest.Shipment.ShipFrom.Address.PostalCode } }; model.ShipmentRequest.Shipment.Shipper = shipper; model.ShipmentRequest.Shipment.PaymentInformation = new ShipmentRequestElements.PaymentInformation { ShipmentCharge = new ShipmentRequestElements.ShipmentCharge { Type = "01", //Shipment BillShipper = new ShipmentRequestElements.BillShipper { AccountNumber = accountNbr } } }; model.ShipmentRequest.Shipment.Shipper.Address.PostalCode = model.ShipmentRequest.Shipment.Shipper.Address.PostalCode.Replace(" ", String.Empty); model.ShipmentRequest.Shipment.ShipFrom.Address.PostalCode = model.ShipmentRequest.Shipment.ShipFrom.Address.PostalCode.Replace(" ", String.Empty); model.ShipmentRequest.Shipment.ShipTo.Address.PostalCode = model.ShipmentRequest.Shipment.ShipTo.Address.PostalCode.Replace(" ", String.Empty); HttpContent httContent = new StringContent(JsonConvert.SerializeObject(model), Encoding.UTF8); ShipmentResponse resData = _shippingService.ProcessShipment(requestUrl, httContent); return(Json(new { success = true, resData })); } catch (Exception ex) { return(Json(new { success = false, errorMessage = ex.ToString() })); } }
/// <summary> /// UpdateShipment /// Function to update the shipment details /// </summary> /// <param name="companyID">Company ID</param> /// <param name="password">Password</param> /// <param name="shipmentReq">ShipmentRequest object</param> /// <returns>ShipmentResponse object</returns> /// <param name="VersionNo">VersionNo</param> public ShipmentResponse UpdateShipment(string companyID, string password, ShipmentRequest shipmentReq, String VersionNo = "") { ShipmentResponse shipmentResponse = null; ISession session = null; try { ValidateCustomerLogin(companyID, password, VersionNo); session = GetSession(); session.BeginTransaction(); shipmentResponse = DALMethods.UpdateShipment(session, shipmentReq, VersionNo); DALMethods.ClearShipmentErrors(shipmentReq.SysTrxNo, shipmentReq.SysTrxLine, session, VersionNo); session.CommitTransaction(); CloseSession(session); } catch (ApplicationException ex) { if (session != null) { session.RollbackTransaction(); CloseSession(session); session = GetSession(); } //Logging.WriteToFile1("Dinesh 3- "); //Logging.WriteToFile1("Dinesh 4- "); DALMethods.UpdateShipmentErrors(shipmentReq, true, ex.StackTrace, ex.Message, session, VersionNo); throw ex; } catch (Exception ex) { if (session != null) { session.RollbackTransaction(); CloseSession(session); } //session = GetSession(); //DALMethods.UpdateShipmentErrors(shipmentReq, true, ex.StackTrace, ex.Message, session, VersionNo); Logging.LogError(ex); //Logging.WriteToFile1("Dinesh 4- "); //shipmentResponse = new ShipmentResponse(); //shipmentResponse.ErrorMessage = ex.Message + " - " + ex.StackTrace; //Logging.WriteToFile1("Dinesh 5- "); //return shipmentResponse; throw ex; } return(shipmentResponse); }
public ShipmentResponse Create(ShipmentViewModel re) { ShipmentResponse response = new ShipmentResponse(); try { response = WpfApiHandler.SendToApi <ShipmentViewModel, ShipmentResponse>(re, "Create"); } catch (Exception ex) { response.Shipment = new ShipmentViewModel(); response.Success = false; response.Message = ex.Message; } return(response); }
private void BtnSubmit_Click(object sender, RoutedEventArgs e) { #region Validation if (ShipmentDocumentsFromDB == null || ShipmentDocumentsFromDB.Count == 0) { MainWindow.WarningMessage = ((string)Application.Current.FindResource("Morate_uneti_osnovne_podatkeUzvičnik")); return; } #endregion Thread td = new Thread(() => { SubmitButtonContent = ((string)Application.Current.FindResource("Čuvanje_u_tokuTriTacke")); SubmitButtonEnabled = false; CurrentShipment.ShipmentDocuments = ShipmentDocumentsFromDB; ShipmentResponse response = ShipmentService.Create(CurrentShipment); if (!response.Success) { MainWindow.ErrorMessage = ((string)Application.Current.FindResource("Greška_kod_čuvanja_na_serveruUzvičnik")); SubmitButtonContent = ((string)Application.Current.FindResource("Proknjiži")); SubmitButtonEnabled = true; } if (response.Success) { MainWindow.SuccessMessage = ((string)Application.Current.FindResource("Podaci_su_uspešno_sačuvaniUzvičnik")); SubmitButtonContent = ((string)Application.Current.FindResource("Proknjiži")); SubmitButtonEnabled = true; ShipmentCreatedUpdated(); Application.Current.Dispatcher.BeginInvoke( System.Windows.Threading.DispatcherPriority.Normal, new Action(() => { FlyoutHelper.CloseFlyout(this); }) ); } }); td.IsBackground = true; td.Start(); }
public ShipmentResponse ProcessShipment(string requestUrl, HttpContent httpContent) { var resObj = _upsApiService.GetResultFromUpsApi(requestUrl, httpContent); ShipmentResponse resData = new ShipmentResponse(); ErrorsResponse resError = new ErrorsResponse(); if (resObj.IsSuccessStatusCode) { FormatShipmentResponse(resObj.JObject, resData, requestUrl); } else { FormatErrorResponse(resObj.JObject, resError); } return(resData); }
public ShipmentResponse GetShipments(string sessionId) { var response = new ShipmentResponse(); try { response.Shipments = shipmentAgent.GetExecutingShipments(GetToken(sessionId).AccessToken); response.Code = 0; response.Message = ""; } catch (Exception ex) { logger.LogError(ex, "Get shipments failed"); response.Code = ShipmentErrorCode.SystemUnhandledException; response.Message = "运单获取失败,请重新进入小程序后重试"; } return(response); }
public ShipmentResponse Delete(Guid identifier) { ShipmentResponse response = new ShipmentResponse(); try { ShipmentViewModel re = new ShipmentViewModel(); re.Identifier = identifier; response = WpfApiHandler.SendToApi <ShipmentViewModel, ShipmentResponse>(re, "Delete"); } catch (Exception ex) { response.Shipment = new ShipmentViewModel(); response.Success = false; response.Message = ex.Message; } return(response); }
public JsonResult Delete([FromBody] ShipmentViewModel shipment) { ShipmentResponse response = new ShipmentResponse(); try { response = this.shipmentService.Delete(shipment.Identifier); } catch (Exception ex) { response.Success = false; response.Message = ex.Message; Console.WriteLine(ex.Message); } return(Json(response, new Newtonsoft.Json.JsonSerializerSettings() { Formatting = Newtonsoft.Json.Formatting.Indented })); }
private void DHL_Test(int OrderID) { SC_WebService SCWS = new SC_WebService(Session["ApiUserName"].ToString(), Session["ApiPassword"].ToString()); IRepository <Orders> Orders = new GenericRepository <Orders>(db); Orders order = Orders.Get(OrderID); Packages package = order.Packages.First(p => p.IsEnable.Value); try { DHL_API DHL = new DHL_API(package.Method.Carriers.CarrierAPI); ShipmentResponse result = DHL.Create(package); //String OutputImage = "JVBERi0xLjQKJeLjz9MKMiAwIG9iago8PC9MZW5ndGggNTEvRmlsdGVyL0ZsYXRlRGVjb2RlPj5zdHJlYW0KeJwr5HIK4TJQMLU01TOyUAhJ4XIN4QrkKlQwVDAAQgiZnKugH5FmqOCSrxDIBQD9oQpWCmVuZHN0cmVhbQplbmRvYmoKNCAwIG9iago8PC9CYXNlRm9udC9IZWx2ZXRpY2EtQm9sZC9UeXBlL0ZvbnQvRW5jb2RpbmcvV2luQW5zaUVuY29kaW5nL1N1YnR5cGUvVHlwZTE+PgplbmRvYmoKNSAwIG9iago8PC9CYXNlRm9udC9IZWx2ZXRpY2EvVHlwZS9Gb250L0VuY29kaW5nL1dpbkFuc2lFbmNvZGluZy9TdWJ0eXBlL1R5cGUxPj4KZW5kb2JqCjMgMCBvYmoKPD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3NDY2Pl0vSW5mbyAxMyAwIFIvU2l6ZSAxND4+CnN0YXJ0eHJlZgo4ODIzCiUlRU9GCg=="; //System.IO.File.WriteAllBytes(@"C:\Downloads\DHL_test.pdf", Crop(Convert.FromBase64String(OutputImage), 97f, 30f, 356f, 553f)); //System.IO.File.WriteAllBytes(@"C:\Users\qdtuk\Downloads\DHL_test.pdf", Crop(result.LabelImage.First().OutputImage, 97f, 30f, 356f, 553f)); //System.IO.File.WriteAllBytes(@"C:\Users\qdtuk\Downloads\DHL_Invoice_test.pdf", result.LabelImage.First().MultiLabels.First().DocImageVal); } catch (Exception e) { } }
public ShipmentResponse Delete(Guid identifier) { ShipmentResponse response = new ShipmentResponse(); try { DomainCore.Common.Shipments.Shipment deletedShipment = unitOfWork.GetShipmentRepository().Delete(identifier); unitOfWork.Save(); response.Shipment = deletedShipment.ConvertToShipmentViewModel(); response.Success = true; } catch (Exception ex) { response.Shipment = new ShipmentViewModel(); response.Success = false; response.Message = ex.Message; } return(response); }
public ShipmentResponse GetShipment(Guid identifier) { ShipmentResponse response = new ShipmentResponse(); ShipmentViewModel Shipment = new ShipmentViewModel(); using (SqliteConnection db = new SqliteConnection("Filename=SirmiumERPGFC.db")) { db.Open(); try { SqliteCommand selectCommand = new SqliteCommand( SqlCommandSelectPart + "FROM Shipments " + "WHERE Identifier = @Identifier;", db); selectCommand.Parameters.AddWithValue("@Identifier", identifier); SqliteDataReader query = selectCommand.ExecuteReader(); if (query.Read()) { ShipmentViewModel dbEntry = Read(query); Shipment = dbEntry; } } catch (SqliteException error) { MainWindow.ErrorMessage = error.Message; response.Success = false; response.Message = error.Message; response.Shipment = new ShipmentViewModel(); return(response); } db.Close(); } response.Success = true; response.Shipment = Shipment; return(response); }
private void FormatShipmentResponse(JObject resObj, ShipmentResponse resData, string requestUrl) { if (resObj != null && !String.IsNullOrEmpty(resObj.ToString())) { if (resObj.ContainsKey(typeof(ShipmentResponse).Name)) { //Assign Response resData.Response = resObj[typeof(ShipmentResponse).Name][typeof(ShipmentResponseElements.Response).Name].ToObject <ShipmentResponseElements.Response>(); //End Assign Response //Add Alert var responseObj = resObj[typeof(ShipmentResponse).Name][typeof(ShipmentResponseElements.Response).Name].ToObject <JObject>(); if (responseObj.ContainsKey(typeof(Alert).Name)) { resData.Response.ListAlert = new List <Alert>(); JToken alerts = responseObj[typeof(Alert).Name]; if (alerts.ToString().Contains("[")) { resData.Response.ListAlert.AddRange(alerts.ToObject <List <Alert> >()); } else { resData.Response.ListAlert.Add(alerts.ToObject <Alert>()); } } //End Add Alert //Assign ShipmentResults resData.ShipmentResults = resObj[typeof(ShipmentResponse).Name][typeof(ShipmentResults).Name].ToObject <ShipmentResults>(); //End Assign ShipmentResults //Add ItemizedCharges var shipmentResultsObj = resObj[typeof(ShipmentResponse).Name][typeof(ShipmentResults).Name].ToObject <JObject>(); if (shipmentResultsObj.ContainsKey(typeof(ShipmentCharges).Name)) { var shipmentChargeObj = shipmentResultsObj[typeof(ShipmentCharges).Name].ToObject <JObject>(); if (shipmentChargeObj.ContainsKey(typeof(ItemizedCharges).Name)) { resData.ShipmentResults.ShipmentCharges.ListItemizedCharges = new List <ItemizedCharges>(); JToken itemizedCharges = shipmentChargeObj[typeof(ItemizedCharges).Name]; if (itemizedCharges.ToString().Contains("[")) { resData.ShipmentResults.ShipmentCharges.ListItemizedCharges.AddRange(itemizedCharges.ToObject <List <ItemizedCharges> >()); } else { resData.ShipmentResults.ShipmentCharges.ListItemizedCharges.Add(itemizedCharges.ToObject <ItemizedCharges>()); } } } //End Add ItemizedCharges //Add PackageResults if (shipmentResultsObj.ContainsKey(typeof(PackageResults).Name)) { resData.ShipmentResults.ListPackageResults = new List <PackageResults>(); JToken packageResults = shipmentResultsObj[typeof(PackageResults).Name]; if (packageResults.ToString().Contains("[")) { resData.ShipmentResults.ListPackageResults.AddRange(packageResults.ToObject <List <PackageResults> >()); } else { resData.ShipmentResults.ListPackageResults.Add(packageResults.ToObject <PackageResults>()); } } //End Add PackageResults } } }
private static void ScheduleShipment() { try { ShipService shpSvc = new ShipService(); ShipmentRequest shipmentRequest = new ShipmentRequest(); // security UPSSecurity upss = new UPSSecurity(); UPSSecurityServiceAccessToken upssSvcAccessToken = new UPSSecurityServiceAccessToken(); upssSvcAccessToken.AccessLicenseNumber = "4CF6E9703C30E4B6"; upss.ServiceAccessToken = upssSvcAccessToken; UPSSecurityUsernameToken upssUsrNameToken = new UPSSecurityUsernameToken(); upssUsrNameToken.Username = "******"; upssUsrNameToken.Password = "******"; upss.UsernameToken = upssUsrNameToken; shpSvc.UPSSecurityValue = upss; RequestType request = new RequestType(); String[] requestOption = { "nonvalidate" }; request.RequestOption = requestOption; shipmentRequest.Request = request; ShipmentType shipment = new ShipmentType(); shipment.Description = "New shipment ..."; // payment PaymentInfoType paymentInfo = new PaymentInfoType(); ShipmentChargeType shpmentCharge = new ShipmentChargeType(); BillShipperType billShipper = new BillShipperType(); billShipper.AccountNumber = "1YA077"; shpmentCharge.BillShipper = billShipper; shpmentCharge.Type = "01"; ShipmentChargeType[] shpmentChargeArray = { shpmentCharge }; paymentInfo.ShipmentCharge = shpmentChargeArray; shipment.PaymentInformation = paymentInfo; // shipper ShipperType shipper = new ShipperType(); shipper.ShipperNumber = "1YA077"; ShipWSSample.ShipWebReference.ShipAddressType shipperAddress = new ShipWSSample.ShipWebReference.ShipAddressType(); String[] addressLine = { "88 Foster Crescent" }; shipperAddress.AddressLine = addressLine; shipperAddress.City = "Mississauga"; shipperAddress.PostalCode = "L5R4A2"; shipperAddress.StateProvinceCode = "ON"; shipperAddress.CountryCode = "CA"; shipper.Address = shipperAddress; shipper.Name = "CATO"; shipper.AttentionName = "Ingram Micro - Mississauga"; ShipPhoneType shipperPhone = new ShipPhoneType(); shipperPhone.Number = "1234567890"; shipper.Phone = shipperPhone; shipment.Shipper = shipper; // ship from ShipFromType shipFrom = new ShipFromType(); ShipWSSample.ShipWebReference.ShipAddressType shipFromAddress = new ShipWSSample.ShipWebReference.ShipAddressType(); String[] shipFromAddressLine = { "135 Liberty St. Suite 101" }; shipFromAddress.AddressLine = addressLine; shipFromAddress.City = "Toronto"; shipFromAddress.PostalCode = "M6K1A7"; shipFromAddress.StateProvinceCode = "ON"; shipFromAddress.CountryCode = "CA"; shipFrom.Address = shipFromAddress; shipFrom.AttentionName = "Mr. Andy Feng"; shipFrom.Name = "Kobo Inc."; shipment.ShipFrom = shipFrom; // ship to ShipToType shipTo = new ShipToType(); ShipToAddressType shipToAddress = new ShipToAddressType(); String[] addressLine1 = { "403 Burr Oak Drive" }; shipToAddress.AddressLine = addressLine1; shipToAddress.City = "Oswego"; shipToAddress.PostalCode = "60543"; shipToAddress.StateProvinceCode = "IL"; shipToAddress.CountryCode = "US"; shipTo.Address = shipToAddress; shipTo.AttentionName = "Mr. John Smith"; shipTo.Name = "DEF Associates"; ShipPhoneType shipToPhone = new ShipPhoneType(); shipToPhone.Number = "(905) 123-1234"; shipTo.Phone = shipToPhone; shipment.ShipTo = shipTo; //service ServiceType service = new ServiceType(); //service.Code = "01"; // next day air service.Code = "11";//ups standard shipment.Service = service; // package PackageType package = new PackageType(); PackageWeightType packageWeight = new PackageWeightType(); packageWeight.Weight = "10"; ShipUnitOfMeasurementType uom = new ShipUnitOfMeasurementType(); uom.Code = "LBS"; packageWeight.UnitOfMeasurement = uom; package.PackageWeight = packageWeight; PackagingType packType = new PackagingType(); packType.Code = "02"; package.Packaging = packType; // package 2 PackageType package2 = new PackageType(); PackageWeightType packageWeight2 = new PackageWeightType(); packageWeight2.Weight = "9"; ShipUnitOfMeasurementType uom2 = new ShipUnitOfMeasurementType(); uom2.Code = "LBS"; packageWeight2.UnitOfMeasurement = uom2; package2.PackageWeight = packageWeight2; PackagingType packType2 = new PackagingType(); packType2.Code = "02"; package2.Packaging = packType2; PackageType[] pkgArray = { package, package2 }; shipment.Package = pkgArray; // add delivery confirmation for package level //PackageServiceOptionsType packageServiceOptions = new PackageServiceOptionsType(); //package.PackageServiceOptions = packageServiceOptions; //package2.PackageServiceOptions = packageServiceOptions; //DeliveryConfirmationType deliveryConfirmation = new DeliveryConfirmationType(); ////Service DCIS Type, The type of confirmation required upon delivery of the package. //deliveryConfirmation.DCISType = "2"; //Delivery Confirmation Signature Required //// The delivery confirmation control number that confirms the package's delivery. ////deliveryConfirmation.DCISNumber = "xxxxxxxx"; //packageServiceOptions.DeliveryConfirmation = deliveryConfirmation; // label LabelSpecificationType labelSpec = new LabelSpecificationType(); LabelStockSizeType labelStockSize = new LabelStockSizeType(); labelStockSize.Height = "1"; labelStockSize.Width = "1"; labelSpec.LabelStockSize = labelStockSize; LabelImageFormatType labelImageFormat = new LabelImageFormatType(); //// for zpl //labelStockSize.Height = "6"; //labelStockSize.Width = "4"; //labelImageFormat.Code = "ZPL"; // for gif labelImageFormat.Code = "GIF"; labelSpec.LabelImageFormat = labelImageFormat; shipmentRequest.LabelSpecification = labelSpec; shipmentRequest.Shipment = shipment; // label ShipmentTypeShipmentServiceOptions options = new ShipmentTypeShipmentServiceOptions(); //options.LabelDelivery = new LabelDeliveryType(); shipment.ShipmentServiceOptions = options; // international form for paperless invoice InternationalFormType internationalForm = new InternationalFormType(); internationalForm.AdditionalDocumentIndicator = null; internationalForm.ReasonForExport = "SALE"; internationalForm.ExportDate = DateTime.Now.ToString("yyyyMMdd"); internationalForm.ExportingCarrier = "UPS"; internationalForm.InvoiceDate = DateTime.Now.ToString("yyyyMMdd"); internationalForm.CurrencyCode = "CAD"; internationalForm.FormType = new String[] { "01" }; internationalForm.Contacts = new ContactType() { SoldTo = new SoldToType() { Name = "andy", Address = new AddressType() { AddressLine = new String[] { "box 40" }, City = "Tornnn", CountryCode = "US", PostalCode = "M1S2S5", StateProvinceCode = "ON" } } }; internationalForm.Product = new ProductType[] { new ProductType() { ProducerInfo = "product1", Description = new String[] { "1233" }, Unit = new UnitType() { Number = "1", UnitOfMeasurement = new UnitOfMeasurementType() { Code = "BG" }, Value = "1" }, OriginCountryCode = "CA", CommodityCode = "123456", NumberOfPackagesPerCommodity = "1", ProductWeight = new ProductWeightType() { UnitOfMeasurement = new UnitOfMeasurementType() { Code = "LBS" }, Weight = "12" } } }; options.InternationalForms = internationalForm; // delivery confirmation for shipment level DeliveryConfirmationType deliveryConfirmation = new DeliveryConfirmationType(); deliveryConfirmation.DCISType = "2"; options.DeliveryConfirmation = deliveryConfirmation; Console.WriteLine(shipmentRequest); System.Net.ServicePointManager.CertificatePolicy = new TrustAllCertificatePolicy(); // response ShipmentResponse shipmentResponse = shpSvc.ProcessShipment(shipmentRequest); Console.WriteLine("The transaction was a " + shipmentResponse.Response.ResponseStatus.Description); // output label base64 characters string byteFileName = @"c:\Users\afeng\Pictures\label.txt"; using (FileStream fs = new FileStream(byteFileName, FileMode.Create, FileAccess.ReadWrite)) { using (BinaryWriter sw = new BinaryWriter(fs)) { sw.Write(shipmentResponse.ShipmentResults.PackageResults.FirstOrDefault().ShippingLabel.GraphicImage); } } // output label image string filename = @"c:\Users\afeng\Pictures\label.gif"; byte[] byteLabel; using (FileStream fs = new FileStream(filename, FileMode.Create, FileAccess.ReadWrite)) { using (BinaryWriter writer = new BinaryWriter(fs)) { byteLabel = Convert.FromBase64String( shipmentResponse.ShipmentResults.PackageResults.FirstOrDefault().ShippingLabel.GraphicImage); writer.Write(byteLabel); } } // output label html page string htmlFilename = @"c:\Users\afeng\Pictures\label.html"; byte[] htmlByteLabel; using (FileStream fs = new FileStream(htmlFilename, FileMode.Create, FileAccess.ReadWrite)) { using (BinaryWriter writer = new BinaryWriter(fs)) { htmlByteLabel = Convert.FromBase64String( shipmentResponse.ShipmentResults.PackageResults.FirstOrDefault().ShippingLabel.HTMLImage); writer.Write(htmlByteLabel); } } // binary serialize Stream stream = File.Open(@"c:\Users\afeng\Pictures\data.dat", FileMode.Create); BinaryFormatter bformatter = new BinaryFormatter(); Console.WriteLine("Writing binary serialize Information"); bformatter.Serialize(stream, shipmentResponse); stream.Close(); // xml serialize Stream requetStream = File.Open(@"c:\Users\afeng\Pictures\request.xml", FileMode.Create); XmlSerializer requestSerializer = new XmlSerializer(shipment.GetType()); Console.WriteLine("Writing xml serialize Information"); requestSerializer.Serialize(requetStream, shipment); requetStream.Close(); Stream responseStream = File.Open(@"c:\Users\afeng\Pictures\response.xml", FileMode.Create); XmlSerializer serializer = new XmlSerializer(shipmentResponse.GetType()); Console.WriteLine("Writing xml serialize Information"); serializer.Serialize(responseStream, shipmentResponse); responseStream.Close(); // resize picture int width = (int)(8.25 * 72); int height = (int)(4.25 * 72); // resize picture 1 Bitmap imgIn = new Bitmap(filename); double y = imgIn.Height; double x = imgIn.Width; double factor = 1; if (width > 0) { factor = width / x; } else if (height > 0) { factor = height / y; } System.IO.MemoryStream outStream = new System.IO.MemoryStream(); Bitmap imgOut = new Bitmap((int)(x * factor), (int)(y * factor)); // Set DPI of image (xDpi, yDpi) //imgOut.SetResolution(72, 72); imgOut.SetResolution(96, 96); Graphics g = Graphics.FromImage(imgOut); g.Clear(Color.White); g.DrawImage(imgIn, new Rectangle(0, 0, (int)(factor * x), (int)(factor * y)), new Rectangle(0, 0, (int)x, (int)y), GraphicsUnit.Pixel); imgOut.Save(outStream, ImageFormat.Gif); string filename2 = @"c:\Users\afeng\Pictures\label2.gif"; FileStream fs2 = new FileStream(filename2, FileMode.Create, FileAccess.ReadWrite); BinaryWriter writer2 = new BinaryWriter(fs2); writer2.Write(outStream.ToArray()); writer2.Close(); // resize picture 2 //Creates a new Bitmap as the size of the window Bitmap bmp = new Bitmap(width, height); //Creates a new graphics to handle the image that is coming from the stream Graphics g2 = Graphics.FromImage((Image)bmp); g2.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.AntiAlias; g2.InterpolationMode = System.Drawing.Drawing2D.InterpolationMode.HighQualityBicubic; //Resizes the image from the stream to fit our windows Bitmap imgIn2 = new Bitmap(filename); g2.DrawImage(imgIn2, 0, 0, width, height); string filename3 = @"c:\Users\afeng\Pictures\label3.gif"; FileStream fs3 = new FileStream(filename3, FileMode.Create, FileAccess.ReadWrite); BinaryWriter writer3 = new BinaryWriter(fs3); System.IO.MemoryStream outStream2 = new System.IO.MemoryStream(); bmp.Save(outStream2, ImageFormat.Gif); writer3.Write(outStream2.ToArray()); writer3.Close(); // resize picture 3 Bitmap newImage = new Bitmap(width, height); using (Graphics gr = Graphics.FromImage(newImage)) { gr.SmoothingMode = SmoothingMode.HighQuality; //gr.InterpolationMode = InterpolationMode.HighQualityBicubic; gr.InterpolationMode = InterpolationMode.NearestNeighbor; gr.PixelOffsetMode = PixelOffsetMode.HighQuality; gr.DrawImage(new Bitmap(filename), new Rectangle(0, 0, width, height)); string filename4 = @"c:\Users\afeng\Pictures\label4.gif"; FileStream fs4 = new FileStream(filename4, FileMode.Create, FileAccess.ReadWrite); //newImage.Save(filename4, System.Drawing.Imaging.ImageFormat.Gif); BinaryWriter writer4 = new BinaryWriter(fs4); System.IO.MemoryStream outStream4 = new System.IO.MemoryStream(); newImage.Save(outStream4, ImageFormat.Gif); writer4.Write(outStream4.ToArray()); writer4.Close(); } // resize picture 4 ImageHandler ih = new ImageHandler(); string filename5 = @"c:\Users\afeng\Pictures\label5.jpg"; MemoryStream stream5 = new MemoryStream(); stream5.Write(byteLabel, 0, byteLabel.Length); //Bitmap b = new Bitmap(filename); Bitmap b = new Bitmap(stream5); ih.Save(b, width, height, 100, filename5); Console.WriteLine("The 1Z number of the new shipment is " + shipmentResponse.ShipmentResults.ShipmentIdentificationNumber); Console.ReadKey(); } catch (System.Web.Services.Protocols.SoapException ex) { Console.WriteLine(""); Console.WriteLine("---------Ship Web Service returns error----------------"); Console.WriteLine("---------\"Hard\" is user error \"Transient\" is system error----------------"); Console.WriteLine("SoapException Message= " + ex.Message); Console.WriteLine(""); Console.WriteLine("SoapException Category:Code:Message= " + ex.Detail.LastChild.InnerText); Console.WriteLine(""); Console.WriteLine("SoapException XML String for all= " + ex.Detail.LastChild.OuterXml); Console.WriteLine(""); Console.WriteLine("SoapException StackTrace= " + ex.StackTrace); Console.WriteLine("-------------------------"); Console.WriteLine(""); } catch (System.ServiceModel.CommunicationException ex) { Console.WriteLine(""); Console.WriteLine("--------------------"); Console.WriteLine("CommunicationException= " + ex.Message); Console.WriteLine("CommunicationException-StackTrace= " + ex.StackTrace); Console.WriteLine("-------------------------"); Console.WriteLine(""); } catch (Exception ex) { Console.WriteLine(""); Console.WriteLine("-------------------------"); Console.WriteLine(" General Exception= " + ex.Message); Console.WriteLine(" General Exception-StackTrace= " + ex.StackTrace); Console.WriteLine("-------------------------"); } finally { Console.ReadKey(); } }
public void CreateShipmentRequest() { try { ShipService shipService = new ShipService(); ShipmentRequest shipmentRequest = new ShipmentRequest(); // Security UPSSecurity upss = new UPSSecurity(); UPSSecurityServiceAccessToken upssSvcAccessToken = new UPSSecurityServiceAccessToken { AccessLicenseNumber = "1CBF3AD5FB29C105" }; upss.ServiceAccessToken = upssSvcAccessToken; UPSSecurityUsernameToken upssUsrNameToken = new UPSSecurityUsernameToken(); if (radioButton_PLZFT.Checked == true) { upssUsrNameToken.Username = "******"; upssUsrNameToken.Password = "******"; } else { upssUsrNameToken.Username = "******"; // AAC upssUsrNameToken.Password = "******"; // AAC } upss.UsernameToken = upssUsrNameToken; shipService.UPSSecurityValue = upss; // Request RequestType request = new RequestType(); shipmentRequest.Request = request; // Request Option String[] requestOption = { "nonvalidate" }; request.RequestOption = requestOption; shipmentRequest.Request = request; // Shipment ShipmentType shipment = new ShipmentType(); shipment.Description = "Amazon Gift Card"; // Shipper ShipperType shipper = new ShipperType(); //shipper.ShipperNumber = "9E6741"; //if (radioButton_PLZFT.Checked == true) shipper.ShipperNumber = "9E6741"; // <- gleich dem im AccessToken !? //else // 9E6741 // shipper.ShipperNumber = "9E6741"; // <- gleich dem im AccessToken !? // Payment Info PaymentInfoType paymentInfo = new PaymentInfoType(); ShipmentChargeType shipmentCharge = new ShipmentChargeType(); shipmentCharge.Type = "01"; //Payment Info -> BillShipper BillShipperType billShipper = new BillShipperType(); //billShipper.AccountNumber = "9E6741"; billShipper.AccountNumber = "587997"; shipmentCharge.BillShipper = billShipper; ShipmentChargeType shipmentCharge2 = new ShipmentChargeType(); shipmentCharge2.Type = "02"; // Payment Info -> BillReceiver BillReceiverType billReceiver = new BillReceiverType(); billReceiver.AccountNumber = "9E6741"; shipmentCharge2.BillReceiver = billReceiver; // Payment Info -> Bill3rdParty //BillThirdPartyChargeType bill3rdParty = new BillThirdPartyChargeType(); //bill3rdParty.AccountNumber = "9E6741"; //AccountAddressType thirdPartyAddress = new AccountAddressType //{ // PostalCode = "94032", // CountryCode = "DE" //}; //bill3rdParty.Address = thirdPartyAddress; //shipmentCharge2.BillThirdParty = bill3rdParty; ShipmentChargeType[] shpmentChargeArray = { shipmentCharge, shipmentCharge2 }; //ShipmentChargeType[] shpmentChargeArray = { shipmentCharge2 }; //ShipmentChargeType[] shpmentChargeArray = { shipmentCharge2 }; paymentInfo.ShipmentCharge = shpmentChargeArray; // Shipment -> Payment Information shipment.PaymentInformation = paymentInfo; // Shipper UPS_API.ShipWebReference.ShipAddressType shipperAddress = new UPS_API.ShipWebReference.ShipAddressType(); String[] addressLine = { textBox_Shipper_AddressLine.Text }; shipperAddress.AddressLine = addressLine; shipperAddress.City = textBox_Shipper_City.Text; shipperAddress.PostalCode = textBox_Shipper_PostalCode.Text; shipperAddress.StateProvinceCode = textBox_Shipper_StateProvince.Text; shipperAddress.CountryCode = textBox_Shipper_CountryCode.Text; shipperAddress.AddressLine = addressLine; shipper.Address = shipperAddress; shipper.Name = textBox_Shipper_Name.Text; shipper.AttentionName = textBox_Shipper_AttentionName.Text; ShipPhoneType shipperPhone = new ShipPhoneType(); shipperPhone.Number = textBox_Shipper_PhoneNumber.Text; shipper.Phone = shipperPhone; // Shipment -> Shipper shipment.Shipper = shipper; // ShipFrom ShipFromType shipFrom = new ShipFromType(); UPS_API.ShipWebReference.ShipAddressType shipFromAddress = new UPS_API.ShipWebReference.ShipAddressType(); String[] shipFromAddressLine = { textBox_ShipFrom_AddressLine.Text }; shipFromAddress.AddressLine = addressLine; shipFromAddress.City = textBox_ShipFrom_City.Text; shipFromAddress.PostalCode = textBox_ShipFrom_PostalCode.Text; shipFromAddress.StateProvinceCode = textBox_ShipFrom_StateProvince.Text; shipFromAddress.CountryCode = textBox_ShipFrom_CountryCode.Text; shipFrom.Address = shipFromAddress; shipFrom.Name = textBox_ShipFrom_Name.Text; shipFrom.AttentionName = textBox_ShipFrom_AttentionName.Text; ShipPhoneType shipFromPhone = new ShipPhoneType(); shipFromPhone.Number = textBox_ShipFrom_PhoneNumber.Text; shipFrom.Phone = shipFromPhone; // Shipment -> ShipFrom shipment.ShipFrom = shipFrom; // ShipTo ShipToType shipTo = new ShipToType(); ShipToAddressType shipToAddress = new ShipToAddressType(); String[] addressLine1 = { textBox_ShipTo_AddressLine1.Text }; shipToAddress.AddressLine = addressLine1; shipToAddress.City = textBox_ShipTo_City.Text; shipToAddress.PostalCode = textBox_ShipTo_PostalCode.Text; shipToAddress.StateProvinceCode = textBox_ShipTo_StateProvince.Text; shipToAddress.CountryCode = textBox_ShiptTo_CountryCode.Text; shipTo.Address = shipToAddress; shipTo.Name = textBox_ShipTo_Name.Text; shipTo.AttentionName = textBox_ShipTo_AttentionName.Text; ShipPhoneType shipToPhone = new ShipPhoneType(); shipToPhone.Number = textBox_ShipTo_PhoneNumber.Text; shipTo.Phone = shipToPhone; // Shipment -> ShipTo shipment.ShipTo = shipTo; // Services ServiceType service = new ServiceType(); service.Code = "11"; //ShipmentServiceOptionsType shipmentServiceOptions = new ShipmentServiceOptionsType(); // Shipment -> Services shipment.Service = service; // Package PackageType package = new PackageType(); PackageWeightType packageWeight = new PackageWeightType(); packageWeight.Weight = textBox_Package_Weight.Text; ShipUnitOfMeasurementType uom = new ShipUnitOfMeasurementType(); uom.Code = textBox_Package_MeasurementCode.Text; packageWeight.UnitOfMeasurement = uom; package.PackageWeight = packageWeight; PackagingType packType = new PackagingType(); packType.Code = textBox_Package_TypeCode.Text; package.Packaging = packType; PackageType[] pkgArray = { package }; // Shipment -> Package shipment.Package = pkgArray; // Label LabelSpecificationType labelSpec = new LabelSpecificationType(); LabelStockSizeType labelStockSize = new LabelStockSizeType(); labelStockSize.Height = "6"; labelStockSize.Width = "4"; labelSpec.LabelStockSize = labelStockSize; LabelImageFormatType labelImageFormat = new LabelImageFormatType(); labelImageFormat.Code = "PNG"; labelSpec.LabelImageFormat = labelImageFormat; // Shipment Request -> Label shipmentRequest.LabelSpecification = labelSpec; // Shipment Request -> Shipment shipmentRequest.Shipment = shipment; // Request -> Execute richTextBox1.Text += shipmentRequest + "\r\n"; System.Net.ServicePointManager.SecurityProtocol = System.Net.SecurityProtocolType.Tls12 | System.Net.SecurityProtocolType.Tls | System.Net.SecurityProtocolType.Tls11; //This line will ensure the latest security protocol for consuming the web service call. ShipmentResponse shipmentResponse = shipService.ProcessShipment(shipmentRequest); string shipmentIdentificationNumber = shipmentResponse.ShipmentResults.ShipmentIdentificationNumber; richTextBox1.Text += "The transaction was a " + shipmentResponse.Response.ResponseStatus.Description + "\r\n"; richTextBox1.Text += "The 1Z number of the new shipment is " + shipmentIdentificationNumber + "\r\n"; textBox_ShipmentIdentificationNumber.Text = shipmentIdentificationNumber; // Save label as PNG string base64Label = shipmentResponse.ShipmentResults.PackageResults[0].ShippingLabel.GraphicImage; byte[] data = Convert.FromBase64String(base64Label); using (var stream = new MemoryStream(data, 0, data.Length)) { Image imageLabel = Image.FromStream(stream); pictureBox_Label.Image = imageLabel; pictureBox_Label.Image.RotateFlip(RotateFlipType.Rotate90FlipNone); imageLabel.Save(Path.Combine(@Environment.GetFolderPath(Environment.SpecialFolder.Desktop), "ups_" + shipmentResponse.ShipmentResults.ShipmentIdentificationNumber + ".png")); } textBox_ErrorLog.ForeColor = Color.LimeGreen; textBox_ErrorLog.Text = "OK"; } catch (System.Web.Services.Protocols.SoapException ex) { textBox_ErrorLog.ForeColor = Color.Salmon; textBox_ErrorLog.Text = ex.Detail.LastChild.InnerText; richTextBox1.Text += "\r\n"; richTextBox1.Text += "---------Ship Web Service returns error----------------\r\n"; richTextBox1.Text += "---------\"Hard\" is user error \"Transient\" is system error----------------\r\n"; richTextBox1.Text += "SoapException Message= " + ex.Message; richTextBox1.Text += "\r\n"; richTextBox1.Text += "SoapException Category:Code:Message= " + ex.Detail.LastChild.InnerText; richTextBox1.Text += "\r\n"; richTextBox1.Text += "SoapException XML String for all= " + ex.Detail.LastChild.OuterXml; richTextBox1.Text += "\r\n"; richTextBox1.Text += "SoapException StackTrace= " + ex.StackTrace; richTextBox1.Text += "-------------------------\r\n"; richTextBox1.Text += "\r\n"; } catch (System.ServiceModel.CommunicationException ex) { textBox_ErrorLog.ForeColor = Color.Salmon; textBox_ErrorLog.Text = ex.Message; richTextBox1.Text += "\r\n"; richTextBox1.Text += "--------------------\r\n"; richTextBox1.Text += "CommunicationException= " + ex.Message; richTextBox1.Text += "CommunicationException-StackTrace= " + ex.StackTrace; richTextBox1.Text += "-------------------------\r\n"; richTextBox1.Text += "\r\n"; } catch (Exception ex) { textBox_ErrorLog.ForeColor = Color.Salmon; textBox_ErrorLog.Text = ex.Message; richTextBox1.Text += "\r\n"; richTextBox1.Text += "-------------------------\r\n"; richTextBox1.Text += " General Exception= " + ex.Message; richTextBox1.Text += " General Exception-StackTrace= " + ex.StackTrace; richTextBox1.Text += "-------------------------\r\n"; } finally { } }
static void Main() { try { ShipService shpSvc = new ShipService(); ShipmentRequest shipmentRequest = new ShipmentRequest(); UPSSecurity upss = new UPSSecurity(); UPSSecurityServiceAccessToken upssSvcAccessToken = new UPSSecurityServiceAccessToken(); upssSvcAccessToken.AccessLicenseNumber = "Your Access License"; upss.ServiceAccessToken = upssSvcAccessToken; UPSSecurityUsernameToken upssUsrNameToken = new UPSSecurityUsernameToken(); upssUsrNameToken.Username = "******"; upssUsrNameToken.Password = "******"; upss.UsernameToken = upssUsrNameToken; shpSvc.UPSSecurityValue = upss; RequestType request = new RequestType(); String[] requestOption = { "nonvalidate" }; request.RequestOption = requestOption; shipmentRequest.Request = request; ShipmentType shipment = new ShipmentType(); shipment.Description = "Ship webservice example"; ShipperType shipper = new ShipperType(); shipper.ShipperNumber = "Your Shipper Number"; PaymentInfoType paymentInfo = new PaymentInfoType(); ShipmentChargeType shpmentCharge = new ShipmentChargeType(); BillShipperType billShipper = new BillShipperType(); billShipper.AccountNumber = "Your Account Number"; shpmentCharge.BillShipper = billShipper; shpmentCharge.Type = "01"; ShipmentChargeType[] shpmentChargeArray = { shpmentCharge }; paymentInfo.ShipmentCharge = shpmentChargeArray; shipment.PaymentInformation = paymentInfo; ShipWSSample.ShipWebReference.ShipAddressType shipperAddress = new ShipWSSample.ShipWebReference.ShipAddressType(); String[] addressLine = { "480 Parkton Plaza" }; shipperAddress.AddressLine = addressLine; shipperAddress.City = "Timonium"; shipperAddress.PostalCode = "21093"; shipperAddress.StateProvinceCode = "MD"; shipperAddress.CountryCode = "US"; shipperAddress.AddressLine = addressLine; shipper.Address = shipperAddress; shipper.Name = "ABC Associates"; shipper.AttentionName = "ABC Associates"; ShipPhoneType shipperPhone = new ShipPhoneType(); shipperPhone.Number = "1234567890"; shipper.Phone = shipperPhone; shipment.Shipper = shipper; ShipFromType shipFrom = new ShipFromType(); ShipWSSample.ShipWebReference.ShipAddressType shipFromAddress = new ShipWSSample.ShipWebReference.ShipAddressType(); String[] shipFromAddressLine = { "Ship From Street" }; shipFromAddress.AddressLine = addressLine; shipFromAddress.City = "Timonium"; shipFromAddress.PostalCode = "21093"; shipFromAddress.StateProvinceCode = "MD"; shipFromAddress.CountryCode = "US"; shipFrom.Address = shipFromAddress; shipFrom.AttentionName = "Mr.ABC"; shipFrom.Name = "ABC Associates"; shipment.ShipFrom = shipFrom; ShipToType shipTo = new ShipToType(); ShipToAddressType shipToAddress = new ShipToAddressType(); String[] addressLine1 = { "GOERLITZER STR.1" }; shipToAddress.AddressLine = addressLine1; shipToAddress.City = "Neuss"; shipToAddress.PostalCode = "41456"; shipToAddress.CountryCode = "DE"; shipTo.Address = shipToAddress; shipTo.AttentionName = "DEF"; shipTo.Name = "DEF Associates"; ShipPhoneType shipToPhone = new ShipPhoneType(); shipToPhone.Number = "1234567890"; shipTo.Phone = shipToPhone; shipment.ShipTo = shipTo; ServiceType service = new ServiceType(); service.Code = "08"; shipment.Service = service; ShipmentTypeShipmentServiceOptions shpServiceOptions = new ShipmentTypeShipmentServiceOptions(); /** **** International Forms ***** */ InternationalFormType internationalForms = new InternationalFormType(); /** **** Commercial Invoice ***** */ String[] formTypeList = { "01" }; internationalForms.FormType = formTypeList; /** **** Contacts and Sold To ***** */ ContactType contacts = new ContactType(); SoldToType soldTo = new SoldToType(); soldTo.Option = "1"; soldTo.AttentionName = "Sold To Attn Name"; soldTo.Name = "Sold To Name"; PhoneType soldToPhone = new PhoneType(); soldToPhone.Number = "1234567890"; soldToPhone.Extension = "1234"; soldTo.Phone = soldToPhone; AddressType soldToAddress = new AddressType(); String[] soldToAddressLine = { "34 Queen St" }; soldToAddress.AddressLine = soldToAddressLine; soldToAddress.City = "Frankfurt"; soldToAddress.PostalCode = "60547"; soldToAddress.CountryCode = "DE"; soldTo.Address = soldToAddress; contacts.SoldTo = soldTo; internationalForms.Contacts = contacts; /** **** Product ***** */ ProductType product1 = new ProductType(); String[] description = { "Product 1" }; product1.Description = description; product1.CommodityCode = "111222AA"; product1.OriginCountryCode = "US"; UnitType unit = new UnitType(); unit.Number = "147"; unit.Value = "478"; UnitOfMeasurementType uomProduct = new UnitOfMeasurementType(); uomProduct.Code = "BOX"; uomProduct.Description = "BOX"; unit.UnitOfMeasurement = uomProduct; product1.Unit = unit; ProductWeightType productWeight = new ProductWeightType(); productWeight.Weight = "10"; UnitOfMeasurementType uomForWeight = new UnitOfMeasurementType(); uomForWeight.Code = "LBS"; uomForWeight.Description = "LBS"; productWeight.UnitOfMeasurement = uomForWeight; product1.ProductWeight = productWeight; ProductType[] productList = { product1 }; internationalForms.Product = productList; /** **** InvoiceNumber, InvoiceDate, PurchaseOrderNumber, TermsOfShipment, ReasonForExport, Comments and DeclarationStatement ***** */ internationalForms.InvoiceNumber = "asdf123"; internationalForms.InvoiceDate = "20151225"; internationalForms.PurchaseOrderNumber = "999jjj777"; internationalForms.TermsOfShipment = "CFR"; internationalForms.ReasonForExport = "Sale"; internationalForms.Comments = "Your Comments"; internationalForms.DeclarationStatement = "Your Declaration Statement"; /** **** Discount, FreightCharges, InsuranceCharges, OtherCharges and CurrencyCode ***** */ IFChargesType discount = new IFChargesType(); discount.MonetaryValue = "100"; internationalForms.Discount = discount; IFChargesType freight = new IFChargesType(); freight.MonetaryValue = "50"; internationalForms.FreightCharges = freight; IFChargesType insurance = new IFChargesType(); insurance.MonetaryValue = "200"; internationalForms.InsuranceCharges = insurance; OtherChargesType otherCharges = new OtherChargesType(); otherCharges.MonetaryValue = "50"; otherCharges.Description = "Misc"; internationalForms.OtherCharges = otherCharges; internationalForms.CurrencyCode = "USD"; shpServiceOptions.InternationalForms = internationalForms; shipment.ShipmentServiceOptions = shpServiceOptions; PackageType package = new PackageType(); PackageWeightType packageWeight = new PackageWeightType(); packageWeight.Weight = "10"; ShipUnitOfMeasurementType uom = new ShipUnitOfMeasurementType(); uom.Code = "LBS"; packageWeight.UnitOfMeasurement = uom; package.PackageWeight = packageWeight; PackagingType packType = new PackagingType(); packType.Code = "02"; package.Packaging = packType; PackageType[] pkgArray = { package }; shipment.Package = pkgArray; LabelSpecificationType labelSpec = new LabelSpecificationType(); LabelStockSizeType labelStockSize = new LabelStockSizeType(); labelStockSize.Height = "6"; labelStockSize.Width = "4"; labelSpec.LabelStockSize = labelStockSize; LabelImageFormatType labelImageFormat = new LabelImageFormatType(); labelImageFormat.Code = "GIF"; labelSpec.LabelImageFormat = labelImageFormat; shipmentRequest.LabelSpecification = labelSpec; shipmentRequest.Shipment = shipment; Console.WriteLine(shipmentRequest); System.Net.ServicePointManager.CertificatePolicy = new TrustAllCertificatePolicy(); ShipmentResponse shipmentResponse = shpSvc.ProcessShipment(shipmentRequest); Console.WriteLine("The transaction was a " + shipmentResponse.Response.ResponseStatus.Description); Console.WriteLine("The 1Z number of the new shipment is " + shipmentResponse.ShipmentResults.ShipmentIdentificationNumber); Console.ReadKey(); } catch (System.Web.Services.Protocols.SoapException ex) { Console.WriteLine(""); Console.WriteLine("---------Ship Web Service returns error----------------"); Console.WriteLine("---------\"Hard\" is user error \"Transient\" is system error----------------"); Console.WriteLine("SoapException Message= " + ex.Message); Console.WriteLine(""); Console.WriteLine("SoapException Category:Code:Message= " + ex.Detail.LastChild.InnerText); Console.WriteLine(""); Console.WriteLine("SoapException XML String for all= " + ex.Detail.LastChild.OuterXml); Console.WriteLine(""); Console.WriteLine("SoapException StackTrace= " + ex.StackTrace); Console.WriteLine("-------------------------"); Console.WriteLine(""); } catch (System.ServiceModel.CommunicationException ex) { Console.WriteLine(""); Console.WriteLine("--------------------"); Console.WriteLine("CommunicationException= " + ex.Message); Console.WriteLine("CommunicationException-StackTrace= " + ex.StackTrace); Console.WriteLine("-------------------------"); Console.WriteLine(""); } catch (Exception ex) { Console.WriteLine(""); Console.WriteLine("-------------------------"); Console.WriteLine(" General Exception= " + ex.Message); Console.WriteLine(" General Exception-StackTrace= " + ex.StackTrace); Console.WriteLine("-------------------------"); } finally { Console.ReadKey(); } }
private string PrintLabel() { try { ShipService shpSvc = new ShipService(); ShipmentRequest shipmentRequest = new ShipmentRequest(); UPSSecurity upss = new UPSSecurity(); UPSSecurityServiceAccessToken upssSvcAccessToken = new UPSSecurityServiceAccessToken(); upssSvcAccessToken.AccessLicenseNumber = hfLicense.Value; upss.ServiceAccessToken = upssSvcAccessToken; UPSSecurityUsernameToken upssUsrNameToken = new UPSSecurityUsernameToken(); upssUsrNameToken.Username = hfUserName.Value; upssUsrNameToken.Password = hfPassword.Value; upss.UsernameToken = upssUsrNameToken; shpSvc.UPSSecurityValue = upss; RequestType request = new RequestType(); String[] requestOption = { lblAddressValidation.Text.Trim() }; request.RequestOption = requestOption; shipmentRequest.Request = request; ShipmentType shipment = new ShipmentType(); shipment.Description = "CMS Label Printing"; ShipperType shipper = new ShipperType(); shipper.ShipperNumber = hfAccountNumber.Value; PaymentInfoType paymentInfo = new PaymentInfoType(); ShipmentChargeType shpmentCharge = new ShipmentChargeType(); BillShipperType billShipper = new BillShipperType(); billShipper.AccountNumber = hfAccountNumber.Value; shpmentCharge.BillShipper = billShipper; shpmentCharge.Type = lblChargeType.Text.Trim(); ShipmentChargeType[] shpmentChargeArray = { shpmentCharge }; paymentInfo.ShipmentCharge = shpmentChargeArray; shipment.PaymentInformation = paymentInfo; UPSShipWebReference.ShipAddressType shipperAddress = new UPSShipWebReference.ShipAddressType(); String[] addressLine = { lblFromStreet.Text.Trim() }; shipperAddress.AddressLine = addressLine; shipperAddress.City = lblFromCity.Text.Trim(); shipperAddress.PostalCode = lblFromZip.Text.Trim(); shipperAddress.StateProvinceCode = hfFromStateUPSCode.Value; shipperAddress.CountryCode = hfFromCountryUPSCode.Value; shipperAddress.AddressLine = addressLine; shipper.Address = shipperAddress; shipper.Name = lblFromName.Text.Trim(); shipper.AttentionName = lblFromName.Text.Trim(); ShipPhoneType shipperPhone = new ShipPhoneType(); shipperPhone.Number = lblFromPhone.Text.Trim(); shipper.Phone = shipperPhone; shipment.Shipper = shipper; ShipFromType shipFrom = new ShipFromType(); UPSShipWebReference.ShipAddressType shipFromAddress = new UPSShipWebReference.ShipAddressType(); String[] shipFromAddressLine = { lblFromStreet.Text.Trim() }; shipFromAddress.AddressLine = addressLine; shipFromAddress.City = lblFromCity.Text.Trim(); shipFromAddress.PostalCode = lblFromZip.Text.Trim(); shipFromAddress.StateProvinceCode = hfFromStateUPSCode.Value; shipFromAddress.CountryCode = hfFromCountryUPSCode.Value; shipFrom.Address = shipFromAddress; shipFrom.AttentionName = lblFromName.Text.Trim(); shipFrom.Name = lblFromName.Text.Trim(); shipment.ShipFrom = shipFrom; ShipToType shipTo = new ShipToType(); ShipToAddressType shipToAddress = new ShipToAddressType(); String[] addressLine1 = { lblToStreet.Text.Trim() }; shipToAddress.AddressLine = addressLine1; shipToAddress.City = lblToCity.Text.Trim(); shipToAddress.PostalCode = lblToZip.Text.Trim(); shipToAddress.StateProvinceCode = hfToStateUPSCode.Value; shipToAddress.CountryCode = hfToCountryUPSCode.Value; shipTo.Address = shipToAddress; shipTo.AttentionName = lblToName.Text.Trim(); shipTo.Name = lblToName.Text.Trim(); ShipPhoneType shipToPhone = new ShipPhoneType(); shipToPhone.Number = lblToPhone.Text.Trim(); shipTo.Phone = shipToPhone; shipment.ShipTo = shipTo; ServiceType service = new ServiceType(); service.Code = lblShipService.Text.Trim(); shipment.Service = service; PackageType package = new PackageType(); PackageWeightType packageWeight = new PackageWeightType(); packageWeight.Weight = lblWeight.Text.Trim(); ShipUnitOfMeasurementType uom = new ShipUnitOfMeasurementType(); uom.Code = lblMeasurementType.Text.Trim(); packageWeight.UnitOfMeasurement = uom; package.PackageWeight = packageWeight; PackagingType packType = new PackagingType(); packType.Code = lblPackagingType.Text.Trim(); package.Packaging = packType; PackageType[] pkgArray = { package }; shipment.Package = pkgArray; LabelSpecificationType labelSpec = new LabelSpecificationType(); LabelStockSizeType labelStockSize = new LabelStockSizeType(); labelStockSize.Height = "6"; labelStockSize.Width = "4"; labelSpec.LabelStockSize = labelStockSize; LabelImageFormatType labelImageFormat = new LabelImageFormatType(); labelImageFormat.Code = "GIF"; labelSpec.LabelImageFormat = labelImageFormat; shipmentRequest.LabelSpecification = labelSpec; shipmentRequest.Shipment = shipment; System.Net.ServicePointManager.CertificatePolicy = new TrustAllCertificatePolicy(); ShipmentResponse shipmentResponse = shpSvc.ProcessShipment(shipmentRequest); iTextSharp.text.Document doc = new iTextSharp.text.Document(); //Output to File string localPath = Server.MapPath("../Labels") + "\\" + shipmentResponse.ShipmentResults.ShipmentIdentificationNumber + ".pdf"; PdfWriter.GetInstance(doc, new FileStream(localPath, FileMode.Create)); doc.Open(); Byte[] labelBuffer = System.Convert.FromBase64String(shipmentResponse.ShipmentResults.PackageResults[0].ShippingLabel.GraphicImage); MemoryStream stream = new MemoryStream(labelBuffer); iTextSharp.text.Image gif = iTextSharp.text.Image.GetInstance(stream); gif.RotationDegrees = -90f; gif.ScalePercent(50f); stream.Close(); doc.NewPage(); doc.Add(gif); doc.Close(); MemoryStream output = new MemoryStream(); doc = new iTextSharp.text.Document(); PdfWriter.GetInstance(doc, output); doc.Open(); doc.NewPage(); doc.Add(gif); doc.Close(); (new OrderEntryDAL()).UploadShippingLabel_DAL("Shipping Label", output.ToArray(), "application/pdf", shipmentResponse.ShipmentResults.ShipmentIdentificationNumber + ".pdf", "", labelBuffer.Length, int.Parse(hfOrderId.Value), int.Parse(Session["UserID"].ToString())); output.Close(); return(shipmentResponse.ShipmentResults.ShipmentIdentificationNumber); } catch (System.Web.Services.Protocols.SoapException ex) { lblErr.Text = ex.Message; MPEPrepare.Show(); return(""); } catch (Exception ex) { lblErr.Text = ex.Message; MPEPrepare.Show(); return(""); } }
/// <summary> /// UpdateShipment /// Function to update the shipment details /// </summary> /// <param name="session">Session object</param> /// <param name="shipmentReq">ShipmentRequest object</param> /// <returns>ShipmentResponse object</returns> public static ShipmentResponse UpdateShipment(ISession session, ShipmentRequest shipmentReq, String VersionNo = "") { string ComponentsXML = string.Empty; string innerExceptionMsg = string.Empty; string exceptionMsg = string.Empty; using (StringWriter sw = new StringWriter()) { XmlSerializer xs = new XmlSerializer(typeof(List <ShipmentRequestComponents>)); xs.Serialize(sw, shipmentReq.Components); ComponentsXML = sw.ToString().Replace("utf-16", "utf-8"); } List <string> strBOLQtyVarianceReason = shipmentReq.Components.Select(item => item.BOLQtyVarianceReason).Distinct().ToList(); string BOLQtyVarianceReason = string.Empty; string netQtyVarianceReason = string.Empty; foreach (string reason in strBOLQtyVarianceReason) { if (!string.IsNullOrEmpty(reason)) { if (string.IsNullOrEmpty(BOLQtyVarianceReason)) { BOLQtyVarianceReason = reason; } else { BOLQtyVarianceReason = BOLQtyVarianceReason + ", "; BOLQtyVarianceReason = BOLQtyVarianceReason + reason; } } } //shipmentReq.Components.Select(item=>item.NetQtyVarianceReason).DistinctBy(item => item.NetQtyVarianceReason).ToList(); ShipmentResponse shipmentResponse = new ShipmentResponse(); //SqlCommand cmdAudit = (SqlCommand)session.CreateCommand(); //cmdAudit.CommandText = "Cloud_UpdateShipmentDetailsAuditLog"; //cmdAudit.CommandType = CommandType.StoredProcedure; //cmdAudit.Parameters.AddWithValue("@SysTrxNo", shipmentReq.SysTrxNo); //cmdAudit.Parameters.AddWithValue("@SysLineNo", shipmentReq.SysTrxLine); //cmdAudit.Parameters.AddWithValue("@ComponentsXML", ComponentsXML); //cmdAudit.Parameters.AddWithValue("@OrderLoadReviewEnabled", shipmentReq.OrderLoadReviewEnabled); //cmdAudit.ExecuteNonQuery(); SqlCommand cmd = (SqlCommand)session.CreateCommand(); cmd.CommandText = "Cloud_UpdateShipmentDetails"; cmd.CommandType = CommandType.StoredProcedure; cmd.Parameters.AddWithValue("@SysTrxNo", shipmentReq.SysTrxNo); cmd.Parameters.AddWithValue("@SysLineNo", shipmentReq.SysTrxLine); cmd.Parameters.AddWithValue("@ComponentsXML", ComponentsXML); cmd.Parameters.AddWithValue("@UserID", shipmentReq.UserID); cmd.Parameters.AddWithValue("@OrderLoadReviewEnabled", shipmentReq.OrderLoadReviewEnabled); cmd.Parameters.AddWithValue("@BOLQtyVarianceReason", BOLQtyVarianceReason); //2013.09.23 FSWW, Ramesh M Added For CR#60090 to push BolImage data to Ascend cmd.Parameters.AddWithValue("@BOLImage", shipmentReq.Components.Select(item => item.BOLImage).First()); //2014.01.28 Ramesh M Added For Support Multi BOL ites added ExtSysTrxLine For CR#62038 //cmd.Parameters.AddWithValue("@SupplierCode", shipmentReq.SupplierCode); //cmd.Parameters.AddWithValue("@SupplyPtCode", shipmentReq.SupplyPointCode); //cmd.Parameters.AddWithValue("@ExtSysLineNo", shipmentReq.ExtSysTrxLine); IDataReader dreader = null; try { dreader = cmd.ExecuteReader(); } catch (Exception ex) { shipmentResponse = new ShipmentResponse(); shipmentResponse.ErrorMessage = ex.Message + " - " + ex.StackTrace; Logging.LogError(ex); return(shipmentResponse); } if (dreader != null) { while (dreader.Read()) { shipmentResponse.ShipDocSysTrxNo = Convert.ToDecimal(dreader["ShipDocSysTrxNo"]); shipmentResponse.ShipDocSysTrxLine = Convert.ToInt32(dreader["ShipDocSysTrxLine"]); shipmentResponse.OrderLoadReviewEnabled = Convert.ToString(dreader["OrderLoadReviewEnabled"]).Equals("Y", StringComparison.CurrentCultureIgnoreCase); shipmentResponse.ErrorMessage = ""; } dreader.Close(); } if (!shipmentResponse.OrderLoadReviewEnabled && (shipmentResponse.ShipDocSysTrxNo <= 0 || shipmentResponse.ShipDocSysTrxLine <= 0)) { shipmentResponse = null; //throw new ApplicationException(String.Format("ShipDocSysTrxNo returned 0. Unable to update shipment details for SysTrxNo = {0}, SysLineNo={1} and UserID={2}", shipmentReq.SysTrxNo, shipmentReq.SysTrxLine, shipmentReq.UserID)); } return(shipmentResponse); }
static void Main() { try { ShipService shpSvc = new ShipService(); ShipmentRequest shipmentRequest = new ShipmentRequest(); UPSSecurity upss = new UPSSecurity(); UPSSecurityServiceAccessToken upssSvcAccessToken = new UPSSecurityServiceAccessToken(); upssSvcAccessToken.AccessLicenseNumber = "Your Access License"; upss.ServiceAccessToken = upssSvcAccessToken; UPSSecurityUsernameToken upssUsrNameToken = new UPSSecurityUsernameToken(); upssUsrNameToken.Username = "******"; upssUsrNameToken.Password = "******"; upss.UsernameToken = upssUsrNameToken; shpSvc.UPSSecurityValue = upss; RequestType request = new RequestType(); String[] requestOption = { "nonvalidate" }; request.RequestOption = requestOption; shipmentRequest.Request = request; ShipmentType shipment = new ShipmentType(); shipment.Description = "Ship webservice example"; ShipperType shipper = new ShipperType(); shipper.ShipperNumber = "Your Shipper Number"; PaymentInfoType paymentInfo = new PaymentInfoType(); ShipmentChargeType shpmentCharge = new ShipmentChargeType(); BillShipperType billShipper = new BillShipperType(); billShipper.AccountNumber = "Your Account Number"; shpmentCharge.BillShipper = billShipper; shpmentCharge.Type = "01"; ShipmentChargeType[] shpmentChargeArray = { shpmentCharge }; paymentInfo.ShipmentCharge = shpmentChargeArray; shipment.PaymentInformation = paymentInfo; ShipWSSample.ShipWebReference.ShipAddressType shipperAddress = new ShipWSSample.ShipWebReference.ShipAddressType(); String[] addressLine = { "480 Parkton Plaza" }; shipperAddress.AddressLine = addressLine; shipperAddress.City = "Timonium"; shipperAddress.PostalCode = "21093"; shipperAddress.StateProvinceCode = "MD"; shipperAddress.CountryCode = "US"; shipperAddress.AddressLine = addressLine; shipper.Address = shipperAddress; shipper.Name = "ABC Associates"; shipper.AttentionName = "ABC Associates"; ShipPhoneType shipperPhone = new ShipPhoneType(); shipperPhone.Number = "1234567890"; shipper.Phone = shipperPhone; shipment.Shipper = shipper; ShipFromType shipFrom = new ShipFromType(); ShipWSSample.ShipWebReference.ShipAddressType shipFromAddress = new ShipWSSample.ShipWebReference.ShipAddressType(); String[] shipFromAddressLine = { "Ship From Street" }; shipFromAddress.AddressLine = addressLine; shipFromAddress.City = "Timonium"; shipFromAddress.PostalCode = "21093"; shipFromAddress.StateProvinceCode = "MD"; shipFromAddress.CountryCode = "US"; shipFrom.Address = shipFromAddress; shipFrom.AttentionName = "Mr.ABC"; shipFrom.Name = "ABC Associates"; shipment.ShipFrom = shipFrom; ShipToType shipTo = new ShipToType(); ShipToAddressType shipToAddress = new ShipToAddressType(); String[] addressLine1 = { "Some Street" }; shipToAddress.AddressLine = addressLine1; shipToAddress.City = "Roswell"; shipToAddress.PostalCode = "30076"; shipToAddress.StateProvinceCode = "GA"; shipToAddress.CountryCode = "US"; shipTo.Address = shipToAddress; shipTo.AttentionName = "DEF"; shipTo.Name = "DEF Associates"; ShipPhoneType shipToPhone = new ShipPhoneType(); shipToPhone.Number = "1234567890"; shipTo.Phone = shipToPhone; shipment.ShipTo = shipTo; ServiceType service = new ServiceType(); service.Code = "01"; shipment.Service = service; PackageType package = new PackageType(); PackageWeightType packageWeight = new PackageWeightType(); packageWeight.Weight = "10"; ShipUnitOfMeasurementType uom = new ShipUnitOfMeasurementType(); uom.Code = "LBS"; packageWeight.UnitOfMeasurement = uom; package.PackageWeight = packageWeight; PackagingType packType = new PackagingType(); packType.Code = "02"; package.Packaging = packType; PackageType[] pkgArray = { package }; shipment.Package = pkgArray; LabelSpecificationType labelSpec = new LabelSpecificationType(); LabelStockSizeType labelStockSize = new LabelStockSizeType(); labelStockSize.Height = "6"; labelStockSize.Width = "4"; labelSpec.LabelStockSize = labelStockSize; LabelImageFormatType labelImageFormat = new LabelImageFormatType(); labelImageFormat.Code = "SPL"; labelSpec.LabelImageFormat = labelImageFormat; shipmentRequest.LabelSpecification = labelSpec; shipmentRequest.Shipment = shipment; Console.WriteLine(shipmentRequest); System.Net.ServicePointManager.CertificatePolicy = new TrustAllCertificatePolicy(); ShipmentResponse shipmentResponse = shpSvc.ProcessShipment(shipmentRequest); Console.WriteLine("The transaction was a " + shipmentResponse.Response.ResponseStatus.Description); Console.WriteLine("The 1Z number of the new shipment is " + shipmentResponse.ShipmentResults.ShipmentIdentificationNumber); Console.ReadKey(); } catch (System.Web.Services.Protocols.SoapException ex) { Console.WriteLine(""); Console.WriteLine("---------Ship Web Service returns error----------------"); Console.WriteLine("---------\"Hard\" is user error \"Transient\" is system error----------------"); Console.WriteLine("SoapException Message= " + ex.Message); Console.WriteLine(""); Console.WriteLine("SoapException Category:Code:Message= " + ex.Detail.LastChild.InnerText); Console.WriteLine(""); Console.WriteLine("SoapException XML String for all= " + ex.Detail.LastChild.OuterXml); Console.WriteLine(""); Console.WriteLine("SoapException StackTrace= " + ex.StackTrace); Console.WriteLine("-------------------------"); Console.WriteLine(""); } catch (System.ServiceModel.CommunicationException ex) { Console.WriteLine(""); Console.WriteLine("--------------------"); Console.WriteLine("CommunicationException= " + ex.Message); Console.WriteLine("CommunicationException-StackTrace= " + ex.StackTrace); Console.WriteLine("-------------------------"); Console.WriteLine(""); } catch (Exception ex) { Console.WriteLine(""); Console.WriteLine("-------------------------"); Console.WriteLine(" General Exception= " + ex.Message); Console.WriteLine(" General Exception-StackTrace= " + ex.StackTrace); Console.WriteLine("-------------------------"); } finally { Console.ReadKey(); } }