Esempio n. 1
0
        private static void SaveStreamToFileAndLink(TSI.Utils.Shipping.Endicia.EndiciaLabelService.LabelRequestResponse response, TSI.Utils.Shipping.Endicia.LabelRequestResponse result, string phyisicalPathToSave, string virtualPath, int orderId)
        {
            ILabel    label;
            ImageData i;

            ImageData[] image;
            int         num;

            result.Labels      = new List <ILabel>();
            result.CustomForms = new List <ILabel>();
            if (!Directory.Exists(phyisicalPathToSave))
            {
                Directory.CreateDirectory(phyisicalPathToSave);
            }
            try
            {
                if (!string.IsNullOrEmpty(response.Base64LabelImage))
                {
                    label = PrintLabelsClass.GetLabelData("L", orderId, response.TransactionDateTime, 0, phyisicalPathToSave, virtualPath);
                    PrintLabelsClass.SaveFile(label, response.Base64LabelImage);
                    result.Labels.Add(label);
                }
                if (response.Label != null)
                {
                    image = response.Label.Image;
                    for (num = 0; num < (int)image.Length; num++)
                    {
                        i     = image[num];
                        label = PrintLabelsClass.GetLabelData("L", orderId, response.TransactionDateTime, i.PartNumber, phyisicalPathToSave, virtualPath);
                        PrintLabelsClass.SaveFile(label, i.Value);
                        result.Labels.Add(label);
                    }
                }
                if (response.CustomsForm != null)
                {
                    image = response.CustomsForm.Image;
                    for (num = 0; num < (int)image.Length; num++)
                    {
                        i     = image[num];
                        label = PrintLabelsClass.GetLabelData("C", orderId, response.TransactionDateTime, i.PartNumber, phyisicalPathToSave, virtualPath);
                        PrintLabelsClass.SaveFile(label, i.Value);
                        result.Labels.Add(label);
                    }
                }
            }
            catch (Exception exception)
            {
            }
        }
Esempio n. 2
0
 public static ILabelRequestResponse ConstructLabelResponse(TSI.Utils.Shipping.Endicia.EndiciaLabelService.LabelRequestResponse response, ILabelRequestRequest request)
 {
     TSI.Utils.Shipping.Endicia.LabelRequestResponse result = new TSI.Utils.Shipping.Endicia.LabelRequestResponse();
     if (response.Status != 0)
     {
         result.ErrorMessage = response.ErrorMessage;
         result.Status       = TransactionResultEnum.Failed;
     }
     else
     {
         result.Status         = TransactionResultEnum.Succeed;
         result.ErrorMessage   = response.ErrorMessage;
         result.CostCenter     = response.CostCenter;
         result.CustomNumber   = response.CustomsNumber;
         result.FinalPostage   = response.FinalPostage;
         result.ReferenceId    = response.ReferenceID;
         result.TransactionId  = response.TransactionID;
         result.PostmarkDate   = response.PostmarkDate;
         result.TrackingNumber = response.TrackingNumber;
         PrintLabelsClass.SaveStreamToFileAndLink(response, result, request.PhyisicalPathToSave, request.VirtualPath, request.OrderId);
     }
     return(result);
 }