示例#1
0
        public static void InsertAcc(List <string> insertFileList, InsertConfig config, List <InsertDatum> insertDatumList)
        {
            foreach (var filePath in insertFileList)
            //Parallel.For(0, insertFileList.Count, i =>
            {
                string[] word = filePath.Split('\\');

                // ACCファイルでない場合はcontinue
                if (System.Text.RegularExpressions.Regex.IsMatch(word[word.Length - 1], @"\d{14}Unsent16HzAccel.csv"))
                {
                    var datum = new InsertDatum()
                    {
                        DriverId          = DriverNames.GetDriverId(word[DriverIndex]),
                        CarId             = CarNames.GetCarId(word[CarIndex]),
                        SensorId          = SensorNames.GetSensorId(word[SensorIndex]),
                        StartTime         = config.StartDate,
                        EndTime           = config.EndDate,
                        EstimatedCarModel = EstimatedCarModel.GetModel(config.CarModel)
                    };

                    InsertDatum.AddDatumToList(insertDatumList, datum);

                    InsertAccRaw(filePath, datum);
                }
                //});
            }
        }
示例#2
0
        public static Task InsertGps(List <string> insertFileList, InsertConfig config, int correctionIndex, List <InsertDatum> insertDatumList)
        {
            var tasks = new List <Task>();

            foreach (string filePath in insertFileList)
            {
                Console.WriteLine("GPSinserting:" + filePath);
                string[] word = filePath.Split('\\');

                // GPSファイルでない場合はcontinue
                if (!System.Text.RegularExpressions.Regex.IsMatch(word[word.Length - 1], @"\d{14}UnsentGPS.csv"))
                {
                    continue;
                }

                var datum = new InsertDatum()
                {
                    DriverId          = DriverNames.GetDriverId(word[DriverIndex]),
                    CarId             = CarNames.GetCarId(word[CarIndex]),
                    SensorId          = SensorNames.GetSensorId(word[SensorIndex]),
                    StartTime         = config.StartDate,
                    EndTime           = config.EndDate,
                    EstimatedCarModel = EstimatedCarModel.GetModel(config.CarModel)
                };

                InsertDatum.AddDatumToList(insertDatumList, datum);

                LogWritter.WriteLog(LogWritter.LogMode.Gps, $"インサートデータ, FilePath: {filePath}, DriverId: {datum.DriverId}, CarId: {datum.CarId}, SensorId: {datum.SensorId}");

                // ファイルごとの処理なので主キー違反があっても挿入されないだけ
                var gpsRawTable = InsertGpsRaw(filePath, datum, config.Correction[correctionIndex]);
                if (config.Correction[correctionIndex] == InsertConfig.GpsCorrection.SpeedLPFMapMatching ||
                    config.Correction[correctionIndex] == InsertConfig.GpsCorrection.MapMatching)
                {
                    gpsRawTable = MapMatching.getResultMapMatching(gpsRawTable, datum);
                }
                else if (config.Correction[correctionIndex] == InsertConfig.GpsCorrection.DopplerSpeed)
                {
                    gpsRawTable = MapMatching.getResultMapMatchingDoppler(gpsRawTable, datum);
                }
                if (gpsRawTable.Rows.Count != 0)
                {
                    var task = Task.Run(() =>
                    {
                        InsertCorrectedGps(gpsRawTable, config.Correction[correctionIndex]);
                    });

                    tasks.Add(task);

                    TripInserter.InsertTripRaw(gpsRawTable, config.Correction[correctionIndex]);
                    //TripInserter.InsertTrip(datum, config.Correction[correctionIndex]);
                }
                else
                {
                    LogWritter.WriteLog(LogWritter.LogMode.Gps, $"ファイルの行数が0行のためインサートを行いませんでした: {filePath}");
                }
            }
            return(Task.WhenAll(tasks));
        }
        private void FillUserCompanyTrailerList()
        {
            DataTable  combDT = new DataTable();
            DataColumn dc     = new DataColumn("UserTrailerNameless", typeof(string));

            combDT.Columns.Add(dc);

            dc = new DataColumn("TrailerType", typeof(string));
            combDT.Columns.Add(dc);

            dc = new DataColumn("TrailerName", typeof(string));
            combDT.Columns.Add(dc);

            dc = new DataColumn("GarageName", typeof(string));
            combDT.Columns.Add(dc);

            dc = new DataColumn("DriverName", typeof(string));
            combDT.Columns.Add(dc);

            DataColumn dcDisplay = new DataColumn("DisplayMember");

            dcDisplay.Expression = string.Format("IIF(UserTrailerNameless <> 'null', '[' + {0} +'] ' + IIF(GarageName <> '', {1} +' || ','') + {2} + IIF(DriverName <> 'null', ' || In use - ' + {3},'')," +
                                                 "'-- NONE --')",
                                                 "TrailerType", "GarageName", "TrailerName", "DriverName");
            combDT.Columns.Add(dcDisplay);
            //

            combDT.Rows.Add("null");

            foreach (KeyValuePair <string, UserCompanyTruckData> UserTrailer in UserTrailerDictionary)
            {
                if (UserTrailer.Value.Main)
                {
                    string trailername = "";
                    //
                    string tmpTrailerType = "", tmpTrailerkName = "", tmpGarageName = "", tmpDriverName = "";

                    if (UserTrailerDictionary[UserTrailer.Key].Users)
                    {
                        tmpTrailerType = "U";

                        tmpGarageName = GaragesList.Find(x => x.Trailers.Contains(UserTrailer.Key)).GarageNameTranslated;
                    }
                    else
                    {
                        tmpTrailerType = "Q";
                    }
                    //
                    string trailerdef = UserTrailerDictionary[UserTrailer.Key].Parts.Find(x => x.PartType == "trailerdef").PartNameless;

                    if (UserTrailerDefDictionary.Count > 0)
                    {
                        if (UserTrailerDefDictionary.ContainsKey(trailerdef))
                        {
                            string[] trailerDefPropertys = { "body_type", "axles", "chain_type" };
                            string[] trailerDefExtra     = { "{0}", "{0} axles", "{0}" };

                            int           iCounter      = 0;
                            List <string> CurTrailerDef = UserTrailerDefDictionary[trailerdef];

                            bool wasfound = false;

                            foreach (string Property in trailerDefPropertys)
                            {
                                try
                                {
                                    string tmp = CurTrailerDef.Find(x => x.StartsWith(" " + Property + ":")).Split(':')[1].Trim(new char[] { ' ' }).Replace('_', ' ');

                                    if (wasfound)
                                    {
                                        trailername += " | ";
                                    }
                                    trailername += String.Format(trailerDefExtra[iCounter], System.Globalization.CultureInfo.CurrentCulture.TextInfo.ToTitleCase(tmp));

                                    wasfound = true;
                                }
                                catch { wasfound = false; }

                                iCounter++;
                            }

                            tmpTrailerkName = trailername;
                        }
                        else
                        {
                            tmpTrailerkName = trailerdef;
                        }
                    }
                    else
                    {
                        tmpTrailerkName = trailerdef;
                    }

                    tmpDriverName = UserDriverDictionary.Where(tX => tX.Value.AssignedTrailer == UserTrailer.Key)?.SingleOrDefault().Key ?? "null";

                    if (tmpDriverName != "null")
                    {
                        if (PlayerDataData.UserDriver == tmpDriverName)
                        {
                            tmpDriverName = "> " + Utilities.TextUtilities.FromHexToString(Globals.SelectedProfile);
                        }
                        else
                        {
                            DriverNames.TryGetValue(tmpDriverName, out string _resultvalue);

                            if (_resultvalue != null && _resultvalue != "")
                            {
                                tmpDriverName = _resultvalue.TrimStart(new char[] { '+' });
                            }
                        }
                    }

                    combDT.Rows.Add(UserTrailer.Key, tmpTrailerType, tmpTrailerkName, tmpGarageName, tmpDriverName); //(UserTrailer.Key, trailername);
                }
            }

            if (combDT.Rows.Count > 1)
            {
                comboBoxUserTrailerCompanyTrailers.Enabled = true;
            }
            else
            {
                comboBoxUserTrailerCompanyTrailers.Enabled = false;
            }

            comboBoxUserTrailerCompanyTrailers.ValueMember   = "UserTrailerNameless";
            comboBoxUserTrailerCompanyTrailers.DisplayMember = "DisplayMember";
            comboBoxUserTrailerCompanyTrailers.DataSource    = combDT;


            comboBoxUserTrailerCompanyTrailers.SelectedValue = PlayerDataData.UserCompanyAssignedTrailer;
        }
        private void FillUserCompanyTrucksList()
        {
            DataTable  combDT = new DataTable();
            DataColumn dc     = new DataColumn("UserTruckNameless", typeof(string));

            combDT.Columns.Add(dc);

            //dc = new DataColumn("UserTruckName", typeof(string));
            //combDT.Columns.Add(dc);
            //

            dc = new DataColumn("TruckType", typeof(string));
            combDT.Columns.Add(dc);

            dc = new DataColumn("TruckName", typeof(string));
            combDT.Columns.Add(dc);

            dc = new DataColumn("GarageName", typeof(string));
            combDT.Columns.Add(dc);

            dc = new DataColumn("DriverName", typeof(string));
            combDT.Columns.Add(dc);

            DataColumn dcDisplay = new DataColumn("DisplayMember");

            dcDisplay.Expression = string.Format("IIF(UserTruckNameless <> '', '[' + {0} +'] ' + IIF(GarageName <> '', {1} +' || ','') + {2} + IIF(DriverName <> 'null', ' || In use - ' + {3},'')," +
                                                 "'-- NONE --')",
                                                 "TruckType", "GarageName", "TruckName", "DriverName");
            combDT.Columns.Add(dcDisplay);
            //

            foreach (KeyValuePair <string, UserCompanyTruckData> UserTruck in UserTruckDictionary)
            {
                string truckname = "";

                try
                {
                    string templine = UserTruck.Value.Parts.Find(x => x.PartType == "truckbrandname").PartData.Find(xline => xline.StartsWith(" data_path:"));
                    truckname = templine.Split(new char[] { '"' })[1].Split(new char[] { '/' })[4];
                }
                catch { }

                TruckBrandsLngDict.TryGetValue(truckname, out string trucknamevalue);
                //
                string tmpTruckType = "", tmpTruckName = "", tmpGarageName = "", tmpDriverName = "";

                if (UserTruckDictionary[UserTruck.Key].Users)
                {
                    tmpTruckType = "U";

                    tmpGarageName = GaragesList.Find(x => x.Vehicles.Contains(UserTruck.Key)).GarageNameTranslated;
                }
                else
                {
                    tmpTruckType = "Q";
                }
                //
                if (trucknamevalue != null && trucknamevalue != "")
                {
                    tmpTruckName = trucknamevalue;
                }
                else
                {
                    tmpTruckName = truckname;
                }

                Garages tmpGrg = GaragesList.Where(tX => tX.Vehicles.Contains(UserTruck.Key))?.SingleOrDefault() ?? null;

                if (tmpGrg != null)
                {
                    tmpDriverName = tmpGrg.Drivers[tmpGrg.Vehicles.IndexOf(UserTruck.Key)];
                }
                else
                {
                    tmpDriverName = UserDriverDictionary.Where(tX => tX.Value.AssignedTruck == UserTruck.Key)?.SingleOrDefault().Key ?? "null";
                }

                if (tmpDriverName != null && tmpDriverName != "null")
                {
                    if (PlayerDataData.UserDriver == tmpDriverName)
                    {
                        tmpDriverName = "> " + Utilities.TextUtilities.FromHexToString(Globals.SelectedProfile);
                    }
                    else
                    {
                        DriverNames.TryGetValue(tmpDriverName, out string _resultvalue);

                        if (_resultvalue != null && _resultvalue != "")
                        {
                            tmpDriverName = _resultvalue.TrimStart(new char[] { '+' });
                        }
                    }
                }

                combDT.Rows.Add(UserTruck.Key, tmpTruckType, tmpTruckName, tmpGarageName, tmpDriverName);
            }

            bool noTrucks = false;

            if (combDT.Rows.Count == 0)
            {
                combDT.Rows.Add("null");//, "-- NONE --"); //none
                noTrucks = true;
            }

            comboBoxUserTruckCompanyTrucks.ValueMember   = "UserTruckNameless";
            comboBoxUserTruckCompanyTrucks.DisplayMember = "DisplayMember";
            comboBoxUserTruckCompanyTrucks.DataSource    = combDT;

            if (!noTrucks)
            {
                //combDT.DefaultView.Sort = "UserTruckName ASC";
                comboBoxUserTruckCompanyTrucks.Enabled       = true;
                comboBoxUserTruckCompanyTrucks.SelectedValue = PlayerDataData.UserCompanyAssignedTruck;
            }
            else
            {
                comboBoxUserTruckCompanyTrucks.Enabled       = false;
                comboBoxUserTruckCompanyTrucks.SelectedValue = "null";
            }
        }