コード例 #1
0
 private void SaveLabelInfo(ShippingLabelInfo info)
 {
     try
     {
         AspxCommonInfo commonObj = new AspxCommonInfo();
         commonObj.StoreID  = _storeId;
         commonObj.PortalID = _portalId;
         commonObj.UserName = GetUsername;
         AspxShipProviderMgntController ctl = new AspxShipProviderMgntController();
         ctl.SaveShippingLabelInfo(info, commonObj);
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
コード例 #2
0
 private void GetLabelDetail(int orderId, int storeId, int portalId)
 {
     try
     {
         AspxShipProviderMgntController ctl = new AspxShipProviderMgntController();
         AspxCommonInfo commonObj           = new AspxCommonInfo();
         commonObj.StoreID  = storeId;
         commonObj.PortalID = portalId;
         ShippingLabelInfo detail = ctl.GetShippingLabelInfo(orderId, commonObj);
         DisplayFile(detail);
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
コード例 #3
0
    private void DisplayDetail(ShippingLabelInfo info)
    {
        StringBuilder builder = new StringBuilder();

        builder.Append("<table>");
        builder.Append("<tr><td>Shipping Label ID:</td><td>");
        builder.Append(info.ShippingLabelID);
        builder.Append("</td><tr/>");
        builder.Append("<tr><td>Barcode No:</td><td>");
        builder.Append(info.BarcodeNo);
        builder.Append("</td><tr/>");
        builder.Append("<tr><td>Tracking No:</td><td>");
        builder.Append(info.TrackingNo);
        builder.Append("<td></tr>");
        builder.Append("</table>");
        ltLabelDetail.Text = builder.ToString();
    }
コード例 #4
0
    private void DisplayFile(ShippingLabelInfo info)
    {
        string strExtenstion = info.Extension.ToLower();

        Response.Clear();
        Response.Buffer = true;
        if (strExtenstion == "doc" || strExtenstion == "docx")
        {
            Response.ContentType = "application/vnd.ms-word";
            //inline to view on browser and attachment to download
            Response.AddHeader("content-disposition", "inline;filename=_labelPreview.doc");
        }
        else if (strExtenstion == "xls" || strExtenstion == "xlsx")
        {
            Response.ContentType = "application/vnd.ms-excel";
            Response.AddHeader("content-disposition", "inline;filename=_labelPreview.xls");
        }
        else if (strExtenstion == "pdf")
        {
            Response.ContentType = "application/pdf";
            Response.AddHeader("content-disposition", "inline;filename=_labelPreview.pdf");
        }
        else if (strExtenstion == "tif")
        {
            Response.ContentType = "image/tiff";
            Response.AddHeader("content-disposition", "inline;filename=_labelPreview.tif");
        }
        else if (strExtenstion == "jpeg" || strExtenstion == "jpg")
        {
            Response.ContentType = "image/jpeg";
            Response.AddHeader("content-disposition", "inline;filename=_labelPreview.jpg");
        }
        else if (strExtenstion == "gif")
        {
            Response.ContentType = "image/gif";
            Response.AddHeader("content-disposition", "inline;filename=_labelPreview.gif");
        }
        Response.Charset = "";
        Response.Cache.SetCacheability(HttpCacheability.NoCache);
        // Response.WriteFile(fileInfo.FullName);

        Response.BinaryWrite(Convert.FromBase64String(info.ShippingLabelImage));
        Response.End();
    }
コード例 #5
0
    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;
        }
    }