private void MainWin_Shown(object sender, EventArgs e) { // -- 0001 try { Ground.I = new Ground(); Ground.I.LoadDataDir(); this.CurrPair.SelectedIndex = 22; // USDJPY { long ed = Ground.I.Period_DateTimeEd; long st = DateTimeToSec.ToDateTime(DateTimeToSec.ToSec(ed) - 86400 * 5); this.DateTimeSt.Text = st.ToString(); this.DateTimeEd.Text = ed.ToString(); } this.CondChanged(); } catch (Exception ex) { MessageDlgTools.Error(Program.APP_TITLE + " - Error @ Shown", ex); Environment.Exit(1); // unrecoverable error } // ---- this.MTBusy.Leave(); }
private void ExpandSpan(double rate) { long sec1 = DateTimeToSec.ToSec(long.Parse(this.DateTimeSt.Text)); long sec2 = DateTimeToSec.ToSec(long.Parse(this.DateTimeEd.Text)); long span = sec2 - sec1; span = Math.Max(span, 120); // 2 min <= span = DoubleTools.ToLong(span * rate); sec1 = sec2 - span; long st = DateTimeToSec.ToDateTime(sec1); st = Math.Max(st, Ground.I.Period_DateTimeSt); sec1 = DateTimeToSec.ToSec(st); sec2 = sec1 + span; long ed = DateTimeToSec.ToDateTime(sec2); ed = Math.Min(ed, Ground.I.Period_DateTimeEd); this.DateTimeSt.Text = st.ToString(); this.DateTimeEd.Text = ed.ToString(); }
private void BtnForward_Click(object sender, EventArgs e) { this.UIEvent_Go(() => { { long sec1 = DateTimeToSec.ToSec(long.Parse(this.DateTimeSt.Text)); long sec2 = DateTimeToSec.ToSec(long.Parse(this.DateTimeEd.Text)); long span = sec2 - sec1; span = Math.Max(span, 0); sec2 += span / 2; long ed = DateTimeToSec.ToDateTime(sec2); ed = Math.Min(ed, Ground.I.Period_DateTimeEd); sec2 = DateTimeToSec.ToSec(ed); sec1 = sec2 - span; long st = DateTimeToSec.ToDateTime(sec1); st = Math.Max(st, Ground.I.Period_DateTimeSt); this.DateTimeSt.Text = st.ToString(); this.DateTimeEd.Text = ed.ToString(); } CondChanged_ByBtn(); }); }
private void Test01() { Console.WriteLine("TTConsts.TTSEC_MIN: " + TTConsts.TTSEC_MIN); Console.WriteLine("TTConsts.TTSEC_MAX: " + TTConsts.TTSEC_MAX); Console.WriteLine("TTConsts.DTSEC_MIN: " + DateTimeToSec.ToSec(CSConsts.DATE_TIME_MIN)); Console.WriteLine("TTConsts.DTSEC_MAX: " + DateTimeToSec.ToSec(CSConsts.DATE_TIME_MAX)); }
private void Slim() { long currDateTime = DateTimeToSec.Now.GetDateTime(); long expireDateTime = DateTimeToSec.ToDateTime(DateTimeToSec.ToSec(currDateTime) - Consts.SESSION_TIMEOUT_SEC); ProcMain.WriteLog("SessionBundle.Slim()"); ProcMain.WriteLog("現在日時 ⇒ " + currDateTime); ProcMain.WriteLog("期限切れ ⇒ " + expireDateTime); this.Sessions.RemoveAll(v => v.LastAccessedDateTime < expireDateTime); }
public static void CheckDateTime(long dateTime) { if (dateTime < CSConsts.DATE_TIME_MIN || CSConsts.DATE_TIME_MAX < dateTime) { throw new Exception("Out of range dateTime: " + dateTime); } if (DateTimeToSec.ToDateTime(DateTimeToSec.ToSec(dateTime)) != dateTime) { throw new Exception("Bad dateTime: " + dateTime); } }
private static void DeleteDeadData() { FileData[] files = Directory.GetFiles(Consts.DATA_DIR).Select(v => new FileData() { File = v, WroteDateTime = DateTimeToSec.ToDateTime(new FileInfo(v).LastWriteTime), }) .ToArray(); Array.Sort(files, (a, b) => { int ret = LongTools.Comp(a.WroteDateTime, b.WroteDateTime); if (ret != 0) { return(ret); } ret = StringTools.CompIgnoreCase(a.File, b.File); return(ret); }); long currDateTime = DateTimeToSec.Now.GetDateTime(); long expireDateTime = DateTimeToSec.ToDateTime(DateTimeToSec.ToSec(currDateTime) - Consts.DATA_LIFESPAN_SEC); for (int index = 0; index < files.Length; index++) { bool deleting = index + Consts.DATA_NUM_MAX < files.Length || files[index].WroteDateTime < expireDateTime; if (deleting == false) { break; } FileTools.Delete(files[index].File); } }
public static bool IsFairDateTime(long dt) { return(DateTimeToSec.ToDateTime(DateTimeToSec.ToSec(dt)) == dt); }
public CSPrice GetPrice(long dateTime) { Validators.CheckDateTime(dateTime); int day = DateToDay.ToDay((int)(dateTime / 1000000)); SortedList <CSPrice> prices = GetDayPrices(day); CSPrice[] matched = prices.GetMatchWithEdge(prices.GetFerret(new CSPrice() { DateTime = dateTime })).ToArray(); if (matched.Length == 3) { return(matched[1]); } if (matched.Length != 2) { throw null; // 2bs -- 同じ日時のデータは無いはず! } if (matched[0] == null) { for (int c = 1; c <= Consts.MARGIN_DAY_MAX; c++) { prices = GetDayPrices(day - c); if (1 <= prices.Count) { matched[0] = prices.Get(prices.Count - 1); break; } } } if (matched[1] == null) { for (int c = 1; c <= Consts.MARGIN_DAY_MAX; c++) { prices = GetDayPrices(day + c); if (1 <= prices.Count) { matched[0] = prices.Get(0); break; } } } matched = matched.Where(v => v != null).ToArray(); if (matched.Length == 0) { return new CSPrice() { DateTime = dateTime } } ; if (matched.Length == 1) { return(matched[0]); } long sec1 = DateTimeToSec.ToSec(matched[0].DateTime); long sec2 = DateTimeToSec.ToSec(dateTime); long sec3 = DateTimeToSec.ToSec(matched[1].DateTime); double rate = (sec2 - sec1) * 1.0 / (sec3 - sec1); return(new CSPrice() { DateTime = dateTime, Hig = matched[0].Hig + rate * (matched[1].Hig - matched[0].Hig), Low = matched[0].Low + rate * (matched[1].Low - matched[0].Low), Ask = matched[0].Ask + rate * (matched[1].Ask - matched[0].Ask), Bid = matched[0].Bid + rate * (matched[1].Bid - matched[0].Bid), }); } }
public static long DateTimeToTTSec(long dateTime) { return(DTSecToTTSec(DateTimeToSec.ToSec(dateTime))); }
public void Perform() { Console.WriteLine("Slimdown_Start"); //Console.WriteLine("Slimdown_Start, DY: " + this.DiskYellowFlag); // del @ 2020.4.1 long currDateTime = DateTimeToSec.Now.GetDateTime(); foreach (LiteGroup liteGroup in new GroupBundle().LiteGroups) { Group group = liteGroup.GetGroup(); List <UploadedFile> upFiles = new List <UploadedFile>(); long total = 0L; foreach (string file in group.GetFileBundle().Files) { FileInfo info = new FileInfo(file); UploadedFile upFile = new UploadedFile() { FilePath = file, Size = info.Length, WroteDateTime = DateTimeToSec.ToDateTime(info.LastWriteTime), }; upFiles.Add(upFile); total += upFile.Size; } upFiles.Sort((a, b) => { int ret = VariantTools.Comp(a, b, v => StringTools.EndsWithIgnoreCase(v.FilePath, Consts.TMP_FILE_SUFFIX) && DateTimeToSec.ToSec(v.WroteDateTime) + 3600 <= DateTimeToSec.ToSec(currDateTime) ? 0 : 1); // "1時間以上放置された作業ファイル" を先に if (ret != 0) { return(ret); } ret = LongTools.Comp(a.WroteDateTime, b.WroteDateTime); // 古い順 return(ret); }); while (1 <= upFiles.Count && (Consts.FILE_NUM_MAX < this.UploadedFiles.Count || group.GroupTotalFileSizeMax < total)) { UploadedFile upFile = upFiles[0]; upFiles.RemoveAt(0); upFile.Delete(); total -= upFile.Size; } this.UploadedFiles.AddRange(upFiles); this.TotalSize += total; } this.UploadedFiles.Sort((a, b) => LongTools.Comp(a.WroteDateTime, b.WroteDateTime)); // 古い順 while (1 <= this.UploadedFiles.Count && Consts.TOTAL_FILE_SIZE_MAX < this.TotalSize) { UploadedFile upFile = this.UploadedFiles[0]; this.UploadedFiles.RemoveAt(0); FileTools.Delete(upFile.FilePath); this.TotalSize -= upFile.Size; } #if false // del @ 2020.4.1 if (this.DiskYellowFlag) { int count = this.UploadedFiles.Count; // 10ファイル以上 -> 10% // 1~9ファイル -> 1 // 0ファイル -> 0 // if (10 <= count) { count /= 10; } else { count = Math.Min(1, count); } for (int index = 0; index < count; index++) { UploadedFile upFile = this.UploadedFiles[index]; upFile.Delete(); } } #endif Console.WriteLine("Slimdown_End"); }