Esempio n. 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  然後寫入檔案內

            MiMarginMeta meta = new MiMarginMeta
            {
                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_MARGIN.txt", true))
            {
                sw.WriteLine(metaRow);
            }
        }
Esempio n. 2
0
        protected override void LoadCompleteFileData()
        {
            string fileContent = null;

            //檢查Meta檔案是否存在,不存在會建立出來
            FileInfo fi = new FileInfo("./Data/TseMeta/MI_MARGIN.txt");

            if (fi.Exists == false)
            {
                fi.Create().Close();
            }
            //Meat檔案會記錄到目前為止,MiMargin這類型的資料已經處理到哪一天了
            using (StreamReader sr = new StreamReader("./Data/TseMeta/MI_MARGIN.txt"))
            {
                fileContent = sr.ReadToEnd();
            }

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