예제 #1
0
        /// <summary>
        /// Called when [sync end].
        /// </summary>
        /// <param name="sender">The sender.</param>
        /// <param name="args">The <see cref="System.EventArgs"/> instance containing the event data.</param>
        protected virtual void OnSyncEnd(object sender, EventArgs args)
        {
            if (_syncApp.CurrentProcessedSyncType == null)
            {
                throw new NullReferenceException("CurrentProcessedSyncType");
            }
            SyncApplication syncApp = sender as SyncApplication;

            if (syncApp == null)
            {
                throw new NullReferenceException("syncApp");
            }

            //Устанавливаем новый статус
            SyncItemInfo status = new SyncItemInfo();

            status.Status       = syncApp.LastSyncErrorOccur ? eSyncStatus.Failed : eSyncStatus.Ok;
            status.Status       = syncApp.SkippedItems.Count() != 0 ? eSyncStatus.SkipedChangesDetected : status.Status;
            status.LastSyncDate = DateTime.Now;
            status.ErrorDescr   = syncApp.LastSyncErrorDescr;
            status.SkippedCount = syncApp.SkippedItems.Count();
            //Вызываем в потоке формы функцию установки статуса
            _syncItemForm.ThrSetSyncItemStatus(_syncApp.CurrentProcessedSyncType.Value, status);
            _syncItemForm.ThrUpdateSyncStatisticStatus(_syncApp.SyncStatistics);

            //Запоминаем статус и дату последней синхронизации
            syncProviderSetting provSetting = _syncApp.GetSyncProviderSettingByType(_syncApp.CurrentProcessedSyncType.Value);

            if (provSetting != null)
            {
                provSetting.lastSyncStatus = (int)status.Status;
                provSetting.lastSyncDate   = DateTime.Now.Ticks / TimeSpan.TicksPerSecond;
                _syncApp.CurrentSettings.SaveActiveProfile();
            }
        }
예제 #2
0
        protected virtual void OnProcessSync(object sender, SyncItemEventArgs args)
        {
            //Устанавливаем новый статус
            SyncItemInfo status = new SyncItemInfo();

            status.Status = eSyncStatus.InProgress;
            _syncItemForm.ThrSetSyncItemStatus(args.oItemType, status);
            //Планируем задание синхронизации
            _syncApp.SheduleSyncronizeTask(args.oItemType);
        }
예제 #3
0
        /// <summary>
        /// Called when [sync begin].
        /// </summary>
        /// <param name="sender">The sender.</param>
        /// <param name="args">The <see cref="System.EventArgs"/> instance containing the event data.</param>
        protected virtual void OnSyncBegin(object sender, EventArgs args)
        {
            if (_syncApp.CurrentProcessedSyncType == null)
            {
                throw new NullReferenceException("CurrentProcessedSyncType");
            }
            //Устанавливаем новый статус
            SyncItemInfo status = new SyncItemInfo();

            status.Status = eSyncStatus.InProgress;
            //Вызываем в потоке формы функцию установки статуса
            _syncItemForm.ThrSetSyncItemStatus(_syncApp.CurrentProcessedSyncType.Value, status);
            _syncItemForm.ThrUpdateSyncStatisticStatus(_syncApp.SyncStatistics);
        }
예제 #4
0
        //this method must call in Addin thread
        public static UIController CreateInstance(AddinModule addinModule)
        {
            if (addinModule == null)
            {
                throw new ArgumentNullException("addinModule");
            }

            if (_instance != null)
            {
                return(_instance);
            }

            //Set LogFilePath
            DebugAssistant.LogFilePath = ApplicationConfig.LogPathFile;

            FormSyncOptions            syncOptionsForm     = new FormSyncOptions();
            FormSyncItem               syncForm            = new FormSyncItem();
            FormSyncConflictResolution syncConflictResForm = new FormSyncConflictResolution();
            OutlookListener            listener            = new OutlookListener(addinModule);
            IntPtr             handle             = listener.Handle;
            OutlookApplication outlookApplication = OutlookApplication.CreateInstance(listener);
            SyncApplication    syncApp            = SyncApplication.CreateInstance(outlookApplication);

            if (syncApp == null)
            {
                throw new NullReferenceException("syncApp");
            }

            UIController retVal = new UIController(addinModule, listener, syncApp, syncForm,
                                                   syncOptionsForm, syncConflictResForm);

            if (syncConflictResForm != null)
            {
                //Force create control
                handle = syncConflictResForm.Handle;
            }

            if (syncForm != null)
            {
                //Subscribe events SyncApp(Model)
                retVal.HookEvents(syncApp);
                //Sunscribe events syncForm(View)
                retVal.HookEvents(syncForm);
                //Force create control
                handle = syncForm.Handle;

                //TODO: Нужно прочитать историю последней синхронизации и установить статус прошлой синхронизации
                syncForm.AddSyncMenuItem(Outlook.OlItemType.olAppointmentItem);
                syncForm.AddSyncMenuItem(Outlook.OlItemType.olContactItem);
                syncForm.AddSyncMenuItem(Outlook.OlItemType.olTaskItem);
                syncForm.AddSyncMenuItem(Outlook.OlItemType.olNoteItem);
                //Appointment
                SyncItemInfo           status          = new SyncItemInfo();
                syncAppointmentSetting apppointSetting = syncApp.CurrentSettings.CurrentSyncAppointentSetting;
                if (apppointSetting != null)
                {
                    status.Status = (eSyncStatus)apppointSetting.lastSyncStatus;
                    if (status.Status != eSyncStatus.Unknow)
                    {
                        status.LastSyncDate = new DateTime(TimeSpan.TicksPerSecond * apppointSetting.lastSyncDate);
                    }

                    if (status.Status == eSyncStatus.Ok || status.Status == eSyncStatus.Unknow)
                    {
                        status.Status = eSyncStatus.Ready;
                    }
                }

                syncForm.ThrSetSyncItemStatus(Outlook.OlItemType.olAppointmentItem, status);
                //Contact
                //Task
                status        = new SyncItemInfo();
                status.Status = eSyncStatus.Ready;
                syncForm.ThrSetSyncItemStatus(Outlook.OlItemType.olTaskItem, status);
                //Note
                status        = new SyncItemInfo();
                status.Status = eSyncStatus.Unknow;
                syncForm.ThrSetSyncItemStatus(Outlook.OlItemType.olContactItem, status);

                syncForm.ThrSetSyncItemStatus(Outlook.OlItemType.olNoteItem, status);


                retVal._syncItemForm = syncForm;
            }

            if (syncOptionsForm != null)
            {
                //Force create control
                handle = syncOptionsForm.Handle;
                //Sunscribe events syncOptionsForm(View)
                retVal.HookEvents(syncOptionsForm);
            }

            _instance = retVal;

            return(retVal);
        }
예제 #5
0
파일: UIController.cs 프로젝트: 0anion0/IBN
        //this method must call in Addin thread
        public static UIController CreateInstance(AddinModule addinModule)
        {
            if (addinModule == null)
                throw new ArgumentNullException("addinModule");

            if (_instance != null)
                return _instance;

            //Set LogFilePath
            DebugAssistant.LogFilePath = ApplicationConfig.LogPathFile;

            FormSyncOptions syncOptionsForm = new FormSyncOptions();
            FormSyncItem syncForm= new FormSyncItem();
            FormSyncConflictResolution syncConflictResForm = new FormSyncConflictResolution();
            OutlookListener listener = new OutlookListener(addinModule);
            IntPtr handle = listener.Handle;
            OutlookApplication outlookApplication = OutlookApplication.CreateInstance(listener);
            SyncApplication syncApp = SyncApplication.CreateInstance(outlookApplication);

            if (syncApp == null)
                throw new NullReferenceException("syncApp");

            UIController retVal = new UIController(addinModule, listener, syncApp, syncForm,
                                                   syncOptionsForm, syncConflictResForm);

            if (syncConflictResForm != null)
            {
                //Force create control
                handle = syncConflictResForm.Handle;
            }

            if (syncForm != null)
            {
                //Subscribe events SyncApp(Model)
                retVal.HookEvents(syncApp);
                //Sunscribe events syncForm(View)
                retVal.HookEvents(syncForm);
                //Force create control
                handle = syncForm.Handle;

                //TODO: Нужно прочитать историю последней синхронизации и установить статус прошлой синхронизации
                syncForm.AddSyncMenuItem(Outlook.OlItemType.olAppointmentItem);
                syncForm.AddSyncMenuItem(Outlook.OlItemType.olContactItem);
                syncForm.AddSyncMenuItem(Outlook.OlItemType.olTaskItem);
                syncForm.AddSyncMenuItem(Outlook.OlItemType.olNoteItem);
                //Appointment
                SyncItemInfo status = new SyncItemInfo();
                syncAppointmentSetting apppointSetting = syncApp.CurrentSettings.CurrentSyncAppointentSetting;
                if(apppointSetting != null)
                {
                    status.Status = (eSyncStatus)apppointSetting.lastSyncStatus;
                    if (status.Status != eSyncStatus.Unknow)
                    {
                        status.LastSyncDate = new DateTime(TimeSpan.TicksPerSecond * apppointSetting.lastSyncDate);
                    }

                    if(status.Status == eSyncStatus.Ok || status.Status == eSyncStatus.Unknow)
                    {
                        status.Status = eSyncStatus.Ready;
                    }
                }

                syncForm.ThrSetSyncItemStatus(Outlook.OlItemType.olAppointmentItem, status);
                //Contact
                //Task
                status = new SyncItemInfo();
                status.Status = eSyncStatus.Ready;
                syncForm.ThrSetSyncItemStatus(Outlook.OlItemType.olTaskItem, status);
                //Note
                status = new SyncItemInfo();
                status.Status = eSyncStatus.Unknow;
                syncForm.ThrSetSyncItemStatus(Outlook.OlItemType.olContactItem, status);

                syncForm.ThrSetSyncItemStatus(Outlook.OlItemType.olNoteItem, status);

                retVal._syncItemForm = syncForm;

            }

            if (syncOptionsForm != null)
            {
                //Force create control
                handle = syncOptionsForm.Handle;
                //Sunscribe events syncOptionsForm(View)
                retVal.HookEvents(syncOptionsForm);
            }

            _instance = retVal;

            return retVal;
        }
예제 #6
0
파일: UIController.cs 프로젝트: 0anion0/IBN
        /// <summary>
        /// Called when [sync end].
        /// </summary>
        /// <param name="sender">The sender.</param>
        /// <param name="args">The <see cref="System.EventArgs"/> instance containing the event data.</param>
        protected virtual void OnSyncEnd(object sender, EventArgs args)
        {
            if (_syncApp.CurrentProcessedSyncType == null)
            {
                throw new NullReferenceException("CurrentProcessedSyncType");
            }
            SyncApplication syncApp = sender as SyncApplication;
            if (syncApp == null)
                throw new NullReferenceException("syncApp");

            //Устанавливаем новый статус
            SyncItemInfo status = new SyncItemInfo();
            status.Status = syncApp.LastSyncErrorOccur ? eSyncStatus.Failed : eSyncStatus.Ok;
            status.Status = syncApp.SkippedItems.Count() != 0 ? eSyncStatus.SkipedChangesDetected : status.Status;
            status.LastSyncDate = DateTime.Now;
            status.ErrorDescr = syncApp.LastSyncErrorDescr;
            status.SkippedCount = syncApp.SkippedItems.Count();
            //Вызываем в потоке формы функцию установки статуса
            _syncItemForm.ThrSetSyncItemStatus(_syncApp.CurrentProcessedSyncType.Value, status);
            _syncItemForm.ThrUpdateSyncStatisticStatus(_syncApp.SyncStatistics);

            //Запоминаем статус и дату последней синхронизации
            syncProviderSetting provSetting = _syncApp.GetSyncProviderSettingByType(_syncApp.CurrentProcessedSyncType.Value);
            if (provSetting != null)
            {
                provSetting.lastSyncStatus = (int)status.Status;
                provSetting.lastSyncDate = DateTime.Now.Ticks / TimeSpan.TicksPerSecond;
                _syncApp.CurrentSettings.SaveActiveProfile();
            }
        }
예제 #7
0
파일: UIController.cs 프로젝트: 0anion0/IBN
 /// <summary>
 /// Called when [sync begin].
 /// </summary>
 /// <param name="sender">The sender.</param>
 /// <param name="args">The <see cref="System.EventArgs"/> instance containing the event data.</param>
 protected virtual void OnSyncBegin(object sender, EventArgs args)
 {
     if (_syncApp.CurrentProcessedSyncType == null)
     {
         throw new NullReferenceException("CurrentProcessedSyncType");
     }
     //Устанавливаем новый статус
     SyncItemInfo status = new SyncItemInfo();
     status.Status = eSyncStatus.InProgress;
     //Вызываем в потоке формы функцию установки статуса
     _syncItemForm.ThrSetSyncItemStatus(_syncApp.CurrentProcessedSyncType.Value, status);
     _syncItemForm.ThrUpdateSyncStatisticStatus(_syncApp.SyncStatistics);
 }
예제 #8
0
파일: UIController.cs 프로젝트: 0anion0/IBN
 protected virtual void OnProcessSync(object sender, SyncItemEventArgs args)
 {
     //Устанавливаем новый статус
     SyncItemInfo status = new SyncItemInfo();
     status.Status = eSyncStatus.InProgress;
     _syncItemForm.ThrSetSyncItemStatus(args.oItemType, status);
     //Планируем задание синхронизации
     _syncApp.SheduleSyncronizeTask(args.oItemType);
 }
예제 #9
0
        /// <summary>
        /// Sets the sync item status.
        /// </summary>
        /// <param name="oItemType">Type of the o item.</param>
        /// <param name="status">The status.</param>
        public bool ThrSetSyncItemStatus(Outlook.OlItemType oItemType, SyncItemInfo syncInfo)
        {
            if (this.InvokeRequired)
            {
                Func<Outlook.OlItemType, SyncItemInfo, bool> func = this.ThrSetSyncItemStatus;
                this.Invoke(func, oItemType, syncInfo);
            }
            else
            {
                SyncMenuItem item = FindSyncMenuItem(oItemType);
                if (item != null)
                {
                    //Если предыдущий статус был InProgress, снимаем disable c других пунктов
                    if (item.CurrentSyncStatus == eSyncStatus.InProgress && syncInfo.Status != eSyncStatus.InProgress)
                    {
                        EnableAllSyncItems(x=>x.CurrentSyncStatus != eSyncStatus.Unknow);
                    }

                    if (syncInfo.Status == eSyncStatus.InProgress)
                    {
                        //Делаем неактивнми остальные пункты меню синхронизации
                        DisableAllSyncItems(x=>(Outlook.OlItemType)x.ItemTag != oItemType );
                        item.Description = Resources.FormSyncMenuItem_ProcessStatus;
                    }
                    else if (syncInfo.Status == eSyncStatus.Ready || syncInfo.Status == eSyncStatus.Ok)
                    {
                        if (syncInfo.LastSyncDate != DateTime.MinValue)
                        {
                            item.Description = FormatingStatus(Resources.FormSyncMenuItem_ReadyStatus_Pattern, new object[] { syncInfo.LastSyncDate });
                        }
                        else
                        {
                            item.Description = Resources.FormSyncMenuItem_NotSyncStatus_Pattern;
                        }
                    }
                    else if (syncInfo.Status == eSyncStatus.Failed)
                    {
                        item.Description = FormatingStatus(Resources.FormSyncmenuItem_FailStatus_Pattern, new object[] { syncInfo.ErrorDescr });
                    }
                    else if (syncInfo.Status == eSyncStatus.SkipedChangesDetected)
                    {
                        item.Description = FormatingStatus(Resources.FormSyncMenuItem_SkippedItemPattern, new object[] { syncInfo.SkippedCount });
                    }
                    else if (syncInfo.Status == eSyncStatus.Unknow)
                    {
                        //Disabling unknow status
                        item.Description = Resources.FormSyncMenuItem_NotSyncStatus_Pattern;
                        DisableSyncItem(oItemType);
                    }
                    //Устанавливаем новый статус
                    item.CurrentSyncStatus = syncInfo.Status;
                    item.AnimateStatusImg = false;
                    switch (item.CurrentSyncStatus)
                    {
                        case eSyncStatus.InProgress:
                            item.AnimateStatusImg = true;
                            item.AnimateDuration = -1;
                            break;
                        case eSyncStatus.ReadyProgress:
                            item.AnimateDuration = _onMouseHoverAnimateDuration;
                            item.AnimateStatusImg = true;
                            break;
                    }

                }
            }
            return true;
        }
예제 #10
0
파일: FormSyncItem.cs 프로젝트: 0anion0/IBN
        /// <summary>
        /// Sets the sync item status.
        /// </summary>
        /// <param name="oItemType">Type of the o item.</param>
        /// <param name="status">The status.</param>
        public bool ThrSetSyncItemStatus(Outlook.OlItemType oItemType, SyncItemInfo syncInfo)
        {
            if (this.InvokeRequired)
            {
                Func <Outlook.OlItemType, SyncItemInfo, bool> func = this.ThrSetSyncItemStatus;
                this.Invoke(func, oItemType, syncInfo);
            }
            else
            {
                SyncMenuItem item = FindSyncMenuItem(oItemType);
                if (item != null)
                {
                    //Если предыдущий статус был InProgress, снимаем disable c других пунктов
                    if (item.CurrentSyncStatus == eSyncStatus.InProgress && syncInfo.Status != eSyncStatus.InProgress)
                    {
                        EnableAllSyncItems(x => x.CurrentSyncStatus != eSyncStatus.Unknow);
                    }

                    if (syncInfo.Status == eSyncStatus.InProgress)
                    {
                        //Делаем неактивнми остальные пункты меню синхронизации
                        DisableAllSyncItems(x => (Outlook.OlItemType)x.ItemTag != oItemType);
                        item.Description = Resources.FormSyncMenuItem_ProcessStatus;
                    }
                    else if (syncInfo.Status == eSyncStatus.Ready || syncInfo.Status == eSyncStatus.Ok)
                    {
                        if (syncInfo.LastSyncDate != DateTime.MinValue)
                        {
                            item.Description = FormatingStatus(Resources.FormSyncMenuItem_ReadyStatus_Pattern, new object[] { syncInfo.LastSyncDate });
                        }
                        else
                        {
                            item.Description = Resources.FormSyncMenuItem_NotSyncStatus_Pattern;
                        }
                    }
                    else if (syncInfo.Status == eSyncStatus.Failed)
                    {
                        item.Description = FormatingStatus(Resources.FormSyncmenuItem_FailStatus_Pattern, new object[] { syncInfo.ErrorDescr });
                    }
                    else if (syncInfo.Status == eSyncStatus.SkipedChangesDetected)
                    {
                        item.Description = FormatingStatus(Resources.FormSyncMenuItem_SkippedItemPattern, new object[] { syncInfo.SkippedCount });
                    }
                    else if (syncInfo.Status == eSyncStatus.Unknow)
                    {
                        //Disabling unknow status
                        item.Description = Resources.FormSyncMenuItem_NotSyncStatus_Pattern;
                        DisableSyncItem(oItemType);
                    }
                    //Устанавливаем новый статус
                    item.CurrentSyncStatus = syncInfo.Status;
                    item.AnimateStatusImg  = false;
                    switch (item.CurrentSyncStatus)
                    {
                    case eSyncStatus.InProgress:
                        item.AnimateStatusImg = true;
                        item.AnimateDuration  = -1;
                        break;

                    case eSyncStatus.ReadyProgress:
                        item.AnimateDuration  = _onMouseHoverAnimateDuration;
                        item.AnimateStatusImg = true;
                        break;
                    }
                }
            }
            return(true);
        }