Exemplo n.º 1
0
        /// <summary>
        /// Validation files, then preserve a list of all, valid and invalid files
        /// </summary>
        /// <returns></returns>
        public bool Validate()
        {
            try
            {
                List <string> tempFiles = new List <string>();
                if (this.transferManager == null)
                {
                    throw new Exception("Transfer manager found null.");
                }

                //Get files from provided masks
                _validFiles = new List <string>();
                if (validations.Count > 0)
                {
                    foreach (var mask in validations)
                    {
                        _validFiles.AddRange(transferManager.GetFileList(mask));
                    }
                }
                else
                {
                    _allFiles = transferManager.GetFileList(null);
                    _validFiles.AddRange(_allFiles);
                }

                //Just for safe side if system have picked same file with multiple masks e.g (test-pdf.txt, test.pdf)- Support we have to pick files with pdf keyword in name
                if (_validFiles.Count > 0)
                {
                    _validFiles = _validFiles.Distinct().ToList();
                }
                _readyToDownload = true;
                return(true);
            }
            catch (Exception ex)
            {
                throw new Exception("Error in validate() in defaultValidation : " + ex);
            }
        }
Exemplo n.º 2
0
        /// <summary>
        /// Validation files, then preserve a list of all, valid and invalid files
        /// </summary>
        /// <returns></returns>
        public bool Validate()
        {
            try
            {
                List <string> tempFiles = new List <string>();
                if (this.transferManager == null)
                {
                    throw new Exception("Transfer manager found null.");
                }

                //Get files from provided masks
                _validFiles = new List <string>();
                if (validations.Count > 0)
                {
                    var IsRequiredMasks = validations.Where(x => x.Required == true).Select(x => x.Mask).ToList();
                    foreach (var validation in IsRequiredMasks)
                    {
                        SingletonLogger.Instance.Debug("Required file mask - " + validation);
                        var files = transferManager.GetFileList(validation);
                        if (files.Count > 0)
                        {
                            SingletonLogger.Instance.Debug("");
                            _validFiles.AddRange(files);
                        }
                        else
                        {
                            Console.WriteLine("No files found for mask " + validation + " But it is required ");
                            return(false);
                        }
                    }

                    var masksHavingIsNotRequired = validations.Where(x => x.Required == false).Select(x => x.Mask).ToList();
                    foreach (var validation in masksHavingIsNotRequired)
                    {
                        var files = transferManager.GetFileList(validation);
                        if (files.Count > 0)
                        {
                            _validFiles.AddRange(files);
                        }
                        else
                        {
                            Console.WriteLine("No files found for mask " + validation);
                        }
                    }


                    //var outputCount = masksHavingIsRequired.Where(e => validFilesName.Any(d => d.Contains(e))).Count();
                    if (_validFiles.Count > 0)
                    {
                        _readyToDownload = true;
                    }
                }
                else
                {
                    _allFiles = transferManager.GetFileList(null);
                    _validFiles.AddRange(_allFiles);
                    _readyToDownload = true;
                }

                //Just for safe side if system have picked same file with multiple masks e.g (test-pdf.txt, test.pdf)- Support we have to pick files with pdf keyword in name
                if (_validFiles.Count > 0)
                {
                    _validFiles = _validFiles.Distinct().ToList();
                }
                _readyToDownload = true;
                return(true);
            }
            catch (Exception ex)
            {
                throw new Exception("Error in validate() in BatchValidation " + ex);
            }
        }