public DefaultVisualStudioDocumentTrackerFactory( TextBufferProjectService projectService, ITextDocumentFactoryService textDocumentFactory, VisualStudioWorkspaceAccessor workspaceAccessor, ImportDocumentManager importDocumentManager) { if (projectService == null) { throw new ArgumentNullException(nameof(projectService)); } if (textDocumentFactory == null) { throw new ArgumentNullException(nameof(textDocumentFactory)); } if (workspaceAccessor == null) { throw new ArgumentNullException(nameof(workspaceAccessor)); } _projectService = projectService; _textDocumentFactory = textDocumentFactory; _workspace = workspaceAccessor.Workspace; _importDocumentManager = importDocumentManager; _foregroundDispatcher = _workspace.Services.GetRequiredService <ForegroundDispatcher>(); var razorLanguageServices = _workspace.Services.GetLanguageServices(RazorLanguage.Name); _projectManager = razorLanguageServices.GetRequiredService <ProjectSnapshotManager>(); _editorSettingsManager = razorLanguageServices.GetRequiredService <EditorSettingsManagerInternal>(); }
protected void _btnImport_Click(object sender, EventArgs e) { string filepath; HttpFileCollection uploadedFiles; HttpPostedFile userPostedFile; bool result = true; bool fileCaricati = false; InfoUtente infoUtente; try { filepath = Server.MapPath("\\Upload"); uploadedFiles = Request.Files; //Span1.Text = string.Empty; infoUtente = UIManager.UserManager.GetInfoUser(); for (int i = 0; i < uploadedFiles.Count; i++) { userPostedFile = uploadedFiles[i]; if (userPostedFile == null) { continue; } if (String.IsNullOrWhiteSpace(userPostedFile.FileName) || userPostedFile.FileName.Equals("formatPdfExport.xml")) { continue; } result = ImportDocumentManager.UploadFileOnServer(userPostedFile.InputStream, userPostedFile.FileName, infoUtente); if (!result) { throw new Exception("Errore nell'upload del file"); } fileCaricati = true; } if (fileCaricati) { ScriptManager.RegisterStartupScript(this, this.GetType(), "ajaxDialogModal", "ajaxDialogModal('ErrorCustom', 'info', '', '" + "Files caricati con successo" + "');", true); } else { ScriptManager.RegisterStartupScript(this, this.GetType(), "ajaxDialogModal", "ajaxDialogModal('ErrorCustom', 'info', '', '" + "Nessun file selezionato" + "');", true); } } catch (Exception) { ScriptManager.RegisterStartupScript(this, this.GetType(), "ajaxDialogModal", "ajaxDialogModal('ErrorCustom', 'error', '', '" + "Errore upload dei file al server" + "');", true); } }
protected void Page_Load(object sender, EventArgs e) { // Si prova a prelevare dal call context il report ResultsContainer report = HttpContext.Current.Session["report"] as ResultsContainer; byte[] temp = null; try { temp = ImportDocumentManager.CreateZipFromReport(report, UserManager.GetInfoUser()); } catch (Exception) { } Response.ContentType = "zip"; Response.AddHeader("content-disposition", "attachment; filename=documenti.zip"); if (temp != null) { Response.AddHeader("content-length", "" + temp.Length); Response.BinaryWrite(temp); } else { Response.AddHeader("content-length", "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.grdAllegati.DataSource = null; this.grdArrivo.DataSource = null; this.grdGenerale.DataSource = null; this.grdGrigi.DataSource = null; this.grdInterni.DataSource = null; this.grdPartenza.DataSource = null; this.grdAllegati.DataBind(); this.grdArrivo.DataBind(); this.grdGenerale.DataBind(); this.grdGrigi.DataBind(); this.grdInterni.DataBind(); this.grdPartenza.DataBind(); // Reperimento delle informazioni sui documenti da importare string error; DocumentRowDataContainer drdc = ImportDocumentManager.ReadDocumentDataFromExcelFile( content, UserManager.GetInfoUser(), RoleManager.GetRoleInSession(), !this.StampaUnione, out error); if (String.IsNullOrEmpty(error)) { // Reperimento del numero massimo di documenti importabili int maxNumber = ImportDocumentManager.GetMaxDocumentsNumber(UserManager.GetInfoUser()); // Se maxNumber è più minore del numero di documenti estratti dal foglio excel if (maxNumber < drdc.AttachmentDocument.Length + drdc.GrayDocument.Length + drdc.InDocument.Length + drdc.OutDocument.Length + drdc.OwnDocument.Length) { ScriptManager.RegisterStartupScript(this, this.GetType(), "ajaxDialogModal", "ajaxDialogModal('ErrorImportDocumentsMaxNumber', 'warning', '', '" + utils.FormatJs(maxNumber.ToString()) + "');", true); return; } // Creazione di un nuovo oggetto cui delegare l'importazione dei documenti this.importExecutor = new ImportDocumentExecutor(this.StampaUnione); 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(); } else { report = new ResultsContainer(); report.General = new ImportResult[1]; report.General[0] = new ImportResult() { Outcome = OutcomeEnumeration.KO, Message = error }; } // 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; this.grdGrigi.DataSource = report.GrayDocument; this.grdAllegati.DataSource = report.Attachment; // Binding delle sorgenti dati this.grdGenerale.DataBind(); this.grdArrivo.DataBind(); this.grdPartenza.DataBind(); this.grdInterni.DataBind(); this.grdGrigi.DataBind(); this.grdAllegati.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 (this.StampaUnione) { this.lnkDownload.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); } }