/* * public void RenameObject(object treeViewItem) * { * var window = new RenameObjectWindow(); * * if (treeViewItem is Table) * window.ViewModel = new RenameObjectViewModel(database, treeViewItem as Table); * else if (treeViewItem is Column) * window.ViewModel = new RenameObjectViewModel(database, treeViewItem as Column); * * if (window.ViewModel != null) * window.ShowDialog(); * } */ private void CreateNewDatabase() { var window = new CreateDatabaseWindow(); var dialogResult = window.ShowDialog(); if (!dialogResult.GetValueOrDefault()) { return; } var viewModel = window.DataContext as CreateDatabaseViewModel; if (viewModel == null) { return; } Text = "SQL Compact Query Analyzer"; Tree = null; ResetTableData(); ResultsContainer.Clear(); ResultSetMessages = ResultSetErrors = ResultSetXml.Text = Query.Text = string.Empty; RaisePropertyChanged("Tree"); RaisePropertyChanged("Query"); RaisePropertyChanged("ResultSetXml"); CurrentMainTabIndex = 0; lastSelectedTable = null; database = null; dataSource = viewModel.Filename; password = viewModel.Password; AnalyzeDatabase(); }
public static void Gaps() { ArtesianDataChecker_GapCheck gap = new ArtesianDataChecker_GapCheck(); ArtesianDataChecker_Request req = new ArtesianDataChecker_Request(); ArtesianDataChecker_Console csl = new ArtesianDataChecker_Console(); ResultsContainer res = new ResultsContainer() { GapResults = new List <GapResult>() }; List <string> providers = ArtesianDataChecker_Constants.AvailableProviders; Paramaters param = csl.SetParameters(providers, "gaps"); for (int i = 0; i < param.TestIds.Count; i++) { var data = req.DataRequest(param.TestIds[i], param.Provider1, param.Start, param.End); if (data != null) { res.GapResults.Add(gap.CheckIntervals(data)); } else { Console.WriteLine("Error: Data Request returned NULL."); } } csl.PrintResultsToConsole(res.GapResults, param.Provider2); }
public MainWindow() { InitializeComponent(); // load settings var settings = UserSettings.LoadSettings(); _model.Settings = settings; // prepare results view _model.EventGrid = new EventViewHandler(ResultGridBox, settings, this.Resources["TextConverter"] as IValueConverter); _model.EventGrid.BuildColumns(settings.Columns, _model.Events); _model.EventGrid.ApplyFilter(_model.Events); // prepare SQL code preview control _model.SqlPreview = new SqlPreviewHandler(SqlPreviewBox, _model.Settings.Editor); _model.SqlPreview.Setup(); // events this.Closing += (ss, ee) => _model.OnExit(); // auto scroll to bottom _model.Events.CollectionChanged += (ss, ee) => { if (settings.App.AutoScroll) { ResultsContainer.ScrollIntoView(_model.Events.LastOrDefault()); } }; this.DataContext = _model; }
public IResultsContainer <T> Build() { var convertedResults = new ResultsContainer <T> { Message = _message, ErrorMessage = _errorMessage, Status = _status, CurrentPage = _currentPage, NumberOfPages = _numberOfPages, TotalResults = _totalResults, HttpStatusCode = _httpStatusCode }; if (HttpStatusCode.OK == _httpStatusCode) { if (_data != null) { if (typeof(JArray) == _data.GetType()) { foreach (var jToken in _data) { ProcessJData(jToken, ref convertedResults); } } else { ProcessJData(_data, ref convertedResults); } } } return(convertedResults); }
private ResultsContainer DailyCentroidAnalysis2() { int pass = 0; var results = new ResultsContainer() { Name = "Centroid Analysis - Daily", PageName = "DailyCentroidAnalysis" }; foreach (var setup in this.setups) { pass++; var patientResults = new List <LocalityResult>(); var analyser = new CentroidDailyAnalysisMethod(setup); OutputAllocationStrategyName(pass); analyser.Execute(); if (pass == 1) { analyser.ResultsByLocality.ForEach(x => results.HomeResultsByLocality.Add(x)); results.HomeAllocation = analyser.Results; } else { analyser.ResultsByLocality.ForEach(x => results.GPResultsByLocality.Add(x)); results.GPAllocation = analyser.Results; } } return(results); }
public void SetResults(ResultsContainer results, List <string> selectedLocalities) { LoadChart(results.HomeResultsByLocality, results.GPResultsByLocality, selectedLocalities); DisplayLocalityStatistics(results.HomeResultsByLocality, results.GPResultsByLocality); DisplayHighLevelStatistics(results); DisplayDifferences(results); }
public static ImportResult ImportAndAcquireDocument( DocumentRowData documentToImport, ProtoType protoType, string serverPath, InfoUtente userInfo, Ruolo role, ref ResultsContainer resultsContainer) { // Impostazione del timeout ad infinito ws.Timeout = System.Threading.Timeout.Infinite; // Lettura del valore di configurazione utilizzato per indicare // se è obbligatoria la profilazione del documento bool isProfilationRequired = false; //Boolean.TryParse( // ConfigurationManager.AppSettings["TIPO_ATTO_REQUIRED"], // out isProfilationRequired); string idAmm = userInfo.idAmministrazione; if (DocumentManager.GetTipoDocObbl(idAmm).Equals("1")) { isProfilationRequired = true; } // Lettura del valore di configurazione utilizzato per indicare // se è obbligatoria la classificazione del documento bool isClassificationRequired = false; if (!string.IsNullOrEmpty(Utils.InitConfigurationKeys.GetValue(UserManager.GetInfoUser().idAmministrazione, DBKeys.FE_FASC_RAPIDA_REQUIRED.ToString()))) { isClassificationRequired = bool.Parse(Utils.InitConfigurationKeys.GetValue(UserManager.GetInfoUser().idAmministrazione, DBKeys.FE_FASC_RAPIDA_REQUIRED.ToString())); } try { // Chiamata del webservice per l'importazione dei documenti da // foglio Excel e restituzione della lista dei risultati return(ws.ImportAndAcquireDocument( documentToImport, protoType, serverPath, userInfo, role, isProfilationRequired, isClassificationRequired, false, ref resultsContainer, importazionePregressiAbilitata())); } catch (Exception e) { throw new Exception("Ricevuto errore dal servizio."); } }
/// <summary> /// Costruttore di default. /// </summary> public ImportRDEExecutor() { // Inizializzazione del report this.report = new ResultsContainer(); // Inizializzazione del numero di documenti importati this.totalNumberOfAnalyzedDocuments = 0; // Inizializzazione del numero di documenti da importare this.totalNumberOfDocumentToImport = 0; }
public StartCompetitionPresenter(IStartCompetition view, ResultsContainer resultsContainer) { ResultsContainer = resultsContainer; if (view == null) { throw new ArgumentNullException("View cannot be null"); } View = view; }
/// <summary> /// Get Build results object from aggregated data /// </summary> /// <returns>Aggregated results</returns> public ResultsContainer GetResults() { ResultsContainer result = null; if (_orderLearner.LearnedOrder.Count != 0) { ResultsMapper mapper = new ResultsMapper(_orderLearner); IEnumerable <ResultItemRow> resultRows = mapper.Map(_statsAggregator); result = new ResultsContainer(resultRows.ToList(), new ResultItemTotals(_statsAggregator)); } return(result); }
private void DisplayHighLevelStatistics(ResultsContainer allResults) { List <AllocationResult> results = new List <AllocationResult>(); results.Add(allResults.HomeAllocation); results.Add(allResults.GPAllocation); results[0].AllocationName = "Home Allocation"; results[1].AllocationName = "GP Allocation"; this.allocationResultsPanel1.SetResults(results); }
/// <summary> /// Funzione per l'importazione di documenti definiti all'interno di un file Excel /// </summary> /// <param name="content"></param> /// <param name="fileName"></param> /// <param name="serverPath"></param> /// <param name="modelPath"></param> /// <param name="userInfo"></param> /// <param name="role"></param> /// <param name="isProfilationRequired"></param> /// <param name="isRapidClassificationRequired"></param> /// <param name="sharedDirectoryPath"></param> /// <param name="isSmistamentoEnabled"></param> /// <returns></returns> public static ResultsContainer ImportDocuments( byte[] content, string fileName, string serverPath, string modelPath, InfoUtente userInfo, Ruolo role, bool isProfilationRequired, bool isRapidClassificationRequired, string ftpAddress, bool isSmistamentoEnabled, String ftpUsername, String ftpPassword, bool isEnabledPregressi) { // Il path completo in cui è posizionato il file excel contenente i dati // sui documenti da importare string completePath = String.Empty; // Il risultato dell'elaborazione ResultsContainer result = new ResultsContainer(); try { // 1. Creazione del file temporaneo in cui poggiare il foglio // excel contenente i dati sui documenti da importare completePath = ImportUtils.CreateTemporaryFile(content, modelPath, fileName); // 2. Creazione dei documenti result = CreateDocuments(completePath, userInfo, role, serverPath, isProfilationRequired, isRapidClassificationRequired, ftpAddress, isSmistamentoEnabled, ftpUsername, ftpPassword, isEnabledPregressi); // 3. Cancellazione file temporaneo ImportUtils.DeleteTemporaryFile(completePath); } catch (Exception e) { // Se il file è stato creato, cancellazione if (!String.IsNullOrEmpty(completePath)) { ImportUtils.DeleteTemporaryFile(completePath); } // Creazione di un nuovo risultato con i dettagli dell'eccezione result.General.Add(new ImportResult() { Outcome = ImportResult.OutcomeEnumeration.KO, Message = e.Message }); } // 4. Restituzione del risultato return(result); }
/// <summary> /// Costruttore di default. /// </summary> public AsyncImportRDEExecutor() { // Inizializzazione del report this.report = new ResultsContainer(); // Inizializzazione del numero di documenti importati this.totalNumberOfAnalyzedDocuments = 0; // Inizializzazione del numero di documenti da importare this.totalNumberOfDocumentToImport = 0; // Inizializzazione dell'oggetto di sincronizzazione manuale this.waitReading = new ManualResetEvent(false); }
private void ResetFields() { Tree = null; ResetTableData(); ResultsContainer.Clear(); ResultSetMessages = ResultSetErrors = ResultSetXml.Text = Query.Text = string.Empty; RaisePropertyChanged("Tree"); RaisePropertyChanged("Query"); RaisePropertyChanged("ResultSetXml"); CurrentMainTabIndex = 0; lastSelectedTable = null; dataSource = null; database = null; password = null; }
public static byte[] CreateZipFromReport(ResultsContainer report, InfoUtente userInfo) { // Impostazione del timeout ad infinito ws.Timeout = System.Threading.Timeout.Infinite; try { // Chiamata del webservice per l'importazione dei documenti da // foglio Excel e restituzione della lista dei risultati return(ws.CreateZipFromReport(report, userInfo)); } catch (Exception e) { throw new Exception("Ricevuto errore dal servizio."); } }
private void DisplayDifferences(ResultsContainer results) { var diffCI = new ConfidenceIntervalForMeanDifference(results.HomeAllocation.Stats, results.GPAllocation.Stats); var differences = new List <AllocationResult>(); differences.Add(new AllocationResult() { AllocationName = "Metres", Mean = diffCI.Mean, LCI = diffCI.LowerBound, UCI = diffCI.UpperBound }); differences.Add(new AllocationResult() { AllocationName = "%", Mean = (diffCI.Mean / results.HomeAllocation.Mean) * 100, LCI = (diffCI.LowerBound / results.HomeAllocation.Mean) * 100, UCI = (diffCI.UpperBound / results.HomeAllocation.Mean) * 100 }); this.meanDifferenceConfidenceIntervalPanel1.SetResults(differences); }
public static byte[] CreateZipFromReport(ResultsContainer report, InfoUtente infoUtente) { ZipBuilder builder = new ZipBuilder(); List <ImportResult> grayList = report.GrayDocument.FindAll(e => !string.IsNullOrEmpty(e.DocNumber)); addDocsInZip(grayList, builder, "Documenti grigi", infoUtente); List <ImportResult> inList = report.InDocument.FindAll(e => !string.IsNullOrEmpty(e.DocNumber)); addDocsInZip(inList, builder, "Documenti in arrivo", infoUtente); List <ImportResult> outList = report.OutDocument.FindAll(e => !string.IsNullOrEmpty(e.DocNumber)); addDocsInZip(outList, builder, "Documenti in partenza", infoUtente); List <ImportResult> ownList = report.OwnDocument.FindAll(e => !string.IsNullOrEmpty(e.DocNumber)); addDocsInZip(ownList, builder, "Documenti interni", infoUtente); return(builder.GetOutput()); }
private async Task ExecuteCore() { DirectoryInfo directory = Directory.CreateDirectory(Path.Combine(OutputDirectory, JobId)); using (FileStream stream = File.Open(Path.Combine(directory.FullName, MetadataFile), FileMode.Create, FileAccess.Write)) using (var writer = new StreamWriter(stream)) { foreach (ITaskItem metadata in MetadataToWrite) { await writer.WriteLineAsync(metadata.GetMetadata("Identity")); } } ResultsContainer = ResultsContainer.EndsWith("/") ? ResultsContainer : ResultsContainer + "/"; await Task.WhenAll(WorkItems.Select(wi => DownloadFilesForWorkItem(wi, directory.FullName, _cancellationSource.Token))); return; }
public StartCompetitionPresenter(IStartCompetition view) { AgeGroupTypesContainer = new AgeGroupTypesContainer(); AgeGroupContainer = new AgeGroupContainer(); CompetitorsContainer = new CompetitorsContainer(); CompetitionContainer = new CompetitionContainer(); SubGroupsContainer = new SubGroupsContainer(); EventsContainer = new EventsContainer(); EventTypes = new EventTypesContainer(); ResultsContainer = new ResultsContainer(); CompetitionEvents = new CompetitionEventsContainer(); if (view == null) { throw new ArgumentNullException("View cannot be null"); } View = view; }
public static void Compare() { ArtesianDataChecker_Compare cmp = new ArtesianDataChecker_Compare(); ArtesianDataChecker_Request req = new ArtesianDataChecker_Request(); ArtesianDataChecker_Console csl = new ArtesianDataChecker_Console(); ResultsContainer res = new ResultsContainer { Results = new List <CheckResult>() }; //Paramaters param = csl.SetParametersDefault(); List <string> providers = ArtesianDataChecker_Constants.AvailableProviders; Paramaters param = csl.SetParameters(providers, "compare"); Stopwatch stopWatch = new Stopwatch(); string reqTime = ""; long totalTime = 0; Console.WriteLine("Starting check of " + param.TestIds.Count + " curves."); for (int i = 0; i < param.TestIds.Count; i++) { stopWatch.Start(); var curveName = _getCurveName(param.TestIds[i], param.Provider1, req); var ProdId = _getIdFromMetadata(curveName, param.Provider2, req); var TestData = req.DataRequest(param.TestIds[i], param.Provider1, param.End, param.Start); var ProdData = req.DataRequest(ProdId, param.Provider2, param.End, param.Start); if (TestData != null && ProdData != null) { var result = cmp.CompareData(TestData, ProdData); res.Results.Add(result); reqTime = stopWatch.ElapsedMilliseconds.ToString(); totalTime += stopWatch.ElapsedMilliseconds; Console.WriteLine("Curve Checked : " + (i + 1) + "/" + param.TestIds.Count + " : " + result.ProdFileName + " | Time : " + reqTime); } else { Console.WriteLine("Error: Data request returned NULL."); } stopWatch.Reset(); } Console.WriteLine("Finished checking curves : Total time taken :" + (totalTime / 1000) + " sec"); csl.PrintResultsToConsole(res.Results, param.Provider2); }
private void Export(ResultsContainer rc, double frequency) { ForwardLoggerHelper.WriteStatus(_logger, "Exporting results..."); var resultPath = _project.ResultsPath; var responsesFileName = PlainTextExporter.GetResponsesFileName(frequency); var fieldsFileName = PlainTextExporter.GetFieldsFileName(frequency); if (!Directory.Exists(resultPath)) { Directory.CreateDirectory(resultPath); } var exporter = new PlainTextExporter(rc, frequency); ForwardLoggerHelper.WriteStatus(_logger, "\t Export Raw fields"); exporter.ExportRawFields(Path.Combine(resultPath, fieldsFileName), 0); ForwardLoggerHelper.WriteStatus(_logger, "\t Export MT responses"); exporter.ExportMtResponses(Path.Combine(resultPath, responsesFileName)); }
/// <summary> /// Costruttore di default. /// </summary> public ImportDocumentExecutor(bool stampaUnione) { // Inizializzazione del report this.report = new ResultsContainer(); // Inizializzazione del numero di documenti importati this.totalNumberOfAnalyzedDocuments = 0; // Inizializzazione del numero di documenti da importare this.totalNumberOfDocumentToImport = 0; // Inizializzazione dell'oggetto di sincronizzazione manuale if (!stampaUnione) { this._delegate = ImportDocumentManager.ImportDocument; } else { this._delegate = ImportDocumentManager.ImportAndAcquireDocument; } this._stampaUnione = stampaUnione; }
public static void GapsVersioned() { ArtesianDataChecker_Console csl = new ArtesianDataChecker_Console(); ArtesianDataChecker_Request req = new ArtesianDataChecker_Request(); ArtesianDataChecker_GapCheck gap = new ArtesianDataChecker_GapCheck(); ResultsContainer res = new ResultsContainer() { GapResults = new List <GapResult>() }; List <string> providers = ArtesianDataChecker_Constants.AvailableProviders; Paramaters param = csl.SetParameters(providers, "gaps"); //Paramaters param = csl.SetParametersDefault(); foreach (var id in param.ProdIds) { var versions = req.DataRequestVersioned(id, param.Provider2, param.Start, param.End); foreach (var v in versions) { res.GapResults.Add(gap.CheckIntervals(v)); } } csl.PrintResultsToConsole(res.GapResults, param.Provider2); }
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"); } }
private ResultsContainer DistanceAnalysis2() { int pass = 0; var results = new ResultsContainer() { Name = "TSP Results", PageName = "TSPResults" }; Console.WriteLine("## Running travelling salesman analysis ## "); foreach (var setup in this.setups) { pass++; var patientResults = new List <LocalityResult>(); var salesman = new TravelingSalesmanAnalyser(setup, this.analysisOptionPanel1); OutputAllocationStrategyName(pass); salesman.Execute(); if (pass == 1) { salesman.ResultsByLocality.ForEach(x => results.HomeResultsByLocality.Add(x)); results.HomeAllocation = salesman.Results; } else { salesman.ResultsByLocality.ForEach(x => results.GPResultsByLocality.Add(x)); results.GPAllocation = salesman.Results; } } return(results); }
public static ImportResult[] ImportDocumentsFromArray( DocumentRowData[] documentToImport, ProtoType protoType, string serverPath, InfoUtente userInfo, Ruolo role, ref ResultsContainer resultsContainer) { // Instanziazione del web service DocsPaWebService ws = new DocsPaWebService(); // Impostazione del timeout ad infinito ws.Timeout = System.Threading.Timeout.Infinite; // Lettura del valore di configurazione utilizzato per indicare // se è obbligatoria la profilazione del documento bool isProfilationRequired = false; //Boolean.TryParse( // ConfigurationManager.AppSettings["TIPO_ATTO_REQUIRED"], // out isProfilationRequired); string idAmm = userInfo.idAmministrazione; if (DocumentManager.GetTipoDocObbl(idAmm).Equals("1")) { isProfilationRequired = true; } // Lettura del valore di configurazione utilizzato per indicare // se è obbligatoria la classificazione del documento bool isClassificationRequired = false; string valoreChiaveFasc = utils.InitConfigurationKeys.GetValue(UserManager.getInfoUtente().idAmministrazione, "FE_FASC_RAPIDA_REQUIRED"); if (string.IsNullOrEmpty(valoreChiaveFasc)) { valoreChiaveFasc = "false"; } Boolean.TryParse( valoreChiaveFasc, out isClassificationRequired); try { // Chiamata del webservice per l'importazione dei documenti da // foglio Excel e restituzione della lista dei risultati return(ws.ImportDocumentsFromArray( documentToImport, protoType, serverPath, userInfo, role, isProfilationRequired, isClassificationRequired, Utils.getAbilitazioneSmistamento() == "1", ref resultsContainer, importazionePregressiAbilitata())); } catch (Exception e) { throw new Exception("Ricevuto errore dal servizio."); } }
/// <summary> /// Funzione per la creazione del dataset del report /// </summary> /// <param name="report">Il file con i risultati dell'importazione</param> /// <returns>Il dataset con i dati da inserire nel PDF</returns> private DataSet GenerateDataSet(ResultsContainer report) { #region Dichiarazione variabili // L'oggetto da restituire DataSet toReturn; // La tabella in cui inserire i dati DataTable dataTable; #endregion #region Creazione struttura del dataset // Creazione del dataset toReturn = new DataSet(); // Creazione di un nuovo data table dataTable = new DataTable(); // Aggiunta delle quattro colonne con le informazioni sui risultati di importazione dataTable.Columns.Add("Ordinale", typeof(string)); // Ordinale dataTable.Columns.Add("Tipo", typeof(string)); // Tipo documento dataTable.Columns.Add("Messaggio", typeof(string)); // Messaggio dataTable.Columns.Add("Risultato", typeof(string)); // Risultato dataTable.Columns.Add("Dettagli", typeof(string)); // Dettagli // Aggiunta della tabella al data set toReturn.Tables.Add(dataTable); #endregion #region Aggiunta dei dati sui documenti in Arrivo if (report.InDocument != null) { foreach (ImportResult importResult in report.InDocument) { this.AddRow(dataTable, importResult, "Arrivo"); } } #endregion #region Aggiunta dei dati sui documenti in partenza if (report.OutDocument != null) { foreach (ImportResult importResult in report.OutDocument) { this.AddRow(dataTable, importResult, "Partenza"); } } #endregion #region Aggiunta dei dati sui documenti Interni if (report.OwnDocument != null) { foreach (ImportResult importResult in report.OwnDocument) { this.AddRow(dataTable, importResult, "Interni"); } } #endregion #region Aggiunta dei dati sui documenti Grigi if (report.GrayDocument != null) { foreach (ImportResult importResult in report.GrayDocument) { this.AddRow(dataTable, importResult, "Grigi"); } } #endregion #region Aggiunta dei dati sugli allegati if (report.Attachment != null) { foreach (ImportResult importResult in report.Attachment) { this.AddRow(dataTable, importResult, "Allegato"); } } #endregion // Restituzione del dataset generato return(toReturn); }
/// <summary> /// Alla pressione sul bottone di creazione documenti viene avviata la procedura /// per la creazione dei documenti /// </summary> protected void btnCreaDocumenti_Click(object sender, EventArgs e) { #region Definizione variabili // Un booleano utilizzato per determinare la validità del // file excel bool canImport; // Il file postato HttpPostedFile postedFile; // Il content del documento byte[] content; // Il nome da attribuire al file temporaneo string temporaryFileName; // Il server path string serverPath; // L'eventuale errore avvenuto durante la lettura dei dati dal foglio string error; // L'oggetto con le informazioni sui documenti da importare DocumentRowDataContainer drdc; // L'oggetto cui delegare l'esecuzione dell'importazione AsyncImportDocumentExecutor importExecutor; // Oggetto per specificare un thread con parametri ParameterizedThreadStart entry; // Thread Thread thread; // Oggetto in cui memorizzare i parametri object[] parameters; // Il numero massimo di documenti che è possibile importare int maxNumber = 0; #endregion // Prelevamento del file postato postedFile = this.fileUploader.PostedFile; // Verifica del content type e dell'estensione del file al fine // di verificarne la validità //canImport = (postedFile.ContentType == "application/vnd.ms-excel") // && postedFile.FileName.ToLower().EndsWith("xls"); canImport = postedFile.FileName.ToLower().EndsWith("xls"); // Se la verifica ha avuto esito positivo... if (canImport) { // Prelevamento del contenuto del file content = this.GetContent(); // Creazione del nome per il file temporaneo temporaryFileName = String.Format("{0}.xls", Guid.NewGuid().ToString()); // Prelevamento del serverPath serverPath = Utils.getHttpFullPath(); try { // Pulizia del call context CallContextStack.CurrentContext.ContextState["documentExporter"] = null; CallContextStack.CurrentContext.ContextState["reportImport"] = null; // Reset del campo nascosto con il valore da raggiungere. this.hfTargetPerc.Value = "0"; // 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 drdc = ImportDocumentsUtils.ReadDocumentDataFromExcelFile( content, UserManager.getInfoUtente(), UserManager.getRuolo(), !StampaUnione, out error); if (String.IsNullOrEmpty(error)) { // Reperimento del numero massimo di documenti importabili maxNumber = ImportDocumentsUtils.GetMaxDocumentsNumber(UserManager.getInfoUtente()); // 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) { throw new Exception(String.Format( "E' possibile importare al massimo {0} documenti per volta.", maxNumber)); } // Creazione di un nuovo oggetto cui delegare l'importazione dei documenti importExecutor = new AsyncImportDocumentExecutor(StampaUnione); // Salvataggio dell'oggetto esecutore nel CallContext CallContextStack.CurrentContext.ContextState["documentExporter"] = importExecutor; // Creazione del thread con parametri //entry = new ParameterizedThreadStart(importExecutor.ExecuteImport); // Creazione del thread //thread = new Thread(entry); // Creazione dell'array dei parametri //parameters = new object[] { // drdc, // Utils.getHttpFullPath(), // UserManager.getInfoUtente(), // UserManager.getRuolo() //}; // Partenza del thread //thread.Start(parameters); // Avvio del timer //this.tmrUpdateInfo.Enabled = true; importExecutor.ExecuteImport( new object[] { drdc, Utils.getHttpFullPath(), UserManager.getInfoUtente(), UserManager.getRuolo() }); 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(); // 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 CallContextStack.CurrentContext.ContextState["reportImport"] = global::ProspettiRiepilogativi.Frontend.PdfReport.do_MakePdfReport( global::ProspettiRiepilogativi.Frontend.ReportDisponibili.ReportLogMassiveImport, templateFilePath, dataSet, null); // Abilitazione pulsante esportazione this.btnEsportaReport.Enabled = true; // Aggiornamento pannello bottoniera this.upButtons.Update(); //link di scarica zip if (StampaUnione) { CallContextStack.CurrentContext.ContextState["report"] = report; this.hlScaricaDoc.Visible = true; this.upScarica.Update(); } } catch (Exception ex) { // Creazione di un array di result con un solo elemento // che conterrà il dettaglio dell'eccezione report = new ResultsContainer(); report.General = new ImportResult[1]; report.General[0] = new ImportResult { Outcome = OutcomeEnumeration.KO, Message = ex.Message, }; this.grdGenerale.DataSource = report.General; this.grdGenerale.DataBind(); } } else { report = new ResultsContainer(); report.General = new ImportResult[1]; report.General[0] = new ImportResult { Outcome = OutcomeEnumeration.KO, Message = "Estensione del file non valida." }; } // Si nasconde il popup this.mdlPopupWait.Hide(); }
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); } }
public void ExecuteQuery(string sql) { if (database == null || queryExecuting) { return; } Task.Factory.StartNew(() => { var errors = new StringBuilder(); var messages = new StringBuilder(); var stopwatch = Stopwatch.StartNew(); try { queryExecuting = true; QueryStringIsBusy = QueryIsBusy = true; ResultSetMessages = "Executing query..."; ResultSetErrors = string.Empty; Application.Current.Dispatcher.Invoke((Action) delegate { if (string.IsNullOrEmpty(sql)) { sql = Query.Text; } ResultSetXml.Text = string.Empty; ResultsContainer.Clear(); }); int resultCount; var result = database.ExecuteQuery(sql, errors, messages, out resultCount) as DataSet; QueryResultCount = resultCount; if (result == null) { return; } if (DisplayResultsInGrid) { Application.Current.Dispatcher.Invoke((Action) delegate { foreach (DataTable table in result.Tables) { ResultsContainer.Add(new DataGridViewEx { DataSource = table }); } }); } if (DisplayResultsAsXml) { var sb = new StringBuilder(); using (var writer = new StringWriter(sb)) using (var xml = new XmlTextWriter(writer) { Formatting = Formatting.Indented }) { result.WriteXml(xml); writer.WriteLine(string.Empty); } Application.Current.Dispatcher.Invoke((Action) delegate { ResultSetXml.Text = sb.ToString(); RaisePropertyChanged("ResultSetXml"); }); } CurrentResultsTabIndex = result.Tables.Count > 0 ? 0 : 2; } catch (Exception e) { ResultSetErrors = e.ToString(); CurrentResultsTabIndex = 3; } finally { QueryExecutionTime = stopwatch.Elapsed; ResultSetMessages = messages.ToString(); ResultSetErrors = errors.ToString(); QueryStringIsBusy = QueryIsBusy = false; queryExecuting = false; if (!string.IsNullOrEmpty(ResultSetErrors) && ResultsContainer.Count == 0) { CurrentResultsTabIndex = 3; } sql = sql.ToLower(); if (sql.Contains("create") || sql.Contains("alter") || sql.Contains("drop") || sql.Contains("insert") || sql.Contains("update") || sql.Contains("delete")) { AnalyzeDatabase(); } } }); }