<commit_before>﻿using System;
using System.Threading.Tasks;
using Dulcet.Twitter.Rest;
using Inscribe.Commnuication.CruiseControl.Core;
using Inscribe.Communication.CruiseControl.DefaultTasks;
using Inscribe.Model;
using Inscribe.Threading;

namespace Inscribe.Communication.CruiseControl
{
    public class AccountScheduler : SupervisorScheduler
    {
        private AccountInfo _accountInfo;
        public AccountInfo AccountInfo
        {
            get { return this._accountInfo; }
        }

        public AccountScheduler(AccountInfo info)
        {
            this._accountInfo = info;
            this.AddSchedule(new HomeReceiveTask(info));
            this.AddSchedule(new MentionReceiveTask(info));
            this.AddSchedule(new DirectMessageReceiveTask(info));
            this.AddSchedule(new SentDirectMessageReceiveTask(info));
            this.AddSchedule(new FavoritesReceiveTask(info));
            Task.Factory.StartNew(() =>
                {
                    try
                    {
                        // テストを飛ばす
                        ApiHelper.ExecApi(() => info.Test());
                    }
                    catch { }
                });
            ThreadHelper.Halt += () => this.StopSchedule();
        }

        protected override void OnFallingASleep()
        {
            this.TaskRateLimit = this._accountInfo.RateLimitRemaining
                - (int)(this._accountInfo.RateLimitMax * (1 - this._accountInfo.AccoutProperty.AutoCruiseApiConsumeRate));
            int wndTime = (int)this._accountInfo.RateLimitReset.Subtract(DateTime.Now).TotalMilliseconds;
            if (wndTime < 0)
                this.WindowTime = 0;
            else
                this.WindowTime = wndTime;
        }

        protected override void OnWakeup()
        {
            this.TargetMu = this._accountInfo.AccoutProperty.AutoCruiseDefaultMu;
        }

        protected override int MinWindowTime
        {
            get
            {
                return TwitterDefine.MinWindowTime;
            }
        }

        protected override double MinDensity
        {
            get
            {
                return TwitterDefine.MinDensity;
            }
        }
    }
}
<commit_msg>bug fix: handling configuration load error<commit_after>﻿using System;
using System.Threading.Tasks;
using Dulcet.Twitter.Rest;
using Inscribe.Commnuication.CruiseControl.Core;
using Inscribe.Communication.CruiseControl.DefaultTasks;
using Inscribe.Model;
using Inscribe.Storage;
using Inscribe.Threading;

namespace Inscribe.Communication.CruiseControl
{
    public class AccountScheduler : SupervisorScheduler
    {
        private AccountInfo _accountInfo;
        public AccountInfo AccountInfo
        {
            get { return this._accountInfo; }
        }

        public AccountScheduler(AccountInfo info)
        {
            this._accountInfo = info;
            this.AddSchedule(new HomeReceiveTask(info));
            this.AddSchedule(new MentionReceiveTask(info));
            this.AddSchedule(new DirectMessageReceiveTask(info));
            this.AddSchedule(new SentDirectMessageReceiveTask(info));
            this.AddSchedule(new FavoritesReceiveTask(info));
            Task.Factory.StartNew(() =>
                {
                    try
                    {
                        // テストを飛ばす
                        ApiHelper.ExecApi(() => info.Test());
                    }
                    catch { }
                });
            ThreadHelper.Halt += () => this.StopSchedule();
        }

        protected override void OnFallingASleep()
        {
            this.TaskRateLimit = this._accountInfo.RateLimitRemaining
                - (int)(this._accountInfo.RateLimitMax * (1 - this._accountInfo.AccoutProperty.AutoCruiseApiConsumeRate));
            int wndTime = (int)this._accountInfo.RateLimitReset.Subtract(DateTime.Now).TotalMilliseconds;
            if (wndTime < 0)
                this.WindowTime = 0;
            else
                this.WindowTime = wndTime;
        }

        protected override void OnWakeup()
        {
            try
            {
                this.TargetMu = this._accountInfo.AccoutProperty.AutoCruiseDefaultMu;
            }
            catch (Exception e)
            {
                ExceptionStorage.Register(e, ExceptionCategory.ConfigurationError, "設定が破損しています。");
                this.TargetMu = 0.5;
            }
        }

        protected override int MinWindowTime
        {
            get
            {
                return TwitterDefine.MinWindowTime;
            }
        }

        protected override double MinDensity
        {
            get
            {
                return TwitterDefine.MinDensity;
            }
        }
    }
}

{'fraction_non_alphanumeric': 0.07933849696462215, 'fraction_numerical': 0.0016746912288046892, 'mean_word_length': 1.6354109211252068, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 9, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4889105', 'n_tokens_mistral': 1253, 'n_tokens_neox': 1187, 'n_words': 200}