diff --git a/TestBenchFramework/ProceduresDlg.cs b/TestBenchFramework/ProceduresDlg.cs index ef70133a3..c88411d5a 100644 --- a/TestBenchFramework/ProceduresDlg.cs +++ b/TestBenchFramework/ProceduresDlg.cs @@ -117,6 +117,11 @@ namespace TBF private void downButton_Click(object sender, EventArgs e) { + //if (DialogResult.Yes == MessageBox.Show("Chcete naplnit 'Publish' a 'Evaluate' vsetkych testov?", "Otazka", MessageBoxButtons.YesNo, MessageBoxIcon.Question)) + //{ + // UpgradeAllTests(); + // return; + //} proceduresCtrl.MoveDownSelected(); } @@ -169,5 +174,52 @@ namespace TBF sharedButtons.DisableButtons(SharedButtons.Buttons.Remove | SharedButtons.Buttons.Up | SharedButtons.Buttons.Down); } } + + private void UpgradeAllTests() + { + NHibernate.ISession session = Config.FluentCommon.CreateSession(Config.Entities.DBKind.Config); + + IList procedures = session.CreateQuery("FROM Procedure ORDER BY ItemNr") + .List(); + + ///IList components = TBF.BenchControl.TbfComponents.LoadComponentsFromDB(session); + /// + int successful = 0; + int failed = 0; + string lastMsg = string.Empty; + + int N = procedures.Count; + for (int i = 0; i < N; i++) + { + Config.Entities.Procedure proc = procedures[i]; + Text = string.Format("{0} ({1}/{2})", proc.Name, i+1, N); + + //TBF.BenchControl.Generic.IComponent component = TBF.BenchControl.TbfComponents.FindComponent() + + NHibernate.ITransaction transaction = session.BeginTransaction(); + + try + { + IList tests = session.QueryOver() + .Where(x => (x.Procedure == proc)) + .OrderBy(x => x.ItemNr).Desc + .List(); + + + transaction.Commit(); + + successful++; + } + catch (Exception exc) + { + transaction.Rollback(); + lastMsg = exc.Message; + failed++; + } + } + + MessageBox.Show(string.Format("Successful: {0}, Failed: {1}\r\nMessage: {2}", successful, failed, lastMsg), "Result", + MessageBoxButtons.OK, (failed > 0) ? MessageBoxIcon.Error : MessageBoxIcon.Information); + } } }