Exemplo n.º 1
0
        /// <summary>
        /// Connects the clint to the SQL database.
        /// </summary>
        /// <param name="connectionString">The connection string.</param>
        /// <param name="progressChanged">The progress changed.</param>
        /// <returns>Instance of the <see cref="SHRARCHIVE"/>.</returns>
        internal static SHRARCHIVE Connect2SQL(string connectionString, Action <string> progressChanged)
        {
            progressChanged(String.Format("Attempt to connect to SQL at: {0}", connectionString));
            System.Data.IDbConnection _connection = new SqlConnection(connectionString);
            SHRARCHIVE _entities = new SHRARCHIVE(_connection);

            if (_entities.DatabaseExists())
            {
                progressChanged("The specified database exists.");
            }
            else
            {
                progressChanged("The specified database does not exist.");
            }
            return(_entities);
        }
Exemplo n.º 2
0
        /// <summary>
        /// Does the content cleanup.
        /// </summary>
        /// <param name="URL">The requested URL.</param>
        /// <param name="sqlConnectionString">The SQL connection string.</param>
        /// <param name="reportProgress">An action to report the progress.</param>
        /// <param name="trace">An action to trace progress in a log stream.</param>
        /// <exception cref="System.ArgumentException">
        /// Cannot connect to SQL database.;SQLConnectionString
        /// </exception>
        /// <exception cref="System.ApplicationException">DoCleanupContent has encountered breaking inconsistency - review the log and remove problems to pass to next phase.</exception>
        public static void DoCleanupContent(string URL, string sqlConnectionString, Action <ProgressChangedEventArgs> reportProgress, Action <String> trace)
        {
            bool _breakingIssueEncountered = false;

            reportProgress(new ProgressChangedEventArgs(1, String.Format("Starting DoCleanupContent and establishing connection with the site {0}.", URL)));
            reportProgress(new ProgressChangedEventArgs(1, String.Format("Connection string {0}", sqlConnectionString)));
            System.Data.IDbConnection _connection = new SqlConnection(sqlConnectionString);
            using (Linq2SQL.SHRARCHIVE _sqledc = new Linq2SQL.SHRARCHIVE(_connection))
            {
                if (!_sqledc.DatabaseExists())
                {
                    throw new ArgumentException("Cannot connect to SQL database.", "SQLConnectionString");
                }
                using (Linq.Entities _spedc = new Linq.Entities(trace, URL))
                {
                    //Warehouse
                    //Partner

                    _breakingIssueEncountered |= DoTimeSlotsTemplate(_spedc, _sqledc, reportProgress, trace);
                    _breakingIssueEncountered |= DoShippingPoint(_spedc, _sqledc, reportProgress, trace);
                }
            }
            using (Linq2SQL.SHRARCHIVE _sqledc = new Linq2SQL.SHRARCHIVE(_connection))
            {
                if (!_sqledc.DatabaseExists())
                {
                    throw new ArgumentException("Cannot connect to SQL database.", "SQLConnectionString");
                }
                using (Linq.Entities _spedc = new Linq.Entities(trace, URL))
                {
                    _breakingIssueEncountered |= DoLoadDescription(_spedc, reportProgress, trace);
                }
            }
            using (Linq2SQL.SHRARCHIVE _sqledc = new Linq2SQL.SHRARCHIVE(_connection))
            {
                if (!_sqledc.DatabaseExists())
                {
                    throw new ArgumentException("Cannot connect to SQL database.", "SQLConnectionString");
                }
                using (Linq.Entities _spedc = new Linq.Entities(trace, URL))
                {
                    _breakingIssueEncountered |= DoDriversTeam(_spedc, _sqledc, reportProgress, trace);
                }
            }
            using (Linq2SQL.SHRARCHIVE _sqledc = new Linq2SQL.SHRARCHIVE(_connection))
            {
                if (!_sqledc.DatabaseExists())
                {
                    throw new ArgumentException("Cannot connect to SQL database.", "SQLConnectionString");
                }
                using (Linq.Entities _spedc = new Linq.Entities(trace, URL))
                {
                    _breakingIssueEncountered |= DoDriver(_spedc, reportProgress, trace);
                    _breakingIssueEncountered |= DoTruck(_spedc, reportProgress, trace);
                    _breakingIssueEncountered |= DoDestinationMarket(_spedc, reportProgress, trace);
                    _breakingIssueEncountered |= DoCarrierPerformanceReport(_spedc, reportProgress, trace);
                    _breakingIssueEncountered |= DoRoute(_spedc, reportProgress, trace);
                    _breakingIssueEncountered |= DoCity(_spedc, reportProgress, trace);
                    _breakingIssueEncountered |= DoSecurityEscortRoute(_spedc, reportProgress, trace);
                }
            }
            using (Linq2SQL.SHRARCHIVE _sqledc = new Linq2SQL.SHRARCHIVE(_connection))
                CAS.SharePoint.Client.Link2SQL.ArchivingOperationLogs.UpdateActivitiesLogs <Linq2SQL.ArchivingOperationLogs>(_sqledc, CAS.SharePoint.Client.Link2SQL.ArchivingOperationLogs.OperationName.Cleanup, reportProgress);
            reportProgress(new ProgressChangedEventArgs(1, "Finished DoCleanupContent"));
            if (_breakingIssueEncountered)
            {
                throw new ApplicationException("DoCleanupContent has encountered breaking inconsistency - review the log and remove problems to pass to next phase.");
            }
        }