protected void btnTrack_Click(object sender, EventArgs e) { try { System.Net.ServicePointManager.Expect100Continue = false; var radiobuttonList = (RadioButtonList)Parent.FindControl("rblProviderList"); var providerId = int.Parse(radiobuttonList.SelectedValue); var usps = new USPS(); string trackingNo = txtTrackingNo.Text.Trim().Replace(" ", ""); txtTrackingNo.Text = trackingNo; AspxCommonInfo commonObj = new AspxCommonInfo(); commonObj.StoreID = GetStoreID; commonObj.PortalID = GetPortalID; var response = usps.GetTrackingInfo(trackingNo, providerId, commonObj); if (!response.IsFailed) { lblError.Text = ""; ShowResult(response); } else { dvTrackResponse.InnerHtml = ""; ShowError(response.Error); ShowMessage(SageMessageTitle.Exception.ToString(), response.Error, response.Error, SageMessageType.Error); } } catch (Exception ex) { ShowError(ex.Message); ProcessException(ex); } }
private void CreateLabel() { try { string api = rblLabelTypeList.SelectedValue; var items = (List<ItemDetail>)Session["sl_items"]; var orderInfo = (OrderLabel)Session["labelOrderInfo"]; if (items == null) { BindPackageDetails(orderInfo); items = (List<ItemDetail>)Session["sl_items"]; } var totalWt = items.Sum(itemDetail => itemDetail.Weight); if (totalWt == 0) { throw new Exception("Minimum weight of package must be 0.1"); } decimal totalWtInOunce = 0; if (_weightUnit.ToLower().Trim() == "lbs" || _weightUnit.ToLower().Trim() == "lb") { totalWtInOunce = (decimal)((totalWt) * 16); } else { totalWt = totalWt * (decimal)2.2; } var package = new USPSShipment(); package.Width = decimal.Parse(txtPackageWidth.Text.Trim()); package.Height = decimal.Parse(txtPackageHeight.Text.Trim()); package.FromAddress = (OriginAddress)Session["sl_frAddress"]; package.GrossOunce = totalWtInOunce; package.GrossPound = totalWt; var total = CalculateGirth(); package.Container = Container.RECTANGULAR; package.ContentType = ContentType.OTHER; package.ImageLayout = ImageLayout.ALLINONEFILE; package.ImageType = (ImageType)Enum.Parse(typeof(ImageType), ddlImageType.SelectedValue); package.Items = items; package.NonDeliveryOption = NonDeliveryOption.RETURN; package.Option = "1"; package.POZipCode = ""; package.ServiceType = (ServiceType)Enum.Parse(typeof(ServiceType), ddlServiceType.SelectedValue); package.ToAddress = (DestinationAddress)Session["sl_toAddress"]; package.Length = decimal.Parse(txtPackageLength.Text.Trim()); package.Grith = decimal.Parse(txtPackageGirth.Text.Trim()); package.Api = api; var providerId = int.Parse(Session["sl_pid"].ToString()); var labelCreater = new USPS(); var response = labelCreater.SendShipmentConfirmation(package, providerId, GetStoreID, GetPortalID); if (!response.IsFailed) { if (response.IsDomestic) { string trackingNo = response.DeliveryConfirmationNumber; ShippingLabelInfo info = new ShippingLabelInfo(); info.TrackingNo = trackingNo; info.ShippingLabelImage = response.LabelString; info.OrderID = orderInfo.OrderId; info.Extension = package.ImageType.ToString().ToLower(); info.IsRealTime = true; SaveLabelInfo(info); DisplayFile(response.TempLabelPath); lblErrorMessage.Text = ""; } else { string barcodeNo = response.IntlResponse.BarcodeNumber; ShippingLabelInfo info = new ShippingLabelInfo(); info.ShippingLabelImage = response.LabelString; info.OrderID = orderInfo.OrderId; info.Extension = package.ImageType.ToString().ToLower(); info.IsRealTime = true; info.TrackingNo = ""; info.BarcodeNo = barcodeNo; SaveLabelInfo(info); } ClearForm(); } else { lblErrorMessage.Text = response.Error; } } catch (Exception ex) { throw ex; } }