diff --git a/Config/CalendarEvent/Utils.cs b/Config/CalendarEvent/Utils.cs
index 2895c28dc..9bdec2a01 100644
--- a/Config/CalendarEvent/Utils.cs
+++ b/Config/CalendarEvent/Utils.cs
@@ -122,7 +122,7 @@ namespace Config.CalendarEvent
}
- public static bool IsCalendarEventTrigerred(ICalendarEvent evnt, DateTime currentDate)
+ public static bool IsCalendarEventTrigerred(ICalendarEvent evnt, DateTime dateTimeNow)
{
DateTime evntDT = evnt.AllDay
? new DateTime(evnt.Date.Year, evnt.Date.Month, evnt.Date.Day, 0, 0, 0)
@@ -133,17 +133,17 @@ namespace Config.CalendarEvent
DateTime dt1 = evntDT;
DateTime dt2 = evntDT + new TimeSpan(8, 0, 0);
DateTime dt3 = evntDT + new TimeSpan(16, 0, 0);
- return (currentDate >= dt1) || (currentDate >= dt1) || (currentDate >= dt3);
+ return (dateTimeNow >= dt1) || (dateTimeNow >= dt1) || (dateTimeNow >= dt3);
}
else if (!evnt.TriggerOnExactDayOnly)
{
/// Trigger after event expires
- return (currentDate >= evntDT);
+ return (dateTimeNow >= evntDT);
}
else
{
/// Trigger event on exact date only
- return (currentDate >= evntDT) && DayMatchesExactly(evnt, currentDate);
+ return (dateTimeNow >= evntDT) && DayMatchesExactly(evnt, dateTimeNow);
}
}
diff --git a/Config/Entities/CustomEvent.cs b/Config/Entities/CustomEvent.cs
index 30bb606c2..34057f914 100644
--- a/Config/Entities/CustomEvent.cs
+++ b/Config/Entities/CustomEvent.cs
@@ -46,8 +46,8 @@ namespace Config.Entities
Rank = 2;
Hidden = false;
ReadOnly = false;
- BackColor = unchecked((int)0xFFFF5050);
- TextColor = unchecked((int)0xFFFFFFFF);
+ BackColor = unchecked((int)0xFFFF5050); /// (MSB)AARRGGBB(LSB) ... pink
+ TextColor = unchecked((int)0xFFFFFFFF); /// (MSB)AARRGGBB(LSB) ... white
TooltipEnabled = true;
CustomRecurringFunction = null;
}
diff --git a/EventViewer/EViewerDB.cs b/EventViewer/EViewerDB.cs
new file mode 100644
index 000000000..cc38ab846
--- /dev/null
+++ b/EventViewer/EViewerDB.cs
@@ -0,0 +1,137 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using FluentNHibernate.Cfg;
+using FluentNHibernate.Cfg.Db;
+using NHibernate;
+using NHibernate.Cfg;
+using NHibernate.Tool.hbm2ddl;
+using Common;
+using Events;
+
+namespace EventViewer
+{
+ public static class EViewerDB
+ {
+ /// Session factory for all regular sessions, not for CreateEmptyResultsDB().
+ public static ISessionFactory SessionFactory;
+
+ /// Connection string for all sessions
+ static string connectionString;
+ ///
+ public static string ConnectionString
+ {
+ get { return connectionString; }
+ set
+ {
+ if (value != connectionString)
+ {
+ connectionString = value;
+ SessionFactory = null; /// Clear SessionFactory on connection string change
+ }
+ }
+ }
+
+ /// Database type (MySQL or SQLite) for all sessions
+ private static DBType dbType;
+ ///
+ public static DBType DbType
+ {
+ get { return dbType; }
+ set { dbType = value; SessionFactory = null; }
+ }
+
+ ///
+ /// NHibernate session factory (to create the database session 'SessionFactory')
+ ///
+ /// A database session
+ static ISessionFactory CreateSessionFactory()
+ {
+ return CreateSessionFactory(false);
+ }
+
+ ///
+ /// NHibernate session factory (to create the database session 'SessionFactory')
+ ///
+ /// true = Create a new DB, false = Regular DB
+ /// A database session
+ public static ISessionFactory CreateSessionFactory(bool createDB)
+ {
+ FluentConfiguration cfg = Fluently.Configure();
+
+ switch (dbType)
+ {
+ default:
+ case DBType.MySql:
+ cfg = cfg.Database(MySQLConfiguration.Standard.ConnectionString(connectionString));
+ break;
+ case DBType.SQLite:
+ cfg = cfg.Database(SQLiteConfiguration.Standard.UsingFile(connectionString));
+ break;
+ }
+
+ cfg = cfg.Mappings(m => m.FluentMappings.AddFromAssemblyOf());
+
+ if (createDB)
+ {
+ return cfg.ExposeConfiguration(BuildSchemaCreate).BuildSessionFactory();
+ }
+ else
+ {
+ return cfg.ExposeConfiguration(BuildSchema).BuildSessionFactory();
+ }
+ }
+
+ static void BuildSchema(Configuration config)
+ {
+ /// This NHibernate tool takes a configuration with mapping info and exports a database schema
+ new SchemaExport(config).SetOutputFile("db_schema");
+ }
+
+ static void BuildSchemaCreate(Configuration config)
+ {
+ /// This NHibernate tool takes a configuration with mapping info and exports a database schema
+ new SchemaExport(config).Create(true, true);
+ }
+
+ /// Create a NHibernate session for the given database
+ public static ISession CreateSession()
+ {
+ if (string.IsNullOrEmpty(connectionString))
+ {
+ throw new Exception("Connection string was not specified");
+ }
+
+ if (SessionFactory == null) SessionFactory = CreateSessionFactory();
+
+ return SessionFactory.OpenSession();
+ }
+
+
+ ///
+ /// Create an empty users database.
+ /// Database contains only the user 'admin' and the control board component 'CB'.
+ ///
+ /// DBType.SQLite or DBType.MySql
+ /// Connection string
+ /// true=success, false=error
+ public static bool CreateEmptyDB()
+ {
+ ISessionFactory sessionFactory = CreateSessionFactory(true);
+ if (sessionFactory == null) return false;
+
+ /// Populate the database
+ using (var session = sessionFactory.OpenSession())
+ {
+ using (var transaction = session.BeginTransaction())
+ {
+ transaction.Commit();
+ }
+ }
+
+ return true;
+ }
+ }
+}
diff --git a/EventViewer/EventViewer.csproj b/EventViewer/EventViewer.csproj
index dd4c0a1dd..0b8951890 100644
--- a/EventViewer/EventViewer.csproj
+++ b/EventViewer/EventViewer.csproj
@@ -66,6 +66,7 @@
EventViewerWnd.cs
+
Form
diff --git a/EventViewer/EventViewerWnd.cs b/EventViewer/EventViewerWnd.cs
index a3718384d..5a472d1fe 100644
--- a/EventViewer/EventViewerWnd.cs
+++ b/EventViewer/EventViewerWnd.cs
@@ -102,9 +102,9 @@ namespace EventViewer
{
try
{
- DB.DbType = DBType.MySql;
- DB.ConnectionString = Program.LocalSettings.ConnectionString;
- session = DB.CreateSession();
+ EViewerDB.DbType = DBType.MySql;
+ EViewerDB.ConnectionString = Program.LocalSettings.ConnectionString;
+ session = EViewerDB.CreateSession();
subscribers = session.QueryOver().List();
unreadEventsRadioButton.Checked = true;
}
diff --git a/Events/DB.cs b/Events/DB.cs
index 716c3be05..f7f65f6a6 100644
--- a/Events/DB.cs
+++ b/Events/DB.cs
@@ -1,5 +1,5 @@
///
-/// Copyright (c) 2020 Sensus Slovensko a.s.
+/// Copyright (c) 2020-2023 Sensus Slovensko a.s.
///
using System;
using System.Collections.Generic;
@@ -15,156 +15,6 @@ namespace Events
{
public static class DB
{
- /// Session factory for all regular sessions, not for CreateEmptyResultsDB().
- public static ISessionFactory SessionFactory;
-
- /// Connection string for all sessions
- static string connectionString;
- ///
- public static string ConnectionString
- {
- get { return connectionString; }
- set
- {
- if (value != connectionString)
- {
- connectionString = value;
- SessionFactory = null; /// Clear SessionFactory on connection string change
- }
- }
- }
-
- /// Database type (MySQL or SQLite) for all sessions
- private static DBType dbType;
- ///
- public static DBType DbType
- {
- get { return dbType; }
- set { dbType = value; SessionFactory = null; }
- }
-
- ///
- /// NHibernate session factory (to create the database session 'SessionFactory')
- ///
- /// A database session
- static ISessionFactory CreateSessionFactory()
- {
- return CreateSessionFactory(false);
- }
-
- ///
- /// NHibernate session factory (to create the database session 'SessionFactory')
- ///
- /// true = Create a new DB, false = Regular DB
- /// A database session
- public static ISessionFactory CreateSessionFactory(bool createDB)
- {
- FluentConfiguration cfg = Fluently.Configure();
-
- switch (dbType)
- {
- default:
- case DBType.MySql:
- cfg = cfg.Database(MySQLConfiguration.Standard.ConnectionString(connectionString));
- break;
- case DBType.SQLite:
- cfg = cfg.Database(SQLiteConfiguration.Standard.UsingFile(connectionString));
- break;
- }
-
- cfg = cfg.Mappings(m => m.FluentMappings.AddFromAssemblyOf());
-
- if (createDB)
- {
- return cfg.ExposeConfiguration(BuildSchemaCreate).BuildSessionFactory();
- }
- else
- {
- return cfg.ExposeConfiguration(BuildSchema).BuildSessionFactory();
- }
- }
-
- static void BuildSchema(Configuration config)
- {
- /// This NHibernate tool takes a configuration with mapping info and exports a database schema
- new SchemaExport(config).SetOutputFile("db_schema");
- }
-
- static void BuildSchemaCreate(Configuration config)
- {
- /// This NHibernate tool takes a configuration with mapping info and exports a database schema
- new SchemaExport(config).Create(true, true);
- }
-
- /// Create a NHibernate session for the given database
- public static ISession CreateSession()
- {
- if (string.IsNullOrEmpty(connectionString))
- {
- throw new Exception("Connection string was not specified");
- }
-
- if (SessionFactory == null) SessionFactory = CreateSessionFactory();
-
- return SessionFactory.OpenSession();
- }
-
-
- public static void SaveObject(object obj)
- {
- SaveObject(CreateSession(), obj);
- }
- ///
- public static void SaveObject(ISession session, object obj)
- {
- using (var transaction = session.BeginTransaction())
- {
- session.SaveOrUpdate(obj);
- try { transaction.Commit(); }
- catch { }
- }
- }
-
-
- public static void DeleteObject(object obj)
- {
- DeleteObject(CreateSession(), obj);
- }
- ///
- public static void DeleteObject(ISession session, object obj)
- {
- using (var transaction = session.BeginTransaction())
- {
- session.Delete(obj);
- transaction.Commit();
- }
- }
-
-
- ///
- /// Create an empty users database.
- /// Database contains only the user 'admin' and the control board component 'CB'.
- ///
- /// DBType.SQLite or DBType.MySql
- /// Connection string
- /// true=success, false=error
- public static bool CreateEmptyDB()
- {
- ISessionFactory sessionFactory = CreateSessionFactory(true);
- if (sessionFactory == null) return false;
-
- /// Populate the database
- using (var session = sessionFactory.OpenSession())
- {
- using (var transaction = session.BeginTransaction())
- {
- transaction.Commit();
- }
- }
-
- return true;
- }
-
///
/// Shared data (initially empty)
///
@@ -180,7 +30,7 @@ namespace Events
DB.BenchName = benchName;
}
- ///
+ ///
/// Loads shared data from the database
///
public static void LoadSubscribers(ISession session)
@@ -193,6 +43,7 @@ namespace Events
///
public static void LoadRecentEvents(ISession session, string benchName, int days)
{
+ BenchName = benchName;
RecentEvents = session.QueryOver()
.Where(e => (e.Bench == benchName))
.And(e => (e.TimeStamp >= DateTime.Now - new TimeSpan(days, 0, 0, 0)))
@@ -201,7 +52,8 @@ namespace Events
public static void SaveEvent(ISession session, Event evnt, SubscriberGroup groups)
{
- if (allSubscribers == null) return;
+ if (allSubscribers == null) LoadSubscribers(session);
+
IList thisEventSubscribers = new List();
foreach (var s in allSubscribers)
{
@@ -211,10 +63,10 @@ namespace Events
thisEventSubscribers.Add(s);
}
}
- evnt.Bench = BenchName;
evnt.Subscribers = thisEventSubscribers;
+
+ evnt.Bench = BenchName;
session.SaveOrUpdate(evnt);
- session.Flush();
}
}
}
diff --git a/TBF/Program.cs b/TBF/Program.cs
index 75b77b087..298a6a66d 100644
--- a/TBF/Program.cs
+++ b/TBF/Program.cs
@@ -437,16 +437,6 @@ namespace TBF
}
if (rsltDBSession != null && rsltDBSession.IsOpen) rsltDBSession.Close();
- ///
- /// Connect to Events database (if any) and load recent events from this test bench.
- ///
- if (TBF.DB.EventsDBSessionFactory != null)
- {
- var evntsDBsession = TBF.DB.EventsDBSessionFactory.OpenSession();
- Events.DB.LoadRecentEvents(evntsDBsession, loginDlgBench.BenchName, 7); /// Last 7 days
- evntsDBsession.Close();
- }
-
retryLogin = false;
break;
}
diff --git a/TBF/Rig/DataContainers/BenchInfo/iPerl/Component.cs b/TBF/Rig/DataContainers/BenchInfo/iPerl/Component.cs
index d5d3f9441..1137f6c8d 100644
--- a/TBF/Rig/DataContainers/BenchInfo/iPerl/Component.cs
+++ b/TBF/Rig/DataContainers/BenchInfo/iPerl/Component.cs
@@ -10,6 +10,7 @@ using Config;
using TBF.Rig;
using TBF.Rig.Generic;
using TBF.Resources;
+using TBF.UI.Calendar;
namespace TBF.Rig.DataContainers.BenchInfo.iPerl
{
@@ -56,35 +57,51 @@ namespace TBF.Rig.DataContainers.BenchInfo.iPerl
}
- public IList GetCalendarEvents()
+ public List GetCalendarEvents()
{
- DateTime calibrationDue = myCfg.CalibValidDate;
- IList calendarEvents = new List();
+ var calEvents = new List();
- if (calibrationDue > TBF.UI.Constants.MinDate)
+ DateTime calibDue = myCfg.CalibValidDate;
+ if (calibDue > TBF.UI.Constants.MinDate)
{
- /// Calibration due date calendar event
- calendarEvents.Add(new TBF.UI.Calendar.CalibrationDueDateEvent(calibrationDue.Date, Name,
- string.Format(Strings.Calibration_due_date_is_0,
- calibrationDue.Date.ToString(TBF.UI.Constants.DateFormat))));
- if (DateTime.Now.Date <= calibrationDue.AddDays(-7))
+ /// Five weekly notifications
+ foreach (var days in new int[] { -35, -28, -21, -14 })
{
- /// Weekly reminders (last 5 weeks)
- calendarEvents.Add(new TBF.UI.Calendar.CalibrationReminderEvent(calibrationDue.Date.AddDays(-35), Name,
- string.Format(Strings.Calibration_due_date_is_0,
- calibrationDue.Date.ToString(TBF.UI.Constants.DateFormat)),
- false));
+ if (calibDue.Date.AddDays(days + 6) >= DateTime.Now.Date)
+ {
+ calEvents.Add(new CalibrationReminderEvent(Config.CalendarEvent.AutoAction.Notification,
+ calibDue.Date.AddDays(days),
+ Name,
+ string.Format(Strings.Calibration_due_date_is_0,
+ calibDue.Date.ToString(TBF.UI.Constants.DateFormat))));
+ }
}
- if (DateTime.Now.Date <= calibrationDue.Date)
+
+ /// Five daily warnings
+ foreach (var days in new int[] { -7, -6, -5, -4, -3, -2, -1 })
{
- /// Daily reminders (last 5 days)
- calendarEvents.Add(new TBF.UI.Calendar.CalibrationReminderEvent(calibrationDue.AddDays(-5), Name,
- string.Format(Strings.Calibration_due_date_is_0,
- calibrationDue.Date.ToString(TBF.UI.Constants.DateFormat)),
- true));
+ if (calibDue.Date.AddDays(days) >= DateTime.Now.Date)
+ {
+ /// Weekly reminders (last 5 weeks)
+ calEvents.Add(new CalibrationReminderEvent(Config.CalendarEvent.AutoAction.Warning,
+ calibDue.Date.AddDays(days),
+ Name,
+ string.Format(Strings.Calibration_due_date_is_0,
+ calibDue.Date.ToString(TBF.UI.Constants.DateFormat))));
+ }
+ }
+
+ /// Calibration due date
+ if (calibDue.Date >= DateTime.Now.Date)
+ {
+ calEvents.Add(new CalibrationDueDateEvent(calibDue.Date,
+ Name,
+ string.Format(Strings.Calibration_due_date_is_0,
+ calibDue.Date.ToString(TBF.UI.Constants.DateFormat))));
}
}
- return calendarEvents;
+
+ return calEvents;
}
}
}
diff --git a/TBF/Rig/DataContainers/Buoyancy/Component.cs b/TBF/Rig/DataContainers/Buoyancy/Component.cs
index 624e15828..4b41cf838 100644
--- a/TBF/Rig/DataContainers/Buoyancy/Component.cs
+++ b/TBF/Rig/DataContainers/Buoyancy/Component.cs
@@ -1,10 +1,11 @@
///
-/// Copyright (c) 2019-2020 Sensus Slovensko a.s.
+/// Copyright (c) 2019-2023 Sensus Slovensko a.s.
///
using System;
using System.Collections.Generic;
using log4net;
using TBF.Resources;
+using TBF.UI.Calendar;
namespace TBF.Rig.DataContainers.Buoyancy
{
@@ -36,35 +37,51 @@ namespace TBF.Rig.DataContainers.Buoyancy
}
- public IList GetCalendarEvents()
+ public List GetCalendarEvents()
{
- DateTime calibrationDue = myCfg.CalibValidDate;
- IList calendarEvents = new List();
+ var calEvents = new List();
- if (calibrationDue > TBF.UI.Constants.MinDate)
+ DateTime calibDue = myCfg.CalibValidDate;
+ if (calibDue > TBF.UI.Constants.MinDate)
{
- /// Calibration due date calendar event
- calendarEvents.Add(new TBF.UI.Calendar.CalibrationDueDateEvent(calibrationDue.Date, Name,
- string.Format(Strings.Calibration_due_date_is_0,
- calibrationDue.Date.ToString(TBF.UI.Constants.DateFormat))));
- if (DateTime.Now.Date <= calibrationDue.AddDays(-7))
+ /// Five weekly notifications
+ foreach (var days in new int[] { -35, -28, -21, -14 })
{
- /// Weekly reminders (last 5 weeks)
- calendarEvents.Add(new TBF.UI.Calendar.CalibrationReminderEvent(calibrationDue.Date.AddDays(-35), Name,
- string.Format(Strings.Calibration_due_date_is_0,
- calibrationDue.Date.ToString(TBF.UI.Constants.DateFormat)),
- false));
+ if (calibDue.Date.AddDays(days + 6) >= DateTime.Now.Date)
+ {
+ calEvents.Add(new CalibrationReminderEvent(Config.CalendarEvent.AutoAction.Notification,
+ calibDue.Date.AddDays(days),
+ Name,
+ string.Format(Strings.Calibration_due_date_is_0,
+ calibDue.Date.ToString(TBF.UI.Constants.DateFormat))));
+ }
}
- if (DateTime.Now.Date <= calibrationDue.Date)
+
+ /// Five daily warnings
+ foreach (var days in new int[] { -7, -6, -5, -4, -3, -2, -1 })
{
- /// Daily reminders (last 5 days)
- calendarEvents.Add(new TBF.UI.Calendar.CalibrationReminderEvent(calibrationDue.AddDays(-5), Name,
- string.Format(Strings.Calibration_due_date_is_0,
- calibrationDue.Date.ToString(TBF.UI.Constants.DateFormat)),
- true));
+ if (calibDue.Date.AddDays(days) >= DateTime.Now.Date)
+ {
+ /// Weekly reminders (last 5 weeks)
+ calEvents.Add(new CalibrationReminderEvent(Config.CalendarEvent.AutoAction.Warning,
+ calibDue.Date.AddDays(days),
+ Name,
+ string.Format(Strings.Calibration_due_date_is_0,
+ calibDue.Date.ToString(TBF.UI.Constants.DateFormat))));
+ }
+ }
+
+ /// Calibration due date
+ if (calibDue.Date >= DateTime.Now.Date)
+ {
+ calEvents.Add(new CalibrationDueDateEvent(calibDue.Date,
+ Name,
+ string.Format(Strings.Calibration_due_date_is_0,
+ calibDue.Date.ToString(TBF.UI.Constants.DateFormat))));
}
}
- return calendarEvents;
+
+ return calEvents;
}
}
}
diff --git a/TBF/Rig/DataContainers/Density/Component.cs b/TBF/Rig/DataContainers/Density/Component.cs
index 93874a09d..fee77f209 100644
--- a/TBF/Rig/DataContainers/Density/Component.cs
+++ b/TBF/Rig/DataContainers/Density/Component.cs
@@ -1,10 +1,11 @@
///
-/// Copyright (c) 2019-2020 Sensus Slovensko a.s.
+/// Copyright (c) 2019-2023 Sensus Slovensko a.s.
///
using System;
using System.Collections.Generic;
using log4net;
using TBF.Resources;
+using TBF.UI.Calendar;
namespace TBF.Rig.DataContainers.Density
{
@@ -39,35 +40,51 @@ namespace TBF.Rig.DataContainers.Density
}
- public IList GetCalendarEvents()
+ public List GetCalendarEvents()
{
- DateTime calibrationDue = myCfg.CalibValidDate;
- IList calendarEvents = new List();
+ var calEvents = new List();
- if (calibrationDue > TBF.UI.Constants.MinDate)
+ DateTime calibDue = myCfg.CalibValidDate;
+ if (calibDue > TBF.UI.Constants.MinDate)
{
- /// Calibration due date calendar event
- calendarEvents.Add(new TBF.UI.Calendar.CalibrationDueDateEvent(calibrationDue.Date, Name,
- string.Format(Strings.Calibration_due_date_is_0,
- calibrationDue.Date.ToString(TBF.UI.Constants.DateFormat))));
- if (DateTime.Now.Date <= calibrationDue.AddDays(-7))
+ /// Five weekly notifications
+ foreach (var days in new int[] { -35, -28, -21, -14 })
{
- /// Weekly reminders (last 5 weeks)
- calendarEvents.Add(new TBF.UI.Calendar.CalibrationReminderEvent(calibrationDue.Date.AddDays(-35), Name,
- string.Format(Strings.Calibration_due_date_is_0,
- calibrationDue.Date.ToString(TBF.UI.Constants.DateFormat)),
- false));
+ if (calibDue.Date.AddDays(days + 6) >= DateTime.Now.Date)
+ {
+ calEvents.Add(new CalibrationReminderEvent(Config.CalendarEvent.AutoAction.Notification,
+ calibDue.Date.AddDays(days),
+ Name,
+ string.Format(Strings.Calibration_due_date_is_0,
+ calibDue.Date.ToString(TBF.UI.Constants.DateFormat))));
+ }
}
- if (DateTime.Now.Date <= calibrationDue.Date)
+
+ /// Five daily warnings
+ foreach (var days in new int[] { -7, -6, -5, -4, -3, -2, -1 })
{
- /// Daily reminders (last 5 days)
- calendarEvents.Add(new TBF.UI.Calendar.CalibrationReminderEvent(calibrationDue.AddDays(-5), Name,
- string.Format(Strings.Calibration_due_date_is_0,
- calibrationDue.Date.ToString(TBF.UI.Constants.DateFormat)),
- true));
+ if (calibDue.Date.AddDays(days) >= DateTime.Now.Date)
+ {
+ /// Weekly reminders (last 5 weeks)
+ calEvents.Add(new CalibrationReminderEvent(Config.CalendarEvent.AutoAction.Warning,
+ calibDue.Date.AddDays(days),
+ Name,
+ string.Format(Strings.Calibration_due_date_is_0,
+ calibDue.Date.ToString(TBF.UI.Constants.DateFormat))));
+ }
+ }
+
+ /// Calibration due date
+ if (calibDue.Date >= DateTime.Now.Date)
+ {
+ calEvents.Add(new CalibrationDueDateEvent(calibDue.Date,
+ Name,
+ string.Format(Strings.Calibration_due_date_is_0,
+ calibDue.Date.ToString(TBF.UI.Constants.DateFormat))));
}
}
- return calendarEvents;
+
+ return calEvents;
}
}
}
diff --git a/TBF/Rig/DataContainers/Evaporation/Component.cs b/TBF/Rig/DataContainers/Evaporation/Component.cs
index e38486807..0d2b65e1c 100644
--- a/TBF/Rig/DataContainers/Evaporation/Component.cs
+++ b/TBF/Rig/DataContainers/Evaporation/Component.cs
@@ -1,5 +1,5 @@
///
-/// Copyright (c) 2020 Sensus Slovensko a.s.
+/// Copyright (c) 2020-2023 Sensus Slovensko a.s.
///
using System;
using System.Collections.Generic;
@@ -7,6 +7,7 @@ using log4net;
using Config.Entities;
using TBF.Rig.GenericDevices;
using TBF.Resources;
+using TBF.UI.Calendar;
namespace TBF.Rig.DataContainers.Evaporation
{
@@ -40,35 +41,51 @@ namespace TBF.Rig.DataContainers.Evaporation
}
- public IList GetCalendarEvents()
+ public List GetCalendarEvents()
{
- DateTime calibrationDue = myCfg.CalibValidDate;
- IList calendarEvents = new List();
+ var calEvents = new List();
- if (calibrationDue > TBF.UI.Constants.MinDate)
+ DateTime calibDue = myCfg.CalibValidDate;
+ if (calibDue > TBF.UI.Constants.MinDate)
{
- /// Calibration due date calendar event
- calendarEvents.Add(new TBF.UI.Calendar.CalibrationDueDateEvent(calibrationDue.Date, Name,
- string.Format(Strings.Calibration_due_date_is_0,
- calibrationDue.Date.ToString(TBF.UI.Constants.DateFormat))));
- if (DateTime.Now.Date <= calibrationDue.AddDays(-7))
+ /// Five weekly notifications
+ foreach (var days in new int[] { -35, -28, -21, -14 })
{
- /// Weekly reminders (last 5 weeks)
- calendarEvents.Add(new TBF.UI.Calendar.CalibrationReminderEvent(calibrationDue.Date.AddDays(-35), Name,
- string.Format(Strings.Calibration_due_date_is_0,
- calibrationDue.Date.ToString(TBF.UI.Constants.DateFormat)),
- false));
+ if (calibDue.Date.AddDays(days + 6) >= DateTime.Now.Date)
+ {
+ calEvents.Add(new CalibrationReminderEvent(Config.CalendarEvent.AutoAction.Notification,
+ calibDue.Date.AddDays(days),
+ Name,
+ string.Format(Strings.Calibration_due_date_is_0,
+ calibDue.Date.ToString(TBF.UI.Constants.DateFormat))));
+ }
}
- if (DateTime.Now.Date <= calibrationDue.Date)
+
+ /// Five daily warnings
+ foreach (var days in new int[] { -7, -6, -5, -4, -3, -2, -1 })
{
- /// Daily reminders (last 5 days)
- calendarEvents.Add(new TBF.UI.Calendar.CalibrationReminderEvent(calibrationDue.AddDays(-5), Name,
- string.Format(Strings.Calibration_due_date_is_0,
- calibrationDue.Date.ToString(TBF.UI.Constants.DateFormat)),
- true));
+ if (calibDue.Date.AddDays(days) >= DateTime.Now.Date)
+ {
+ /// Weekly reminders (last 5 weeks)
+ calEvents.Add(new CalibrationReminderEvent(Config.CalendarEvent.AutoAction.Warning,
+ calibDue.Date.AddDays(days),
+ Name,
+ string.Format(Strings.Calibration_due_date_is_0,
+ calibDue.Date.ToString(TBF.UI.Constants.DateFormat))));
+ }
+ }
+
+ /// Calibration due date
+ if (calibDue.Date >= DateTime.Now.Date)
+ {
+ calEvents.Add(new CalibrationDueDateEvent(calibDue.Date,
+ Name,
+ string.Format(Strings.Calibration_due_date_is_0,
+ calibDue.Date.ToString(TBF.UI.Constants.DateFormat))));
}
}
- return calendarEvents;
+
+ return calEvents;
}
}
}
diff --git a/TBF/Rig/Elde/Diverter/Diverter.cs b/TBF/Rig/Elde/Diverter/Diverter.cs
index f1152ef31..796692b0b 100644
--- a/TBF/Rig/Elde/Diverter/Diverter.cs
+++ b/TBF/Rig/Elde/Diverter/Diverter.cs
@@ -1,5 +1,5 @@
///
-/// Copyright (c) 2013-2022 Sensus Slovensko a.s.
+/// Copyright (c) 2013-2023 Sensus Slovensko a.s.
///
using System;
using System.Collections.Generic;
@@ -9,6 +9,7 @@ using Dirichlet.Numerics;
using TBF.Rig.Generic;
using TBF.Boxes;
using TBF.Resources;
+using TBF.UI.Calendar;
namespace TBF.Rig.Elde.Diverter
{
@@ -152,35 +153,51 @@ namespace TBF.Rig.Elde.Diverter
///
/// Calendar support
///
- public IList GetCalendarEvents()
+ public List GetCalendarEvents()
{
- DateTime calibrationDue = diverterCfg.CalibValidDate;
- IList calendarEvents = new List();
+ var calEvents = new List();
- if (calibrationDue > TBF.UI.Constants.MinDate)
+ DateTime calibDue = diverterCfg.CalibValidDate;
+ if (calibDue > TBF.UI.Constants.MinDate)
{
- /// Calibration due date calendar event
- calendarEvents.Add(new TBF.UI.Calendar.CalibrationDueDateEvent(calibrationDue.Date, Name,
- string.Format(Strings.Calibration_due_date_is_0,
- calibrationDue.Date.ToString(TBF.UI.Constants.DateFormat))));
- if (DateTime.Now.Date <= calibrationDue.AddDays(-7))
+ /// Five weekly notifications
+ foreach (var days in new int[] { -35, -28, -21, -14 })
{
- /// Weekly reminders (last 5 weeks)
- calendarEvents.Add(new TBF.UI.Calendar.CalibrationReminderEvent(calibrationDue.Date.AddDays(-35), Name,
- string.Format(Strings.Calibration_due_date_is_0,
- calibrationDue.Date.ToString(TBF.UI.Constants.DateFormat)),
- false));
+ if (calibDue.Date.AddDays(days + 6) >= DateTime.Now.Date)
+ {
+ calEvents.Add(new CalibrationReminderEvent(Config.CalendarEvent.AutoAction.Notification,
+ calibDue.Date.AddDays(days),
+ Name,
+ string.Format(Strings.Calibration_due_date_is_0,
+ calibDue.Date.ToString(TBF.UI.Constants.DateFormat))));
+ }
}
- if (DateTime.Now.Date <= calibrationDue.Date)
+
+ /// Five daily warnings
+ foreach (var days in new int[] { -7, -6, -5, -4, -3, -2, -1 })
{
- /// Daily reminders (last 5 days)
- calendarEvents.Add(new TBF.UI.Calendar.CalibrationReminderEvent(calibrationDue.AddDays(-5), Name,
- string.Format(Strings.Calibration_due_date_is_0,
- calibrationDue.Date.ToString(TBF.UI.Constants.DateFormat)),
- true));
+ if (calibDue.Date.AddDays(days) >= DateTime.Now.Date)
+ {
+ /// Weekly reminders (last 5 weeks)
+ calEvents.Add(new CalibrationReminderEvent(Config.CalendarEvent.AutoAction.Warning,
+ calibDue.Date.AddDays(days),
+ Name,
+ string.Format(Strings.Calibration_due_date_is_0,
+ calibDue.Date.ToString(TBF.UI.Constants.DateFormat))));
+ }
+ }
+
+ /// Calibration due date
+ if (calibDue.Date >= DateTime.Now.Date)
+ {
+ calEvents.Add(new CalibrationDueDateEvent(calibDue.Date,
+ Name,
+ string.Format(Strings.Calibration_due_date_is_0,
+ calibDue.Date.ToString(TBF.UI.Constants.DateFormat))));
}
}
- return calendarEvents;
+
+ return calEvents;
}
///
diff --git a/TBF/Rig/Elde/FlowMeter/FlowMeter.cs b/TBF/Rig/Elde/FlowMeter/FlowMeter.cs
index 129f47a21..f69780ddb 100644
--- a/TBF/Rig/Elde/FlowMeter/FlowMeter.cs
+++ b/TBF/Rig/Elde/FlowMeter/FlowMeter.cs
@@ -1,5 +1,5 @@
///
-/// Copyright (c) 2013-2018 Sensus Slovensko a.s.
+/// Copyright (c) 2013-2023 Sensus Slovensko a.s.
///
using System;
using System.Collections.Generic;
@@ -7,6 +7,7 @@ using log4net;
using Config.Entities;
using TBF.Boxes;
using TBF.Resources;
+using TBF.UI.Calendar;
namespace TBF.Rig.Elde.FlowMeter
{
@@ -68,7 +69,7 @@ namespace TBF.Rig.Elde.FlowMeter
{
for (int r = 0; r <= 5; r++)
{
- if (RangeEnabled(r) && flowMeterCfg.GetCalibValidDate(r) != DateTime.MinValue
+ if (RangeEnabled(r) && flowMeterCfg.GetCalibValidDate(r) > DateTime.MinValue
&& flowMeterCfg.GetCalibValidDate(r).Date < DateTime.Now.Date)
{
throw new Exception(string.Format("{0}/r{1}: {2}", Name, r, Strings.Calibration_certificate_validity_expired));
@@ -86,35 +87,51 @@ namespace TBF.Rig.Elde.FlowMeter
///
/// Calendar support
///
- public IList GetCalendarEvents()
+ public List GetCalendarEvents()
{
- DateTime calibrationDue = flowMeterCfg.CalibValidDate;
- IList calendarEvents = new List();
+ var calEvents = new List();
- if (calibrationDue > TBF.UI.Constants.MinDate)
+ DateTime calibDue = flowMeterCfg.CalibValidDate;
+ if (calibDue > TBF.UI.Constants.MinDate)
{
- /// Calibration due date calendar event
- calendarEvents.Add(new TBF.UI.Calendar.CalibrationDueDateEvent(calibrationDue.Date, Name,
- string.Format(Strings.Calibration_due_date_is_0,
- calibrationDue.Date.ToString(TBF.UI.Constants.DateFormat))));
- if (DateTime.Now.Date <= calibrationDue.AddDays(-7))
+ /// Five weekly notifications
+ foreach (var days in new int[] { -35, -28, -21, -14 })
{
- /// Weekly reminders (last 5 weeks)
- calendarEvents.Add(new TBF.UI.Calendar.CalibrationReminderEvent(calibrationDue.Date.AddDays(-35), Name,
- string.Format(Strings.Calibration_due_date_is_0,
- calibrationDue.Date.ToString(TBF.UI.Constants.DateFormat)),
- false));
+ if (calibDue.Date.AddDays(days + 6) >= DateTime.Now.Date)
+ {
+ calEvents.Add(new CalibrationReminderEvent(Config.CalendarEvent.AutoAction.Notification,
+ calibDue.Date.AddDays(days),
+ Name,
+ string.Format(Strings.Calibration_due_date_is_0,
+ calibDue.Date.ToString(TBF.UI.Constants.DateFormat))));
+ }
}
- if (DateTime.Now.Date <= calibrationDue.Date)
+
+ /// Five daily warnings
+ foreach (var days in new int[] { -7, -6, -5, -4, -3, -2, -1 })
{
- /// Daily reminders (last 5 days)
- calendarEvents.Add(new TBF.UI.Calendar.CalibrationReminderEvent(calibrationDue.AddDays(-5), Name,
- string.Format(Strings.Calibration_due_date_is_0,
- calibrationDue.Date.ToString(TBF.UI.Constants.DateFormat)),
- true));
+ if (calibDue.Date.AddDays(days) >= DateTime.Now.Date)
+ {
+ /// Weekly reminders (last 5 weeks)
+ calEvents.Add(new CalibrationReminderEvent(Config.CalendarEvent.AutoAction.Warning,
+ calibDue.Date.AddDays(days),
+ Name,
+ string.Format(Strings.Calibration_due_date_is_0,
+ calibDue.Date.ToString(TBF.UI.Constants.DateFormat))));
+ }
+ }
+
+ /// Calibration due date
+ if (calibDue.Date >= DateTime.Now.Date)
+ {
+ calEvents.Add(new CalibrationDueDateEvent(calibDue.Date,
+ Name,
+ string.Format(Strings.Calibration_due_date_is_0,
+ calibDue.Date.ToString(TBF.UI.Constants.DateFormat))));
}
}
- return calendarEvents;
+
+ return calEvents;
}
diff --git a/TBF/Rig/Elde/PressureMeter/PressureMeter.cs b/TBF/Rig/Elde/PressureMeter/PressureMeter.cs
index 1e982f590..d083606c8 100644
--- a/TBF/Rig/Elde/PressureMeter/PressureMeter.cs
+++ b/TBF/Rig/Elde/PressureMeter/PressureMeter.cs
@@ -1,5 +1,5 @@
///
-/// Copyright (c) 2013-2020 Sensus Slovensko a.s.
+/// Copyright (c) 2013-2023 Sensus Slovensko a.s.
///
using System;
using System.Collections.Generic;
@@ -7,6 +7,7 @@ using log4net;
using TBF.Rig.Generic;
using TBF.Boxes;
using TBF.Resources;
+using TBF.UI.Calendar;
namespace TBF.Rig.Elde.PressureMeter
{
@@ -55,35 +56,51 @@ namespace TBF.Rig.Elde.PressureMeter
}
- public IList GetCalendarEvents()
+ public List GetCalendarEvents()
{
- DateTime calibrationDue = pressureMeterCfg.CalibValidDate;
- IList calendarEvents = new List();
+ var calEvents = new List();
- if (calibrationDue > TBF.UI.Constants.MinDate)
+ DateTime calibDue = pressureMeterCfg.CalibValidDate;
+ if (calibDue > TBF.UI.Constants.MinDate)
{
- /// Calibration due date calendar event
- calendarEvents.Add(new TBF.UI.Calendar.CalibrationDueDateEvent(calibrationDue.Date, Name,
- string.Format(Strings.Calibration_due_date_is_0,
- calibrationDue.Date.ToString(TBF.UI.Constants.DateFormat))));
- if (DateTime.Now.Date <= calibrationDue.AddDays(-7))
+ /// Five weekly notifications
+ foreach (var days in new int[] { -35, -28, -21, -14 })
{
- /// Weekly reminders (last 5 weeks)
- calendarEvents.Add(new TBF.UI.Calendar.CalibrationReminderEvent(calibrationDue.Date.AddDays(-35), Name,
- string.Format(Strings.Calibration_due_date_is_0,
- calibrationDue.Date.ToString(TBF.UI.Constants.DateFormat)),
- false));
+ if (calibDue.Date.AddDays(days + 6) >= DateTime.Now.Date)
+ {
+ calEvents.Add(new CalibrationReminderEvent(Config.CalendarEvent.AutoAction.Notification,
+ calibDue.Date.AddDays(days),
+ Name,
+ string.Format(Strings.Calibration_due_date_is_0,
+ calibDue.Date.ToString(TBF.UI.Constants.DateFormat))));
+ }
}
- if (DateTime.Now.Date <= calibrationDue.Date)
+
+ /// Five daily warnings
+ foreach (var days in new int[] { -7, -6, -5, -4, -3, -2, -1 })
{
- /// Daily reminders (last 5 days)
- calendarEvents.Add(new TBF.UI.Calendar.CalibrationReminderEvent(calibrationDue.AddDays(-5), Name,
- string.Format(Strings.Calibration_due_date_is_0,
- calibrationDue.Date.ToString(TBF.UI.Constants.DateFormat)),
- true));
+ if (calibDue.Date.AddDays(days) >= DateTime.Now.Date)
+ {
+ /// Weekly reminders (last 5 weeks)
+ calEvents.Add(new CalibrationReminderEvent(Config.CalendarEvent.AutoAction.Warning,
+ calibDue.Date.AddDays(days),
+ Name,
+ string.Format(Strings.Calibration_due_date_is_0,
+ calibDue.Date.ToString(TBF.UI.Constants.DateFormat))));
+ }
+ }
+
+ /// Calibration due date
+ if (calibDue.Date >= DateTime.Now.Date)
+ {
+ calEvents.Add(new CalibrationDueDateEvent(calibDue.Date,
+ Name,
+ string.Format(Strings.Calibration_due_date_is_0,
+ calibDue.Date.ToString(TBF.UI.Constants.DateFormat))));
}
}
- return calendarEvents;
+
+ return calEvents;
}
diff --git a/TBF/Rig/Elde/PressureMeterInternal/PressureMeter.cs b/TBF/Rig/Elde/PressureMeterInternal/PressureMeter.cs
index 5f6fb5535..7f322ba61 100644
--- a/TBF/Rig/Elde/PressureMeterInternal/PressureMeter.cs
+++ b/TBF/Rig/Elde/PressureMeterInternal/PressureMeter.cs
@@ -1,5 +1,5 @@
///
-/// Copyright (c) 2015 Sensus Metering Systems
+/// Copyright (c) 2015-2023 Sensus Slovensko a.s.
/// Author: Milan Hanajik
///
using System;
@@ -8,6 +8,7 @@ using log4net;
using TBF.Rig.Generic;
using TBF.Boxes;
using TBF.Resources;
+using TBF.UI.Calendar;
namespace TBF.Rig.Elde.PressureMeterInternal
{
@@ -49,35 +50,51 @@ namespace TBF.Rig.Elde.PressureMeterInternal
}
- public IList GetCalendarEvents()
+ public List GetCalendarEvents()
{
- DateTime calibrationDue = pressureMeterCfg.CalibValidDate;
- IList calendarEvents = new List();
+ var calEvents = new List();
- if (calibrationDue > TBF.UI.Constants.MinDate)
+ DateTime calibDue = pressureMeterCfg.CalibValidDate;
+ if (calibDue > TBF.UI.Constants.MinDate)
{
- /// Calibration due date calendar event
- calendarEvents.Add(new TBF.UI.Calendar.CalibrationDueDateEvent(calibrationDue.Date, Name,
- string.Format(Strings.Calibration_due_date_is_0,
- calibrationDue.Date.ToString(TBF.UI.Constants.DateFormat))));
- if (DateTime.Now.Date <= calibrationDue.AddDays(-7))
+ /// Five weekly notifications
+ foreach (var days in new int[] { -35, -28, -21, -14 })
{
- /// Weekly reminders (last 5 weeks)
- calendarEvents.Add(new TBF.UI.Calendar.CalibrationReminderEvent(calibrationDue.Date.AddDays(-35), Name,
- string.Format(Strings.Calibration_due_date_is_0,
- calibrationDue.Date.ToString(TBF.UI.Constants.DateFormat)),
- false));
+ if (calibDue.Date.AddDays(days + 6) >= DateTime.Now.Date)
+ {
+ calEvents.Add(new CalibrationReminderEvent(Config.CalendarEvent.AutoAction.Notification,
+ calibDue.Date.AddDays(days),
+ Name,
+ string.Format(Strings.Calibration_due_date_is_0,
+ calibDue.Date.ToString(TBF.UI.Constants.DateFormat))));
+ }
}
- if (DateTime.Now.Date <= calibrationDue.Date)
+
+ /// Five daily warnings
+ foreach (var days in new int[] { -7, -6, -5, -4, -3, -2, -1 })
{
- /// Daily reminders (last 5 days)
- calendarEvents.Add(new TBF.UI.Calendar.CalibrationReminderEvent(calibrationDue.AddDays(-5), Name,
- string.Format(Strings.Calibration_due_date_is_0,
- calibrationDue.Date.ToString(TBF.UI.Constants.DateFormat)),
- true));
+ if (calibDue.Date.AddDays(days) >= DateTime.Now.Date)
+ {
+ /// Weekly reminders (last 5 weeks)
+ calEvents.Add(new CalibrationReminderEvent(Config.CalendarEvent.AutoAction.Warning,
+ calibDue.Date.AddDays(days),
+ Name,
+ string.Format(Strings.Calibration_due_date_is_0,
+ calibDue.Date.ToString(TBF.UI.Constants.DateFormat))));
+ }
+ }
+
+ /// Calibration due date
+ if (calibDue.Date >= DateTime.Now.Date)
+ {
+ calEvents.Add(new CalibrationDueDateEvent(calibDue.Date,
+ Name,
+ string.Format(Strings.Calibration_due_date_is_0,
+ calibDue.Date.ToString(TBF.UI.Constants.DateFormat))));
}
}
- return calendarEvents;
+
+ return calEvents;
}
diff --git a/TBF/Rig/Elde/TempMeter/TempMeter.cs b/TBF/Rig/Elde/TempMeter/TempMeter.cs
index 0e94b8cb7..6a33a69f9 100644
--- a/TBF/Rig/Elde/TempMeter/TempMeter.cs
+++ b/TBF/Rig/Elde/TempMeter/TempMeter.cs
@@ -1,5 +1,5 @@
///
-/// Copyright (c) 2013-2020 Sensus Slovensko a.s.
+/// Copyright (c) 2013-2023 Sensus Slovensko a.s.
///
using System;
using System.Collections.Generic;
@@ -8,6 +8,7 @@ using Common;
using TBF.Rig.Generic;
using TBF.Boxes;
using TBF.Resources;
+using TBF.UI.Calendar;
namespace TBF.Rig.Elde.TempMeter
{
@@ -52,35 +53,51 @@ namespace TBF.Rig.Elde.TempMeter
}
- public IList GetCalendarEvents()
+ public List GetCalendarEvents()
{
- DateTime calibrationDue = tempMtrCfg.CalibValidDate;
- IList calendarEvents = new List();
+ var calEvents = new List();
- if (calibrationDue > TBF.UI.Constants.MinDate)
+ DateTime calibDue = tempMtrCfg.CalibValidDate;
+ if (calibDue > TBF.UI.Constants.MinDate)
{
- /// Calibration due date calendar event
- calendarEvents.Add(new TBF.UI.Calendar.CalibrationDueDateEvent(calibrationDue.Date, Name,
- string.Format(Strings.Calibration_due_date_is_0,
- calibrationDue.Date.ToString(TBF.UI.Constants.DateFormat))));
- if (DateTime.Now.Date <= calibrationDue.AddDays(-7))
+ /// Five weekly notifications
+ foreach (var days in new int[] { -35, -28, -21, -14 })
{
- /// Weekly reminders (last 5 weeks)
- calendarEvents.Add(new TBF.UI.Calendar.CalibrationReminderEvent(calibrationDue.Date.AddDays(-35), Name,
- string.Format(Strings.Calibration_due_date_is_0,
- calibrationDue.Date.ToString(TBF.UI.Constants.DateFormat)),
- false));
+ if (calibDue.Date.AddDays(days + 6) >= DateTime.Now.Date)
+ {
+ calEvents.Add(new CalibrationReminderEvent(Config.CalendarEvent.AutoAction.Notification,
+ calibDue.Date.AddDays(days),
+ Name,
+ string.Format(Strings.Calibration_due_date_is_0,
+ calibDue.Date.ToString(TBF.UI.Constants.DateFormat))));
+ }
}
- if (DateTime.Now.Date <= calibrationDue.Date)
+
+ /// Five daily warnings
+ foreach (var days in new int[] { -7, -6, -5, -4, -3, -2, -1 })
{
- /// Daily reminders (last 5 days)
- calendarEvents.Add(new TBF.UI.Calendar.CalibrationReminderEvent(calibrationDue.AddDays(-5), Name,
- string.Format(Strings.Calibration_due_date_is_0,
- calibrationDue.Date.ToString(TBF.UI.Constants.DateFormat)),
- true));
+ if (calibDue.Date.AddDays(days) >= DateTime.Now.Date)
+ {
+ /// Weekly reminders (last 5 weeks)
+ calEvents.Add(new CalibrationReminderEvent(Config.CalendarEvent.AutoAction.Warning,
+ calibDue.Date.AddDays(days),
+ Name,
+ string.Format(Strings.Calibration_due_date_is_0,
+ calibDue.Date.ToString(TBF.UI.Constants.DateFormat))));
+ }
+ }
+
+ /// Calibration due date
+ if (calibDue.Date >= DateTime.Now.Date)
+ {
+ calEvents.Add(new CalibrationDueDateEvent(calibDue.Date,
+ Name,
+ string.Format(Strings.Calibration_due_date_is_0,
+ calibDue.Date.ToString(TBF.UI.Constants.DateFormat))));
}
}
- return calendarEvents;
+
+ return calEvents;
}
public double ReadTemperature()
diff --git a/TBF/Rig/Elde/TempMeterInternal/TempMeter.cs b/TBF/Rig/Elde/TempMeterInternal/TempMeter.cs
index 53263460c..7ae4ea4ea 100644
--- a/TBF/Rig/Elde/TempMeterInternal/TempMeter.cs
+++ b/TBF/Rig/Elde/TempMeterInternal/TempMeter.cs
@@ -1,5 +1,5 @@
///
-/// Copyright (c) 2015 Sensus Metering Systems
+/// Copyright (c) 2015-2023 Sensus Slovensko a.s.
///
using System;
using System.Collections.Generic;
@@ -7,6 +7,7 @@ using log4net;
using TBF.Rig.Generic;
using TBF.Boxes;
using TBF.Resources;
+using TBF.UI.Calendar;
namespace TBF.Rig.Elde.TempMeterInternal
{
@@ -46,35 +47,51 @@ namespace TBF.Rig.Elde.TempMeterInternal
}
- public IList GetCalendarEvents()
+ public List GetCalendarEvents()
{
- DateTime calibrationDue = tempMtrCfg.CalibValidDate;
- IList calendarEvents = new List();
+ var calEvents = new List();
- if (calibrationDue > TBF.UI.Constants.MinDate)
+ DateTime calibDue = tempMtrCfg.CalibValidDate;
+ if (calibDue > TBF.UI.Constants.MinDate)
{
- /// Calibration due date calendar event
- calendarEvents.Add(new TBF.UI.Calendar.CalibrationDueDateEvent(calibrationDue.Date, Name,
- string.Format(Strings.Calibration_due_date_is_0,
- calibrationDue.Date.ToString(TBF.UI.Constants.DateFormat))));
- if (DateTime.Now.Date <= calibrationDue.AddDays(-7))
+ /// Five weekly notifications
+ foreach (var days in new int[] { -35, -28, -21, -14 })
{
- /// Weekly reminders (last 5 weeks)
- calendarEvents.Add(new TBF.UI.Calendar.CalibrationReminderEvent(calibrationDue.Date.AddDays(-35), Name,
- string.Format(Strings.Calibration_due_date_is_0,
- calibrationDue.Date.ToString(TBF.UI.Constants.DateFormat)),
- false));
+ if (calibDue.Date.AddDays(days + 6) >= DateTime.Now.Date)
+ {
+ calEvents.Add(new CalibrationReminderEvent(Config.CalendarEvent.AutoAction.Notification,
+ calibDue.Date.AddDays(days),
+ Name,
+ string.Format(Strings.Calibration_due_date_is_0,
+ calibDue.Date.ToString(TBF.UI.Constants.DateFormat))));
+ }
}
- if (DateTime.Now.Date <= calibrationDue.Date)
+
+ /// Five daily warnings
+ foreach (var days in new int[] { -7, -6, -5, -4, -3, -2, -1 })
{
- /// Daily reminders (last 5 days)
- calendarEvents.Add(new TBF.UI.Calendar.CalibrationReminderEvent(calibrationDue.AddDays(-5), Name,
- string.Format(Strings.Calibration_due_date_is_0,
- calibrationDue.Date.ToString(TBF.UI.Constants.DateFormat)),
- true));
+ if (calibDue.Date.AddDays(days) >= DateTime.Now.Date)
+ {
+ /// Weekly reminders (last 5 weeks)
+ calEvents.Add(new CalibrationReminderEvent(Config.CalendarEvent.AutoAction.Warning,
+ calibDue.Date.AddDays(days),
+ Name,
+ string.Format(Strings.Calibration_due_date_is_0,
+ calibDue.Date.ToString(TBF.UI.Constants.DateFormat))));
+ }
+ }
+
+ /// Calibration due date
+ if (calibDue.Date >= DateTime.Now.Date)
+ {
+ calEvents.Add(new CalibrationDueDateEvent(calibDue.Date,
+ Name,
+ string.Format(Strings.Calibration_due_date_is_0,
+ calibDue.Date.ToString(TBF.UI.Constants.DateFormat))));
}
}
- return calendarEvents;
+
+ return calEvents;
}
diff --git a/TBF/Rig/Elde/TempMeterMeret/TempMeter.cs b/TBF/Rig/Elde/TempMeterMeret/TempMeter.cs
index b579ddba1..c75a05382 100644
--- a/TBF/Rig/Elde/TempMeterMeret/TempMeter.cs
+++ b/TBF/Rig/Elde/TempMeterMeret/TempMeter.cs
@@ -1,11 +1,12 @@
///
-/// Copyright (c) 2018 Sensus Slovensko a.s.
+/// Copyright (c) 2018-2023 Sensus Slovensko a.s.
///
using System;
using System.Collections.Generic;
using log4net;
using TBF.Boxes;
using TBF.Resources;
+using TBF.UI.Calendar;
namespace TBF.Rig.Elde.TempMeterMeret
{
@@ -39,35 +40,51 @@ namespace TBF.Rig.Elde.TempMeterMeret
}
- public IList GetCalendarEvents()
+ public List GetCalendarEvents()
{
- DateTime calibrationDue = tempMtrCfg.CalibValidDate;
- IList calendarEvents = new List();
+ var calEvents = new List();
- if (calibrationDue > TBF.UI.Constants.MinDate)
+ DateTime calibDue = tempMtrCfg.CalibValidDate;
+ if (calibDue > TBF.UI.Constants.MinDate)
{
- /// Calibration due date calendar event
- calendarEvents.Add(new TBF.UI.Calendar.CalibrationDueDateEvent(calibrationDue.Date, Name,
- string.Format(Strings.Calibration_due_date_is_0,
- calibrationDue.Date.ToString(TBF.UI.Constants.DateFormat))));
- if (DateTime.Now.Date <= calibrationDue.AddDays(-7))
+ /// Five weekly notifications
+ foreach (var days in new int[] { -35, -28, -21, -14 })
{
- /// Weekly reminders (last 5 weeks)
- calendarEvents.Add(new TBF.UI.Calendar.CalibrationReminderEvent(calibrationDue.Date.AddDays(-35), Name,
- string.Format(Strings.Calibration_due_date_is_0,
- calibrationDue.Date.ToString(TBF.UI.Constants.DateFormat)),
- false));
+ if (calibDue.Date.AddDays(days + 6) >= DateTime.Now.Date)
+ {
+ calEvents.Add(new CalibrationReminderEvent(Config.CalendarEvent.AutoAction.Notification,
+ calibDue.Date.AddDays(days),
+ Name,
+ string.Format(Strings.Calibration_due_date_is_0,
+ calibDue.Date.ToString(TBF.UI.Constants.DateFormat))));
+ }
}
- if (DateTime.Now.Date <= calibrationDue.Date)
+
+ /// Five daily warnings
+ foreach (var days in new int[] { -7, -6, -5, -4, -3, -2, -1 })
{
- /// Daily reminders (last 5 days)
- calendarEvents.Add(new TBF.UI.Calendar.CalibrationReminderEvent(calibrationDue.AddDays(-5), Name,
- string.Format(Strings.Calibration_due_date_is_0,
- calibrationDue.Date.ToString(TBF.UI.Constants.DateFormat)),
- true));
+ if (calibDue.Date.AddDays(days) >= DateTime.Now.Date)
+ {
+ /// Weekly reminders (last 5 weeks)
+ calEvents.Add(new CalibrationReminderEvent(Config.CalendarEvent.AutoAction.Warning,
+ calibDue.Date.AddDays(days),
+ Name,
+ string.Format(Strings.Calibration_due_date_is_0,
+ calibDue.Date.ToString(TBF.UI.Constants.DateFormat))));
+ }
+ }
+
+ /// Calibration due date
+ if (calibDue.Date >= DateTime.Now.Date)
+ {
+ calEvents.Add(new CalibrationDueDateEvent(calibDue.Date,
+ Name,
+ string.Format(Strings.Calibration_due_date_is_0,
+ calibDue.Date.ToString(TBF.UI.Constants.DateFormat))));
}
}
- return calendarEvents;
+
+ return calEvents;
}
diff --git a/TBF/Rig/GenericDevices/IHasCalendarEvents.cs b/TBF/Rig/GenericDevices/IHasCalendarEvents.cs
index 32b9166c4..8cf959f2b 100644
--- a/TBF/Rig/GenericDevices/IHasCalendarEvents.cs
+++ b/TBF/Rig/GenericDevices/IHasCalendarEvents.cs
@@ -8,6 +8,6 @@ namespace TBF.Rig.GenericDevices
{
interface IHasCalendarEvents
{
- IList GetCalendarEvents();
+ List GetCalendarEvents();
}
}
diff --git a/TBF/Rig/Hart/Nivotrack/Nivotrack.cs b/TBF/Rig/Hart/Nivotrack/Nivotrack.cs
index 8d6d5d78c..ec08398fe 100644
--- a/TBF/Rig/Hart/Nivotrack/Nivotrack.cs
+++ b/TBF/Rig/Hart/Nivotrack/Nivotrack.cs
@@ -1,5 +1,5 @@
///
-/// Copyright (c) 2018 Sensus Slovensko a.s.
+/// Copyright (c) 2018-2023 Sensus Slovensko a.s.
///
using System;
using System.Collections.Generic;
@@ -10,6 +10,7 @@ using TBF.Rig.GenericDevices;
using TBF.Boxes;
using TBF.Rig.Hart.Common;
using TBF.Resources;
+using TBF.UI.Calendar;
namespace TBF.Rig.Hart.Nivotrack
{
@@ -77,35 +78,51 @@ namespace TBF.Rig.Hart.Nivotrack
///
/// Calendar support
///
- public IList GetCalendarEvents()
+ public List GetCalendarEvents()
{
- DateTime calibrationDue = nivotrackCfg.CalibValidDate;
- IList calendarEvents = new List();
+ var calEvents = new List();
- if (calibrationDue > TBF.UI.Constants.MinDate)
+ DateTime calibDue = nivotrackCfg.CalibValidDate;
+ if (calibDue > TBF.UI.Constants.MinDate)
{
- /// Calibration due date calendar event
- calendarEvents.Add(new TBF.UI.Calendar.CalibrationDueDateEvent(calibrationDue.Date, Name,
- string.Format(Strings.Calibration_due_date_is_0,
- calibrationDue.Date.ToString(TBF.UI.Constants.DateFormat))));
- if (DateTime.Now.Date <= calibrationDue.AddDays(-7))
+ /// Five weekly notifications
+ foreach (var days in new int[] { -35, -28, -21, -14 })
{
- /// Weekly reminders (last 5 weeks)
- calendarEvents.Add(new TBF.UI.Calendar.CalibrationReminderEvent(calibrationDue.Date.AddDays(-35), Name,
- string.Format(Strings.Calibration_due_date_is_0,
- calibrationDue.Date.ToString(TBF.UI.Constants.DateFormat)),
- false));
+ if (calibDue.Date.AddDays(days + 6) >= DateTime.Now.Date)
+ {
+ calEvents.Add(new CalibrationReminderEvent(Config.CalendarEvent.AutoAction.Notification,
+ calibDue.Date.AddDays(days),
+ Name,
+ string.Format(Strings.Calibration_due_date_is_0,
+ calibDue.Date.ToString(TBF.UI.Constants.DateFormat))));
+ }
}
- if (DateTime.Now.Date <= calibrationDue.Date)
+
+ /// Five daily warnings
+ foreach (var days in new int[] { -7, -6, -5, -4, -3, -2, -1 })
{
- /// Daily reminders (last 5 days)
- calendarEvents.Add(new TBF.UI.Calendar.CalibrationReminderEvent(calibrationDue.AddDays(-5), Name,
- string.Format(Strings.Calibration_due_date_is_0,
- calibrationDue.Date.ToString(TBF.UI.Constants.DateFormat)),
- true));
+ if (calibDue.Date.AddDays(days) >= DateTime.Now.Date)
+ {
+ /// Weekly reminders (last 5 weeks)
+ calEvents.Add(new CalibrationReminderEvent(Config.CalendarEvent.AutoAction.Warning,
+ calibDue.Date.AddDays(days),
+ Name,
+ string.Format(Strings.Calibration_due_date_is_0,
+ calibDue.Date.ToString(TBF.UI.Constants.DateFormat))));
+ }
+ }
+
+ /// Calibration due date
+ if (calibDue.Date >= DateTime.Now.Date)
+ {
+ calEvents.Add(new CalibrationDueDateEvent(calibDue.Date,
+ Name,
+ string.Format(Strings.Calibration_due_date_is_0,
+ calibDue.Date.ToString(TBF.UI.Constants.DateFormat))));
}
}
- return calendarEvents;
+
+ return calEvents;
}
diff --git a/TBF/Rig/Keithley/TempMeter/TempMeter.cs b/TBF/Rig/Keithley/TempMeter/TempMeter.cs
index f7fc0fed4..57151cd0e 100644
--- a/TBF/Rig/Keithley/TempMeter/TempMeter.cs
+++ b/TBF/Rig/Keithley/TempMeter/TempMeter.cs
@@ -1,5 +1,5 @@
///
-/// Copyright (c) 2016-2020 Sensus Metering Systems
+/// Copyright (c) 2016-2023 Sensus Slovensko a.s.
///
using System;
using System.Collections.Generic;
@@ -8,6 +8,7 @@ using log4net;
using TBF.Boxes;
using TBF.Rig.Keithley.Multimeter_2010_RS232;
using TBF.Resources;
+using TBF.UI.Calendar;
namespace TBF.Rig.Keithley.TempMeter
{
@@ -49,35 +50,51 @@ namespace TBF.Rig.Keithley.TempMeter
///
/// Calendar support
///
- public IList GetCalendarEvents()
+ public List GetCalendarEvents()
{
- DateTime calibrationDue = tempMtrCfg.CalibValidDate;
- IList calendarEvents = new List();
+ var calEvents = new List();
- if (calibrationDue > TBF.UI.Constants.MinDate)
+ DateTime calibDue = tempMtrCfg.CalibValidDate;
+ if (calibDue > TBF.UI.Constants.MinDate)
{
- /// Calibration due date calendar event
- calendarEvents.Add(new TBF.UI.Calendar.CalibrationDueDateEvent(calibrationDue.Date, Name,
- string.Format(Strings.Calibration_due_date_is_0,
- calibrationDue.Date.ToString(TBF.UI.Constants.DateFormat))));
- if (DateTime.Now.Date <= calibrationDue.AddDays(-7))
+ /// Five weekly notifications
+ foreach (var days in new int[] { -35, -28, -21, -14 })
{
- /// Weekly reminders (last 5 weeks)
- calendarEvents.Add(new TBF.UI.Calendar.CalibrationReminderEvent(calibrationDue.Date.AddDays(-35), Name,
- string.Format(Strings.Calibration_due_date_is_0,
- calibrationDue.Date.ToString(TBF.UI.Constants.DateFormat)),
- false));
+ if (calibDue.Date.AddDays(days + 6) >= DateTime.Now.Date)
+ {
+ calEvents.Add(new CalibrationReminderEvent(Config.CalendarEvent.AutoAction.Notification,
+ calibDue.Date.AddDays(days),
+ Name,
+ string.Format(Strings.Calibration_due_date_is_0,
+ calibDue.Date.ToString(TBF.UI.Constants.DateFormat))));
+ }
}
- if (DateTime.Now.Date <= calibrationDue.Date)
+
+ /// Five daily warnings
+ foreach (var days in new int[] { -7, -6, -5, -4, -3, -2, -1 })
{
- /// Daily reminders (last 5 days)
- calendarEvents.Add(new TBF.UI.Calendar.CalibrationReminderEvent(calibrationDue.AddDays(-5), Name,
- string.Format(Strings.Calibration_due_date_is_0,
- calibrationDue.Date.ToString(TBF.UI.Constants.DateFormat)),
- true));
+ if (calibDue.Date.AddDays(days) >= DateTime.Now.Date)
+ {
+ /// Weekly reminders (last 5 weeks)
+ calEvents.Add(new CalibrationReminderEvent(Config.CalendarEvent.AutoAction.Warning,
+ calibDue.Date.AddDays(days),
+ Name,
+ string.Format(Strings.Calibration_due_date_is_0,
+ calibDue.Date.ToString(TBF.UI.Constants.DateFormat))));
+ }
+ }
+
+ /// Calibration due date
+ if (calibDue.Date >= DateTime.Now.Date)
+ {
+ calEvents.Add(new CalibrationDueDateEvent(calibDue.Date,
+ Name,
+ string.Format(Strings.Calibration_due_date_is_0,
+ calibDue.Date.ToString(TBF.UI.Constants.DateFormat))));
}
}
- return calendarEvents;
+
+ return calEvents;
}
public double ReadTemperature()
diff --git a/TBF/Rig/MettlerToledo/Standard/BalanceDev.cs b/TBF/Rig/MettlerToledo/Standard/BalanceDev.cs
index 9fb42b1d7..eb25554ec 100644
--- a/TBF/Rig/MettlerToledo/Standard/BalanceDev.cs
+++ b/TBF/Rig/MettlerToledo/Standard/BalanceDev.cs
@@ -1,5 +1,5 @@
///
-/// Copyright (c) 2013-2021 Sensus Slovensko a.s.
+/// Copyright (c) 2013-2023 Sensus Slovensko a.s.
///
using System;
using System.Collections.Generic;
@@ -12,6 +12,7 @@ using TBF.Rig.Generic;
using TBF.Rig.GenericDevices;
using TBF.Boxes;
using TBF.Resources;
+using TBF.UI.Calendar;
namespace TBF.Rig.MettlerToledo.Standard
{
@@ -111,7 +112,7 @@ namespace TBF.Rig.MettlerToledo.Standard
Balances[nextBalanceIdx - 1] = this;
}
- if (balanceCfg.CalibValidDate != DateTime.MinValue && balanceCfg.CalibValidDate.Date < DateTime.Now.Date)
+ if (balanceCfg.CalibValidDate > DateTime.MinValue && balanceCfg.CalibValidDate.Date < DateTime.Now.Date)
{
throw new Exception(string.Format("{0}: {1}", Name, Strings.Calibration_certificate_validity_expired));
}
@@ -137,35 +138,51 @@ namespace TBF.Rig.MettlerToledo.Standard
}
- public IList GetCalendarEvents()
+ public List GetCalendarEvents()
{
- DateTime calibrationDue = balanceCfg.CalibValidDate;
- IList calendarEvents = new List();
+ var calEvents = new List();
- if (calibrationDue > TBF.UI.Constants.MinDate)
+ DateTime calibDue = balanceCfg.CalibValidDate;
+ if (calibDue > TBF.UI.Constants.MinDate)
{
- /// Calibration due date calendar event
- calendarEvents.Add(new TBF.UI.Calendar.CalibrationDueDateEvent(calibrationDue.Date, Name,
- string.Format(Strings.Calibration_due_date_is_0,
- calibrationDue.Date.ToString(TBF.UI.Constants.DateFormat))));
- if (DateTime.Now.Date <= calibrationDue.AddDays(-7))
+ /// Five weekly notifications
+ foreach (var days in new int[] { -35, -28, -21, -14 })
{
- /// Weekly reminders (last 5 weeks)
- calendarEvents.Add(new TBF.UI.Calendar.CalibrationReminderEvent(calibrationDue.Date.AddDays(-35), Name,
- string.Format(Strings.Calibration_due_date_is_0,
- calibrationDue.Date.ToString(TBF.UI.Constants.DateFormat)),
- false));
+ if (calibDue.Date.AddDays(days + 6) >= DateTime.Now.Date)
+ {
+ calEvents.Add(new CalibrationReminderEvent(Config.CalendarEvent.AutoAction.Notification,
+ calibDue.Date.AddDays(days),
+ Name,
+ string.Format(Strings.Calibration_due_date_is_0,
+ calibDue.Date.ToString(TBF.UI.Constants.DateFormat))));
+ }
}
- if (DateTime.Now.Date <= calibrationDue.Date)
+
+ /// Five daily warnings
+ foreach (var days in new int[] { -7, -6, -5, -4, -3, -2, -1 })
{
- /// Daily reminders (last 5 days)
- calendarEvents.Add(new TBF.UI.Calendar.CalibrationReminderEvent(calibrationDue.AddDays(-5), Name,
- string.Format(Strings.Calibration_due_date_is_0,
- calibrationDue.Date.ToString(TBF.UI.Constants.DateFormat)),
- true));
+ if (calibDue.Date.AddDays(days) >= DateTime.Now.Date)
+ {
+ /// Weekly reminders (last 5 weeks)
+ calEvents.Add(new CalibrationReminderEvent(Config.CalendarEvent.AutoAction.Warning,
+ calibDue.Date.AddDays(days),
+ Name,
+ string.Format(Strings.Calibration_due_date_is_0,
+ calibDue.Date.ToString(TBF.UI.Constants.DateFormat))));
+ }
+ }
+
+ /// Calibration due date
+ if (calibDue.Date >= DateTime.Now.Date)
+ {
+ calEvents.Add(new CalibrationDueDateEvent(calibDue.Date,
+ Name,
+ string.Format(Strings.Calibration_due_date_is_0,
+ calibDue.Date.ToString(TBF.UI.Constants.DateFormat))));
}
}
- return calendarEvents;
+
+ return calEvents;
}
diff --git a/TBF/Rig/Output/DB/ProductionTracing/Tracing.cs b/TBF/Rig/Output/DB/ProductionTracing/Tracing.cs
index 71fb853b8..6b8564f66 100644
--- a/TBF/Rig/Output/DB/ProductionTracing/Tracing.cs
+++ b/TBF/Rig/Output/DB/ProductionTracing/Tracing.cs
@@ -275,11 +275,12 @@ namespace TBF.Rig.Output.DB.ProductionTracing
opCompleted = true;
if (SaveTracingRecords(batch) != Retv.OK) anyError = true;
- if (anyError && !string.IsNullOrEmpty(Events.DB.ConnectionString))
+ if (TBF.DB.EventsDBSessionFactory != null && anyError)
{
+ NHibernate.ISession session = null;
try
{
- NHibernate.ISession session = Events.DB.CreateSession();
+ session = TBF.DB.EventsDBSessionFactory.OpenSession();
Events.DB.LoadSubscribers(session);
TBF.UiBridge.Bridge.TriggerEvent(session, Name, EventClass.ComputerResources, Severity.Error,
@@ -291,17 +292,22 @@ namespace TBF.Rig.Output.DB.ProductionTracing
{
log.ErrorFormat("Triggering event(s) failed: {0}", exc.Message);
}
+ finally
+ {
+ if (session != null && session.IsOpen) session.Close();
+ }
}
return anyError ? Event.ErrorProcessingResults : Event.ResultsWritten;
}
else
{
- if (anyError && !string.IsNullOrEmpty(Events.DB.ConnectionString))
+ if (TBF.DB.EventsDBSessionFactory != null && anyError)
{
+ NHibernate.ISession session = null;
try
{
- NHibernate.ISession session = Events.DB.CreateSession();
+ session = TBF.DB.EventsDBSessionFactory.OpenSession();
Events.DB.LoadSubscribers(session);
TBF.UiBridge.Bridge.TriggerEvent(session, Name, EventClass.ComputerResources, Severity.Error,
@@ -313,6 +319,10 @@ namespace TBF.Rig.Output.DB.ProductionTracing
{
log.ErrorFormat("Triggering event(s) failed: {0}", exc.Message);
}
+ finally
+ {
+ if (session != null && session.IsOpen) session.Close();
+ }
}
return anyError ? Event.ErrorProcessingResults : Event.ResultsWritten;
diff --git a/TBF/Rig/Output/DB/SensusOracle/Database.cs b/TBF/Rig/Output/DB/SensusOracle/Database.cs
index d0481c8a8..b32505ed2 100644
--- a/TBF/Rig/Output/DB/SensusOracle/Database.cs
+++ b/TBF/Rig/Output/DB/SensusOracle/Database.cs
@@ -357,11 +357,12 @@ namespace TBF.Rig.Output.DB.SensusOracle
opCompleted = true;
}
- if (anyError && !string.IsNullOrEmpty(Events.DB.ConnectionString))
+ if (TBF.DB.EventsDBSessionFactory != null && anyError)
{
+ NHibernate.ISession session = null;
try
{
- NHibernate.ISession session = Events.DB.CreateSession();
+ session = TBF.DB.EventsDBSessionFactory.OpenSession();
Events.DB.LoadSubscribers(session);
TBF.UiBridge.Bridge.TriggerEvent(session, Name, EventClass.ComputerResources, Severity.Error,
@@ -373,6 +374,10 @@ namespace TBF.Rig.Output.DB.SensusOracle
{
log.ErrorFormat("Triggering event(s) failed: {0}", exc.Message);
}
+ finally
+ {
+ if (session != null && session.IsOpen) session.Close();
+ }
}
return anyError ? Event.ErrorProcessingResults : Event.ResultsWritten;
diff --git a/TBF/Rig/Output/EventTriggers/Standard/Trigger.cs b/TBF/Rig/Output/EventTriggers/Standard/Trigger.cs
index a75d01957..d487724d5 100644
--- a/TBF/Rig/Output/EventTriggers/Standard/Trigger.cs
+++ b/TBF/Rig/Output/EventTriggers/Standard/Trigger.cs
@@ -142,9 +142,10 @@ namespace TBF.Rig.Output.EventTriggers.Standard
return;
}
+ ISession session = null;
try
{
- ISession session = Events.DB.CreateSession();
+ session = TBF.DB.EventsDBSessionFactory.OpenSession();
Events.DB.LoadSubscribers(session);
///
@@ -226,15 +227,15 @@ namespace TBF.Rig.Output.EventTriggers.Standard
long eFlags = batch.ErrorFlags();
long iFlags = batch.InfoFlags();
///
- if (triggerCfg.E1) OnExTriggerEvent(session, eFlags, iFlags, 1);
- if (triggerCfg.E2) OnExTriggerEvent(session, eFlags, iFlags, 2);
- if (triggerCfg.E3) OnExTriggerEvent(session, eFlags, iFlags, 3);
- if (triggerCfg.E4) OnExTriggerEvent(session, eFlags, iFlags, 4);
- if (triggerCfg.E5) OnExTriggerEvent(session, eFlags, iFlags, 5);
- if (triggerCfg.E6) OnExTriggerEvent(session, eFlags, iFlags, 6);
- if (triggerCfg.E7) OnExTriggerEvent(session, eFlags, iFlags, 7);
- if (triggerCfg.E8) OnExTriggerEvent(session, eFlags, iFlags, 8);
- if (triggerCfg.E9) OnExTriggerEvent(session, eFlags, iFlags, 9);
+ if (triggerCfg.E1) OnExTriggerEvent(session, eFlags, iFlags, 1);
+ if (triggerCfg.E2) OnExTriggerEvent(session, eFlags, iFlags, 2);
+ if (triggerCfg.E3) OnExTriggerEvent(session, eFlags, iFlags, 3);
+ if (triggerCfg.E4) OnExTriggerEvent(session, eFlags, iFlags, 4);
+ if (triggerCfg.E5) OnExTriggerEvent(session, eFlags, iFlags, 5);
+ if (triggerCfg.E6) OnExTriggerEvent(session, eFlags, iFlags, 6);
+ if (triggerCfg.E7) OnExTriggerEvent(session, eFlags, iFlags, 7);
+ if (triggerCfg.E8) OnExTriggerEvent(session, eFlags, iFlags, 8);
+ if (triggerCfg.E9) OnExTriggerEvent(session, eFlags, iFlags, 9);
if (triggerCfg.E10) OnExTriggerEvent(session, eFlags, iFlags, 10);
if (triggerCfg.E11) OnExTriggerEvent(session, eFlags, iFlags, 11);
if (triggerCfg.E12) OnExTriggerEvent(session, eFlags, iFlags, 12);
@@ -254,6 +255,10 @@ namespace TBF.Rig.Output.EventTriggers.Standard
{
log.ErrorFormat("Triggering event(s) failed: {0}", exc.Message);
}
+ finally
+ {
+ if (session != null && session.IsOpen) session.Close();
+ }
}
void OnExTriggerEvent(ISession session, long eFlags, long iFlags, int x)
diff --git a/TBF/Rig/Output/FileWriters/IperlLogger/Writer.cs b/TBF/Rig/Output/FileWriters/IperlLogger/Writer.cs
index 6733f61ed..1d5e5f400 100644
--- a/TBF/Rig/Output/FileWriters/IperlLogger/Writer.cs
+++ b/TBF/Rig/Output/FileWriters/IperlLogger/Writer.cs
@@ -162,11 +162,12 @@ namespace TBF.Rig.Output.FileWriters.IperlLogger
opCompleted = true;
}
- if (anyError && !string.IsNullOrEmpty(Events.DB.ConnectionString))
+ if (TBF.DB.EventsDBSessionFactory != null && anyError)
{
+ NHibernate.ISession session = null;
try
{
- NHibernate.ISession session = Events.DB.CreateSession();
+ session = TBF.DB.EventsDBSessionFactory.OpenSession();
Events.DB.LoadSubscribers(session);
TBF.UiBridge.Bridge.TriggerEvent(session, Name, EventClass.ComputerResources, Severity.Error,
@@ -178,6 +179,10 @@ namespace TBF.Rig.Output.FileWriters.IperlLogger
{
log.ErrorFormat("Triggering event(s) failed: {0}", exc.Message);
}
+ finally
+ {
+ if (session != null && session.IsOpen) session.Close();
+ }
}
return anyError ? Event.ErrorProcessingResults: Event.ResultsWritten;
diff --git a/TBF/Rig/StateMachine.cs b/TBF/Rig/StateMachine.cs
index c4a92346d..cd0e620fa 100644
--- a/TBF/Rig/StateMachine.cs
+++ b/TBF/Rig/StateMachine.cs
@@ -209,11 +209,9 @@ namespace TBF.Rig
#elif BERLIN || GELSENWASSER || GENESIS || IZRAEL_200 || PETERSBURG_200 || PUCHONG_200 || SLM_150
public static void InitializeBoardEtc(ControlComponent_Izrael2014.UserControl1 ctrlBrdComponent)
#else /// all newer benches
- public static void InitializeBoardEtc(ControlComponent_Torino2015.UserControl1 ctrlBrdComponent)
+ public static void InitializeBoardEtc(ISession session, ControlComponent_Torino2015.UserControl1 ctrlBrdComponent)
#endif
{
- var session = TBF.DB.ConfigDBSessionFactory.OpenSession();
-
/// Load the list of components (entities) from the database.
/// Then create the components (derived from IComponent).
components = Rig.TbfComponents.LoadComponentsFromDB(session);
@@ -299,8 +297,6 @@ namespace TBF.Rig
if ((eldeValve != null) && eldeValve.Inverted) valvesToInvert |= eldeValve.Mask;
}
- session.Close();
-
/// Pre-initialize the control board (= buffer the arguments ctrlBrdComponent, tankCapacities)
if (ControlBoard != null)
{
@@ -428,7 +424,7 @@ namespace TBF.Rig
/// Checks remote and local configuration DB paths and transitions for compatibility
///
/// true when DB-s are compatible
- public static bool IsRemoteDBCompatible(out string message)
+ public static bool IsRemoteDBCompatible(ISession localSession, out string message)
{
IList remoteFeedingPaths = new List();
IList remoteBenchPaths = new List();
@@ -456,16 +452,12 @@ namespace TBF.Rig
return false;
}
- var localSession = TBF.DB.ConfigDBSessionFactory.OpenSession();
-
var localFeedingPaths = localSession.QueryOver().List();
var localBenchPaths = localSession.QueryOver().List();
var localOutputPaths = localSession.QueryOver().List();
var localMetersPaths = localSession.QueryOver().List();
var localTransitions = localSession.QueryOver().List();
- localSession.Close();
-
string subMsg;
if (!IsCompatible(localFeedingPaths, remoteFeedingPaths, out subMsg))
{
@@ -583,7 +575,6 @@ namespace TBF.Rig
#if HEAT_METERS
heatMetersPaths = session.QueryOver().OrderBy(x => x.ItemNr).Asc.List();
#endif
- session.Flush();
}
catch (Exception e)
{
diff --git a/TBF/UI/Calendar/CalendarTabPageCtrl.cs b/TBF/UI/Calendar/CalendarTabPageCtrl.cs
index f5926b27c..5b38931c1 100644
--- a/TBF/UI/Calendar/CalendarTabPageCtrl.cs
+++ b/TBF/UI/Calendar/CalendarTabPageCtrl.cs
@@ -9,9 +9,7 @@ using NHibernate;
using Common;
using Config.Entities;
using Config.CalendarEvent;
-using Events.Entities;
using TBF.Resources;
-using TBF.UiBridge;
namespace TBF.UI.Calendar
{
@@ -19,16 +17,15 @@ namespace TBF.UI.Calendar
{
static readonly ILog log = LogManager.GetLogger(typeof(CalendarTabPageCtrl));
- IList eventsFromComponents;
- IList customEvents; /// Custom events loaded from the local config DB
+ public IList EventsFromComponents;
Timer timer;
- DateTime lastTimeCalendarEventsServed;
+ DateTime LastTimeCalendarEventsServed;
public CalendarTabPageCtrl()
{
InitializeComponent();
- eventsFromComponents = new List();
+ EventsFromComponents = new List();
Localize();
}
@@ -61,16 +58,22 @@ namespace TBF.UI.Calendar
calendarEventsListViewEx.Items.Add(lvi);
}
+ ///
+ /// Initializes 'public IList<...> EventsFromComponents.
+ ///
+ ///
+ ///
+ ///
public void StartCalendar(IList eventsFromComponents, ISession session = null)
{
+ this.EventsFromComponents = eventsFromComponents;
bool openAndCloseSession = (session == null);
- this.eventsFromComponents = eventsFromComponents;
try
{
/// Read custom events from the database
if (openAndCloseSession) session = TBF.DB.ConfigDBSessionFactory.OpenSession();
- customEvents = session.QueryOver().List();
+ var customEvents = session.QueryOver().List();
TripplicateShiftCustomEvents(customEvents);
@@ -84,15 +87,16 @@ namespace TBF.UI.Calendar
foreach (var e in eventsFromComponents) if (!e.Hidden) AddOne(e);
/// Serve events (determine if any event was triggered)
- lastTimeCalendarEventsServed = DateTime.Now;
- ServeCalendarEventsNotifWarnErrorFatal(lastTimeCalendarEventsServed, session, customEvents);
- if (openAndCloseSession) session.Close();
+ ServeCalendarEventsNotifWarnErrorFatal(DateTime.Now, session, customEvents);
}
catch (Exception)
{
- customEvents = new List();
log.ErrorFormat("Failed to load custom events from the LOCAL config database");
}
+ finally
+ {
+ if (openAndCloseSession && session != null && session.IsOpen) session.Close();
+ }
calendarCtrl1.CalendarView = CalendarViews.Month;
@@ -109,35 +113,34 @@ namespace TBF.UI.Calendar
///
void timer_Tick(object sender, EventArgs args)
{
- DateTime currentTime = DateTime.Now;
+ DateTime dateTimeNow = DateTime.Now;
- if ((currentTime.Hour != lastTimeCalendarEventsServed.Hour) ||
- (currentTime.Minute % 30) != (lastTimeCalendarEventsServed.Minute % 30))
+ if ((dateTimeNow.Hour != LastTimeCalendarEventsServed.Hour) ||
+ (dateTimeNow.Minute % 30) != (LastTimeCalendarEventsServed.Minute % 30))
{
/// Serve events at the beginning of each half hour
- ServeCalendarEventsNotifWarnErrorFatal(currentTime);
- lastTimeCalendarEventsServed = currentTime;
+ ServeCalendarEventsNotifWarnErrorFatal(dateTimeNow);
}
}
///
/// Triggers events corresponding to triggered motification.warning/error calendar events.
///
- /// Current time
- void ServeCalendarEventsNotifWarnErrorFatal(DateTime currentTime, ISession session = null, IList customEventsFromDB = null)
+ /// Current time
+ void ServeCalendarEventsNotifWarnErrorFatal(DateTime dateTimeNow, ISession session = null, IList customEventsFromDB = null)
{
- bool openAndCloseSession = (session == null);
+ LastTimeCalendarEventsServed = dateTimeNow;
- IList eventsToTrigger = new List();
+ var eventsToTrigger = new List();
- for (int i = eventsFromComponents.Count - 1; i >= 0; i--)
+ for (int i = EventsFromComponents.Count - 1; i >= 0; i--)
{
- ICalendarEvent calEvent = eventsFromComponents[i];
+ ICalendarEvent calEvent = EventsFromComponents[i];
AutoAction a = calEvent.AutoAction;
if (a == AutoAction.Notification || a == AutoAction.Warning || a == AutoAction.Error || a == AutoAction.FatalErr)
{
- if (Config.CalendarEvent.Utils.IsCalendarEventTrigerred(calEvent, currentTime))
+ if (Config.CalendarEvent.Utils.IsCalendarEventTrigerred(calEvent, dateTimeNow))
{
eventsToTrigger.Add(new Events.Entities.Event(null,
calEvent.Source,
@@ -151,21 +154,23 @@ namespace TBF.UI.Calendar
if (calEvent.Frequency == Frequency.Once)
{
- eventsFromComponents.Remove(calEvent);
+ EventsFromComponents.Remove(calEvent);
}
else
{
- Config.CalendarEvent.Utils.UpdateRecurringDate(calEvent, currentTime);
+ Config.CalendarEvent.Utils.UpdateRecurringDate(calEvent, dateTimeNow);
}
}
}
}
+ bool openAndCloseSession = (session == null);
+ ///
try
{
if (openAndCloseSession) session = TBF.DB.ConfigDBSessionFactory.OpenSession();
- var customEvents = (customEventsFromDB != null) ? customEventsFromDB : session.QueryOver() .List();
+ var customEvents = (customEventsFromDB != null) ? customEventsFromDB : session.QueryOver().List();
for (int i = customEvents.Count - 1; i >= 0; i--)
{
@@ -174,7 +179,7 @@ namespace TBF.UI.Calendar
AutoAction a = calEvent.AutoAction;
if (a == AutoAction.Notification || a == AutoAction.Warning || a == AutoAction.Error || a == AutoAction.FatalErr)
{
- if (Config.CalendarEvent.Utils.IsCalendarEventTrigerred(calEvent, currentTime))
+ if (Config.CalendarEvent.Utils.IsCalendarEventTrigerred(calEvent, dateTimeNow))
{
eventsToTrigger.Add(new Events.Entities.Event(null,
calEvent.Source,
@@ -190,7 +195,7 @@ namespace TBF.UI.Calendar
{
session.Delete(calEvent);
}
- else if (calEvent.UpdateRecurringDate(currentTime))
+ else if (calEvent.UpdateRecurringDate(dateTimeNow))
{
session.SaveOrUpdate(calEvent);
}
@@ -198,12 +203,15 @@ namespace TBF.UI.Calendar
}
}
session.Flush();
- if (openAndCloseSession) session.Close();
}
catch (Exception exc)
{
log.ErrorFormat("Failed to load or update CustomEvent-s in ServeTriggerEvtCalendarEvents(): {0}", exc.Message);
}
+ finally
+ {
+ if (openAndCloseSession && session != null && session.IsOpen) session.Close();
+ }
if (eventsToTrigger.Count > 0 && TBF.DB.EventsDBSessionFactory != null)
{
@@ -214,6 +222,7 @@ namespace TBF.UI.Calendar
{
TBF.UiBridge.Bridge.TriggerEvent(evtDBSession, e);
}
+ evtDBSession.Flush();
evtDBSession.Close();
}
}
@@ -258,6 +267,7 @@ namespace TBF.UI.Calendar
if (parametersList.Count >= maxCount) break;
}
}
+ session.Flush();
}
catch (Exception exc)
{
@@ -327,18 +337,18 @@ namespace TBF.UI.Calendar
session.SaveOrUpdate(dlg.NewEvent as CustomEvent);
session.Flush();
- customEvents = session.QueryOver().List();
+ var customEvents = session.QueryOver().List();
TripplicateShiftCustomEvents(customEvents);
/// Calendar
calendarCtrl1.ClearEvents();
- foreach (var e in eventsFromComponents) calendarCtrl1.AddEvent(e);
+ foreach (var e in EventsFromComponents) calendarCtrl1.AddEvent(e);
foreach (var e in customEvents) calendarCtrl1.AddEvent(e);
/// List view in the right pane
calendarEventsListViewEx.Items.Clear();
foreach (var e in customEvents) AddOne(e);
- foreach (var e in eventsFromComponents) if (!e.Hidden) AddOne(e);
+ foreach (var e in EventsFromComponents) if (!e.Hidden) AddOne(e);
}
catch (Exception)
{
@@ -388,18 +398,18 @@ namespace TBF.UI.Calendar
session.SaveOrUpdate(cEvents[0]);
session.Flush();
- customEvents = session.QueryOver().List();
+ var customEvents = session.QueryOver().List();
TripplicateShiftCustomEvents(customEvents);
/// Calendar
calendarCtrl1.ClearEvents();
- foreach (var e in eventsFromComponents) calendarCtrl1.AddEvent(e);
+ foreach (var e in EventsFromComponents) calendarCtrl1.AddEvent(e);
foreach (var e in customEvents) calendarCtrl1.AddEvent(e);
/// List view in the right pane
calendarEventsListViewEx.Items.Clear();
foreach (var e in customEvents) AddOne(e);
- foreach (var e in eventsFromComponents) if (!e.Hidden) AddOne(e);
+ foreach (var e in EventsFromComponents) if (!e.Hidden) AddOne(e);
}
}
catch (Exception)
diff --git a/TBF/UI/Calendar/CalibrationDueDateEvent.cs b/TBF/UI/Calendar/CalibrationDueDateEvent.cs
index c19d8fc9b..931ed8be1 100644
--- a/TBF/UI/Calendar/CalibrationDueDateEvent.cs
+++ b/TBF/UI/Calendar/CalibrationDueDateEvent.cs
@@ -11,14 +11,14 @@ namespace TBF.UI.Calendar
{
public DateTime Date { get; set; } /// The Date that the event occurs
public Frequency Frequency { get; set; } /// A value indicating how often the event occurs
- public bool AllDay { get; set; } /// True if the time component of the date can be ignored
+ public bool AllDay { get; set; } /// True if the time component of the date can be ignored
public bool TriggerOnExactDayOnly { get; set; } /// If this is a recurring event, set this to true to make the event show up only from the day specified forward
public string Source { get; set; } /// Source of this calendar event (becomes the source of the triggered event)
- public string Title { get; set; } /// The name of the event (becomes the text of the triggered event)
+ public string Title { get; set; } /// The name of the event (becomes the text of the triggered event)
public AutoAction AutoAction { get; set; } /// Automated action to be done or event to be triggered (becomes Severity)
public string Parameters { get; set; } /// Automated action parameters (e.g. name of a procedure to start)
public int Rank { get; set; } /// The ranking of the event that determines the order in which it is displayed on a particular day
- public bool Hidden { get; set; } /// True if the event is enabled, otherwise false
+ public bool Hidden { get; set; } /// True if the event is enabled, otherwise false
public bool ReadOnly { get; set; } /// True if the event details cannot be modified
public int BackColor { get; set; } /// The color that the event show up in on the calendar: (MSB)AARRGGBB(LSB)
public int TextColor { get; set; } /// The text color of the event: (MSB)AARRGGBB(LSB)
diff --git a/TBF/UI/Calendar/CalibrationReminderEvent.cs b/TBF/UI/Calendar/CalibrationReminderEvent.cs
index f7b183743..6b0757d48 100644
--- a/TBF/UI/Calendar/CalibrationReminderEvent.cs
+++ b/TBF/UI/Calendar/CalibrationReminderEvent.cs
@@ -26,29 +26,32 @@ namespace TBF.UI.Calendar
public Config.CalendarEvent.CustomRecurringFrequenciesHandler CustomRecurringFunction { get; set; }
+
+ private CalibrationReminderEvent() { }
+
///
/// CalibrationReminderEvent Constructor
///
- public CalibrationReminderEvent(bool daily = false)
+ public CalibrationReminderEvent(AutoAction autoAction)
{
/// Date
- Frequency = daily ? Frequency.Daily : Frequency.Weekly;
+ Frequency = Frequency.Once;
AllDay = true;
TriggerOnExactDayOnly = false;
/// Source
/// Text
- AutoAction = daily ? AutoAction.Warning : AutoAction.Notification;
+ AutoAction = autoAction;
Parameters = string.Empty;
Rank = 1;
Hidden = true;
ReadOnly = true;
- BackColor = unchecked((int)0xFFA00000);
- TextColor = unchecked((int)0xFFFFFFFF);
+ BackColor = unchecked((int)0xFFA00000); /// (MSB)AARRGGBB(LSB) ... red
+ TextColor = unchecked((int)0xFFFFFFFF); /// (MSB)AARRGGBB(LSB) ... white
TooltipEnabled = true;
}
- public CalibrationReminderEvent(DateTime date, string source, string text, bool daily = false)
- : this(daily)
+ public CalibrationReminderEvent(AutoAction autoAction, DateTime date, string source, string text)
+ : this(autoAction)
{
Date = date;
Source = source;
diff --git a/TBF/UI/MainWnd.cs b/TBF/UI/MainWnd.cs
index e9883881c..85ba17588 100644
--- a/TBF/UI/MainWnd.cs
+++ b/TBF/UI/MainWnd.cs
@@ -25,7 +25,7 @@ namespace TBF.UI
static readonly ILog log = LogManager.GetLogger(typeof(MainWnd));
const string ProcSeparator = " "; /// string separating procedure number and procedure name
-
+
public static IDictionary ProcedureNrs = new Dictionary(); /// Used in PreviousResultsDlg
public BenchControlPanel BenchControlPanel;
@@ -34,6 +34,11 @@ namespace TBF.UI
public bool IsShutdownDisabled;
public bool IsShutdownPCAfterClosingTbf;
+ ///
+ /// This local configuration DB session is opened in the constructor and closed at the end of MainWnd_Load( )
+ ///
+ ISession startupSession;
+
///
/// This dialog is shown when emergency stop is activated
///
@@ -135,15 +140,17 @@ namespace TBF.UI
{
try
{
+ startupSession = TBF.DB.ConfigDBSessionFactory.OpenSession();
+
/// Load components, initialize the control board, etc.
- Rig.StateMachine.InitializeBoardEtc(ctrlBrdComponent);
+ Rig.StateMachine.InitializeBoardEtc(startupSession, ctrlBrdComponent);
/// Check remote and local configuration DB compatibility
string msg;
Rig.GenericDevices.IBenchInfo benchInfo = Rig.Sequences.ProcessData.BenchInfo;
RemoteDBUse remoteDbUse = (benchInfo != null) ? benchInfo.RemoteDBUse : RemoteDBUse.LocalDBOnly;
log.FatalFormat("RemoteDbUse = {0}", remoteDbUse);
- if ((remoteDbUse != RemoteDBUse.LocalDBOnly) && !Rig.StateMachine.IsRemoteDBCompatible(out msg))
+ if ((remoteDbUse != RemoteDBUse.LocalDBOnly) && !Rig.StateMachine.IsRemoteDBCompatible(startupSession, out msg))
{
log.FatalFormat("{0} {1}", Strings.Remote_db_is_not_compatible, msg);
throw new Exception(string.Format("{0}{1}{2}", Strings.Remote_db_is_not_compatible, Environment.NewLine, msg));
@@ -321,16 +328,18 @@ namespace TBF.UI
///
/// Populate calendar with calendar events from components
///
- IList calendarEvents = new List();
+ var calEvents = new List();
foreach (var cmpnt in TBF.Rig.StateMachine.Components)
{
- TBF.Rig.GenericDevices.IHasCalendarEvents cmpntWithCalEvents = cmpnt as TBF.Rig.GenericDevices.IHasCalendarEvents;
- if (cmpntWithCalEvents != null)
+ var cmpntWithEvents = cmpnt as TBF.Rig.GenericDevices.IHasCalendarEvents;
+ if (cmpntWithEvents != null)
{
- foreach (var evnt in cmpntWithCalEvents.GetCalendarEvents()) calendarEvents.Add(evnt);
+ foreach (var evnt in cmpntWithEvents.GetCalendarEvents()) calEvents.Add(evnt);
}
}
- calendarTabPageCtrl.StartCalendar(calendarEvents);
+ calendarTabPageCtrl.StartCalendar(calEvents, startupSession);
+
+ if (startupSession != null && startupSession.IsOpen) startupSession.Close();
Rig.StateMachine.Start();
log.Info("Test bench started");
diff --git a/TBF/UI/Settings/DatabaseSettingsDlg.cs b/TBF/UI/Settings/DatabaseSettingsDlg.cs
index 0da75deaf..c8b1ebda0 100644
--- a/TBF/UI/Settings/DatabaseSettingsDlg.cs
+++ b/TBF/UI/Settings/DatabaseSettingsDlg.cs
@@ -272,29 +272,31 @@ namespace TBF.UI.Settings
{
try
{
- string connectionString = bench.EventsDBSettings.ConnectionString;
- string databaseName = Config.Utils.GetDBName(connectionString);
- string userName = Config.Utils.GetDBUser(connectionString);
- string password = Config.Utils.GetDBPassword(connectionString); /// TODO: Use password
+ MessageBox.Show("Not implemented yet");
- if (connectionString == currentConfigDBConnStr || connectionString == currentResultsDBConnStr || connectionString == currentEventsDBConnStr)
- {
- CurrentDBChanged = true;
- }
+ //string connectionString = bench.EventsDBSettings.ConnectionString;
+ //string databaseName = Config.Utils.GetDBName(connectionString);
+ //string userName = Config.Utils.GetDBUser(connectionString);
+ //string password = Config.Utils.GetDBPassword(connectionString); /// TODO: Use password
- Cursor.Current = Cursors.WaitCursor;
+ //if (connectionString == currentConfigDBConnStr || connectionString == currentResultsDBConnStr || connectionString == currentEventsDBConnStr)
+ //{
+ // CurrentDBChanged = true;
+ //}
- log.ErrorFormat("Going to create an empty events database '{0}'", databaseName);
- ExecuteMySqlCmd(string.Format("DROP DATABASE `{0}`;", databaseName), userName, password);
- ExecuteMySqlCmd(string.Format("CREATE DATABASE `{0}` CHARACTER SET utf8 COLLATE utf8_unicode_ci;", databaseName), userName, password);
- global::Events.DB.DbType = (DBType)bench.EventsDBSettings.DbType;
- global::Events.DB.ConnectionString = connectionString;
- global::Events.DB.CreateEmptyDB();
- log.ErrorFormat("An empty events database '{0}' was created", databaseName);
+ //Cursor.Current = Cursors.WaitCursor;
- MessageBox.Show(Strings.DB_was_successfully_created, Strings.Notification);
- Cursor.Current = Cursors.Default;
- DialogResult = DialogResult.None;
+ //log.ErrorFormat("Going to create an empty events database '{0}'", databaseName);
+ //ExecuteMySqlCmd(string.Format("DROP DATABASE `{0}`;", databaseName), userName, password);
+ //ExecuteMySqlCmd(string.Format("CREATE DATABASE `{0}` CHARACTER SET utf8 COLLATE utf8_unicode_ci;", databaseName), userName, password);
+ //global::Events.DB.DbType = (DBType)bench.EventsDBSettings.DbType;
+ //global::Events.DB.ConnectionString = connectionString;
+ //global::Events.DB.CreateEmptyDB();
+ //log.ErrorFormat("An empty events database '{0}' was created", databaseName);
+
+ //MessageBox.Show(Strings.DB_was_successfully_created, Strings.Notification);
+ //Cursor.Current = Cursors.Default;
+ //DialogResult = DialogResult.None;
}
catch (Exception exception)
{