Preparation for DB migration Munich.

This commit is contained in:
Milan Hanajik 2016-05-20 11:02:54 +02:00
parent 1bcbe382d7
commit 4a25dac8ff

View File

@ -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<Config.Entities.Procedure> procedures = session.CreateQuery("FROM Procedure ORDER BY ItemNr")
.List<Config.Entities.Procedure>();
///IList<TBF.BenchControl.Generic.IComponent> 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<Config.Entities.Test> tests = session.QueryOver<Config.Entities.Test>()
.Where(x => (x.Procedure == proc))
.OrderBy(x => x.ItemNr).Desc
.List<Config.Entities.Test>();
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);
}
}
}