コード例 #1
0
        public static bool EditeOptions(COptionSimulationSmartImport option)
        {
            using (CFormOptionsSimulation frm = new CFormOptionsSimulation())
            {
                frm.m_txtStartLine.IntValue = option.StartLine;

                frm.m_txtNbLines.IntValue        = option.NbLineToImport;
                frm.m_chkSimulateWriting.Checked = option.TestDbWriting;
                if (frm.ShowDialog() == DialogResult.OK)
                {
                    option.StartLine      = frm.m_txtStartLine.IntValue;
                    option.NbLineToImport = frm.m_txtNbLines.IntValue;
                    option.TestDbWriting  = frm.m_chkSimulateWriting.Checked;
                    return(true);
                }
                return(false);
            }
        }
コード例 #2
0
        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;
                    }
                }
            }
        }