public void TrimUavLogs()
        {
            int    counter = 0;
            string line;

            // Read the file and display it line by line.
            DjiSrtVideoLogModel        djiSrtVideoLogModel  = new DjiSrtVideoLogModel();
            List <DjiSrtVideoLogModel> djiSrtVideoLogModels = new List <DjiSrtVideoLogModel>();

            using (System.IO.StreamReader file = new System.IO.StreamReader(@"H:\Code\UavLogTool\UavLogToolTest\Data\DJI_0012.SRT"))
            {
                int lineCount = 0;
                int id        = 0;
                while ((line = file.ReadLine()) != null)
                {
                    int idTemp;
                    if (int.TryParse(line, out idTemp))
                    {
                        djiSrtVideoLogModel = new DjiSrtVideoLogModel();
                        id = idTemp;
                        lineCount++;
                    }
                    if (id >= 1)
                    {
                        switch (lineCount)
                        {
                        case 1:
                            djiSrtVideoLogModel.Id = id;
                            lineCount++;
                            break;

                        case 2:
                            djiSrtVideoLogModel = SrtConverter.GetTimeStamp(line, ref djiSrtVideoLogModel);
                            lineCount++;
                            break;

                        case 3:
                            djiSrtVideoLogModel = SrtConverter.GetHomePointAndDateTime(line, ref djiSrtVideoLogModel);
                            lineCount++;
                            break;

                        case 4:
                            djiSrtVideoLogModel = SrtConverter.GetGpsPointAndBarometer(line, ref djiSrtVideoLogModel);
                            lineCount++;
                            break;

                        case 5:
                            djiSrtVideoLogModel = SrtConverter.GetCameraInfo(line, ref djiSrtVideoLogModel);
                            djiSrtVideoLogModels.Add(djiSrtVideoLogModel);
                            lineCount = 0;
                            break;

                        default:
                            break;
                        }
                    }
                    counter++;
                }
            }

            var filePath = Path.Combine(@"C:\Temp\", "djiSrtVideo.csv");

            var noko         = SrtConverter.ConvertSrtToUavLog(djiSrtVideoLogModels);
            var csvVideoLogs = CsvUtilities.ToCsv(",", djiSrtVideoLogModels.ToArray());
            var saved        = CsvUtilities.SaveCsvTofile(filePath, csvVideoLogs);
        }
        public async Task <IActionResult> GetCsvFromSrt(IFormFile srtLog)
        {
            long   size      = srtLog.Length;
            string extension = Path.GetExtension(srtLog.FileName).ToLower();

            if (size > 0)
            {
                if (!extension.Equals(".SRT", StringComparison.OrdinalIgnoreCase))
                {
                    return(BadRequest("wrong file format"));
                }
            }
            else
            {
                return(BadRequest("SRT File Not Found"));
            }
            string line;

            DjiSrtVideoLogModel        djiSrtVideoLogModel  = new DjiSrtVideoLogModel();
            List <DjiSrtVideoLogModel> djiSrtVideoLogModels = new List <DjiSrtVideoLogModel>();

            try
            {
                using (System.IO.StreamReader file = new System.IO.StreamReader(srtLog.OpenReadStream()))
                {
                    int lineCount = 0;
                    int id        = 0;
                    while ((line = file.ReadLine()) != null)
                    {
                        int idTemp;
                        if (int.TryParse(line, out idTemp))
                        {
                            djiSrtVideoLogModel = new DjiSrtVideoLogModel();
                            id = idTemp;
                            lineCount++;
                        }
                        if (id >= 1)
                        {
                            switch (lineCount)
                            {
                            case 1:
                                djiSrtVideoLogModel.Id = id;
                                lineCount++;
                                break;

                            case 2:
                                djiSrtVideoLogModel = SrtConverter.GetTimeStamp(line, ref djiSrtVideoLogModel);
                                lineCount++;
                                break;

                            case 3:
                                djiSrtVideoLogModel = SrtConverter.GetHomePointAndDateTime(line, ref djiSrtVideoLogModel);
                                lineCount++;
                                break;

                            case 4:
                                djiSrtVideoLogModel = SrtConverter.GetGpsPointAndBarometer(line, ref djiSrtVideoLogModel);
                                lineCount++;
                                break;

                            case 5:
                                djiSrtVideoLogModel = SrtConverter.GetCameraInfo(line, ref djiSrtVideoLogModel);
                                djiSrtVideoLogModels.Add(djiSrtVideoLogModel);
                                lineCount = 0;
                                break;

                            default:
                                break;
                            }
                        }
                    }
                    if (djiSrtVideoLogModels.Any())
                    {
                        var csvVideoInfoModels       = CsvUtilities.ToCsv(",", djiSrtVideoLogModels);
                        var fileNameWithoutExtension = Path.GetFileNameWithoutExtension(srtLog.FileName);
                        var saved = CsvUtilities.SaveCsvTofile(Path.Combine(@"C:\Temp\", $"{fileNameWithoutExtension}_resume.csv"), csvVideoInfoModels);

                        return(Ok("Ok creating Srt to Csv"));
                    }
                    else
                    {
                        return(BadRequest("djiSrtVideoLogModels dont have any record"));
                    }
                }
            }
            catch (Exception)
            {
                return(BadRequest("Problem saving Srt to csv"));
            }
        }