private void btBrowserDatabaseFile_Click(object sender, RoutedEventArgs e) { OpenFileDialog openFileDialog = new OpenFileDialog(); openFileDialog.Filter = "Database files (*.db)|*.db|All files (*.*)|*.*"; if (openFileDialog.ShowDialog() == true) { this.tbDatabaseFilePath.Text = openFileDialog.FileName; } if (this.tbDatabaseFilePath.Text == string.Empty) { return; } if (this.tbDatabaseFilePath.Text.Split('\\').Last().Contains("JagwarPlus")) { projectName = "JagwarPlus"; } else { projectName = "Jagwar"; } myDatabase = new MTEDatabaseSetup(this.tbDatabaseFilePath.Text); myDatabase.ConnectDatabase(); this.cmbStations.Items.Clear(); this.cmbStations.Items.Add("FCT"); this.cmbStations.Items.Add("SFG"); this.cmbStations.Items.Add("FG00"); this.cmbStations.Items.Add("FG24"); this.cmbStations.IsEnabled = true; this.dtpStartDateForYield.IsEnabled = true; this.dtpEndDateForYield.IsEnabled = true; string[] interestedTables = new string[] { $"{projectName}_FCT_Summary", $"{ projectName}_SFG_Summary", $"{projectName}_FG00", $"{projectName}_FG24" }; DateTime MaxStartDate = new DateTime(1990, 1, 1); DateTime MinEndDate = new DateTime(2030, 1, 1); for (int index = 0; index < interestedTables.Length; index++) { string[] dateRange = myDatabase.GetDateTimeRange(interestedTables[index]); DateTime start = DateTime.ParseExact(dateRange[0], "yyyy-MM-dd HH:mm:ss.fff", CultureInfo.InvariantCulture); DateTime end = DateTime.ParseExact(dateRange[1], "yyyy-MM-dd HH:mm:ss.fff", CultureInfo.InvariantCulture); MaxStartDate = MaxStartDate > start ? MaxStartDate : start; MinEndDate = MinEndDate < end ? MinEndDate : end; } this.dtpStartDateForYield.DisplayDateStart = MaxStartDate; this.dtpStartDateForYield.DisplayDateEnd = MinEndDate; this.dtpEndDateForYield.DisplayDateStart = MaxStartDate; this.dtpEndDateForYield.DisplayDateEnd = MinEndDate; this.cmbReworkLine.IsEnabled = true; }
public MainForm() { InitializeComponent(); cmbProject.Items.Clear(); cmbProject.Items.AddRange(new string[] { "Jagwar", "JagwarPlus" }); cmbStation.Items.Clear(); cmbStation.Items.AddRange(Enum.GetNames(typeof(StationCategory))); DB_Jagwar = new MTEDatabaseSetup(DatabaseRootFolder, JagwarDatabaseFile); DB_JagwarPlus = new MTEDatabaseSetup(DatabaseRootFolder, JagwarPlusDatabaseFile); DB_Jagwar.ConnectDatabase(); DB_JagwarPlus.ConnectDatabase(); BuildTesterMap(); dtpStartDate.Format = DateTimePickerFormat.Custom; dtpStartDate.CustomFormat = "MM/dd/yyyy hh:mm:ss"; dtpEndDate.Format = DateTimePickerFormat.Custom; dtpEndDate.CustomFormat = "MM/dd/yyyy hh:mm:ss"; }
private void BtInit_Click(object sender, EventArgs e) { MTEDatabaseSetup mydatabase = new MTEDatabaseSetup(this.workspace, this.databasename); mydatabase.CreateDatabase(); mydatabase.ConnectDatabase(); mydatabase.CreateTable("Jagwar_FCT", StationCategory.FCT); mydatabase.CreateTable("Jagwar_SFG", StationCategory.SFG); mydatabase.CreateTable("Jagwar_FG00", StationCategory.FG00); string rootFolder = @"C:\Works\Jagwar\PMTA\Pega example\Line#30\FG00\T170\Raw Data\LINE30_T170_20190815\Pega_FG00_T170\log"; string[] files = Directory.GetFiles(rootFolder, "*.txt", SearchOption.AllDirectories); int newRecords = 0; foreach (string onefile in files) { if (mydatabase.ParseLogIntoDB("Jagwar_FG00", StationCategory.FG00, onefile)) { newRecords++; } } mydatabase.DisconnectDatabase(); lStatus.Text = $"{newRecords} rows are inserted."; }
protected override void OnStart(string[] args) { //Debugger.Launch(); // Update the service state to Start Pending. ServiceStatus serviceStatus = new ServiceStatus(); Log($"JUUL MTE Database setup service starts, version: {System.Reflection.Assembly.GetExecutingAssembly().GetName().Version}."); EventLogWriter("JUUL MTE Database setup service starts.", EventCategory.ServiceStart); DB_Jagwar = new MTEDatabaseSetup(DatabaseRootFolder, JagwarDatabaseFile); DB_JagwarPlus = new MTEDatabaseSetup(DatabaseRootFolder, JagwarPlusDatabaseFile); DB_Jagwar.InitializeVariables(); DB_Jagwar.CreateDatabase(); DB_Jagwar.ConnectDatabase(); DB_Jagwar.CreateTable(DBTable_Jagwar_FCT, StationCategory.FCT); //DB_Jagwar.CreateTable(DBTable_JagwarC_FCT, StationCategory.FCT); DB_Jagwar.CreateTable(DBTable_Jagwar_SFG, StationCategory.SFG); DB_Jagwar.CreateTable(DBTable_Jagwar_FG00, StationCategory.FG00); DB_Jagwar.CreateTable(DBTable_Jagwar_FG24, StationCategory.FG24); DB_Jagwar.CreateFCTSummaryTable(DBTable_Jagwar_FCT_Summary); DB_Jagwar.CreateSFGSummaryTable(DBTable_Jagwar_SFG_Summary); DB_JagwarPlus.InitializeVariables(); DB_JagwarPlus.CreateDatabase(); DB_JagwarPlus.ConnectDatabase(); DB_JagwarPlus.CreateTable(DBTable_JagwarPlus_FCT, StationCategory.FCT); DB_JagwarPlus.CreateTable(DBTable_JagwarPlus_SFG, StationCategory.SFG); DB_JagwarPlus.CreateTable(DBTable_JagwarPlus_FG00, StationCategory.FG00); DB_JagwarPlus.CreateTable(DBTable_JagwarPlus_FG24, StationCategory.FG24); DB_JagwarPlus.CreateFCTSummaryTable(DBTable_JagwarPlus_FCT_Summary); DB_JagwarPlus.CreateSFGSummaryTable(DBTable_JagwarPlus_SFG_Summary); timer.Start(); // Update the service state to Running. serviceStatus.dwCurrentState = ServiceState.SERVICE_RUNNING; SetServiceStatus(this.ServiceHandle, ref serviceStatus); }