public class QuickIOTransferFileCreationJob : QuickIOTransferJobWriteJob
File Create job implementation
File Create job with observer
public void CreateJobWithObserver( IQuickIOTransferObserver observer, String sourceFile, String targetDirectory )
{
var createJob = new QuickIOTransferFileCreationJob( observer, sourceFile, targetDirectory, GenerateDummyContent( ) );
createJob.CreationStarted += OnCreationStarted;
createJob.CreationProgress += OnCreationProgress;
createJob.CreationFinished += OnCreationFinished;
createJob.Run( );
}
File create job
public void CreateJob( String sourceFile, String targetDirectory, Int32 maxBufferSize )
{
var createJob = new QuickIOTransferFileCreationJob( sourceFile, targetDirectory, GenerateDummyContent( ) );
createJob.CreationStarted += OnCreationStarted;
createJob.CreationProgress += OnCreationProgress;
createJob.CreationFinished += OnCreationFinished;
createJob.Run( );
}
Event definitions for this example
private byte[ ] GenerateDummyContent()
{
return System.Text.Encoding.UTF8.GetBytes( "Hello. THis is file creation" );
}
private static void OnCreationFinished( object sender, QuickIOTransferFileCreationFinishedArgs e )
{
Console.WriteLine( "TestFileCreationJob: Creation Finished." );
}
private static void OnCreationProgress( object sender, QuickIOTransferFileCreationProgressArgs e )
{
Console.WriteLine( "TestFileCreationJob: Creation progresss: " + e.Percentage.ToString( "0.00" ) );
}
private static void OnCreationStarted( object sender, QuickIOTransferFileCreationStartedArgs e )
{
Console.WriteLine( "TestFileCreationJob: Creation started." );
}
private Int32 _maxJobRetryAttempts
DirectoryCreated
This event is raised when a directory was created
public DirectoryCreated
DirectoryCreating
This event is raised before an upcoming directory creation operation is performed
public DirectoryCreating
Error
This event is raised if file creation fails
public Error
Finished
This event is raised at the end of the file creation operation.
public Finished
Progress
This event is raised during a creation of a file. It provides current information such as progress, speed and estimated time.
public Progress
Started
This event is triggered at the beginning of the file creation operation.
public Started
QuickIOTransferFileCreationJob(IQuickIOTransferObserver observer, String targetDirectory, String fileName, Byte[] contents, Int32 maxBufferSize, Boolean overwrite, Boolean parentExistanceCheck, Int32 prorityLevel)
Creates a new instance if QuickIOTransferFileCreationJob
public void QuickIOTransferFileCreationJob(IQuickIOTransferObserver observer, String targetDirectory, String fileName, Byte[] contents, Int32 maxBufferSize, Boolean overwrite, Boolean parentExistanceCheck, Int32 prorityLevel)
Parameters
contents
Byte[]Contents to write
overwrite
Booleantrue to overwrite existing elements
maxBufferSize
Int32Set max buffer size for copy transfer
observer
IQuickIOTransferObserverObserver
targetDirectory
StringTarget directory fullname
fileName
StringTarget filename
parentExistanceCheck
Booleantrue to verify parent existance
prorityLevel
Int32Priority level of directory creation should be higher than file creation without parent check
QuickIOTransferFileCreationJob(String targetDirectory, String fileName, Byte[] contents, Int32 maxBufferSize, Boolean overwrite, Boolean parentExistanceCheck, Int32 prorityLevel)
Creates a new instance if QuickIOTransferFileCreationJob
public void QuickIOTransferFileCreationJob(String targetDirectory, String fileName, Byte[] contents, Int32 maxBufferSize, Boolean overwrite, Boolean parentExistanceCheck, Int32 prorityLevel)
Parameters
contents
Byte[]Contents to write
maxBufferSize
Int32Set max buffer size for copy transfer
overwrite
Booleantrue to overwrite existing elements
targetDirectory
StringTarget directory fullname
fileName
StringTarget filename
parentExistanceCheck
Booleantrue to verify parent existance
prorityLevel
Int32Priority level of directory creation should be higher than file creation without parent check
Implementation()
Starts the creation process
protected void Implementation()
OnCreationFinished(Int64 totalBytes)
Fires Finished
private void OnCreationFinished(Int64 totalBytes)
OnCreationProgress(Int64 totalBytes, UInt64 bytesTransfered)
Fires Progress
private void OnCreationProgress(Int64 totalBytes, UInt64 bytesTransfered)
OnCreationStarted(Int64 totalBytes)
Fires Progress
private void OnCreationStarted(Int64 totalBytes)
OnDirectoryCreated(String directoryPath)
Fires DirectoryCreated
private void OnDirectoryCreated(String directoryPath)
OnDirectoryCreating(String directoryPath)
Fire DirectoryCreating
private void OnDirectoryCreating(String directoryPath)
OnError(Exception e)
Fires Error
protected void OnError(Exception e)
Parameters
e
ExceptionContents
Contents to write
public Byte[] Contents { get; set; }
FileName
Filename with extension
public String FileName { get; set; }
JobType
JobType
internal override QuickIOTransferJobType JobType { get; }
MaxJobRetryAttempts
Count of max retries per job
public Int32 MaxJobRetryAttempts { get; set; }
TargetDirectory
Target directory
public String TargetDirectory { get; set; }
TargetFullName
Target directory
public String TargetFullName { get; set; }
TransferStarted
Transfer started
public Nullable<DateTime> TransferStarted { get; set; }