예제 #1
0
 private void btnGetUtmFromSourceFile_Click(object sender, EventArgs e)
 {
     SafeRun(delegate
     {
         LoadDraft draft = new LoadDraft(Config.LOADLIST_STAGE1_PATH);
         List <string> listRecordStrings = new List <string>();
         List <string> guessedDates      = new List <string>();
         LoadListRecord listRecord       = new LoadListRecord();
         foreach (LoadDraftRecord draftRecord in draft.records)
         {
             try
             {
                 listRecord.InitByUtmSourceFile(draftRecord.filePath, draftRecord.fileType, tbSrcProj.Text.Trim(), tbDestProj.Text.Trim());
                 guessedDates.Add(listRecord.guessedDate);
                 listRecordStrings.Add(listRecord.ToString());
             }
             catch (Exception)
             {
                 ShowMessage("failed to get meta info from " + draftRecord.filePath);
                 ShowMessage("rename to " + draftRecord.filePath + ".damaged");
                 File.Move(draftRecord.filePath, draftRecord.filePath + ".damaged");
             }
         }
         File.WriteAllLines(Config.LOADLIST_STAGE2_PATH, listRecordStrings);
         guessedDates.Sort();
         File.WriteAllLines(Config.LOADLIST_STAGE2_DATE_PATH, guessedDates);
         ShowMessage("Stage 2: result saved to " + Config.LOADLIST_STAGE2_PATH);
         ShowMessage("Stage 2: guessed source dates saved to " + Config.LOADLIST_STAGE2_DATE_PATH);
     });
 }
예제 #2
0
        /// <summary>
        /// initialize this list from file
        /// </summary>
        /// <param name="filePath">path of the file</param>
        public LoadList(string filePath)
        {
            // clear old records
            records.Clear();

            // read file
            string[] lines = File.ReadAllLines(filePath);

            // first line is header
            header = new LoadListHeader(lines[0]);

            // the rest are loadRecords or configs
            for (int i = 1; i < lines.Length; i++)
            {
                string line = lines[i].Trim();
                if (line.Length == 0)
                {
                    continue;
                }
                if (line[0] == '#')
                {
                    configString += line.Substring(1).Trim() + "\r\n";
                }
                else
                {
                    LoadListRecord rec = new LoadListRecord();
                    rec.InitByRecordString(line);
                    records.Add(rec);
                }
            }
        }