Example #1
0
 void writeConfigure(ContractManufacture cm, JUULProject p, DeviceStation ds, bool legacy, DateTime dt)
 {
     string[] content = new string[] {
         $"CM: {cm.ToString()}",
         $"project: {p.ToString()}",
         $"station: {ds.ToString()}",
         legacy?"legacy: 1":"legacy: 0",
         $"triggertime_auto: {triggertime_auto.Hour.ToString("D2")}-{triggertime_auto.Minute.ToString("D2")}-{triggertime_auto.Second.ToString("D2")}",
         $"history_backup_datetime: {dt.ToString("yyyy-MM-dd-HH-mm-ss")}"
     };
     File.WriteAllLines(sConfigureFilePath, content);
     Log($"Write the configure file, CM: {cm.ToString()}," +
         $" project: {p.ToString()}," +
         $" station: {ds.ToString()}," +
         $"legacy SW: {legacySW.ToString()}, " +
         $"trigger time: {triggertime_auto.ToString("HH-mm-ss")}" +
         $" history backup time: {dt.ToString("yyyy-MM-dd-HH-mm-ss")}.");
 }
Example #2
0
        public MainForm()
        {
            InitializeComponent();
            this.Text += " by Shawn Zhang @ JUUL Labs, version - " + System.Reflection.Assembly.GetExecutingAssembly().GetName().Version;
            Show();

            createDirectory(@"D:\temp");
            createDirectory(sTempRootFolder);
            LogWriter = File.AppendText(Path.Combine(sTempRootFolder, "BackupLog.txt"));
            Log("Backup thread starts.");

            if (loadConfigure())
            {
                lCMName.Text      = CMName.ToString();
                lProjectName.Text = project.ToString();
                lStationName.Text = station.ToString();
            }
            else
            {
                CMName   = ContractManufacture.AFG;
                project  = JUULProject.Jagwar;
                station  = DeviceStation.FCT;
                legacySW = false;
                writeConfigure(CMName, project, station, legacySW, DateTime.Now.AddYears(-1));
                MessageBox.Show("The config.ini file is generated. Please correct the setting and restart the tool.");
                return;
            }
            switch (station)
            {
            case DeviceStation.ICP:
                sTestDataRootFolder = sICPDataRootFolder;
                break;

            case DeviceStation.FCT:
                sTestDataRootFolder = sFCTDataRootFolder;
                break;

            case DeviceStation.SFG:
                sTestDataRootFolder = sSFGDataRootFolder;
                break;

            case DeviceStation.FG00:
                sTestDataRootFolder = sFG00DataRootFolder;
                break;

            case DeviceStation.FG24:
                sTestDataRootFolder = sFG24DataRootFolder;
                break;

            case DeviceStation.Charger:
                sTestDataRootFolder = sChargerDataRootFolder;
                break;

            default:
                break;
            }

            sNetworkShareFolder_CM                                   = Path.Combine(sNetworkShareRootFolder, CMName.ToString());
            sNetworkShareFolder_CM_Project                           = Path.Combine(sNetworkShareFolder_CM, project.ToString());
            sNetworkShareFolder_CM_Project_Station                   = Path.Combine(sNetworkShareFolder_CM_Project, station.ToString());
            sNetworkShareFolder_CM_Project_Station_Automatic         = Path.Combine(sNetworkShareFolder_CM_Project_Station, BackupMode.Automatic.ToString());
            sNetworkShareFolder_CM_Project_Station_Automatic_Log     = Path.Combine(sNetworkShareFolder_CM_Project_Station_Automatic, "Log");
            sNetworkShareFolder_CM_Project_Station_Automatic_Summary = Path.Combine(sNetworkShareFolder_CM_Project_Station_Automatic, "Summary");
            sNetworkShareFolder_CM_Project_Station_Manual            = Path.Combine(sNetworkShareFolder_CM_Project_Station, BackupMode.Manual.ToString());
            sNetworkShareFolder_CM_Project_Station_Manual_Log        = Path.Combine(sNetworkShareFolder_CM_Project_Station_Manual, "Log");
            sNetworkShareFolder_CM_Project_Station_Manual_Summary    = Path.Combine(sNetworkShareFolder_CM_Project_Station_Manual, "Summary");

            try
            {
                InitializeFolders();

                //Set the mode as automatic mode by default.
                rbAuto.Checked      = true;
                dtpStartDate.Format = DateTimePickerFormat.Time;
                dtpStartDate.Value  = triggertime_auto;
                btStartBackup_Click(new object(), new EventArgs());
                this.WindowState = FormWindowState.Minimized;
                this.MainForm_Resize(new object(), new EventArgs());
            }
            catch (Exception ex)
            {
                UILog("Error: " + ex.Message);
                Log("Error: " + ex.Message);
            }
        }