public static void OnLoadEvent(MongoClient client)
        {
            AlExtension.ColorizeWriteLine(LogIndex.CONFIG_INFORMATION, "-->^ FIRST INITIALIZATION.", new [] { ConsoleColor.Blue, ConsoleColor.Green });

            List <string> configFolders = _ConfigFolderDir();
            Dictionary <string, string[]> configFiles = _ConfigFileDir(configFolders);
            Dictionary <string, Dictionary <string, ConfigScheme> > groupedDict = new Dictionary <string, Dictionary <string, ConfigScheme> >();

            foreach (KeyValuePair <string, string[]> fileComponent in configFiles)
            {
                Dictionary <string, ConfigScheme> loadedDict = new Dictionary <string, ConfigScheme>();
                AlExtension.ColorizeWriteLine(LogIndex.CONFIG_INFORMATION, $"Parse Group [ ^{fileComponent.Key.Substring(GeneralSettings.ConfigDir.Length)}^ ]",
                                              new [] { ConsoleColor.Green, ConsoleColor.Cyan, ConsoleColor.Green });
                // AlConsole.WriteLine(CONFIG_INFORMATION, $"Parse Group [ {fileComponent.Key.Substring(Settings.ConfigDir.Length)} ]");
                foreach (string file in fileComponent.Value)
                {
                    using (StreamReader reader = new StreamReader(file)) {
                        string       raw        = reader.ReadToEnd();
                        ConfigScheme clazzParse = Toml.ReadString <ConfigScheme>(raw);
                        AlExtension.ColorizeWriteLine(LogIndex.CONFIG_INFORMATION, $"{clazzParse.Profile.Name + ".toml", 32}^ => Parsed!",
                                                      new [] { ConsoleColor.Magenta, ConsoleColor.Green });
                        // AlConsole.WriteLine(CONFIG_INFORMATION, $"{clazzParse.Profile.Name + ".toml", 32} => Parsed!");
                        loadedDict.Add(clazzParse.Profile.DBName, clazzParse);
                    }
                }
                groupedDict.Add(fileComponent.Key.Substring(GeneralSettings.ConfigDir.Length), loadedDict);
            }
            AlConsole.WriteLine(LogIndex.CONFIG_INFORMATION, $"Loaded All Config Operational!");
            AlExtension.ColorizeWriteLine(LogIndex.CONFIG_INFORMATION, "-->^ SECOND INITIALIZATION.", new [] { ConsoleColor.Blue, ConsoleColor.Green });
            // AlConsole.WriteLine(CONFIG_INFORMATION, "-> Second Initialization.");
            GenerateDataBaseProperty(client, groupedDict);
            AlConsole.WriteLine(LogIndex.CONFIG_INFORMATION, $"Generated DataBase Property from Loaded Config.");
        }
        private static List <string> _ConfigFolderDir()
        {
            DirectoryInfo dInfo = new DirectoryInfo(GeneralSettings.ConfigDir);

            if (!dInfo.Exists)
            {
                string[] errMsg = new string[] {
                    "Configディレクトリが存在しません。",
                    $"[ {GeneralSettings.ConfigDir} ]に以下URLのConfigファイルをセットしてください。",
                    "NekomataLibrary: https://github.com/ReiRokusanami0010/NekomataLibrary"
                };
                AlExtension.ArrayWrite(LogIndex.CONFIG_EXCEPTION, errMsg);
                Environment.Exit(-1);
            }
            List <string> detectDirNames = Directory.GetDirectories(GeneralSettings.ConfigDir).ToList <string>();

            detectDirNames.Remove($"{GeneralSettings.ConfigDir}.git");
            foreach (string detectName in detectDirNames)
            {
                AlExtension.ColorizeWriteLine(LogIndex.CONFIG_INFORMATION, $"Detect Corp Folder -> ^[ {detectName, -18} ]",
                                              new [] { ConsoleColor.Green, ConsoleColor.Blue });
                // AlConsole.WriteLine(CONFIG_INFORMATION, $"Detect Corp Folder -> [ {detectName, -18} ]");
            }

            return(detectDirNames);
        }
 // Dictionary<MemberName(string), Dictionary<DataBaseName(string), DBProperty(IMongoCollection<RefactorScheme>)>>
 private static void GenerateDataBaseProperty(MongoClient client, Dictionary <string, Dictionary <string, ConfigScheme> > configComponent)
 {
     foreach (KeyValuePair <string, Dictionary <string, ConfigScheme> > groupedCorp in configComponent)
     {
         Dictionary <string, IMongoCollection <RefactorScheme> > collectionsBuf = new Dictionary <string, IMongoCollection <RefactorScheme> >();
         IMongoDatabase targetDataBase = client.GetDatabase(groupedCorp.Key);
         AlExtension.ColorizeWriteLine(LogIndex.CONFIG_INFORMATION, " => Generate DataBase Property",
                                       new [] { ConsoleColor.Cyan, ConsoleColor.Green });
         // AlConsole.WriteLine(CONFIG_INFORMATION, " => Generate DataBase Property");
         AlExtension.ColorizeWriteLine(LogIndex.CONFIG_INFORMATION, $" ┏ ^DataBase[ ^{groupedCorp.Key} ^]",
                                       new [] { ConsoleColor.DarkGray, ConsoleColor.Green, ConsoleColor.Cyan, ConsoleColor.Green });
         // AlConsole.WriteLine(CONFIG_INFORMATION, $" ┏ DataBase[ {groupedCorp.Key} ]");
         foreach (KeyValuePair <string, ConfigScheme> configDict in groupedCorp.Value)
         {
             IMongoCollection <RefactorScheme> generatedCollection =
                 targetDataBase.GetCollection <RefactorScheme>(configDict.Key);
             AlExtension.ColorizeWrite(LogIndex.CONFIG_INFORMATION, " ┣ ^Collection[ ^" + $"{configDict.Key, -26}" + " ^]",
                                       new [] { ConsoleColor.DarkGray, ConsoleColor.Magenta, ConsoleColor.Cyan, ConsoleColor.Magenta });
             // AlConsole.WriteLine(CONFIG_INFORMATION, $" ┣ Collection[ " + $"{configDict.Key, -26}" + " ]");
             collectionsBuf.Add(configDict.Key, generatedCollection);
             LoadedComponent.SetChannelIdComponent(configDict.Value.ChannelData[0].Details[0].ID.ToString(), configDict.Key);
             AlExtension.ColorizeWriteLine(LogIndex.CONFIG_INFORMATION, $" / ^ChannelId[ " + $"^{configDict.Value.ChannelData[0].Details[0].ID.ToString(), -16}" + " ^]",
                                           new [] { ConsoleColor.DarkGray, ConsoleColor.DarkMagenta, ConsoleColor.DarkCyan, ConsoleColor.DarkMagenta }, false);
             // AlConsole.WriteLine(CONFIG_INFORMATION, $" ┃  ┗ ChannelId[ " + $"{configDict.Value.ChannelData[0].Details[0].ID.ToString(), -16}" + " ]");
         }
         LoadedComponent.SetCollectionDict(targetDataBase, collectionsBuf);
         AlExtension.ColorizeWriteLine(LogIndex.CONFIG_INFORMATION, $" ┗ ^[ EOT ]", new [] { ConsoleColor.DarkGray, ConsoleColor.Green });
         // AlConsole.WriteLine(CONFIG_INFORMATION, $" ┗ [ EOT ]");
     }
 }
 private static void Initialization(IMongoDatabase db, string targetCollection)
 {
     AlExtension.ColorizeWrite(DefaultScheme.DB_INITIALIZE_SCHEME, $" ┣ ^Init Collection: ^{targetCollection, -26} ",
                               new [] { ConsoleColor.DarkGray, ConsoleColor.Green, ConsoleColor.Cyan, ConsoleColor.Green });
     // AlConsole.WriteLine(DefaultScheme.DB_INITIALIZE_SCHEME, $" ┣ Init Collection: {targetCollection}");
     db.DropCollection(targetCollection);
     AlExtension.ColorizeWriteLine(DefaultScheme.DB_INITIALIZE_SCHEME, $"/ ^初期化しました。",
                                   new [] { ConsoleColor.DarkGray, ConsoleColor.DarkBlue, ConsoleColor.DarkGreen }, false);
     // AlConsole.WriteLine(DefaultScheme.DB_INITIALIZE_SCHEME, $" ┃  ┗ 初期化しました。");
 }
        public static void Insert(MongoClient client, List <RefactorScheme> schemeList)
        {
            // Start Initialization
            AlConsole.WriteLine(DefaultScheme.DB_INITIALIZE_SCHEME, $"初期化を開始します。");

            foreach (KeyValuePair <IMongoDatabase, Dictionary <string, IMongoCollection <RefactorScheme> > > collection in LoadedComponent.GetAllCollections())
            {
                AlExtension.ColorizeWriteLine(DefaultScheme.DB_INITIALIZE_SCHEME, $" ┏ ^DataBase  ^: ^{collection.Key.DatabaseNamespace.DatabaseName}",
                                              new [] { ConsoleColor.DarkGray, ConsoleColor.Green, ConsoleColor.DarkGray, ConsoleColor.Magenta });
                // AlConsole.WriteLine(DefaultScheme.DB_INITIALIZE_SCHEME, $" ┏ DataBase  : {collection.Key.DatabaseNamespace.DatabaseName}");
                foreach (KeyValuePair <string, IMongoCollection <RefactorScheme> > collectionDict in collection.Value)
                {
                    Initialization(collection.Key, collectionDict.Key);
                }
            }

            AlExtension.ColorizeWriteLine(DefaultScheme.DB_INITIALIZE_SCHEME, $" ┗ ^全ての初期化が終了しました。",
                                          new [] { ConsoleColor.DarkGray, ConsoleColor.Green });

            // AlConsole.WriteLine(DefaultScheme.DB_INITIALIZE_SCHEME, $" ┗ 全ての初期化が終了しました。");
            AlConsole.WriteLine(DefaultScheme.DB_INITIALIZE_SCHEME, $"初期化しました。");

            // Start Insert Data

            AlConsole.WriteLine(DefaultScheme.DB_IN_DATA_SCHEME_STBY, "以下の回収したデータをコレクションに格納します。");
            AlConsole.WriteLine(DefaultScheme.DB_IN_DATA_SCHEME_STBY, $" + List");
            AlConsole.WriteLine(DefaultScheme.DB_IN_DATA_SCHEME_STBY, $" +---------------------+---------------------+---------------------+ ");
            AlConsole.WriteLine(DefaultScheme.DB_IN_DATA_SCHEME_STBY, $" | -> | UUID     | VideoId     | ChannelId                | ChannelName             ");

            schemeList.ForEach(scheme => {
                AlConsole.WriteLine(DefaultScheme.DB_IN_DATA_SCHEME_STBY,
                                    $"   >>   {scheme._id.Substring(0, 8)} | " +
                                    $"{scheme.VideoId} | {scheme.ChannelId} | {scheme.ChannelName}"
                                    );
            });

            AlConsole.WriteLine(DefaultScheme.DB_IN_DATA_SCHEME_STBY, $" +---------------------+---------------------+---------------------+ ");
            AlConsole.Write(DefaultScheme.DB_IN_DATA_SCHEME_STBY, $"Inserting Data... [ 0   % ]");
            int progress = Math.Abs(100 / schemeList.Count);
            int count    = 1;

            schemeList.ForEach(schemes => {
                Console.CursorLeft    = 84;
                string searchedObject = LoadedComponent.GetDataBaseName(schemes.ChannelId);
                LoadedComponent.GetCollection()[searchedObject].InsertOne(schemes);
                Console.Write(progress * count);
                count++;
            });
            Console.Write("\n");
            AlConsole.WriteLine(DefaultScheme.DB_IN_DATA_SCHEME_COMP, "全ての挿入が成功しました。");
        }
        // ReSharper disable all PossibleMultipleEnumeration
        static void Main(string[] args)
        {
            Console.CursorVisible = false;
            Settings.StartupTime  = DateTime.Now;
            AlExtension.ArrayWrite(START_UP, Settings.Startup);

            ArgumentParser.Decomposition(args);

            //Thread.Sleep(50000);

            // Set Client for Environment (Windows or Linux).
            _mongoClient = Settings.isLocal
                ? new MongoClient($"mongodb://{Settings.User}:{Settings.Pass}@124.0.0.1")
                : new MongoClient($"mongodb://{Settings.User}:{Settings.Pass}@{Settings.NekomataAws}");

            ConfigLoader.OnLoadEvent(_mongoClient);

            // Set Http Client. (For Reuse)
            // HttpClient isn't disposable, but is designed to "For Reuse".
            HttpClient httpClient = new HttpClient();

            // Send Request to YoutubeAPI.
            LoadedComponent.GetChannelId().ForEach(channelId => {
                string result = Task.Run(() => YoutubeAPIResponce.requestAsync(httpClient, channelId)).Result;
                //Thread.Sleep(3000);
                ListAggregation.SetResultList(result);
            });

            //ProductionHoloLive.GetAllKey().ForEach(channelId => {
            //    string result = Task.Run(() => YoutubeAPIResponce.requestAsync(httpClient, channelId)).Result;
            //    ListAggregation.SetResultList(result);
            //});

            // Finish Message
            AlConsole.WriteLine(DefaultScheme.RESPONCE_SCHEME, $"Success. Number of Request ({ListAggregation.GetResultList().Count})");

            // Youtube Response Json Deserialize
            ListAggregation.GetResultList().ForEach(result => {
                JsonScheme scheme = JsonConvert.DeserializeObject <JsonScheme>(result);
                ListAggregation.SetJsonSchemeDict(scheme);
            });

            // Result List Re-Initialize.
            ListAggregation.ResultListInit();

            IEnumerable <string> videoIdEnum = ListAggregation.GetVideoIdList().AsEnumerable <string>();

            // Because it is possible to save Quota,
            // When I search for 50 items in a batch, I can add 50 VideoId to the Dictionary<page number(int), VideoId(string)> as a lump organized into.
            // Send Request to YoutubeAPI. (Start Time for ScheduleLive)
            AlConsole.WriteLine(DefaultScheme.REQUEST_SCHEME, "Extend Information Request...");
            while (videoIdEnum.Any())
            {
                string   requestIds = String.Join(",", videoIdEnum.Take <string>(50));
                string[] sliced     = videoIdEnum.ToArray <string>();
                string   startTime  = Task.Run(() => YoutubeAPIResponce.RequestStartTimeAsync(httpClient, requestIds)).Result;
                for (int i = 0; i < (sliced.Length % 50 > 0 ? sliced.Length / 50 + 1 : sliced.Length / 50); i++)
                {
                    for (int j = 0; j < 5; j++)
                    {
                        AlExtension.ColorizeWrite(REQUEST_SCHEME, $"  #-- ^[ ", new [] { ConsoleColor.DarkGray, ConsoleColor.Green });
                        AlExtension.ColorizeWrite(REQUEST_SCHEME, String.Join(", ", sliced.Take(5)),
                                                  new [] { ConsoleColor.Magenta }, false);
                        AlExtension.ColorizeWriteLine(REQUEST_SCHEME, $" ]", new [] { ConsoleColor.Green }, false);
                        sliced = sliced.Skip <string>(5).ToArray();
                    }
                }
                // foreach (string splitValue in requestIds.Split(",")) {
                //     AlConsole.WriteLine(DefaultScheme.REQUEST_SCHEME, $"  #-- {splitValue, 15}");
                // }
                // string startTime = Task.Run(() => YoutubeAPIResponce.RequestStartTimeAsync(httpClient, requestIds)).Result;
                ListAggregation.SetResultList(startTime);
                videoIdEnum = videoIdEnum.Skip <string>(50);
            }

            // Finish Message
            AlConsole.WriteLine(DefaultScheme.RESPONCE_SCHEME, "Success.");

            // Youtube Response Json Deserialize
            ListAggregation.GetResultList().ForEach(result => {
                StartTimeScheme scheme = JsonConvert.DeserializeObject <StartTimeScheme>(result);
                ListAggregation.SetTimeScheme(scheme);
            });

            // Link JsonScheme and ExtendItem whose VideoId is the same.
            ListCombination.Scheme.SetBundleDict(ListAggregation.GetJsonSchemeList(), ListAggregation.GetTimeScheme());

            // Organize necessary information and put it into a RefactorScheme and store it in List(RefactorScheme).

            /*
             * ReSpell.Execute(5, 5,
             *  () => { SchemeOrthopedy.BundleModification(ListCombination.Scheme.GetBundleDict()); }, (count) => {
             *      AlConsole.Write(AlStatusEnum.Caution, $"{"TASK RESUMED", -15}", $"{"Data Bundler", -15}",
             *          "Failed to execute the task. Task will try again.");
             *      Console.CursorLeft = 0;
             *  }, (count) => {
             *      AlConsole.WriteLine(AlStatusEnum.Error, $"{"TASK FAILURE", -15}", $"{"Data Bundler", -15}",
             *          $"Failed to execute the task. TryCount: {count, -10}\n");
             *  }); */
            SchemeOrthopedy.BundleModification(ListCombination.Scheme.GetBundleDict());

            AlConsole.WriteLine(SORTLOG_SCHEME, $"{" ", -63}");
            AlConsole.WriteLine(SORTLOG_SCHEME, "既に終了していたライブ : 以下のものは挿入タスクから除外されます。");
            AlConsole.WriteLine(SORTLOG_SCHEME, "----------------------------- 対象 -----------------------------");
            foreach (KeyValuePair <string, string> liveData in SchemeOrthopedy.GetFinishedLivesDict())
            {
                AlExtension.ColorizeWriteLine(SORTLOG_SCHEME, $"[ ^{liveData.Key} ^] => \"^{liveData.Value}^\"",
                                              new [] { ConsoleColor.Green, ConsoleColor.Blue, ConsoleColor.Green, ConsoleColor.Gray, ConsoleColor.Green });
            }

            // foreach (string lives in SchemeOrthopedy.GetFinishedLives()) {
            //     AlConsole.WriteLine(SORTLOG_SCHEME, lives);
            // }

            AlConsole.WriteLine(SORTLOG_SCHEME, " ");
            AlConsole.WriteLine(SORTLOG_SCHEME, "フリーチャット専用枠 : 以下のものは挿入タスクから除外されます。");
            AlConsole.WriteLine(SORTLOG_SCHEME, "----------------------------- 対象 -----------------------------");
            foreach (KeyValuePair <string, string> liveData in SchemeOrthopedy.GetFreeChatLivesDict())
            {
                AlExtension.ColorizeWriteLine(SORTLOG_SCHEME, $"[ ^{liveData.Key} ^] => \"^{liveData.Value}^\"",
                                              new [] { ConsoleColor.Green, ConsoleColor.Blue, ConsoleColor.Green, ConsoleColor.Gray, ConsoleColor.Green });
            }

            string free = string.Join(',', SchemeOrthopedy.GetFreeChatLivesDict().Keys);

            AlConsole.WriteLine(SORTLOG_SCHEME, " ");
            AlConsole.WriteLine(SORTLOG_SCHEME, "遅刻ライブ : 以下のものは挿入タスクに追加されます。");
            AlConsole.WriteLine(SORTLOG_SCHEME, "----------------------------- 対象 -----------------------------");
            if (SchemeOrthopedy.GetLazyLivesDict().Count != 0)
            {
                foreach (KeyValuePair <string, string> liveData in SchemeOrthopedy.GetLazyLivesDict())
                {
                    AlExtension.ColorizeWriteLine(SORTLOG_SCHEME, $"[ ^{liveData.Key} ^] => \"^{liveData.Value}^\"",
                                                  new [] { ConsoleColor.Green, ConsoleColor.Blue, ConsoleColor.Green, ConsoleColor.Gray, ConsoleColor.Green });
                }
            }
            else
            {
                AlConsole.WriteLine(SORTLOG_SCHEME, "遅刻ライブはありません。");
            }

            AlConsole.WriteLine(SORTLOG_SCHEME, " ");
            // foreach (string lives in SchemeOrthopedy.GetFreeChatLives()) {
            //     AlConsole.WriteLine(SORTLOG_SCHEME, lives);
            // }

            // Serialize the organized information.
            SchemeOrthopedy.GetSchemes().ForEach(i => {
                serializedObject.Add(JsonConvert.SerializeObject(i));
            });

            // Displays serialized information.
            serializedObject.ForEach(i => AlConsole.WriteLine(DefaultScheme.SERIALIZELOG_SCHEME, $"{i.ToString().Substring(0, 64), -67}" + "......[OMT]"));

            // Send the serialize object to Database.
            DataBaseCollection.Insert(_mongoClient, SchemeOrthopedy.GetSchemes());

            // Controller Task Finish Message
            long progressTicks = DateTime.Now.Ticks - Settings.StartupTime.Ticks;

            AlConsole.WriteLine(CONTROLLER,
                                $"Task Finished ! / {progressTicks} Ticks" +
                                $" ({TimeSpan.FromTicks(progressTicks).Seconds} Sec)"
                                );
            AlConsole.WriteLine(CONTROLLER, $"Number of Scheduled Live => {SchemeOrthopedy.GetSchemes().Count}");
            AlConsole.WriteLine(CONTROLLER, $"             Usage Quota => {Settings.UseQuota}");
            AlConsole.WriteLine(CONTROLLER, $"  Validated Caution Data => {Settings.CautData}");
            AlConsole.WriteLine(CONTROLLER, $"  Validated Warning Data => {Settings.WarnData}");
            AlConsole.WriteLine(CONTROLLER, "Have a good live broadcast today !");

            if (Settings.OutputFreeChatVideoId)
            {
                Console.WriteLine(free);
            }
        }