Geeks With Blogs
Blog Moved to Blog Moved to
UPDATE: See Day 9 of the Background Intelligent Transfer Service (BITS) Managed Wrapper for the source code plus binaries.
In previous lessons, I covered the BackgroundCopyManager and how I wrapped the IBackgroundCopyManager in Managed C++.  Today, I'll go a step further to look at the BackgroundCopyJob wrapped class. 
The BackgroundCopyJob wraps the following interfaces:
 As we are dealing with unmanaged types, we must also take into consideration of implementing the System.IDisposable interface.  Let's go over the basic layout of the IDisposable pattern:
     void Dispose();
     virtual void Dispose(bool disposing);
     bool isDisposed;
Now that we got that out of the way, let's go over the methods and properties we will be implementing.  Let's go over the public properties first:
// Gets or sets the ACL tags
__property BackgroundCopyJobFileACLFlags get_ACLTags();
__property void set_ACLTags(BackgroundCopyJobFileACLFlags value);
// Gets the creation time
__property DateTime get_CreationTime();
// Gets and sets the description
__property String* get_Description();
__property void set_Description(String* value);
// Gets and sets the display name
__property String* get_DisplayName();
__property void set_DisplayName(String* value);
// Gets the error for the job
__property BackgroundCopyError* get_Error();
// Gets the error count
__property System::Int64 get_ErrorCount();
// Gets the BackgroundCopyFiles
__property BackgroundCopyFileCollection* get_Files();
// Gets the ID
__property Guid get_Id();
// Gets and sets the minimum retry delay
__property System::Int64 get_MinimumRetryDelay();
__property void set_MinimumRetryDelay(System::Int64 value);
// Gets the modification time
__property DateTime get_ModificationTime();
// Gets and sets the no progress timeout
__property System::Int64 get_NoProgressTimeout();
__property void set_NoProgressTimeout(System::Int64 value);
// Gets or sets the notify command line
__property NotifyCommandLine get_NotifyCmdLine();
__property void set_NotifyCmdLine(NotifyCommandLine value);
// Gets the owner
__property String* get_OwnerId();
// Gets the owner name
__property String* get_OwnerName();
// Gets and sets the priority
__property BackgroundCopyJobPriority get_Priority();
__property void set_Priority(BackgroundCopyJobPriority value);
// Gets the progress
__property BackgroundCopyJobProgress get_Progress();
// Gets and sets the proxy settings
__property BackgroundCopyJobProxySettings get_ProxySettings();
__property void set_ProxySettings(BackgroundCopyJobProxySettings value);
// Gets an in-memory copy of the reply data from the server application
__property MemoryStream* get_ReplyData();
// Gets or sets the name of the file that contains the reply data from the server application.
__property String* get_ReplyFileName();
__property void set_ReplyFileName(String* value);
// Gets the progress information related to the transfer of the reply data from an upload-reply job
__property BackgroundCopyJobReplyProgress get_ReplyProgress();
// Gets the background copy job state
__property BackgroundCopyJobState get_State();
// Get transfer completion time
__property DateTime get_TransferCompletionTime();
// Gets the job type
__property BackgroundCopyJobType get_Type();
And after all that, we still have the methods to review.  Luckily, there are not as many methods as properties.  So, let's review those now:
// Adds a file to the copy job
void AddFile(String* remoteUrl, String* localName);
// Adds a set of files to the copy job
void AddFileSet(BackgroundCopyFileInfo fileInfo[]);
// Add a file to a download job and specify the ranges of the file to download
void AddFileWithRanges(String* remoteUrl, String* localName, BackgroundCopyFileRange ranges[]);
// Cancels the job
void Cancel();
// Completes the job
void Complete();
// Dispose method
__sealed void Dispose();
// Removes credentials
void RemoveCredentials(AuthenticationTarget target, AuthenticationScheme scheme);
// Replace the beginning text of all remote names in the download job with the given string.
void ReplaceRemotePrefix(String* oldPrefix, String* newPrefix);
// Resume job
void Resume();
// Set credentials
void SetCredentials(String* userName, String* password, AuthenticationTarget target, AuthenticationScheme scheme);
// Suspend the job
void Suspend();
// Take ownership of job
void TakeOwnership();
So, as you can see, we have a ton of things to implement.  It especially gets to be a lot of code to not only validate the incoming data (which is important), but translate the unmanaged types into managed ones.  We'll go over some examples of that in another installment.
Posted on Wednesday, May 24, 2006 6:47 PM Microsoft , Background Intelligent Transfer Service , .NET , Windows | Back to top

Comments on this post: Day 6 of the Background Intelligent Transfer Service (BITS) Managed Wrapper

# re: Day 6 of the Background Intelligent Transfer Service (BITS) Managed Wrapper
Requesting Gravatar...
i am facing problem implementing "Setcredentials" method while working on BITS using C#.i have some wrapper code written in C#.
everything is working fine except SetCredentials method and i have spend my 4 days struggling to get it working. i am trying to set basic authentication to work.can u provide me ur C# code for that?
in my case i am able to set user name, password, target and scheme but I am not able to get it work. BITS job always display "connecting" status and after some time status convert to "cancelled".
Even it is not working in local machine.i have windows server 2003.

can u please give me some hint or ur source code.



Left by Jatender on Jul 26, 2010 8:10 AM

Your comment:
 (will show your gravatar)

Copyright © Matthew Podwysocki | Powered by: