Esempio n. 1
0
    protected void generateReport(int pessoaID, String langCode)
    {
        String DestinationReportsPath;
        String TemplateReportsPath;
        Projecto p = Projecto.getProjectoID(Utility.currProjeto.ProjectoID, "");
        Pessoa self = Pessoa.getPessoa(pessoaID, Utility.currProjeto.owner);
        Ticket ticket;
        String selfStrCode = getAAGroupCode();

        if (langCode != "")
            p.traslateTo(langCode);

        if (Utility.currProjeto.GroupsCodes.Length >= 1)
        {
            ticket = Ticket.getAllTicketsAvaliado(pessoaID, p.ProjectoID, p.owner).First();
        }
        else
            ticket = Ticket.getAllTicketsAvaliado(pessoaID, p.ProjectoID, p.owner).First(a => a.Qualidade == selfStrCode);

        ReportFactory report;

        // analisar os templates disponíveis.
        String DocProcessor;

        //assumimos que os tempaltes são custom
        DestinationReportsPath = getCurrentProjectPath();
        TemplateReportsPath = DestinationReportsPath + "\\docTemplates";

        if ((DocProcessor = ReportHelper.getCustomDocProcessor(TemplateReportsPath, p)) == "NO_TEMPLATE") // ve se tem templates
        {
            // se não tem templates, então vamos buscar os templates standard
            TemplateReportsPath = Request.PhysicalApplicationPath + "docTemplates";
            DocProcessor = ReportHelper.getDocProcessor(TemplateReportsPath, p);
        }

        if ((DocProcessor != null) && (DocProcessor != ""))
        {
            if (DocProcessor != "Standard")
            {
                // create an instance of the class from the assembly
                Assembly assembly = Assembly.Load("QtoolsReportGenerators");
                IReportGenerator rep = (IReportGenerator)assembly.CreateInstance("QtoolsReportGenerators." + DocProcessor.Trim() + "Report");

                if (rep.GenerateReport(TemplateReportsPath, DestinationReportsPath, DateTime.Now, self, ticket, p, Guid.NewGuid().ToString().Replace("-", "")))
                {
                    // multiViewPanels.ActiveViewIndex = 3;
                    // se chegou aqui está tudo OK
                }
                else
                {
                    // deveria avisar que ocorreu um erro e que erro foi!
                }
            }
            else
            {

                p.traslateTo(langCode);
                report = new ReportFactory(TemplateReportsPath, DestinationReportsPath, DateTime.Now, self, ticket, p, ticket.Chave, langCode);
                report.asyncStart();
            }
        }

        else
        {
            report = new ReportFactory(TemplateReportsPath, DestinationReportsPath, DateTime.Now, self, ticket, p, ticket.Chave, langCode);
            report.asyncStart();
        }
    }