Ejemplo n.º 1
0
        bool InitSyncMLFacade(SyncMLFacade r)
        {
            r.User = syncSettings.User;
            //    facade.ContactMediumType = ContactExchangeType.Vcard21;
            string password = ObtainPasswordFromSettingsOrUx();

            if (String.IsNullOrEmpty(password))
            {
                return(false);
            }
            else
            {
                r.Password = password;
            }

            r.BasicUriText = syncSettings.BasicUri;

            r.DeviceAddress = syncSettings.DeviceAddress;

            r.LastAnchorTime            = syncItem.LastAnchorTime;
            r.LastAnchor                = syncItem.LastAnchor; // Next anchor is generated so before alert
            r.VendorName                = syncSettings.VendorName;
            r.ModelName                 = syncSettings.ModelName;
            r.ModelVersion              = syncSettings.ModelVersion;
            r.ContactDataSourceAtServer = syncItem.RemoteName;

            r.LastAnchorChangedEvent += HandleLastAnchorChanged;


            #region Wire event handlings to Facade's events regarding to visual effects
            r.StartOperationEvent   += HandleStartOperation;
            r.EndOperationEvent     += HandleEndOperation;
            r.OperationStatusEvent  += HandleOperationMessage;
            r.ServerDeviceInfoEvent += HandleServerDeviceInfo;

            r.InitProgressBarEvent      += HandleInitProgressBar;
            r.IncrementProgressBarEvent += HandleIncrementProgressBar;
            r.StageMessageEvent         += new EventHandler <StatusEventArgs>(HandleStageMessageEvent);

            r.InitProgressBarReceivingEvent      += HandleInitProgressBarReceiving;
            r.IncrementProgressBarReceivingEvent += HandleIncrementProgressBarReceiving;
            r.StageMessageReceivingEvent         += HandleStageMessageReceivingEvent;
            r.GracefulStopEvent += new EventHandler <EventArgs>(facade_GracefulStopEvent);
            #endregion

            System.Net.WebProxy proxy;
            if (syncSettings.UseProxy)
            {
                proxy = new System.Net.WebProxy(syncSettings.Proxy);
                proxy.UseDefaultCredentials = true;
            }
            else
            {
                proxy = null;
            }

            r.Proxy = proxy;

            return(true);
        }
Ejemplo n.º 2
0
        private SyncMLFacade CreateFacadeForSyncSession()
        {
            SyncMLFacade     r;
            ILocalDataSource localDataSource;

            try
            {
                localDataSource = CreateLocalDataSource();
            }
            catch (NullReferenceException e)
            {
                MessageBox.Show(this.ParentForm, e.Message, "Warning");
                AppendStatusText(e.Message);
                return(null);
            }

            if (localDataSource == null)
            {
                return(null);
            }

            r = new SyncMLFacade(localDataSource);

            return(InitSyncMLFacade(r) ? r : null);
        }
Ejemplo n.º 3
0
 private void RefreshFromClient()
 {
     facade = CreateFacadeForSyncSession();
     if (facade != null)
     {
         facade.LogOnAndRefreshFromClientAsync();
     }
 }
Ejemplo n.º 4
0
 private void RefreshFromServer()
 {
     facade = CreateFacadeForSyncSession();
     if (facade != null)
     {
         facade.SyncType = SyncType.RefreshFromServer;
         facade.LogOnAndSyncAsync();
     }
 }
Ejemplo n.º 5
0
 private void SyncFromClient()
 {
     facade = CreateFacadeForSyncSession();
     if (facade != null)
     {
         facade.SyncType = SyncType.OneWayFromClient;
         facade.LogOnAndSyncAsync();
     }
 }
Ejemplo n.º 6
0
 private void SlowSync()
 {
     facade = CreateFacadeForSyncSession();
     if (facade != null)
     {
         facade.SyncType = SyncType.Slow;
         facade.LogOnAndSyncAsync();
     }
 }
Ejemplo n.º 7
0
        private IAsyncResult Sync(SyncType syncType)
        {
            SetControlEnabled(btnSync, false);//will be enabled when sync is finished.
            SetControlVisible(btnStop, true);

            facade = CreateFacadeForSyncSession();
            if (facade != null)
            {
                return(facade.LogOnAndSyncAsync(syncType));
            }
            else
            {
                SetControlEnabled(btnSync, true);
                SetControlVisible(btnStop, false);
            }
            return(null);
        }
Ejemplo n.º 8
0
        private SyncMLFacade CreateFacadeForSyncSession()
        {
            SyncMLFacade facade;

            try
            {
                localDataSource = LoadLocalDataSource();
            }
            catch (NullReferenceException e)
            {
                MessageBox.Show(this, e.Message, "Warning");
                UpdateStatusLogText(e.Message);
                return(null);
            }

            if (localDataSource == null)
            {
                return(null);
            }

            facade = new SyncMLFacade(localDataSource);

            facade.User = Settings.Default.User;
            //    facade.ContactMediumType = ContactExchangeType.Vcard21;
            string password = ObtainPassword();

            if (String.IsNullOrEmpty(password))
            {
                return(null);
            }
            else
            {
                facade.Password = password;
            }
            facade.BasicUriText = Settings.Default.BasicURI;

            facade.DeviceAddress = Settings.Default.DeviceAddress;

            facade.LastAnchorTime            = Settings.Default.LastAnchorTime;
            facade.LastAnchor                = Settings.Default.LastAnchor; // Next anchor is generated so before alert
            facade.VendorName                = Settings.Default.VendorName;
            facade.ModelName                 = Settings.Default.ModelName;
            facade.ModelVersion              = Settings.Default.ModelVersion;
            facade.ContactDataSourceAtServer = Settings.Default.ServerContactSource;

            facade.LastAnchorChangedEvent += HandleLastAnchorChanged;


            #region Wire event handlings to Facade's events regarding to visual effects
            facade.StartOperationEvent   += HandleStartOperation;
            facade.EndOperationEvent     += HandleEndOperation;
            facade.OperationStatusEvent  += HandleOperationMessage;
            facade.ServerDeviceInfoEvent += HandleServerDeviceInfo;

            facade.InitProgressBarEvent      += HandleInitProgressBar;
            facade.IncrementProgressBarEvent += HandleIncrementProgressBar;
            facade.StageMessageEvent         += new EventHandler <StatusEventArgs>(HandleStageMessageEvent);

            facade.InitProgressBarReceivingEvent      += HandleInitProgressBarReceiving;
            facade.IncrementProgressBarReceivingEvent += HandleIncrementProgressBarReceiving;
            facade.StageMessageReceivingEvent         += HandleStageMessageReceivingEvent;
            facade.GracefulStopEvent += new EventHandler <EventArgs>(facade_GracefulStopEvent);
            #endregion


            System.Net.WebProxy proxy;
            if (Settings.Default.UseProxy)
            {
                proxy = new System.Net.WebProxy(Settings.Default.Proxy);
                proxy.UseDefaultCredentials = true;
            }
            else
            {
                proxy = null;
            }

            facade.Proxy = proxy;


            return(facade);
        }