Exemplo n.º 1
0
        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();
        }
Exemplo n.º 2
0
        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();
        }
Exemplo n.º 3
0
        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();
            });
        }
Exemplo n.º 4
0
        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);
        }
Exemplo n.º 5
0
        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);
            }
        }
Exemplo n.º 6
0
        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);
            }
        }
Exemplo n.º 7
0
 public static bool IsFairDateTime(long dt)
 {
     return(DateTimeToSec.ToDateTime(DateTimeToSec.ToSec(dt)) == dt);
 }
Exemplo n.º 8
0
 public static long TTSecToDateTime(long ttSec)
 {
     return(DateTimeToSec.ToDateTime(TTSecToDTSec(ttSec)));
 }
Exemplo n.º 9
0
        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");
        }