예제 #1
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();
            }
        }
예제 #2
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();
            }
        }