示例#1
0
文件: UserFile.cs 项目: JuRogn/OA
 public void Upload(string initParams, T_SYS_FILEUPLOAD FileUpload)
 {
     this.State = Constants.FileStates.Uploading;
     _fileUploader = new WcfFileUploader(this, FileUpload);
     _fileUploader.Event_Upload += new EventHandler<FileUploadEventArgs>(Event_Upload);
     _fileUploader.UploadFinished += new EventHandler(fileUploader_UploadFinished);
     _fileUploader.StartUpload(initParams);
 }
示例#2
0
        /// <summary>
        /// Initializes a new instance of the <see cref="TestServerSettingsForm"/> class.
        /// </summary>
        /// <param name="server">The <see cref="IFileUploader"/> to test.</param>
        /// <exception cref="ArgumentNullException"><paramref name="server"/> is null.</exception>
        public TestServerSettingsForm(IFileUploader server)
        {
            _server = server;

            InitializeComponent();

            Show();
        }
示例#3
0
文件: UserFile.cs 项目: JuRogn/OA
 /// <summary>
 /// 删除已上传的文件
 /// </summary>
 public void Del_FileAndID()
 {
     _fileUploader = new WcfFileUploader(this);
     if (_fileUploader != null)
     {
         _fileUploader.UploadFinished += new EventHandler(fileUploader_DeleteFinished);
         _fileUploader.Del_FileAndID();
     }
 }
 public EnrollmentController(IGenericRepository repository, IMapper<CreateStudentModel, Student> enrollmentMapper,
                                         IMapper<EnterProgramStatusModel, StudentProgramStatus> programStatusMapper, 
                                         IMapper<AcademicDetailModel, StudentAcademicDetail> academicDetailMapper, 
                                         IFileUploader fileUploader,
                                         IMapper<AcademicDetailModel, 
                                         StudentSchoolAssociation> schoolAssociationMapper,
                                         IStudentRepository studentRepository)
 {
     _fileUploader = fileUploader;
     _schoolAssociationMapper = schoolAssociationMapper;
     _studentRepository = studentRepository;
     _academicDetailMapper = academicDetailMapper;
     _repository = repository;
     _enrollmentMapper = enrollmentMapper;
     _programStatusMapper = programStatusMapper;
 }
 public ControlPanelController(IFileUploader uploader)
 {
     _uploader = uploader;
 }
示例#6
0
 public ProductPictureApplication(IProductPictureRepository productPictureRepository, IFileUploader fileUploader, IProductRepository productRepository)
 {
     _productPictureRepository = productPictureRepository;
     _fileUploader             = fileUploader;
     _productRepository        = productRepository;
 }
示例#7
0
 public ArticleApplication(IArticleRepository articleRepository, IFileUploader fileUploader, IArticleCategoryRepository articleCategoryRepository)
 {
     _articleRepository         = articleRepository;
     _fileUploader              = fileUploader;
     _articleCategoryRepository = articleCategoryRepository;
 }
示例#8
0
 public UploadController(IWebHostEnvironment env, IWorkContext workContext, IFileUploader fileManager)
 {
     this._environment = env;
     this._workContext = workContext;
     _fileManager      = fileManager;
 }
示例#9
0
 public ProductApplication(IProductRepo productRepo, IProductCategoryRepo productCategoryRepo, IFileUploader fileUploader)
 {
     _productRepo         = productRepo;
     _productCategoryRepo = productCategoryRepo;
     _fileUploader        = fileUploader;
 }
示例#10
0
        private void fileUploader_UploadFinished(object sender, EventArgs e)
        {
            _fileUploader = null;

            if (this.State != Enums.FileStates.Deleted
               && this.State != Enums.FileStates.Error)
            {
                this.State = Enums.FileStates.Finished;

                if (this.FileStream != null)
                {
                    this.FileStream.Close();
                    this.FileStream.Dispose();
                    this.FileStream = null;
                }
            }

            FinishUpdates(sender, e);
        }
示例#11
0
 public BuildController(IFileUploader uploader)
 {
     this.uploader = uploader;
 }
示例#12
0
        private void fileUploader_UploadFinished(object sender, EventArgs e)
        {
            _fileUploader = null;
            if (State != FileStates.Deleted && State != FileStates.Error)
            {
                State = FileStates.Finished;

                if (FileStream != null)
                {
                    FileStream.Close();
                    FileStream.Dispose();
                    FileStream = null;
                }
                FinishUpdate(sender, e);
            }
        }
示例#13
0
        private void fileUploader_UploadFinished(object sender, EventArgs e)
        {
            UIDispatcher.BeginInvoke(delegate
            {
                // close the file stream; this file will never be accessed again with this object
                this.FileStream.Dispose();

                _fileUploader = null;
                this.State = Constants.FileStates.Finished;
            });
        }
 public TicketController(IMediator mediator, IFileUploader fileUploader)
 {
     _mediator     = mediator;
     _fileUploader = fileUploader;
 }
示例#15
0
        public void Upload(string initParams, System.Windows.Threading.Dispatcher uiDispatcher)
        {
            State = FileStates.Uploading;

            _fileUploader = new HttpFileUploader(this, uiDispatcher);
            _fileUploader.StartUpload(initParams);
            _fileUploader.UploadFinished += new EventHandler(fileUploader_UploadFinished);
        }
示例#16
0
 public CategoriesController(IPickAndBookData data, IFileUploader fileProvider)
     : base(data)
 {
     this.fileUploader = fileProvider;
 }
示例#17
0
文件: UserFile.cs 项目: jjg0519/OA
        /// <summary>
        /// 上传完成事件
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void fileUploader_UploadFinished(object sender, EventArgs e)
        {
            _fileUploader = null;

            this.State = Constants.FileStates.Finished;
        }
 public AdvertsUploadController(IFileUploader fileUploader, IMapper mapper, IAdvertApiClient advertApiClient)
 {
     _fileUploader    = fileUploader;
     _advertApiClient = advertApiClient;
     _mapper          = mapper;
 }
示例#19
0
 /// <summary>
 /// When overridden in the derived class, handles synchronizing the given version.
 /// </summary>
 /// <param name="fu">The <see cref="IFileUploader"/> to use.</param>
 /// <param name="v">The version to synchronize.</param>
 /// <param name="reEnqueue">True if the <paramref name="v"/> should be re-enqueued so it can be re-attempted.
 /// If the method throws an <see cref="Exception"/>, the <paramref name="v"/> will be re-enqueued no matter what.</param>
 /// <returns>The error string, or null if the synchronization was successful.</returns>
 protected abstract string DoSync(IFileUploader fu, int v, out bool reEnqueue);
示例#20
0
文件: UserFile.cs 项目: JuRogn/OA
 /// <summary>
 /// 下载
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 public void Download()
 {           
         _fileUploader = new WcfFileUploader(this);
         _fileUploader.Event_Download += new EventHandler<FileDownloadEventArgs>(Event_Download);
         _fileUploader.Download();           
 }
示例#21
0
        public void CancelUpload()
        {
            if (this.FileStream != null)
            {
                this.FileStream.Close();
                this.FileStream.Dispose();
                this.FileStream = null;
            }

            if (_fileUploader != null && this.State == Enums.FileStates.Uploading)
            {
                _fileUploader.CancelUpload();
            }

            _fileUploader = null;
        }
 public FormFileImageUploader(IFileUploader fileUploader)
 {
     this.fileUploader = fileUploader;
 }
示例#23
0
 public ProductPictureApplication(IProductPictureRepo productPictureRepo, IProductRepo productRepo, IFileUploader fileUploader)
 {
     _productPictureRepo = productPictureRepo;
     _productRepo        = productRepo;
     _fileUploader       = fileUploader;
 }
示例#24
0
文件: UserFile.cs 项目: JuRogn/OA
 private void fileUploader_UploadFinished(object sender, EventArgs e)
 {
     _fileUploader = null;
     this.State = Constants.FileStates.Finished;
 }
示例#25
0
        private void fileUploader_UploadErrorOccurred(object sender, UploadErrorOccurredEventArgs e)
        {
            UIDispatcher.BeginInvoke(delegate
            {
                // leave the file stream open if an upload caused an error, in case the UI allows re-sending

                _fileUploader = null;
                this.ErrorMessage = e.ErrorMessage;
                this.State = Constants.FileStates.Error;
            });
        }
示例#26
0
 public UploadController(IFileUploader fileUploader)
 {
     _fileUploader = fileUploader;
 }
 public UploadFileFromContextRequestHandler(IFileUploader fileUploader)
 {
     _fileUploader = fileUploader;
 }
示例#28
0
 public AdvertManagmentController(IFileUploader s3FileUploader, IAdvertApiClient advertApiCleint, IMapper mapper)
 {
     this._s3FileLoader    = s3FileUploader;
     this._advertApiCleint = advertApiCleint;
     this._mapper          = mapper;
 }
 public ProductCategoryApplication(IProductCategoryRepository productCategoryRepository, IFileUploader fileUploader)
 {
     _productCategoryRepository = productCategoryRepository;
     _fileUploader = fileUploader;
 }
示例#30
0
 public ProductApplication(IProductRepository productRepository, IFileUploader fileUploader, IProductCategoryRepository productCategoryRepository)
 {
     _fileUploader              = fileUploader;
     _productRepository         = productRepository;
     _productCategoryRepository = productCategoryRepository;
 }
示例#31
0
        // GET: News

        public NewsController(IFileUploader fileUploader)
        {
            _fileUploader = fileUploader;
        }
示例#32
0
 public SignUpCase(IAppDbContext context, ILogger <SignUpCase> logger, UserManager <Entity.User> userManager, IAuthDataProvider dataProvider, IFileUploader fileUploader, Microsoft.Extensions.Configuration.IConfiguration configuration1)
 {
     _context       = context;
     _logger        = logger;
     _userManager   = userManager;
     _dataProvider  = dataProvider;
     _fileUploader  = fileUploader;
     _configuration = configuration1;
 }
示例#33
0
 public EditProjectModel(IProjectData projectData, IHtmlHelper htmlHelper, IFileUploader fileUploader)
 {
     _projectData  = projectData;
     _htmlHelper   = htmlHelper;
     _fileUploader = fileUploader;
 }
示例#34
0
 public UploadManager(HttpRequestBase request, IPathResolver pathResolver, IFileUploader fileUploader)
 {
     _pathResolver = pathResolver;
     _fileUploader = fileUploader;
     _files = GetPostedFiles(request);
 }
 public SlideApplication(ISlideRepository slideRepository, IFileUploader fileUploader)
 {
     _slideRepository = slideRepository;
     _fileUploader    = fileUploader;
 }
示例#36
0
 public CategorySearch(IFileUploader fileUploader)
 {
     _fileUploader = fileUploader;
 }
示例#37
0
 public DeleteAccountCommandHandler(IUnitOfWork unitOfWork, IAccountRepository accountRepository, IPostRepository postRepository, IFileUploader fileUploader)
 {
     this.unitOfWork        = unitOfWork;
     this.accountRepository = accountRepository;
     this.postRepository    = postRepository;
     this.fileUploader      = fileUploader;
 }
示例#38
0
 public ScretchesController(ApplicationDbContext context, UserManager <ApplicationUser> userManager, IFileUploader fileUploader)
 {
     _context          = context;
     _userManager      = userManager;
     this.fileUploader = fileUploader;
 }
示例#39
0
        /// <summary>
        /// When overridden in the derived class, handles synchronizing the given version.
        /// </summary>
        /// <param name="fu">The <see cref="IFileUploader"/> to use.</param>
        /// <param name="v">The version to synchronize.</param>
        /// <param name="reEnqueue">True if the <paramref name="v"/> should be re-enqueued so it can be re-attempted.
        /// If the method throws an <see cref="Exception"/>, the <paramref name="v"/> will be re-enqueued no matter what.</param>
        /// <returns>
        /// The error string, or null if the synchronization was successful.
        /// </returns>
        protected override string DoSync(IFileUploader fu, int v, out bool reEnqueue)
        {
            reEnqueue = false;

            // Load the VersionFileList for the version to check
            var vflPath = VersionHelper.GetVersionFileListPath(v);
            if (!File.Exists(vflPath))
            {
                // Version doesn't exist at all
                return null;
            }

            var vfl = VersionFileList.CreateFromFile(vflPath);

            // Try to download the version's file list hash
            var fileListHashPath = GetVersionRemoteFilePath(v, PathHelper.RemoteFileListHashFileName);
            var vflHash = fu.DownloadAsString(fileListHashPath);

            // Check if the hash file exists on the server
            if (vflHash != null)
            {
                // Check if the hash matches the current version's hash
                var expectedVflHash = File.ReadAllText(VersionHelper.GetVersionFileListHashPath(v));
                if (vflHash != expectedVflHash)
                {
                    // Delete the whole version folder first
                    fu.DeleteDirectory(GetVersionRemoteFilePath(v, null));
                }
                else
                {
                    // Hash existed and was correct - good enough for us!
                    return null;
                }
            }
            else
            {
                // Hash didn't exist at all, so we will have to update. As long as SkipIfExists is set to true, files
                // that already exist will be skipped, so we will only end up uploading the new files. In any case, its
                // the same process either way.
            }

            // Check the hashes of the local files
            foreach (var f in vfl.Files)
            {
                // Get the local file path
                var localPath = VersionHelper.GetVersionFile(v, f.FilePath);

                // Confirm the hash of the file
                var fileHash = Hasher.GetFileHash(localPath);
                if (fileHash != f.Hash)
                {
                    const string errmsg =
                        "The cached hash ({0}) of file `{1}` does not match the real hash ({2}) for version {3}." +
                        " Possible version corruption.";
                    return string.Format(errmsg, f.Hash, f.FilePath, fileHash, v);
                }
            }

            // Hashes check out, start uploading
            foreach (var f in vfl.Files)
            {
                // Get the local file path
                var localPath = VersionHelper.GetVersionFile(v, f.FilePath);

                var remotePath = GetVersionRemoteFilePath(v, f.FilePath);
                fu.UploadAsync(localPath, remotePath);
            }

            // Wait for uploads to finish
            while (fu.IsBusy)
            {
                Thread.Sleep(1000);
            }

            // All uploads have finished, so upload the VersionFileList hash
            fu.UploadAsync(VersionHelper.GetVersionFileListHashPath(v), fileListHashPath);

            // All done! That was easy enough, eh? *sigh*
            return null;
        }
示例#40
0
 public EditModel(StoreDbContext dbContext, IFileUploader fileUploader)
 {
     _dbContext    = dbContext;
     _fileUploader = fileUploader;
 }
示例#41
0
        /// <summary>
        /// Recreates the <see cref="IFileUploader"/> and starts updating again.
        /// </summary>
        void RecreateFileUploader()
        {
            // Dispose of the old uploader
            if (_fileUploader != null)
                _fileUploader.Dispose();

            // Create the new uploader
            _fileUploader = CreateFileUploader(FileUploaderType, Host, User, Password);

            _lastJobsRemaining = int.MinValue;

            // Start the synchronization of the live and next version
            EnqueueSyncVersion(_settings.LiveVersion);
            if (_settings.DoesNextVersionExist())
                EnqueueSyncVersion(_settings.LiveVersion + 1);
        }
示例#42
0
 /// <summary>
 /// When overridden in the derived class, handles synchronizing the given version.
 /// </summary>
 /// <param name="fu">The <see cref="IFileUploader"/> to use.</param>
 /// <param name="v">The version to synchronize.</param>
 /// <param name="reEnqueue">True if the <paramref name="v"/> should be re-enqueued so it can be re-attempted.
 /// If the method throws an <see cref="Exception"/>, the <paramref name="v"/> will be re-enqueued no matter what.</param>
 /// <returns>The error string, or null if the synchronization was successful.</returns>
 protected abstract string DoSync(IFileUploader fu, int v, out bool reEnqueue);
示例#43
0
        public void Upload(string initParams, Dispatcher uiDispatcher)
        {
            this.State = Enums.FileStates.Uploading;

            _fileUploader = new HttpFileUploader(this, uiDispatcher);

            _fileUploader.StartUpload(initParams);
            _fileUploader.UploadFinished += new EventHandler(fileUploader_UploadFinished);
        }
 public CeremonyApplication(ICeremonyRepository ceremonyRepository, IFileUploader fileUploader)
 {
     _ceremonyRepository = ceremonyRepository;
     _fileUploader       = fileUploader;
 }
示例#45
0
        void _server_TestConnectionMessage(IFileUploader sender, string message, object userState)
        {
            // Ensure the message is for us
            if (userState != this)
                return;

            // Log it
            Log(message);
        }
示例#46
0
 public AccountApplication(IAccountRepo accountRepo, IFileUploader fileUploader, IAuthHelper authHelper)
 {
     _accountRepo  = accountRepo;
     _fileUploader = fileUploader;
     _authHelper   = authHelper;
 }
示例#47
0
        /// <summary>
        /// Upload the file.
        /// </summary>
        /// <param name="UploadedFileProcessorType">type name for a class that will do post-processing on the uploaded files</param>
        /// <param name="ContextParam">Extra context parameter that is passed to the http handler</param>
        public void Upload(string UploadedFileProcessorType, string ContextParam)
        {
            // if we're already uploading, don't do anything
            if (this.State == Constants.FileStates.Uploading)
                return;

            this.State = Constants.FileStates.Uploading;

            if (HttpUploader)
                _fileUploader = new HttpFileUploader(this, UploadHandlerName, ChunkSizeMB);
            // for now use only the http uploader method
            //else
            //    _fileUploader = new WcfFileUploader(this);

            _fileUploader.UploadFinished += new EventHandler(fileUploader_UploadFinished);
            _fileUploader.UploadCanceled += new EventHandler(fileUploader_UploadCanceled);
            _fileUploader.UploadDataSent += new EventHandler<UploadDataSentArgs>(fileUploader_UploadDataSent);
            _fileUploader.UploadErrorOccurred += new EventHandler<UploadErrorOccurredEventArgs>(fileUploader_UploadErrorOccurred);
            _fileUploader.UploadProcessingStarted += new EventHandler(fileUploader_UploadProcessingStarted);

            _fileUploader.StartUpload(UploadedFileProcessorType, ContextParam);
        }
示例#48
0
 public AdvertManagementController(IFileUploader fileUploader, IMapper mapper, IAdvertApiClient advertApiClient)
 {
     _mapper          = mapper;
     _fileUploader    = fileUploader;
     _advertApiClient = advertApiClient;
 }
示例#49
0
        private void fileUploader_UploadCanceled(object sender, EventArgs e)
        {
            UIDispatcher.BeginInvoke(delegate
            {
                // leave the file stream open if an upload is canceled, in case the UI allows re-sending

                _fileUploader = null;
                this.State = Constants.FileStates.Canceled;
            });
        }
示例#50
0
        /// <summary>
        /// When overridden in the derived class, handles synchronizing the given version.
        /// </summary>
        /// <param name="fu">The <see cref="IFileUploader"/> to use.</param>
        /// <param name="v">The version to synchronize.</param>
        /// <param name="reEnqueue">True if the <paramref name="v"/> should be re-enqueued so it can be re-attempted.
        /// If the method throws an <see cref="Exception"/>, the <paramref name="v"/> will be re-enqueued no matter what.</param>
        /// <returns>The error string, or null if the synchronization was successful.</returns>
        protected override string DoSync(IFileUploader fu, int v, out bool reEnqueue)
        {
            fu.SkipIfExists = false;

            reEnqueue = false;

            var remoteFileListFilePath = PathHelper.GetVersionString(v) + ".txt";
            var remoteFileListHashFilePath = PathHelper.GetVersionString(v) + ".hash";

            // Ensure the live version is written. This is a very small but very important file, so just write it during
            // every synchronization.
            fu.UploadAsync(_settings.LiveVersionFilePath, MasterServerReader.CurrentVersionFilePath);

            // Also ensure the master server and file server lists are up-to-date. Again, we will just do this every time we
            // check to sync since they are relatively small lists but very important to keep up-to-date.
            fu.UploadAsync(_settings.FileServerListFilePath, MasterServerReader.CurrentDownloadSourcesFilePath);
            fu.UploadAsync(_settings.MasterServerListFilePath, MasterServerReader.CurrentMasterServersFilePath);

            // Load the VersionFileList for the version to check
            var vflPath = VersionHelper.GetVersionFileListPath(v);
            if (!File.Exists(vflPath))
            {
                // Version doesn't exist at all
                while (fu.IsBusy)
                {
                    Thread.Sleep(500);
                }
                return null;
            }

            // Test the creation of the VersionFileList to ensure its valid
            VersionFileList.CreateFromFile(vflPath);

            // Try to download the version's file list hash
            var vflHash = fu.DownloadAsString(remoteFileListHashFilePath);

            // Check if the hash file exists on the server
            if (vflHash != null)
            {
                // Check if the hash matches the current version's hash
                var expectedVflHash = File.ReadAllText(VersionHelper.GetVersionFileListHashPath(v));
                if (vflHash != expectedVflHash)
                {
                    // We don't need to delete anything since we make the MasterServer overwrite instead
                }
                else
                {
                    // Hash existed and was correct - good enough for us! But first, wait for uploads to finish...
                    while (fu.IsBusy)
                    {
                        Thread.Sleep(500);
                    }

                    return null;
                }
            }
            else
            {
                // Hash didn't exist at all, so we will have to update. As long as SkipIfExists is set to true, files
                // that already exist will be skipped, so we will only end up uploading the new files. In any case, its
                // the same process either way.
            }

            // Upload the files
            fu.UploadAsync(VersionHelper.GetVersionFileListPath(v), remoteFileListFilePath);
            fu.UploadAsync(VersionHelper.GetVersionFileListHashPath(v), remoteFileListHashFilePath);

            // Wait for uploads to finish
            while (fu.IsBusy)
            {
                Thread.Sleep(1000);
            }

            // All done!
            return null;
        }
 public LoggingFileUploaderDecorator(IFileUploader uploader) {
     _uploader = uploader;
 }
示例#52
0
 public CustomerManager(IFileUploader uploader)
 {
     _uploader = uploader;
 }