public HorarioRpt GetHorarioReport(HorarioInfo item,
                                           bool alumno,
                                           /*bool autorizado,*/
                                           ClaseTeoricaList teoricas,
                                           List <ClasePracticaList> practicas,
                                           ClaseExtraList extras,
                                           InstructorList instructores,
                                           ModuloList modulos,
                                           ListaSesiones sesiones,
                                           bool print_timestamp,
                                           DateTime timestamp)
        {
            if (item == null)
            {
                return(null);
            }

            HorarioRpt doc = new HorarioRpt();

            if (instructores == null)
            {
                instructores = InstructorList.GetList(false);
            }
            if (modulos == null)
            {
                modulos = ModuloList.GetList(false);
            }

            List <HorarioPrint> pList = new List <HorarioPrint>();

            pList.Add(item.GetPrintObject(instructores, modulos));

            doc.SetDataSource(pList);

            FormatReport(doc, sesiones, alumno /*, autorizado*/, teoricas, practicas, extras /*, instructores*/);

            if (print_timestamp)
            {
                doc.SetParameterValue("Timestamp", timestamp.ToString("dd/MM/yy HH:mm:ss"));
            }
            else
            {
                doc.SetParameterValue("Timestamp", string.Empty);
            }


            return(doc);
        }
        private static void FormatReport(HorarioRpt rpt,
                                         ListaSesiones list,
                                         bool alumnos,
                                         /*bool autorizado,*/
                                         ClaseTeoricaList teoricas,
                                         List <ClasePracticaList> practicas,
                                         ClaseExtraList extras /*,
                                                                * InstructorList instructores*/)
        {
            List <string> lista = new List <string>();

            lista.Add("Lunes8AM");
            lista.Add("Lunes");
            lista.Add("Lunes2");
            lista.Add("Lunes3");
            lista.Add("Lunes4");
            lista.Add("Lunes5");
            lista.Add("Lunes6");
            lista.Add("Lunes7");
            lista.Add("Lunes8");
            lista.Add("Lunes9");
            lista.Add("Lunes10");
            lista.Add("Lunes11");
            lista.Add("Lunes12");
            lista.Add("Lunes13");

            lista.Add("Martes8AM");
            lista.Add("Martes");
            lista.Add("Martes2");
            lista.Add("Martes3");
            lista.Add("Martes4");
            lista.Add("Martes5");
            lista.Add("Martes6");
            lista.Add("Martes7");
            lista.Add("Martes8");
            lista.Add("Martes9");
            lista.Add("Martes10");
            lista.Add("Martes11");
            lista.Add("Martes12");
            lista.Add("Martes13");

            lista.Add("Miercoles8AM");
            lista.Add("Miercoles");
            lista.Add("Miercoles2");
            lista.Add("Miercoles3");
            lista.Add("Miercoles4");
            lista.Add("Miercoles5");
            lista.Add("Miercoles6");
            lista.Add("Miercoles7");
            lista.Add("Miercoles8");
            lista.Add("Miercoles9");
            lista.Add("Miercoles10");
            lista.Add("Miercoles12");
            lista.Add("Miercoles11");
            lista.Add("Miercoles13");

            lista.Add("Jueves8AM");
            lista.Add("Jueves");
            lista.Add("Jueves2");
            lista.Add("Jueves3");
            lista.Add("Jueves4");
            lista.Add("Jueves5");
            lista.Add("Jueves6");
            lista.Add("Jueves7");
            lista.Add("Jueves8");
            lista.Add("Jueves9");
            lista.Add("Jueves10");
            lista.Add("Jueves11");
            lista.Add("Jueves12");
            lista.Add("Jueves13");

            lista.Add("Viernes8AM");
            lista.Add("Viernes");
            lista.Add("Viernes2");
            lista.Add("Viernes3");
            lista.Add("Viernes4");
            lista.Add("Viernes5");
            lista.Add("Viernes6");
            lista.Add("Viernes7");
            lista.Add("Viernes8");
            lista.Add("Viernes9");
            lista.Add("Viernes10");
            lista.Add("Viernes11");
            lista.Add("Viernes12");
            lista.Add("Viernes13");

            lista.Add("Sabado");
            lista.Add("Sabado2");
            lista.Add("Sabado3");
            lista.Add("Sabado4");
            lista.Add("Sabado5");

            InstructorList instructores = InstructorList.GetList(true);

            int    ultimo   = 0;
            int    n_clases = 0;
            string aux      = string.Empty;

            foreach (SesionAuxiliar info in list)
            {
                int indice = list.IndexOf(info);

                //si la sesión no tienen ninguna clase asignada, se elimina la etiqueta
                if (info.OidClaseTeorica <= 0 &&
                    info.OidClasePractica == 0 &&
                    info.OidClaseExtra == 0)
                {
                    rpt.SetParameterValue(lista[indice], "");
                    ((FieldObject)(rpt.Section3.ReportObjects[lista[indice]])).ObjectFormat.EnableSuppress = true;
                }
                else
                {
                    //si la sesión tiene una clase asignada una clase teórica
                    if (info.OidClaseTeorica != 0)
                    {
                        ClaseTeoricaInfo teorica = teoricas.GetItem(info.OidClaseTeorica);
                        //si no es la primera clase del día
                        //se comprueba si pertenece a la misma clase que la hora anterior
                        if (indice % 14 != 0 && list[indice - 1].OidClaseTeorica > 0)
                        {
                            bool misma_clase = false;
                            if (teorica.OidModulo ==
                                teoricas.GetItem(list[indice - 1].OidClaseTeorica).OidModulo &&
                                teorica.OidSubmodulo ==
                                teoricas.GetItem(list[indice - 1].OidClaseTeorica).OidSubmodulo &&
                                info.OidProfesor == list[indice - 1].OidProfesor)
                            {
                                misma_clase = true;
                                rpt.SetParameterValue(lista[indice], "");
                                ((FieldObject)(rpt.Section3.ReportObjects[lista[indice]])).ObjectFormat.EnableSuppress = true;
                                if (!alumnos)
                                {
                                    InstructorInfo item       = instructores.GetItem(info.OidProfesor);
                                    string         instructor = item.Alias;
                                    instructor += Environment.NewLine;
                                    int ind = aux.IndexOf(instructor);
                                    if (ind == -1)
                                    {
                                        misma_clase = false;
                                    }
                                }
                                else
                                {
                                    aux = Environment.NewLine + aux;
                                }
                                if (misma_clase)
                                {
                                    ((FieldObject)(rpt.Section3.ReportObjects[lista[ultimo]])).Height = ((FieldObject)(rpt.Section3.ReportObjects[lista[ultimo]])).Height + 720;
                                    rpt.SetParameterValue(lista[ultimo], aux);
                                    if (n_clases == 1)
                                    {
                                        ((FieldObject)(rpt.Section3.ReportObjects[lista[ultimo]])).Top += 80;
                                    }
                                    n_clases++;
                                }
                            }
                            if (!misma_clase)
                            {
                                ModuloInfo modulo = ModuloInfo.Get(teorica.OidModulo, false);
                                aux  = Environment.NewLine + modulo.Alias + Environment.NewLine;
                                aux += teorica.Submodulo + Environment.NewLine;
                                if (!alumnos)
                                {
                                    InstructorInfo item       = instructores.GetItem(info.OidProfesor);
                                    string         instructor = item.Alias;
                                    instructor += Environment.NewLine;
                                    aux        += instructor;
                                }
                                ((FieldObject)(rpt.Section3.ReportObjects[lista[indice]])).ObjectFormat.EnableSuppress = false;
                                ((FieldObject)(rpt.Section3.ReportObjects[lista[indice]])).Top -= 80;
                                rpt.SetParameterValue(lista[indice], aux);
                                ultimo   = indice;
                                n_clases = 1;
                            }
                        }
                        else
                        {
                            ModuloInfo modulo = ModuloInfo.Get(teorica.OidModulo, false);
                            aux  = Environment.NewLine + modulo.Alias + Environment.NewLine;
                            aux += teorica.Submodulo + Environment.NewLine;
                            if (!alumnos)
                            {
                                InstructorInfo item       = instructores.GetItem(info.OidProfesor);
                                string         instructor = item.Alias;
                                instructor += Environment.NewLine;
                                aux        += instructor;
                            }
                            ((FieldObject)(rpt.Section3.ReportObjects[lista[indice]])).ObjectFormat.EnableSuppress = false;
                            ((FieldObject)(rpt.Section3.ReportObjects[lista[indice]])).Top -= 80;
                            rpt.SetParameterValue(lista[indice], aux);
                            ultimo   = indice;
                            n_clases = 1;
                        }
                    }
                    else
                    {
                        if (info.OidClasePractica != 0)
                        {
                            ClasePracticaInfo practica = practicas[(int)info.Grupo].GetItem(info.OidClasePractica);
                            //if (indice % 14 != 0)
                            {
                                int  ind_aux  = 1;
                                bool esta     = false;
                                bool anterior = false;

                                //if (indice % 14 != 0)
                                //{
                                while (ind_aux < 5 && (indice - ind_aux) >= 0 && (indice - ind_aux) % 14 < indice % 14)
                                {
                                    if (list[indice - ind_aux].OidClasePractica != 0 &&
                                        practica.OidModulo ==
                                        practicas[(int)list[indice - ind_aux].Grupo].GetItem(list[indice - ind_aux].OidClasePractica).OidModulo &&
                                        info.OidProfesor == list[indice - ind_aux].OidProfesor &&
                                        info.Grupo == list[indice - ind_aux].Grupo)       //comprobación de grupo por si fuera la misma práctica para los dos grupos
                                    {
                                        esta = true;
                                        break;
                                    }
                                    if (list[indice - ind_aux].OidClasePractica != 0)
                                    {
                                        anterior = true;
                                    }
                                    ind_aux++;
                                }

                                ind_aux = 1;
                                bool posterior = false;
                                while (ind_aux < 5 && (indice + ind_aux) % 14 > indice % 14 && (indice + ind_aux) < 75)
                                {
                                    if (list[indice + ind_aux].OidClasePractica != 0 &&
                                        list[indice + ind_aux].OidClasePractica != list[indice].OidClasePractica)
                                    {
                                        posterior = true;
                                    }
                                    ind_aux++;
                                }
                                //}

                                if (!esta)
                                {
                                    aux  = Environment.NewLine + practica.Modulo + Environment.NewLine;
                                    aux += practica.Alias + " G" + list[indice].Grupo.ToString() + Environment.NewLine;
                                    if (!alumnos)
                                    {
                                        InstructorInfo item       = instructores.GetItem(info.OidProfesor);
                                        string         instructor = item.Alias;
                                        instructor += Environment.NewLine;
                                        aux        += instructor;
                                        aux        += Environment.NewLine;
                                        aux        += "5H";
                                    }
                                    rpt.SetParameterValue(lista[indice], aux);
                                    if (!anterior)
                                    {
                                        if (posterior)
                                        {
                                            ((FieldObject)(rpt.Section3.ReportObjects[lista[indice]])).Height = 1560;
                                        }
                                        else
                                        {
                                            ((FieldObject)(rpt.Section3.ReportObjects[lista[indice]])).Height = 3200;
                                        }
                                    }
                                    else
                                    {
                                        int top = 0;
                                        int i   = 1;
                                        while (i < 5 && indice - i >= 0)
                                        {
                                            if (!((FieldObject)(rpt.Section3.ReportObjects[lista[indice - i]])).ObjectFormat.EnableSuppress)
                                            {
                                                top = ((FieldObject)(rpt.Section3.ReportObjects[lista[indice - i]])).Top + 1560 + 240;
                                                break;
                                            }
                                            i++;
                                        }
                                        ((FieldObject)(rpt.Section3.ReportObjects[lista[indice]])).Height = 1560;
                                        ((FieldObject)(rpt.Section3.ReportObjects[lista[indice]])).Top    = top;
                                    }
                                    ((FieldObject)(rpt.Section3.ReportObjects[lista[indice]])).ObjectFormat.EnableSuppress = false;
                                }
                                else
                                {
                                    rpt.SetParameterValue(lista[indice], "");
                                    ((FieldObject)(rpt.Section3.ReportObjects[lista[indice]])).ObjectFormat.EnableSuppress = true;
                                }
                            }
                        }
                        else
                        {
                            ClaseExtraInfo extra = extras.GetItem(info.OidClaseExtra);
                            //si no es la primera clase del día
                            //se comprueba si pertenece a la misma clase que la hora anterior
                            if (indice % 14 != 0 && list[indice - 1].OidClaseExtra > 0)
                            {
                                bool misma_clase = false;
                                if (extra.OidModulo ==
                                    extras.GetItem(list[indice - 1].OidClaseExtra).OidModulo &&
                                    extra.OidSubmodulo ==
                                    extras.GetItem(list[indice - 1].OidClaseExtra).OidSubmodulo &&
                                    info.OidProfesor == list[indice - 1].OidProfesor)
                                {
                                    misma_clase = true;
                                    rpt.SetParameterValue(lista[indice], "");
                                    ((FieldObject)(rpt.Section3.ReportObjects[lista[indice]])).ObjectFormat.EnableSuppress = true;
                                    if (!alumnos)
                                    {
                                        InstructorInfo item       = instructores.GetItem(info.OidProfesor);
                                        string         instructor = item.Alias;
                                        instructor += Environment.NewLine;
                                        int ind = aux.IndexOf(instructor);
                                        if (ind == -1)
                                        {
                                            misma_clase = false;
                                        }
                                    }
                                    else
                                    {
                                        aux = Environment.NewLine + aux;
                                    }

                                    if (misma_clase)
                                    {
                                        ((FieldObject)(rpt.Section3.ReportObjects[lista[ultimo]])).Height = ((FieldObject)(rpt.Section3.ReportObjects[lista[ultimo]])).Height + 720;
                                        rpt.SetParameterValue(lista[ultimo], aux);
                                        if (n_clases == 1)
                                        {
                                            ((FieldObject)(rpt.Section3.ReportObjects[lista[ultimo]])).Top += 80;
                                        }
                                        n_clases++;
                                    }
                                }
                                if (!misma_clase)
                                {
                                    ModuloInfo modulo = ModuloInfo.Get(extra.OidModulo, false);
                                    aux  = Environment.NewLine + modulo.Alias + Environment.NewLine;
                                    aux += extra.Submodulo + Environment.NewLine;
                                    if (!alumnos)
                                    {
                                        InstructorInfo item       = instructores.GetItem(info.OidProfesor);
                                        string         instructor = item.Alias;
                                        instructor += Environment.NewLine;
                                        aux        += instructor;
                                    }
                                    ((FieldObject)(rpt.Section3.ReportObjects[lista[indice]])).ObjectFormat.EnableSuppress = false;
                                    ((FieldObject)(rpt.Section3.ReportObjects[lista[indice]])).Top -= 80;
                                    rpt.SetParameterValue(lista[indice], aux);
                                    ultimo   = indice;
                                    n_clases = 1;
                                }
                            }
                            else
                            {
                                ModuloInfo modulo = ModuloInfo.Get(extra.OidModulo, false);
                                aux  = Environment.NewLine + modulo.Alias + Environment.NewLine;
                                aux += extra.Submodulo + Environment.NewLine;
                                if (!alumnos)
                                {
                                    InstructorInfo item       = instructores.GetItem(info.OidProfesor);
                                    string         instructor = item.Alias;
                                    instructor += Environment.NewLine;
                                    aux        += instructor;
                                }
                                ((FieldObject)(rpt.Section3.ReportObjects[lista[indice]])).ObjectFormat.EnableSuppress = false;
                                ((FieldObject)(rpt.Section3.ReportObjects[lista[indice]])).Top -= 80;
                                rpt.SetParameterValue(lista[indice], aux);
                                ultimo   = indice;
                                n_clases = 1;
                            }
                        }
                    }
                }
            }
        }
        /// <summary>Imprime la lista del objetos
        /// <returns>void</returns>
        /// </summary>
        public override void PrintList()
        {
            ETipoImpresionCronograma tipo = ETipoImpresionCronograma.Lista;
            SelectEnumInputForm      form = new SelectEnumInputForm(true);

            form.SetDataSource(Library.Instruction.EnumText <ETipoImpresionCronograma> .GetList(false, false, false));
            form.ShowDialog(this);

            if (form.ActionResult == DialogResult.OK)
            {
                ComboBoxSource combo = form.Selected as ComboBoxSource;
                tipo = (ETipoImpresionCronograma)combo.Oid;
            }

            ClaseTeoricaList         teoricas        = ClaseTeoricaList.GetList();
            ClasePracticaList        practicas       = ClasePracticaList.GetList(false);
            List <ClasePracticaList> lista_practicas = new List <ClasePracticaList>();

            lista_practicas.Add(null);
            lista_practicas.Add(practicas);
            lista_practicas.Add(practicas);
            ModuloList modulos = ModuloList.GetList(false);

            CronogramaReportMng reportMng = new CronogramaReportMng(AppContext.ActiveSchema);
            CronogramaRpt       report    = null;

            switch (FilterType)
            {
            case IFilterType.None:
                if (tipo == ETipoImpresionCronograma.Lista)
                {
                    bool        defecto = moleQule.Library.Instruction.ModulePrincipal.GetImpresionEmpresaDefaultBoolSetting();
                    CompanyInfo empresa = null;

                    if (defecto)
                    {
                        empresa = CompanyInfo.Get(moleQule.Library.Instruction.ModulePrincipal.GetImpresionEmpresaDefaultOidSetting(), false);
                    }
                    while (empresa == null)
                    {
                        moleQule.Face.Common.CompanySelectForm sform = new Common.CompanySelectForm(this);
                        DialogResult result = sform.ShowDialog();

                        try
                        {
                            if (result == DialogResult.OK)
                            {
                                empresa = form.Selected as CompanyInfo;
                            }
                        }
                        catch
                        { empresa = null; }
                    }

                    report = reportMng.GetCronogramaReport(_cronograma, empresa, modulos, teoricas, practicas, _sorted_list);

                    if (report != null)
                    {
                        report.SetParameterValue("Empresa", empresa.Name);
                        if (empresa.Oid == 2)
                        {
                            ((CrystalDecisions.CrystalReports.Engine.TextObject)(report.Section5.ReportObjects["Text1"])).Color = System.Drawing.Color.FromArgb(13, 176, 46);
                        }
                        ReportViewer.SetReport(report);
                        ReportViewer.ShowDialog();
                    }
                    else
                    {
                        MessageBox.Show(Resources.Messages.NO_DATA_REPORTS,
                                        moleQule.Face.Resources.Labels.ADVISE_TITLE,
                                        MessageBoxButtons.OK,
                                        MessageBoxIcon.Exclamation);
                    }
                }
                else
                {
                    Dictionary <Horario, ListaSesiones> horarios = Cronograma.GetHorarios(_sorted_list, teoricas, practicas);

                    if (horarios.Count > 0)
                    {
                        PgMng.Reset(horarios.Count + 5, 1, Resources.Messages.LOADING_DATA, this);

                        try
                        {
                            InstructorList instructores = InstructorList.GetList(false);
                            PgMng.Grow();

                            //EntidadInfo entidad = EntidadInfo.Get(typeof(Promocion), true);
                            //Agente agente = null;

                            //PromocionInfo promocion = PromocionInfo.Get(_cronograma.OidPromocion, true);

                            //if (entidad.Agentes.GetItemByProperty("OidAgenteExt", promocion.Oid) != null)
                            //    agente = Agente.Get(typeof(Promocion), promocion);
                            //else
                            //{
                            //    agente = Agente.New();
                            //    agente.CopyFrom(entidad, promocion);
                            //    agente.Codigo = agente.GetCode();
                            //}

                            PgMng.Grow();

                            string       sFile = "C:\\cronograma.pdf";
                            FileStream   fs    = new FileStream(sFile, FileMode.Create, FileAccess.Write, FileShare.None);
                            Document     doc   = new Document();
                            PdfSmartCopy copy  = new PdfSmartCopy(doc, fs);

                            doc.Open();

                            foreach (KeyValuePair <Horario, ListaSesiones> item in horarios)
                            {
                                item.Key.OidPlan      = _cronograma.OidPlan;
                                item.Key.OidPromocion = _cronograma.OidPromocion;
                                HorarioRpt rpt    = reportMng.GetHorarioReport(item.Key.GetInfo(false), true, teoricas, lista_practicas, null, instructores, modulos, item.Value, false, DateTime.Now);
                                PdfReader  reader = new PdfReader(rpt.ExportToStream(ExportFormatType.PortableDocFormat));
                                copy.AddPage(copy.GetImportedPage(reader, 1));
                                rpt.Close();
                                rpt.Dispose();
                                PgMng.Grow();
                            }

                            doc.Close();

                            System.Diagnostics.Process process = new System.Diagnostics.Process();
                            process.StartInfo.FileName = sFile;
                            process.Start();
                            try
                            {
                                process.WaitForExit();
                            }
                            catch { }
                            PgMng.Grow();

                            //Documento documento = Documento.New();
                            //documento.Fecha = DateTime.Now;
                            //documento.FechaAlta = DateTime.Now;
                            //documento.Nombre = documento.Fecha.ToString("yyyyMMdd") + "_CRONOGRAMA";
                            //documento.Ruta = "C:\\";
                            //documento.Tipo = "PDF";


                            //AgenteDocumento agente_documento = agente.Documentos.NewItem(agente);
                            //agente_documento.OidDocumento = documento.Oid;

                            //agente.Save();
                        }
                        catch (Exception ex) { throw ex; }
                        finally { PgMng.FillUp(); }
                    }
                }
                break;

            case IFilterType.Filter:
                if (tipo == ETipoImpresionCronograma.Lista)
                {
                    bool        defecto = moleQule.Library.Instruction.ModulePrincipal.GetImpresionEmpresaDefaultBoolSetting();
                    CompanyInfo empresa = null;

                    if (defecto)
                    {
                        empresa = CompanyInfo.Get(moleQule.Library.Instruction.ModulePrincipal.GetImpresionEmpresaDefaultOidSetting(), false);
                    }
                    while (empresa == null)
                    {
                        moleQule.Face.Common.CompanySelectForm sform = new Common.CompanySelectForm(this);
                        DialogResult result = sform.ShowDialog();

                        try
                        {
                            if (result == DialogResult.OK)
                            {
                                empresa = form.Selected as CompanyInfo;
                            }
                        }
                        catch
                        { empresa = null; }
                    }

                    report = reportMng.GetCronogramaReport(_cronograma, empresa, modulos, teoricas, practicas, _filter_results);

                    if (report != null)
                    {
                        report.SetParameterValue("Empresa", empresa.Name);
                        if (empresa.Oid == 2)
                        {
                            ((CrystalDecisions.CrystalReports.Engine.TextObject)(report.Section5.ReportObjects["Text1"])).Color = System.Drawing.Color.FromArgb(13, 176, 46);
                        }
                        ReportViewer.SetReport(report);
                        ReportViewer.ShowDialog();
                    }
                    else
                    {
                        MessageBox.Show(Resources.Messages.NO_DATA_REPORTS,
                                        moleQule.Face.Resources.Labels.ADVISE_TITLE,
                                        MessageBoxButtons.OK,
                                        MessageBoxIcon.Exclamation);
                    }
                }
                else
                {
                    Dictionary <Horario, ListaSesiones> horarios = Cronograma.GetHorarios(_filter_results, teoricas, practicas);

                    if (horarios.Count > 0)
                    {
                        PgMng.Reset(horarios.Count + 5, 1, Resources.Messages.LOADING_DATA, this);

                        try
                        {
                            InstructorList instructores = InstructorList.GetList(false);
                            PgMng.Grow();

                            //EntidadInfo entidad = EntidadInfo.Get(typeof(Promocion), true);
                            //Agente agente = null;

                            //PromocionInfo promocion = PromocionInfo.Get(_cronograma.OidPromocion, true);

                            //if (entidad.Agentes.GetItemByProperty("OidAgenteExt", promocion.Oid) != null)
                            //    agente = Agente.Get(typeof(Promocion), promocion);
                            //else
                            //{
                            //    agente = Agente.New();
                            //    agente.CopyFrom(entidad, promocion);
                            //    agente.Codigo = agente.GetCode();
                            //}

                            PgMng.Grow();

                            string       sFile = "C:\\cronograma.pdf";
                            FileStream   fs    = new FileStream(sFile, FileMode.Create, FileAccess.Write, FileShare.None);
                            Document     doc   = new Document();
                            PdfSmartCopy copy  = new PdfSmartCopy(doc, fs);

                            doc.Open();

                            foreach (KeyValuePair <Horario, ListaSesiones> item in horarios)
                            {
                                item.Key.OidPlan      = _cronograma.OidPlan;
                                item.Key.OidPromocion = _cronograma.OidPromocion;
                                HorarioRpt rpt    = reportMng.GetHorarioReport(item.Key.GetInfo(false), true, teoricas, lista_practicas, null, instructores, modulos, item.Value, false, DateTime.Now);
                                PdfReader  reader = new PdfReader(rpt.ExportToStream(ExportFormatType.PortableDocFormat));
                                copy.AddPage(copy.GetImportedPage(reader, 1));
                                rpt.Close();
                                rpt.Dispose();
                                PgMng.Grow();
                            }

                            doc.Close();

                            System.Diagnostics.Process process = new System.Diagnostics.Process();
                            process.StartInfo.FileName = sFile;
                            process.Start();
                            try
                            {
                                process.WaitForExit();
                            }
                            catch { }
                            PgMng.Grow();

                            //Documento documento = Documento.New();
                            //documento.Fecha = DateTime.Now;
                            //documento.FechaAlta = DateTime.Now;
                            //documento.Nombre = documento.Fecha.ToString("yyyyMMdd") + "_CRONOGRAMA";
                            //documento.Ruta = "C:\\";
                            //documento.Tipo = "PDF";


                            //AgenteDocumento agente_documento = agente.Documentos.NewItem(agente);
                            //agente_documento.OidDocumento = documento.Oid;

                            //agente.Save();
                        }
                        catch (Exception ex) { throw ex; }
                        finally { PgMng.FillUp(); }
                    }
                }
                break;
            }
        }