Our Products:   CompleteFTP  edtFTPnet/Free  edtFTPnet/PRO  edtFTPj/Free  edtFTPj/PRO
0 votes
37k views
in .NET FTP by (1.9k points)
Hi,
FTP Synchronizer is a great tool. However, I can never get it to work. I am using VB 2005 .NET 2.0. And I started by running it from the example viewer. The example runs and connect to the server, but when I click on "synchronize", I get a lot of errors. The error reads as follows:

- Could not get file modification time. (code 550) "I get 5 pop up messages boxes of this type after clicking synchronize."
- Error - System reference not set to an instance of an object .... "then a lot of exception details."



My second question is, can I do the synchronization tasks at run time in my code rather than in GUI. I want to sun synchronization to almost 200 ftp servers in a loop.

Thanks

38 Answers

0 votes
by (51.6k points)
Hi

We have plans to develop a non-GUI synchronization tool, but have not yet done so. However, we often like to develop new features when users need them and could possibly do so in your case. What would be your requirements?

Also, we'd really like an opportunity to fix the problem you're having with FTPSynchronizeView. Could you please enable logging and email a log to support at enterprisedt dot com?

- Hans (EnterpriseDT)
0 votes
by (1.9k points)
Well, it is working now it seems to have been the ftp server.

Anyway as for run-time requirements. I already manipulated the control and tricked it to do what I want at run time but it is not straightforward. Here is what I did:


- Set the control visible property to false
- Assign an ftp connection to it
- Invoke the Synchronize() method of the control.

 ExFTPConnection1.LocalDirectory = "c:\test"
        ExFTPConnection1.Connect()
        ExFTPConnection1.ChangeWorkingDirectory("/tmp/files/")
        ftpSync.Connection = ExFTPConnection1
        Application.DoEvents()
        ftpSync.Synchronize()


However ftpSync.Synchronize() doesn't execute if put in this context. I have to call it after the FTPSynchronization control is repainted and refreshed with the file list. Then I can call it afterwards. I can fix it if you tell me which event is fired when the files to be compared are all loaded.


Now my wish list are:

- Create an event to be triggered after control is connected and ready for synching
- Create log file to log synching steps
- Create a method to be called to begin synchronization immediately
- Create SynchError event to be triggered when an error occurs. Event Arguments should contain failed files.
- Add file-related properties to the event arguments of the finishedSynchronization event. E.g files sucessfully synched, and files that failed synching.

This is what I can think of now. But please if you can let me know about how I can manage to work it out using the crude method I described earlier.

Thanks
0 votes
by (51.6k points)
How about a new non-visual component called FTPSynchronizer?

It'd have the following interface:
public class FTPSynchronizer : Component
{
    // Properties
    public virtual ExFTPConnection Connection { get; set; }
    public bool DeleteIfSourceAbsent { get; set; }
    public TransferDirection Direction { get; set; }
    public bool ExcludeFilesInFilter { get; set; }
    public string FileNameFilter { get; set; }
    public FTPFilterType FilterType { get; set; }
    public bool IgnoreCase { get; set; }
    public bool IgnoreDate { get; set; }
    public bool SyncDirectories { get; set; }
    public bool SyncLocalDateAfterDownload { get; set; }
    public bool TransferMatchingOnly { get; set; }
    public bool TransferNewOnly { get; set; }

    // Events
    public event SynchFileEventHander EnteringDir;
    public event SynchDirEventHander TransferringFile;

    // Methods
    public void Synchronize();
    public void Abort();
    public IAsyncResult BeginSynchronize(AsyncCallback callback, object state);
    public IAsyncResult BeginSynchronize(string localDirectory, string serverDirectory, AsyncCallback callback, object state);
    public void EndSynchronize(IAsyncResult asyncResult);
}

public delegate void SynchDirEventHander(object sender, SynchDirEventArgs e);
public delegate void SynchFileEventHander(object sender, SynchFileEventArgs e);

public class SynchFileEventArgs : SynchEventArgs
{
    // Properties
    public FTPFile LocalFile { get; set; }
    public FTPFile RemoteFile { get; set; }
    public bool ShouldTransferFile { get; set; }
}

public class SynchDirEventArgs : SynchEventArgs
{
    // Properties
    public FTPFile LocalDirectory { get; set; }
    public FTPFile RemoteDirectory { get; set; }
    public bool ShouldEnterDirectory { get; set; }
}


There'd be two ways of using it. In both cases you'd call Synchronize() or BeginSynchronize() to perform the synchronization operation. You can either set the properties that control the way that files are synchronized, or you can handle the EnteringDir and TransferringFile events where you can decide, on a case by case basis, whether directories should be entered and whether files should be transferred.

Would that do the job for you?

- Hans (EnterpriseDT)
0 votes
by (1.9k points)
Hello,

Well, that would definitely do the job. I believe though that it still misses an event to be fired after the synchronization is completed. My aim is to synchronize over 200 ftp sites simultaneously. So I will sure use threading, therefore I will need to know when the synchronization is completed so as to update the UI and handle any errors.

Also you did not mention whether the operation will be done using synchronous or asynchronous modes? This will determine whether I will use threading. I suggest asynchronous of course.

Last word, do you believe you can release something like this soon. I do need it as soon as possible.

Thanks
0 votes
by (51.6k points)
Yes, an event to indicate completion is a good idea and asynchronous methods (BeginSynchronize) will also be available.

We should be able to have it ready for testing in a week.

- Hans (EnterpriseDT)
0 votes
by (1.9k points)
Great..please let me know as soon as you have it ready. I'd love to give it a try.

Thanks
0 votes
by (51.6k points)
Hi

We are busy developing FTPSynchronizer, but it is taking a bit longer than we estimated last week. We hope to have it ready for you to test by the end of the week. I hope this is acceptable.

- Hans (EnterpriseDT)
0 votes
by (51.6k points)
Hi

We've got the synchronization functionality ready for testing. Please e-mail support@enterprisedt.com so that we can give you download instructions.

Instead of creating a new component called FTPSynchronizer we decided to add Synchronize methods to ExFTPConnection. ExFTPConnection now has a property called DefaultSyncRules of type FTPSyncRules, which is used by the Synchronize methods that don't take an argument of this type.

These are the new methods in ExFTPConnection (and SecureFTPConnection):
void Synchronize()
void Synchronize(string localDirectory, string serverDirectory)
void Synchronize(FTPSyncRules syncRules)
void Synchronize(FTPSyncRules syncRules, string localDirectory, string serverDirectory)

IAsyncResult BeginSynchronize(AsyncCallback callback, object state)
IAsyncResult BeginSynchronize(string localDirectory, string serverDirectory, AsyncCallback callback, object state)
IAsyncResult BeginSynchronize(FTPSyncRules syncRules, AsyncCallback callback, object state)
IAsyncResult BeginSynchronize(FTPSyncRules syncRules, string localDirectory, string serverDirectory, AsyncCallback callback, object state)
void EndSynchronize(IAsyncResult asyncResult)

FTPSyncRules has the following methods:
TransferDirection Direction
bool ExcludeFilesInFilter
FTPFilterType FilterType
string FileNameFilter
bool IgnoreDate
bool TransferNewOnly
bool TransferMatchingOnly
bool DeleteIfSourceAbsent
bool SyncLocalDateAfterDownload
bool IncludeSubdirectories

Most of these are also available in FTPSynchronizeView so you can find explanations of them there.

There is also a new event called SynchronizingFile, which can be used to implement your own logic if that provided by FTPSyncRules is not sufficient.


- Hans (EnterpriseDT)
0 votes
by (1.9k points)
That's great...I will give it a test drive and let you know the updates. Thanks for a great support.
0 votes
by (1.8k points)
I too would be interested in this.
My next project will involve sync-ing (non gui).
So if there are any updates, it would be nice if I could check them here.

Categories

...