Ejemplo n.º 1
0
        public static Task EncodeTimbre417(Detalle d, TipoTask task)
        {
            return(Task.Run(() =>
            {
                string ted = null;
                switch (task)
                {
                case TipoTask.Creditor:
                    ted = d.DteInfoRefLast.FirmaDTE;
                    break;

                case TipoTask.Debtor:
                    DTEDefTypeDocumento doc = (DTEDefTypeDocumento)d.DTEDef.Item;
                    ted = HSerialize.TED_To_Xml(doc.TED);
                    break;
                }

                BarcodeWriter timbre417 = new BarcodeWriter
                {
                    Format = BarcodeFormat.PDF_417,
                    Options = new PDF417EncodingOptions()
                    {
                        ErrorCorrection = ZXing.PDF417.Internal.PDF417ErrorCorrectionLevel.L5,
                        Height = 3,
                        Width = 9,
                        Compaction = ZXing.PDF417.Internal.Compaction.BYTE
                    }
                };
                timbre417
                .Write(ted)
                .Save(Path.GetTempPath() + $"\\timbre{d.Folio}.png");
            }));
        }
Ejemplo n.º 2
0
        public async Task ConvertXmlToPdf(TipoTask task, List <Detalle> lista)
        {
            int c = 0;

            PgModel.StopWatch.Start();
            List <Task <IPdfDocument> > tareas = new List <Task <IPdfDocument> >();
            IPdfDocument pdfDocument           = null;
            string       path = @"C:\Centralizador\Pdf\" + UserParticipant.BusinessName;

            new CreateFile($"{path}");
            try
            {
                await Task.Run(() =>
                {
                    tareas = lista.Select(async item =>
                    {
                        if (item.DTEDef != null)
                        {
                            await HConvertToPdf.EncodeTimbre417(item, task).ContinueWith(async x =>
                            {
                                await HConvertToPdf.XmlToPdf(item, path);
                            });
                        }
                        c++;
                        float porcent = (float)(100 * c) / lista.Count;
                        await ReportProgress(porcent, $"Converting doc N° [{item.Folio}] to PDF.    ({c}/{lista.Count})");
                        return(pdfDocument);
                    }).ToList();
                });

                await Task.WhenAll(tareas).ContinueWith(x =>
                {
                    Process.Start(path);
                });
            }
            catch (Exception)
            {
                throw;
            }
            finally
            {
                // INFO
                PgModel.StopWatch.Stop();
            }
        }
Ejemplo n.º 3
0
        public async Task ConvertXmlToPdf(Detalle d, TipoTask task)
        {
            // INFO
            PgModel.StopWatch.Start();

            IPdfDocument pdfDocument = null;

            try
            {
                //TextInfo ti = CultureInfo.CurrentCulture.TextInfo;
                string path = @"C:\Centralizador\Pdf\" + UserParticipant.BusinessName;
                new CreateFile($"{path}");
                string nomenclatura = null;
                await Task.Run(async() =>
                {
                    if (d.DTEDef != null)
                    {
                        await HConvertToPdf.EncodeTimbre417(d, task);
                        nomenclatura = await HConvertToPdf.XmlToPdf(d, path);
                    }
                    return(pdfDocument);
                }).ContinueWith(x =>
                {
                    //string nomenclatura = d.Folio + "_" + ti.ToTitleCase(d.RznSocRecep.ToLower());
                    //Process.Start(path + "\\" + nomenclatura + ".pdf");
                    Process.Start(nomenclatura);
                });
            }
            catch (Exception)
            {
                throw;
            }
            finally
            {
                // INFO
                PgModel.StopWatch.Stop();
            }
        }
Ejemplo n.º 4
0
 public Task ConvertXmlToPdf(Detalle d, TipoTask task)
 {
     throw new NotImplementedException();
 }
Ejemplo n.º 5
0
 public Task ConvertXmlToPdf(TipoTask task, List <Detalle> lista)
 {
     throw new NotImplementedException();
 }