Пример #1
0
        private async void ImageToPdfConverter(UserDocsClient userDocClient)
        {
            if (userDocClient._DocumentType != FileextensionsTypes.JPEG || userDocClient._DocumentType != FileextensionsTypes.PNG)
            {
                if (UnicontaMessageBox.Show(Uniconta.ClientTools.Localization.lookup("AreYouSureToContinue"),
                                            Uniconta.ClientTools.Localization.lookup("Confirmation"), MessageBoxButton.YesNo, MessageBoxImage.Question) == MessageBoxResult.No)
                {
                    return;
                }

                busyIndicator.IsBusy = true;
                var userDoc = await UtilDisplay.GetUserDocDataOrUrl(userDocClient, api);

                var pdfBytes = UtilDisplay.ConvertImageSourceToPDF(userDoc._Data);

                if (pdfBytes == null || pdfBytes.Length == 0)
                {
                    busyIndicator.IsBusy = false;
                    UnicontaMessageBox.Show(Uniconta.ClientTools.Localization.lookup("PdfStreamfailed"), Uniconta.ClientTools.Localization.lookup("Error"));
                    return;
                }

                //To save any information on the editable grid
                saveGrid();

                userDocClient._DocumentType = FileextensionsTypes.PDF;
                userDocClient._Data         = pdfBytes;
                var result = await api.Update(userDocClient);

                if (result != ErrorCodes.Succes)
                {
                    UtilDisplay.ShowErrorCode(result);
                }
                else
                {
                    dgDocsGrid.Filter(null);
                }
            }
            else
            {
                UnicontaMessageBox.Show(Uniconta.ClientTools.Localization.lookup("ConversionNotSupport"), Uniconta.ClientTools.Localization.lookup("Warning"));
            }
        }