Standard Synchronizer. Implementation of ISynchronizer. Has a simple progressbar UI.
Inheritance: ISynchronizer
Esempio n. 1
0
        public void PerformSynchronize()
        {
            Dictionary <String, HashSet <Device> > deviceinfo = connectedDevices.GetConnectedDevicesWithDrives();
            IDictionaryEnumerator keys = deviceinfo.GetEnumerator();

            try
            {
                // Create synchronizer and form.
                ISynchronizer synchronizer = new StandardSynchronizer();
                synchronizer.Form = syncForm;

                while (keys.MoveNext())
                {
                    string drive = ((string)keys.Key).Substring(0, 3);

                    HashSet <Device> devices = (HashSet <Device>)keys.Value;
                    foreach (Device device in devices)
                    {
                        if (configuration.ConfirmMusicLocation && !GetMusicLocationConfirmation(drive + device.MediaRoot))
                        {
                            syncForm.CloseSafe();
                            syncForm     = null;
                            synchronizer = null;
                            return;
                        }

                        IITPlaylist playlist = PlaylistExists(device);
                        if (playlist == null)
                        {
                            MessageBox.Show("I could not synchronize '" + device.Name + "' because "
                                            + "the playlist does not exist! Try reconnecting the device. If the problem continues"
                                            + " please report the problem to the Notpod developers at http://www.sourceforge.net/projects/ita.",
                                            "Internal synchronization error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                            continue;
                        }

                        synchronizer.Configuration         = deviceConfiguration;
                        synchronizer.SynchronizeError     += new SynchronizeErrorEventHandler(OnSynchronizeError);
                        synchronizer.SynchronizeComplete  += new SynchronizeCompleteEventHandler(OnSynchronizeComplete);
                        synchronizer.SynchronizeCancelled += new SynchronizeCancelledEventHandler(OnSynchronizeCancelled);
                        synchronizer.SynchronizeDevice((IITUserPlaylist)playlist, drive, device);
                    }
                }
            }
            catch (Exception ex)
            {
                l.Error(ex);

                string message = "I encountered an unexpected error while synchronizing your device(s). "
                                 + "\n\nPlease make sure your devices are properly "
                                 + "connected and try again.";

                itaTray.ShowBalloonTip(7, "Synchronize error", message, ToolTipIcon.Error);
            }

            if (syncForm != null && configuration.CloseSyncWindowOnSuccess)
            {
                syncForm.CloseSafe();
            }
        }
Esempio n. 2
0
        public void PerformSynchronize()
        {


            Hashtable deviceinfo = connectedDevices.GetConnectedDevicesWithDrives();
            IEnumerator keys = deviceinfo.Keys.GetEnumerator();
            try
            {
                // Create synchronizer and form.
                ISynchronizer synchronizer = new StandardSynchronizer();                
                synchronizer.Form = syncForm;                

                while (keys.MoveNext())
                {
                    
                    string drive = (string)keys.Current;
                    Device device = (Device)deviceinfo[keys.Current];

                    if (configuration.ConfirmMusicLocation && !GetMusicLocationConfirmation(drive + device.MediaRoot))
                    {
                        syncForm.CloseSafe();
                        syncForm = null;
                        synchronizer = null;
                        return;
                    }

                    List<IITPlaylist> playlist = PlaylistExists(device);
                    if (playlist == null)
                    {
                        MessageBox.Show("I could not synchronize '" + device.Name + "' because "
                            + "the playlist does not exist! Try reconnecting the device. If the problem continues"
                            + " please report the problem to the Notpod developers at http://www.sourceforge.net/projects/ita.",
                            "Internal synchronization error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                        continue;
                    }

                    synchronizer.Configuration = deviceConfiguration;
                    synchronizer.SynchronizeError += new SynchronizeErrorEventHandler(OnSynchronizeError);
                    synchronizer.SynchronizeComplete += new SynchronizeCompleteEventHandler(OnSynchronizeComplete);
                    synchronizer.SynchronizeCancelled += new SynchronizeCancelledEventHandler(OnSynchronizeCancelled);
                    synchronizer.SynchronizeDevice(playlist, drive, device);

                }
                                
            }
            catch (Exception ex)
            {
                l.Error(ex);

                string message = "I encountered an unexpected error while synchronizing your device(s). "
                    + "\n\nPlease make sure your devices are properly "
                    + "connected and try again.";

                itaTray.ShowBalloonTip(7, "Synchronize error", message, ToolTipIcon.Error);
            }

            if (syncForm != null && configuration.CloseSyncWindowOnSuccess)
                syncForm.CloseSafe();
        }