Пример #1
0
        public override void AddCompleteJob(TseJob job)
        {
            List <DateTime> dateList = null;

            if (this._subTypeToFileList.TryGetValue(job.SubDirName, out dateList))
            {
                dateList.Add(job.JobDate);
            }
            //TODO:把TseJob Map成MiIndexMeta  然後寫入檔案內

            MiIndexMeta meta = new MiIndexMeta
            {
                St     = job.SubDirName,
                Dd     = job.JobDate,
                IsH    = job.IsSaturdayOrSunday,
                IsE    = job.IsComplete,
                HasErr = job.WithErr
            };

            string metaRow = JsonConvert.SerializeObject(meta);

            using (StreamWriter sw = new StreamWriter("./Data/TseMeta/MI_INDEX.txt", true))
            {
                sw.WriteLine(metaRow);
            }
        }
Пример #2
0
        /// <summary>
        /// 載入目前已完成的工作資料
        /// </summary>
        protected override void LoadCompleteFileData()
        {
            //FileInfo recordFile = new FileInfo("./Data/TseMeta/MI_INDEX.txt");
            string fileContent = null;

            using (StreamReader sr = new StreamReader("./Data/TseMeta/MI_INDEX.txt"))
            {
                fileContent = sr.ReadToEnd();
            }

            string[] jsonStrings = fileContent.Split(new string[] { "\n\r" }, StringSplitOptions.None);
            foreach (string json in jsonStrings)
            {
                if (string.IsNullOrEmpty(json) == false)
                {
                    MiIndexMeta     metaData = JsonConvert.DeserializeObject <MiIndexMeta>(json);
                    List <DateTime> fileList = null;
                    if (this._subTypeToFileList.TryGetValue(metaData.St, out fileList))
                    {
                        if (fileList.Contains(metaData.Dd) == false)
                        {
                            fileList.Add(metaData.Dd);
                        }
                    }
                    else
                    {
                        fileList = new List <DateTime>();
                        fileList.Add(metaData.Dd);
                        this._subTypeToFileList.Add(metaData.St, fileList);
                    }
                }
            }
        }