예제 #1
0
        protected void InitializePage()
        {
            this.InitializeLanguage();

            this.pageTitle.Text += String.Format("Amministrazione: {0}, Codice: {1}",
                                                 UserManager.getInfoAmmCorrente(UserManager.GetInfoUser().idAmministrazione).Descrizione,
                                                 UserManager.getInfoAmmCorrente(UserManager.GetInfoUser().idAmministrazione).Codice);

            bool isEnabledOwnerProto = ImportRDEManager.IsEnabledOwnerProto();

            this.plcInternal.Visible = isEnabledOwnerProto;
            this.grdInterni.Visible  = isEnabledOwnerProto;
            this.upReport.Update();

            // Impostazione del link per il download del modellO in base alla versione RDE
            this.lnkTemplate.NavigateUrl = "ImportRDE.xls";
            //if (isEnabledOwnerProto)
            //    // Versione 2
            //    this.lnkTemplate.NavigateUrl = "ImportRDE(old).xls";
            //else
            //    // Versione 1
            //    this.lnkTemplate.NavigateUrl = "ModelloRDE_v01.xls";
        }
예제 #2
0
        protected void BtnUploadHidden_Click(object sender, EventArgs e)
        {
            ScriptManager.RegisterStartupScript(this, this.GetType(), "reallowOp", "reallowOp();", true);

            if (this.fileUpload != null && !string.IsNullOrEmpty(this.fileUpload.Value) && this.fileUpload.PostedFile.FileName.ToLower().EndsWith("xls"))
            {
                // Nel CallContext inserisco nome del file(con estensione) a partire dal path del file di import
                this.importFileName = Path.GetFileName(this.fileUpload.Value);

                // Prelevamento del contenuto del file
                HttpPostedFile p       = this.fileUpload.PostedFile;
                Stream         fs      = p.InputStream;
                byte[]         content = new byte[fs.Length];
                fs.Read(content, 0, (int)fs.Length);
                fs.Close();

                if (content.Length > 0)
                {
                    // Creazione del nome per il file temporaneo
                    string temporaryFileName = String.Format("{0}.xls", Guid.NewGuid().ToString());

                    // Prelevamento del serverPath
                    string serverPath = utils.getHttpFullPath();

                    try
                    {
                        // Disassociazione delle sorgenti dati
                        this.grdArrivo.DataSource   = null;
                        this.grdGenerale.DataSource = null;
                        this.grdInterni.DataSource  = null;
                        this.grdPartenza.DataSource = null;
                        this.grdArrivo.DataBind();
                        this.grdGenerale.DataBind();
                        this.grdInterni.DataBind();
                        this.grdPartenza.DataBind();

                        // Reperimento delle informazioni sui documenti da importare
                        string error;
                        DocumentRowDataContainer drdc = ImportRDEManager.ReadRDEDataFromExcel(
                            content,
                            temporaryFileName);

                        // Creazione di un nuovo oggetto cui delegare l'importazione dei documenti
                        this.importExecutor = new ImportRDEExecutor();

                        importExecutor.ExecuteImport(
                            new object[] {
                            drdc,
                            utils.getHttpFullPath(),
                            UserManager.GetInfoUser(),
                            RoleManager.GetRoleInSession()
                        });

                        int analyzedDocument, totalDocument;
                        // Si richiedono le statistiche
                        importExecutor.GetStatistics(out analyzedDocument, out totalDocument);

                        // Viene prelevato il report
                        report = importExecutor.GetReport();

                        // Se il report Generale non contiene elementi, viene aggiunto un
                        // result positivo
                        if (report.General == null || report.General.Length == 0)
                        {
                            report.General = new ImportResult[1];

                            report.General[0] = new ImportResult()
                            {
                                Outcome = OutcomeEnumeration.NONE,
                                Message = "Il processo di importazione è terminato."
                            };
                        }

                        // Associazione degli array dei risultati alle varie griglia
                        this.grdGenerale.DataSource = report.General;
                        this.grdArrivo.DataSource   = report.InDocument;
                        this.grdPartenza.DataSource = report.OutDocument;
                        this.grdInterni.DataSource  = report.OwnDocument;

                        // Binding delle sorgenti dati
                        this.grdGenerale.DataBind();
                        this.grdArrivo.DataBind();
                        this.grdPartenza.DataBind();
                        this.grdInterni.DataBind();

                        this.plcReport.Visible = true;
                        this.upReport.Update();

                        // Creazione del data set per l'esportazione del report di importazione
                        DataSet dataSet = this.GenerateDataSet(report);

                        // Path e nome file del template
                        string templateFilePath = Server.MapPath("formatPdfExport.xml");

                        // Aggiunta nell call context del file documento  con le informazioni
                        // da scivere nel report
                        this.reportImport =
                            global::ProspettiRiepilogativi.Frontend.PdfReport.do_MakePdfReport(
                                global::ProspettiRiepilogativi.Frontend.ReportDisponibili.ReportLogMassiveImport,
                                templateFilePath,
                                dataSet,
                                null);

                        //// Abilitazione pulsante esportazione
                        //this.BtnReportExport.Enabled = true;

                        ////link di scarica zip
                        //if (StampaUnione)
                        //    this.BtnDownloadReport.Visible = true;

                        // Aggiornamento pannello bottoniera
                        this.BtnImport.Enabled = false;
                        this.UpPnlButtons.Update();
                    }
                    catch (Exception ex)
                    {
                        ScriptManager.RegisterStartupScript(this, this.GetType(), "ajaxDialogModal", "ajaxDialogModal('ErrorCustom', 'error', '', '" + utils.FormatJs(ex.Message) + "');", true);
                    }
                }
                else
                {
                    ScriptManager.RegisterStartupScript(this, this.GetType(), "ajaxDialogModal", "ajaxDialogModal('ErrorImportDocumentsFileInvalid', 'error', '');", true);
                }
            }
            else
            {
                ScriptManager.RegisterStartupScript(this, this.GetType(), "ajaxDialogModal", "ajaxDialogModal('ErrorImportDocumentsFileInvalid', 'error', '');", true);
            }
        }