private void SearchThread(object state) { Regex regDir = CPatternMatch.Convert(m_strDirPattern); Regex regFile = CPatternMatch.Convert(m_strFilePattern); CRepertoire repSel = null; CFichier ficSel = null; CFichier fichierTrouve = null; if (m_formMain != null) { repSel = m_formMain.GetRepertoireSel(); ficSel = m_formMain.GetFichierSel(); if (repSel != null) { fichierTrouve = repSel.FindNext(true, repSel, ficSel, regDir, regFile, m_indicateurProgression); if (fichierTrouve != null) { m_formMain.SelectFichier(fichierTrouve); } } } CFormProgression.EndIndicateur(m_indicateurProgression); m_threadSearch = null; Invoke((MethodInvoker) delegate { UpdateVisuel(); }); if (fichierTrouve == null) { MessageBox.Show("Pattern not found"); } }
private void StartExport() { CResultAErreur result = CResultAErreur.True; try { try { CFormProgression.Indicateur.SetBornesSegment(0, 100); CFormProgression.Indicateur.PushSegment(0, 80); CFormProgression.Indicateur.SetInfo(I.T("Generating data|232")); } catch {} result = m_multistructure.GetDataSet(false, m_listeObjets, CFormProgression.Indicateur); try { CFormProgression.Indicateur.PopSegment(); CFormProgression.Indicateur.PushSegment(80, 100); CFormProgression.Indicateur.SetInfo(I.T("Generating data|232")); } catch {} if (!result) { CFormAlerte.Afficher(result); return; } DataSet ds = (DataSet)result.Data; result = m_exporteur.Export(ds, m_destinationExport); try { CFormProgression.EndIndicateur(CFormProgression.Indicateur); } catch {} ds.Dispose(); CFormAlerte.Afficher(I.T("Export completed with succes|225")); } catch (Exception e) { result.EmpileErreur(new CErreurException(e)); result.EmpileErreur(I.T("Error during data export|226")); } if (!result) { CFormAlerte.Afficher(result); } }
//-------------------------------------------------------------- private void m_btnImporter_Click(object sender, EventArgs e) { CConfigMappagesSmartImport config = null; DataTable table = null; CResultAErreur result = PrepareImport(ref config, ref table); if (!result || table == null) { CFormAlerte.Afficher(result.Erreur); return; } if (!CFormOptionsImport.EditeOptions(m_optionsExecution)) { return; } IIndicateurProgression indicateur = null; indicateur = CFormProgression.GetNewIndicateurAndPopup(I.T("Importing data|20245")); CResultAErreurType <CSessionImport> resSession; resSession = config.DoImportSurServeur(CSc2iWin32DataClient.ContexteCourant.IdSession, table, m_optionsExecution, indicateur); CFormProgression.EndIndicateur(indicateur); if (m_optionsExecution.NomFichierSauvegarde != null && m_optionsExecution.NomFichierSauvegarde.Length > 0) { result = CSerializerObjetInFile.SaveToFile(resSession.DataType, "IMPORT_SESSION", m_optionsExecution.NomFichierSauvegarde); if (!result) { CFormAlerte.Afficher(result.Erreur); } } SetSessionEnCours(resSession.DataType); CFormEditionSessionImport.EditeSession(m_sessionImport); }
private void m_btnTesterImport_Click(object sender, EventArgs e) { CConfigMappagesSmartImport config = null; DataTable table = null; CResultAErreur result = PrepareImport(ref config, ref table); if (!result || table == null) { CFormAlerte.Afficher(result.Erreur); return; } DialogResult dr = MessageBox.Show(I.T("Would you like to save configuration first ?|20225"), "", MessageBoxButtons.YesNoCancel, MessageBoxIcon.Question); if (dr == DialogResult.Cancel) { return; } if (dr == DialogResult.Yes) { if (!SaveConfig()) { return; } } if (!CFormOptionsSimulation.EditeOptions(m_optionsSimulation)) { return; } using (CContexteDonnee ctx = new CContexteDonnee(CSc2iWin32DataClient.ContexteCourant.IdSession, true, false)) { CContexteImportDonnee contexteImport = new CContexteImportDonnee(ctx); contexteImport.StartLine = m_optionsSimulation.StartLine; contexteImport.EndLine = m_optionsSimulation.EndLine; contexteImport.BestEffort = true; IIndicateurProgression indicateur = null; indicateur = CFormProgression.GetNewIndicateurAndPopup(I.T("Testing import|20246")); result = config.ImportTable(table, contexteImport, indicateur); CFormProgression.EndIndicateur(indicateur); indicateur = null; if (!result) { CFormAlerte.Afficher(result.Erreur); return; } if (m_optionsSimulation.TestDbWriting) { CSessionClient session = CSessionClient.GetSessionForIdSession(ctx.IdSession); session.BeginTrans(); result = ctx.SaveAll(false); session.RollbackTrans(); if (!result) { if (CFormAlerte.Afficher(result.Erreur, EFormAlerteBoutons.ContinuerAnnuler, EFormAlerteType.Info) == System.Windows.Forms.DialogResult.Cancel) { return; } } } if (CFormResultatSmartImport.ShowImportResult(ctx, contexteImport, config, m_rootValues, table)) { result = ctx.SaveAll(true); if (!result) { CFormAlerte.Afficher(result.Erreur); return; } } } }