Beispiel #1
0
        public static bool Already(this PostCardInfo postCardInfo)
        {
            if (!postCardInfo.IsImage)
            {
                return(false);
            }

            //如果是双面的,并且明信片没有设置反面样式,返回False
            if (postCardInfo.Parent.DoubleSide && (postCardInfo.BackStyle == null || string.IsNullOrEmpty(postCardInfo.BackStyle.FileId)))
            {
                return(false);
            }

            //如果正面样式没有设置,返回False
            if (postCardInfo.FrontStyle == null)
            {
                return(false);
            }

            //如果没有设置张数,返回False
            if (postCardInfo.Copy <= 0)
            {
                return(false);
            }

            //如果没有图片ID返回失败
            if (string.IsNullOrEmpty(postCardInfo.FileId))
            {
                return(false);
            }

            //都校验通过,返回成功
            return(true);
            //否则返回true
        }
        private void BarButtonItem14_ItemClick_1(object sender, ItemClickEventArgs e)
        {
            var tmpEnvelopeInfo = CurrentEnvelopeInfo;

            if (tmpEnvelopeInfo == null)
            {
                return;
            }

            var fileDialog = new OpenFileDialog
            {
                Multiselect      = true,
                InitialDirectory = tmpEnvelopeInfo.DirectoryInfo.FullName
            };

            if (fileDialog.ShowDialog(this) == DialogResult.OK)
            {
                fileDialog.FileNames.ForEach(
                    filePath =>
                {
                    var tmpPostCardInfo = new PostCardInfo(new FileInfo(filePath), tmpEnvelopeInfo);
                    tmpEnvelopeInfo.PostCards.Add(tmpPostCardInfo);
                    tmpEnvelopeInfo.OrderInfo.EnvelopeInfoList.Add(tmpPostCardInfo);
                    _postCardUploadWorker.Upload(tmpPostCardInfo, success => { timer1.Start(); });
                    //添加完成后,刷新列表
                    orderDetailListView.RefreshDataSource();
                }
                    );
            }
        }
 public void Upload(PostCardInfo postCardInfo, PostCardUploadHandler success,
                    PostCardUploadHandler failure = null)
 {
     Upload(new PostCardUploadContext
     {
         PostCardInfo = postCardInfo,
         Success      = success,
         Failure      = failure
     });
 }
 private void ReCropPostCard(PostCardInfo postCardInfo)
 {
     PostCardItemApi.ReCropPostCard(
         postCardInfo.PostCardId,
         response =>
     {
         postCardInfo.ProductFileId     = response.ProductFileId;
         postCardInfo.BackProductFileId = response.BackProductFileId;
         postCardInfo.ProcessStatusText = response.ProcessStatusText;
         PostCardChanged();
     });
 }
Beispiel #5
0
        public static OrderSubmitPostCard PrepareSubmitPostCard(this PostCardInfo postCard)
        {
            var orderSubmitPostCard = new OrderSubmitPostCard
            {
                Copy       = postCard.Copy,
                FileId     = postCard.FileId,
                FileName   = postCard.DirectoryInfo.Name,
                FrontStyle = postCard.FrontStyle
            };

            if (postCard.BackStyle == null)
            {
                return(orderSubmitPostCard);
            }
            orderSubmitPostCard.BackFileId = postCard.BackStyle.FileId;
            orderSubmitPostCard.BackStyle  = postCard.BackStyle.Name;
            return(orderSubmitPostCard);
        }
Beispiel #6
0
    public static PostCardInfo TranlateToPostCard(this PostCardResponse postCardResponse)
    {
        var result = new PostCardInfo
        {
            ProductFileId     = postCardResponse.ProductFileId,
            FileId            = postCardResponse.FileId,
            FileName          = postCardResponse.FileName,
            BackFileId        = postCardResponse.BackFileId,
            BackProductFileId = postCardResponse.BackProductFileId,
            BackStyle         = new BackStyleInfo
            {
                FileId = postCardResponse.BackFileId,
                Name   = postCardResponse.BackStyle
            },
            Copy              = postCardResponse.Copy,
            FrontStyle        = postCardResponse.FrontStyle,
            PostCardId        = postCardResponse.Id,
            ProcessorName     = postCardResponse.ProcessorName,
            ProcessStatusText = postCardResponse.ProcessStatusText,
            // ProcessStatus = (PostCardProcessStatusEnum) postCardResponse.ProcessStatus
        };

        return(result);
    }
        private void AddNewEnvelope(OrderInfo orderInfo, DirectoryInfo directoryInfo, EnvelopeInfo parentEnvelopeInfo = null)
        {
            var orderFolderFile = directoryInfo.GetFiles();
            var tmpEnvelopeInfo = new EnvelopeInfo(orderInfo, parentEnvelopeInfo)
            {
                DirectoryInfo = directoryInfo,
                DoubleSide    = !directoryInfo.FullName.Contains("单面")
            };

            orderInfo.EnvelopeInfoList.Add(tmpEnvelopeInfo);

            //将基准路径下的明信片添加到明信片集合中
            foreach (var fileInfo in orderFolderFile)
            {
                //AddEnvelopeInfo
                //如果非明信片文件扩展名集合中存在此文件路径,跳过到下一个
                if (Resources.notPostCardFileExtension.Contains(fileInfo.Extension))
                {
                    continue;
                }

                if (Resources.notPostCardFileExtension.Contains(fileInfo.Extension.ToLower()))
                {
                    continue;
                }

                if (fileInfo.Name.ToUpper().Contains("backgroundPicture".ToUpper()))
                {
                    if (tmpEnvelopeInfo.DoubleSide)
                    {
                        tmpEnvelopeInfo.BackStyle = new BackStyleInfo
                        {
                            Name = "自定义"
                        };
                        tmpEnvelopeInfo.FrontStyle = "D";
                        //此集合下的所有明信片都设置为D;
                        tmpEnvelopeInfo.PostCards.ForEach(postCard =>
                        {
                            postCard.FrontStyle = "D";
                            postCard.BackStyle  = tmpEnvelopeInfo.BackStyle;
                        });
                        fileInfo.UploadAsync(
                            "backStyle",
                            result => { tmpEnvelopeInfo.BackStyle.FileId = result.Id; },
                            failure: message => { XtraMessageBox.Show("反面文件上传失败,请重新上传"); });
                    }

                    continue;
                }

                var tmpPostCardInfo = new PostCardInfo(fileInfo, tmpEnvelopeInfo)
                {
                    BackStyle = tmpEnvelopeInfo.BackStyle
                };
                Application.DoEvents();
                //上传文件信息
                _postCardUploadWorker.Upload(tmpPostCardInfo, success => { timer1.Start(); });

                tmpEnvelopeInfo.PostCards.Add(tmpPostCardInfo);
                orderInfo.EnvelopeInfoList.Add(tmpPostCardInfo);
                orderDetailListView.RefreshDataSource();
                //展开所有
                if (gridView2.GetFocusedRow() == orderInfo)
                {
                    orderDetailListView.ExpandAll();
                }
            }


            //获取所有子文件夹
            var directories = directoryInfo.GetDirectories();

            //先递归处理子文件夹
            foreach (var tmpDirectoryInfo in directories)
            {
                Application.DoEvents();
                AddNewEnvelope(orderInfo, tmpDirectoryInfo, tmpEnvelopeInfo);
            }
        }