コード例 #1
0
        public async void Insert()
        {
            this.InsertDatumList       = new List <InsertDatum>();
            this.InsertFileList        = new List <string>();
            IsEnabledInsertButton      = false;
            IsEnabledStartUpLoopButton = false;
            System.Diagnostics.Stopwatch sw = new System.Diagnostics.Stopwatch();

            this.InsertConfig = this.GenerateInsertConfig();
            #region ファイル検索

            this.LogText += LogTexts.DuringCheckOfTheUpdateFile + "\n";
            LogWritter.WriteLog(LogWritter.LogMode.Search, LogTexts.DuringCheckOfTheUpdateFile + "\n");

            await Task.Run(() =>
            {
                this.InsertFileList = DirectorySearcher.DirectorySearch(this.InsertConfig);
            });

            this.LogText += $"{LogTexts.NumberOfTheInsertedFile}: {this.InsertFileList.Count}\n";
            LogWritter.WriteLog(LogWritter.LogMode.Search, $"{LogTexts.NumberOfTheInsertedFile}: {this.InsertFileList.Count}\n");

            #endregion

            #region GPS挿入

            this.LogText += LogTexts.TheSrartOfTheInsertingGps + "\n";
            LogWritter.WriteLog(LogWritter.LogMode.Gps, LogTexts.TheSrartOfTheInsertingGps + "\n");

            //await Task.Run(() =>
            //{
            //    for (int i = 0; i < this.InsertConfig.Correction.Count; i++)
            //    {
            //        GpsInserter.InsertGps(this.InsertFileList, this.InsertConfig, i, this.InsertDatumList);
            //    }
            //});

            Parallel.For(0, this.InsertConfig.Correction.Count, i =>
            {
                GpsInserter.InsertGps(this.InsertFileList, this.InsertConfig, i, this.InsertDatumList);
            });

            this.LogText += LogTexts.TheEndOfTheInsertingGps + "\n";
            LogWritter.WriteLog(LogWritter.LogMode.Gps, LogTexts.TheEndOfTheInsertingGps + "\n");

            #endregion

            #region 加速度挿入

            if (IsCheckedInsertAcc)
            {
                this.LogText += LogTexts.TheSrartOfTheInsertingAcc + "\n";
                LogWritter.WriteLog(LogWritter.LogMode.Acc, LogTexts.TheSrartOfTheInsertingAcc + "\n");

                await Task.Run(() =>
                {
                    AccInserter.InsertAcc(this.InsertFileList, this.InsertConfig, this.InsertDatumList);
                });

                this.LogText += LogTexts.TheEndOfTheInsertingAcc + "\n";
                LogWritter.WriteLog(LogWritter.LogMode.Acc, LogTexts.TheEndOfTheInsertingAcc + "\n");
            }

            #endregion

            foreach (var datum in InsertDatumList)
            {
                #region トリップ挿入

                //await Task.Run(() =>
                //{
                for (int i = 0; i < this.InsertConfig.Correction.Count; i++)
                {
                    TripInserter.InsertTrip(datum, InsertConfig.Correction[i]);
                }
                //});

                #endregion

                #region 補正加速度挿入

                //if (IsCheckedInsertCorrectedAcc)
                //{
                //    await Task.Run(() =>
                //    {
                //        AccInserter.InsertCorrectedAcc(datum, InsertConfig);
                //    });
                //}

                #endregion
            }
            int count = 0;
            Parallel.For(0, InsertDatumList.Count, i =>
            {
                #region ECOLOG挿入
                //     sw.Start();

                if (IsCheckedSpeedLPFMapMatching)
                {
                    EcologInserter.InsertEcologSpeedLPF005MM(InsertDatumList[i], this.UpdateText, InsertConfig.GpsCorrection.SpeedLPFMapMatching);
                }
                if (IsCheckedMapMatching)
                {
                    EcologInserter.InsertEcologMM(InsertDatumList[i], this.UpdateText, InsertConfig.GpsCorrection.MapMatching);
                }

                if (IsCheckedNormal)
                {
                    EcologInserter.InsertEcolog(InsertDatumList[i], this.UpdateText, InsertConfig.GpsCorrection.Normal, out count);
                }


                //       sw.Stop();
                //      LogWritter.WriteLog(LogWritter.LogMode.Elapsedtime, "Total Time:" + sw.Elapsed);
                #endregion
            });
            this.LogText += LogTexts.TheEndOfTheInsertingEcolog + "\n";

            /*if (count > 0)
             * {
             *  SlackUtil.commentToSlack(InsertConfig.StartDate, InsertConfig.EndDate, InsertConfig.Correction);
             * }
             * else {
             *  SlackUtil.commentToSlackNotInsert(InsertConfig.StartDate, InsertConfig.EndDate, InsertConfig.Correction);
             * }*/
            IsEnabledInsertButton      = true;
            IsEnabledStartUpLoopButton = true;
        }