public int FetchLogs_SFG(string folder)
        {
            int    count = 0;
            string date  = folder.Split('\\').Last();

            if (!FetchedFileList_SFG.ContainsKey(date))
            {
                FetchedFileList_SFG.Add(date, new List <string>());
            }
            string[] filePaths = Directory.GetFiles(folder);
            foreach (string oneFilePath in filePaths)
            {
                try
                {
                    string fileName = oneFilePath.Split('\\').Last();
                    if (!FetchedFileList_SFG[date].Contains(fileName))
                    {
                        //The file isn't in the fetched file list, add the file name to the list.
                        FetchedFileList_SFG[date].Add(fileName);
                        string[] elemInFileName = fileName.Split('_');
                        string   sn             = elemInFileName[0];
                        if (sn.Trim().Length < 10)  //The serial number is 15.
                        {
                            continue;
                        }
                        string project  = elemInFileName[3].ToUpper();
                        string datetime = MTEDatabaseSetup.ConvertDateTimeFormat(elemInFileName[9]);

                        bool newRecord;
                        if (project == "JAGWAR" || project == "JAGWARC")
                        {
                            newRecord = DB_Jagwar.ParseLogIntoDB(DBTable_Jagwar_SFG, StationCategory.SFG, oneFilePath);
                            MTEDatabaseSetup.SFGHeader sfgInformation = DB_Jagwar.ParseSFGHeader(fileName);
                            DB_Jagwar.AddRecordInSummary(DBTable_Jagwar_SFG_Summary, sfgInformation);
                        }
                        else
                        {
                            newRecord = DB_JagwarPlus.ParseLogIntoDB(DBTable_JagwarPlus_SFG, StationCategory.SFG, oneFilePath);
                            MTEDatabaseSetup.SFGHeader sfgInformation = DB_JagwarPlus.ParseSFGHeader(fileName);
                            DB_JagwarPlus.AddRecordInSummary(DBTable_JagwarPlus_SFG_Summary, sfgInformation);
                        }
                        if (newRecord)
                        {
                            count++;
                        }
                    }
                }
                catch (Exception ex)
                {
                    Log($"Error happens in fetching SFG log {oneFilePath}, {ex.Message}, {ex.StackTrace}");
                }
            }
            return(count);
        }
Пример #2
0
        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;
        }
Пример #3
0
        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";
        }
Пример #4
0
        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);
        }