private void ReadOptionalCell(IRow row, int colNum, ref List <string> rowCells)
        {
            try  //has text in cell
            {
                string cellValue = row.GetCell(colNum).ToString();

                cellValue = CleanLoadSheetCell(cellValue, false, false, false);

                if (colNum == _Config.AltCycleColumn)
                {
                    if (cellValue != "" && !CycleValidator.Validate4DigitCycle(cellValue))
                    {
                        _IsRowAltCycleNotValid = true;
                    }
                }

                if (colNum == _Config.EncodedStatusColumn)
                {
                    if (NormalizeText(cellValue) == Globals.Encoded.ToUpper() || NormalizeText(cellValue) == Globals.Copied.ToUpper())
                    {
                        _IsRowAlreadyEncoded = true;

                        _AlreadyEncodedCount++;
                    }
                }

                rowCells.Add(cellValue);
            }
            catch (Exception)  //cell is empty or NULL
            {
                rowCells.Add("");
            }
        }
Example #2
0
        private void TokenizeArtistAlbumTrack(string stringToTokenize, TokenType type, Tokens cycleTokens, string airline)
        {
            TokenizeGeneralText(stringToTokenize);

            //Alternative Cycle Numbers Detection
            if (type == TokenType.Album)
            {
                List <string> altCycleTokens = new List <string>();

                foreach (string token in _Tokens)
                {
                    if (CycleValidator.Validate4DigitCycle(token))
                    {
                        altCycleTokens.Add(token);
                    }
                }

                if (altCycleTokens.Count > 0)
                {
                    _Tokens = _Tokens.Except(altCycleTokens).ToList();  //remove alternative cycle tokens (valid 4 digit cycle code)

                    foreach (string altCycleToken in altCycleTokens)
                    {
                        _FullToken = Regex.Replace(_FullToken, altCycleToken, "");  //remove alternative cycle text from full token
                    }

                    cycleTokens.SetAlternativeCycle(altCycleTokens.First(), airline);  //first valid 4 digit cycle code will be used to set alternative cycle
                }
            }
        }
        private void AssignCycle()
        {
            string loadSheetFileName = Path.GetFileNameWithoutExtension(_AODLoadSheetFilePath);

            _Cycle = Regex.Match(loadSheetFileName, @"\d{4}$").ToString();  //Grab cycle digits at end of AOD Loadsheet filename

            if (!loadSheetFileName.EndsWith(_Cycle) || !CycleValidator.Validate4DigitCycle(_Cycle))
            {
                ConsolePrintHelpers.PrintRedText("\n  ERROR: Invalid Loadsheet cycle number at end of filename:  " + _Cycle);
                ConsolePrintHelpers.PressAnyKeyToExit();
            }
        }
        private void SetCycle()
        {
            _Cycle = "";

            if (_AreCycleCodesDetected)
            {
                foreach (string cycleCode in _CycleCodes)
                {
                    if (CycleValidator.Validate4DigitCycle(cycleCode))
                    {
                        _Cycle = cycleCode;

                        return;
                    }
                    else if (CycleValidator.ValidateAirlineCodeCycle(cycleCode))
                    {
                        _Cycle = cycleCode.Substring(2, 4);

                        return;
                    }
                }
            }
        }
        private void DetectCycleTokens()
        {
            _AreCycleCodesDetected = false;

            List <string> filePathTokens = new Tokens(_NoDiacriticsSubDirectoriesFilePath, TokenType.FilePath).GetTokens;

            foreach (string filePathtoken in filePathTokens)
            {
                bool isValidCycleToken = false;

                if (CycleValidator.Validate4DigitCycle(filePathtoken))
                {
                    isValidCycleToken = true;
                }
                else if (CycleValidator.ValidateYear(filePathtoken))
                {
                    string yearSearchText = @"\" + filePathtoken + @"\";  //Trying to get the year directory specifically, thus the backslashes. Not a year that is part of the Album/Track text for example.

                    if (FindToken(yearSearchText, _NormalizedSubDirectoriesPath, false))
                    {
                        isValidCycleToken = true;
                    }
                }
                else if (CycleValidator.ValidateAirlineCodeCycle(filePathtoken))
                {
                    isValidCycleToken = true;
                }

                if (isValidCycleToken)
                {
                    if (!_CycleCodes.Any(code => code == filePathtoken))
                    {
                        _CycleCodes.Add(filePathtoken);
                    }
                }
            }

            if (!_IsAirlineDetected || _CycleCodes.Any(code => code.Length == 6))
            {
                if (_CycleCodes.Count > 0)
                {
                    _CycleCodes = _CycleCodes.OrderByDescending(code => code.Length).ThenBy(code => code).ToList();

                    _AreCycleCodesDetected = true;
                }

                return;
            }

            foreach (string cycleCode in _CycleCodes)
            {
                if (CycleValidator.Validate4DigitCycle(cycleCode))
                {
                    string airlineCycle = _AirlineCode + cycleCode;

                    if (FindToken(airlineCycle, _NormalizedSubDirectoriesFilePath, false))
                    {
                        if (!_CycleCodes.Any(code => code == airlineCycle))
                        {
                            _CycleCodes.Add(airlineCycle);
                        }

                        if (_CycleCodes.Count > 0)
                        {
                            _CycleCodes = _CycleCodes.OrderByDescending(code => code.Length).ThenBy(code => code).ToList();

                            _AreCycleCodesDetected = true;
                        }

                        return;
                    }
                }
            }

            if (_CycleCodes.Count > 0)
            {
                _CycleCodes = _CycleCodes.OrderByDescending(code => code.Length).ThenBy(code => code).ToList();

                _AreCycleCodesDetected = true;
            }

            return;
        }
        public AODLoadSheetRow(int loadSheetRowNumber, List <string> loadSheetRowCells, AudioEncoderConfig config)
        {
            _LoadSheetRowNumber = loadSheetRowNumber;

            _Airline        = loadSheetRowCells[0];
            _AltCycle       = loadSheetRowCells[1];
            _Artist         = loadSheetRowCells[2];
            _Album          = loadSheetRowCells[3];
            _TrackNumber    = loadSheetRowCells[4];
            _Track          = loadSheetRowCells[5];
            _OutputFilename = loadSheetRowCells[6];
            _AudioType      = loadSheetRowCells[7];
            _ShipTo         = loadSheetRowCells[8];
            _Status         = loadSheetRowCells[9];

            _Config = config;

            _Cycle = _Config.Cycle;

            _AirlineFullName = GetAirlineFullName();

            _OutputFilenameExtension = Path.GetExtension(_OutputFilename).ToLower();

            _DestinationPath = GetDestinationPath();  //Uses loadsheet's cycle (_Cycle) for file output directory

            _Tokens = new TokensCollection(this);

            _OriginalSearchStrategy = _Tokens.SearchStrategy;

            if (CycleValidator.Validate4DigitCycle(_AltCycle) && _AltCycle != _Cycle)
            {
                //If altCycle was detected in album text, it is overwritten again with the value from the "Alt. Cycle" loadsheet column
                _Tokens.CycleTokens.SetAlternativeCycle(_AltCycle, _Airline);
            }

            _SearchCycle = _Tokens.CycleTokens.FullToken;

            if (NormalizeText(_ShipTo).Contains(Globals.ROCKWELL))
            {
                _LoadSheetRowHash = NormalizeText(_SearchCycle + _Airline + _Artist + _Album + _TrackNumber + _Track + _AudioType + _ShipTo);
            }
            else
            {
                _LoadSheetRowHash = NormalizeText(_SearchCycle + _Airline + _Artist + _Album + _TrackNumber + _Track + _AudioType);
            }

            _AirlineAudioTypeHash = NormalizeText(_Airline + _AudioType);

            _AirlineAlbumAudioTypeHash = NormalizeText(_Airline + _Album + _AudioType);

            _TrackNumberTrackHash = NormalizeText(_TrackNumber + _Track);

            _CharCountArtistAlbumTrackNumberTrack = _Artist.Length
                                                    + _Album.Length
                                                    + _TrackNumber.Length
                                                    + _Track.Length;

            _IsApproved = false;

            _EncodingResult             = Globals.Failed;
            _EncodedFileDurationPretty  = Globals.Failed;
            _EncodedFileDurationSeconds = 0;

            _IsQuickSearchActive = false;

            _QuickSearchNotePastLSR     = "None";
            _QuickSearchNotePreviousLSR = "None";

            _SearchCollection = null;

            _SuggestedAudioFile = null;

            _IsSuggestedAudioFileAssigned = false;
        }