예제 #1
0
 private static void GetSQLContentState(ISQLContentState _cd, Action <ProgressChangedEventArgs> reportProgress)
 {
     try
     {
         reportProgress(new ProgressChangedEventArgs(1, String.Format("Connection string {0}", _cd.SQLConnectionString)));
         System.Data.IDbConnection _connection = new SqlConnection(_cd.SQLConnectionString);
         using (SHRARCHIVE _entities = new SHRARCHIVE(_connection))
             if (_entities.DatabaseExists())
             {
                 reportProgress(new ProgressChangedEventArgs(1, "The specified database exists."));
                 GetLastOperation(_entities, CAS.SharePoint.Client.Link2SQL.ArchivingOperationLogs.OperationName.Cleanup, x => _cd.CleanupLastRunBy      = x, y => _cd.CleanupLastRunDate = y);
                 GetLastOperation(_entities, CAS.SharePoint.Client.Link2SQL.ArchivingOperationLogs.OperationName.Synchronization, x => _cd.SyncLastRunBy = x, y => _cd.SyncLastRunDate = y);
                 GetLastOperation(_entities, CAS.SharePoint.Client.Link2SQL.ArchivingOperationLogs.OperationName.Archiving, x => _cd.ArchivingLastRunBy  = x, y => _cd.ArchivingLastRunDate = y);
                 _cd.SQLConnected = true;
             }
             else
             {
                 reportProgress(new ProgressChangedEventArgs(1, "The specified database cannot be opened."));
             }
     }
     catch (Exception _ex)
     {
         reportProgress(new ProgressChangedEventArgs(1, String.Format("Testing SQL connection has been aborted by the exception: {0}", _ex.Message)));
     }
 }
예제 #2
0
        //INavigationAware
        /// <summary>
        /// Called when the implementer has been navigated to.
        /// </summary>
        /// <param name="navigationContext">The navigation context <see cref="NavigationContext"/>.</param>
        public override void OnNavigatedTo(NavigationContext navigationContext)
        {
            base.OnNavigatedTo(navigationContext);
            RestoreSettings();
            ISPContentState _spContentState = (ISPContentState)navigationContext.Parameters[typeof(ISPContentState).Name];

            Debug.Assert(_spContentState != null, string.Format("{0} parameter cannot be null while navigating to ArchivingViewModel.", typeof(ISPContentState).Name));
            Debug.Assert(_spContentState.SPConnected == true, "SP has to be connected before navigating to ArchivingViewModel.");
            Debug.Assert(!String.IsNullOrEmpty(_spContentState.SharePointWebsiteURL), "SharePoint Website URL cannot be empty.");
            URL = _spContentState.SharePointWebsiteURL;
            ISQLContentState _sqlContentState = (ISQLContentState)navigationContext.Parameters[typeof(ISQLContentState).Name];

            Debug.Assert(_sqlContentState != null, string.Format("{0} parameter cannot be null while navigating to ArchivingViewModel.", typeof(ISPContentState).Name));
            Debug.Assert(_sqlContentState.SQLConnected == true, "SP has to be connected before navigating to ArchivingViewModel.");
            Debug.Assert(!String.IsNullOrEmpty(_sqlContentState.SQLConnectionString), "Connection string cannot be empty.");
            SQLServer            = _sqlContentState.SQLConnectionString;
            SyncLastRunDate      = _sqlContentState.SyncLastRunDate.LocalizedString();
            SyncLastRunBy        = _sqlContentState.SyncLastRunBy.GetValueOrDefault(Settings.Default.RunByUnknown);
            CleanupLastRunDate   = _sqlContentState.CleanupLastRunDate.LocalizedString();
            CleanupLastRunBy     = _sqlContentState.CleanupLastRunBy.GetValueOrDefault(Settings.Default.RunByUnknown);
            ArchivingLastRunDate = _sqlContentState.ArchivingLastRunDate.LocalizedString();
            ArchivingLastRunBy   = _sqlContentState.ArchivingLastRunBy.GetValueOrDefault(Settings.Default.RunByUnknown);
            //Log the current state.
            string _msg = String.Format("OnNavigatedTo - created view model {0} for SharePoint: {1} and database {2}.", typeof(ArchivingViewModel).Name, URL, SQLServer);

            m_loggingService.Log(_msg, Category.Debug, Priority.Low);
        }
예제 #3
0
        private void OnArchiveCommand(ISPContentState spContentState, ISQLContentState sqlContentState)
        {
            NavigationParameters _par = new NavigationParameters();

            _par.Add(typeof(ISPContentState).Name, spContentState);
            _par.Add(typeof(ISQLContentState).Name, sqlContentState);
            Context.RequestNavigate(Infrastructure.ViewNames.ArchivalStateName, _par);
        }