コード例 #1
0
ファイル: SFTPWatcher.cs プロジェクト: mahlin/InrappSos
        private void CheckFilesInFolder(string folder)
        {
            _inCorrectFilenameList = new List <FileInfo>();
            var incorrectPeriodList   = new List <FileInfo>();
            var incorrectFileCodeList = new List <FileInfo>();

            _folderName = GetFolderNameFromPath(folder);
            //folderName equals sftpAccountName
            _ftpAccount = _portalService.HamtaFtpKontoByName(_folderName);

            //Check if registered ftpaccount before handling files
            if (_ftpAccount != null)
            {
                DirectoryInfo dir = new DirectoryInfo(folder);
                _filesInFolder = dir.GetFiles().OrderByDescending(p => p.CreationTime).ToList();

                if (_filesInFolder.Count > 0)
                {
                    //Check if account has any registered contactperson. Otherwise reject files and write to errorlog
                    var userEmails = _portalService.HamtaEpostadresserForSFTPKonto(_ftpAccount.Id);
                    if (userEmails.Any())
                    {
                        //Check files in folder
                        CheckFiles(folder, incorrectPeriodList, incorrectFileCodeList);
                        HandleIncorrectFilenameList(folder);
                    }
                    else
                    {
                        //No contactperson registered for account
                        NoRegisteredContactHandler(folder);
                    }
                }
            }
            else
            {
                NotRegisteredSFTPAccount(folder);
            }
        }