Example #1
0
        public override void AddCompleteJob(TseJob job)
        {
            List <DateTime> dateList = null;

            Console.WriteLine("[ AddCompleteJob ] 把任務的次類型[ {0} ]設定為已完成,任務日期[ {1} ]", job.SubDirName, job.JobDate.ToString("yyyy-MM-dd"));
            if (this._subTypeToFileList.TryGetValue(job.SubDirName, out dateList))
            {
                dateList.Add(job.JobDate);
            }
            //TODO:把TseJob Map成MiIndexMeta  然後寫入檔案內

            Twt72uMeta meta = new Twt72uMeta
            {
                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/TWT72U.txt", true))
            {
                Console.WriteLine("[ AddCompleteJob ] 把任務的次類型[ {0} ]的完成資訊寫入檔案,任務日期[ {1} ]", job.SubDirName, job.JobDate.ToString("yyyy-MM-dd"));
                sw.WriteLine(metaRow);
            }
        }
Example #2
0
        protected override void LoadCompleteFileData()
        {
            string fileContent = null;

            FileInfo fi = new FileInfo("./Data/TseMeta/TWT72U.txt");

            if (fi.Exists == false)
            {
                fi.Create().Close();
            }

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

            string[] jsonStrings = fileContent.Split(new string[] { "\n\r" }, StringSplitOptions.None);
            foreach (string json in jsonStrings)
            {
                if (string.IsNullOrEmpty(json) == false)
                {
                    Twt72uMeta      metaData = JsonConvert.DeserializeObject <Twt72uMeta>(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);
                    }
                }
            }
        }