Ejemplo n.º 1
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);
                }
            }
        }
Ejemplo n.º 2
0
        private void btnAddHeader_Click(object sender, EventArgs e)
        {
            SafeRun(delegate
            {
                // generate loadlist's save path
                string loadlistSavePath = Helper.GetCurrentDir() + tbAddHeaderLoadlistId.Text + ".txt";

                // generate dataset output path
                string outputPath = tbAddHeaderOutputDir.Text.Trim();
                if (!outputPath.EndsWith("\\"))
                {
                    outputPath += "\\";
                }
                outputPath += tbAddHeaderLoadlistId.Text + "_" + Int32.Parse(tbAddHeaderOriginId.Text).ToString("D3") + "_" + tbAddHeaderSourceName.Text + "_" + tbAddHeaderSourceDate.Text.Replace("/", "_");
                ShowMessage("Stage 3: outputpath = " + outputPath);

                // generate header
                LoadListHeader header = new LoadListHeader(outputPath, tbAddHeaderSourceDate.Text, tbAddHeaderOriginId.Text);
                string result         = header.ToString() + "\r\n" + File.ReadAllText(Config.LOADLIST_STAGE2_PATH);
                File.WriteAllText(loadlistSavePath, result);
                ShowMessage("Stage 3: loadlist saved to " + loadlistSavePath);
            });
        }