Exemplo n.º 1
0
        private void ProcessFinishedHandler(object sender, ThreadEventArgs args)
        {
            _logger.Debug($"Finish to process ThreadId:{Thread.CurrentThread.ManagedThreadId} for user:{args.Name}");

            DecrementUserThreadCount(args.Name);

            ((FileCommandsWatcher)_watcher).StopSendEvent -= ((Processor)sender).Processor_StopSendEvent;
        }
Exemplo n.º 2
0
        public void DoWork(object stateInfo)
        {
            ProcessFinished += ((ThreadStateInfo)stateInfo).Handler;

            IUserConfiguration user     = ((ThreadStateInfo)stateInfo).User;
            string             fileName = ((ThreadStateInfo)stateInfo).FileName;
            var result = new ProcessResult();

            try
            {
                _logger.Debug($"Start to process {fileName} for User:{user.Name} in Thread:{Thread.CurrentThread.ManagedThreadId}");

                var ftpHelper = user.Ftp.GetFtpHelper(_logger);

                result.ErrorFileName = GetErrorsFileName(fileName, user);

                SendStartProcessEmail(fileName, user);

                UploadStartFileToFTP(fileName, user, ftpHelper);

                string resultFileName = Process(user, fileName, result);

                UploadErrosToFTP(result.ErrorFileName, user, ftpHelper);

                UploadResultsToFTP(resultFileName, user, ftpHelper);

                if (!string.IsNullOrEmpty(resultFileName))
                {
                    File.Move(fileName, fileName.Replace(".processing", ".processed"));

                    SendEndProcessEmail(fileName, user, result);
                }

                SendErrorEmail(fileName, user.AdminEmail, result);
            }
            catch (Exception e)
            {
                _logger.Error($"ERROR GENERAL PROCESS -- {e}");
            }
            finally
            {
                var args = new ThreadEventArgs()
                {
                    Name = user.Name
                };
                OnProcessFinished(args);
            }
        }
Exemplo n.º 3
0
 protected virtual void OnProcessFinished(ThreadEventArgs args)
 {
     ProcessFinished?.Invoke(this, args);
 }