예제 #1
0
        private static void ArchiveRouts(Linq.Entities spedc, Linq2SQL.SHRARCHIVE sqledc, int archivalDelay, Action <ProgressChangedEventArgs> reportProgress, Action <string> trace)
        {
            int _year = 365;

            reportProgress(new ProgressChangedEventArgs(1, "Starting archive the lists: Route, SecurityEscortCatalog"));
            //Route
            trace("Loading the List Route at ArchiveRouts");
            List <Linq.Route> _Route2BeDeleted = spedc.Route.ToList <Linq.Route>().Where <Linq.Route>(x => x.Shipping.Count == 0 && x.Created.IsLatter(new TimeSpan(_year, 0, 0, 0).Days + archivalDelay)).ToList <Linq.Route>();

            reportProgress(new ProgressChangedEventArgs(1, String.Format("There are {0} Route entries to be deleted.", _Route2BeDeleted.Count)));
            spedc.Route.Delete <Linq.Route, Linq2SQL.History>
                (_Route2BeDeleted, null, x => sqledc.Route.GetAt <Linq2SQL.Route>(x), (id, listName) => sqledc.ArchivingLogs.AddLog(id, listName, Extensions.UserName()),
                x => sqledc.History.AddHistoryEntry(x));
            //SecurityEscortCatalog
            trace("Loading the List Route at ArchiveRouts");
            List <Linq.SecurityEscortCatalog> _SecurityEscortCatalog2BeDeleted =
                spedc.SecurityEscortRoute.ToList <Linq.SecurityEscortCatalog>().Where <Linq.SecurityEscortCatalog>(x => x.Shipping.Count == 0 && x.Created.IsLatter(new TimeSpan(_year, 0, 0, 0).Days + archivalDelay)).ToList <Linq.SecurityEscortCatalog>();

            reportProgress(new ProgressChangedEventArgs(1, String.Format("There are {0} Route entries to be deleted.", _SecurityEscortCatalog2BeDeleted.Count)));
            spedc.SecurityEscortRoute.Delete <Linq.SecurityEscortCatalog, Linq2SQL.History>
                (_SecurityEscortCatalog2BeDeleted, null, x => sqledc.SecurityEscortRoute.GetAt <Linq2SQL.SecurityEscortRoute>(x), (id, listName) => sqledc.ArchivingLogs.AddLog(id, listName, Extensions.UserName()),
                x => sqledc.History.AddHistoryEntry(x));
            trace("SubmitChanges for the lists: Route, SecurityEscortCatalog have been archived.");
            CAS.SharePoint.Client.SP2SQLInteroperability.Extensions.SubmitChanges(spedc, sqledc, (x, y) => reportProgress(y));
            reportProgress(new ProgressChangedEventArgs(1, "The lists: Route, SecurityEscortCatalog have been archived."));
        }
예제 #2
0
        private static bool DoDriversTeam(Linq.Entities spedc, Linq2SQL.SHRARCHIVE sqledc, Action <ProgressChangedEventArgs> reportProgress, Action <string> trace)
        {
            bool _breakingIssueEncountered = false;

            trace("Entering DoDriversTeam");
            List <Linq.Shipping>            _ShippingShippingAll           = spedc.Shipping.ToList <Linq.Shipping>();
            List <Linq.ShippingDriversTeam> _ShippingDriversTeamAll        = spedc.DriversTeam.ToList <Linq.ShippingDriversTeam>();
            List <Linq.ShippingDriversTeam> _ShippingDriversTeam2BeDeleted = _ShippingDriversTeamAll.Where <Linq.ShippingDriversTeam>(x => x.DriverTitle == null).ToList <Linq.ShippingDriversTeam>();

            try
            {
                _ShippingDriversTeam2BeDeleted.AddRange(_ShippingDriversTeamAll.Where <Linq.ShippingDriversTeam>(x => x.ShippingIndex == null));
            }
            catch (Exception ex)
            {
                _ShippingDriversTeamAll = null;
                reportProgress(new ProgressChangedEventArgs(1, String.Format("DoDriversTeam - Shipping lookup test aborter by the exception: {0}.", ex.Message)));
            }
            reportProgress(new ProgressChangedEventArgs(1, String.Format("There are {0} ShippingDriversTeam entries to be deleted because they have empty lookup on Shipping or Driver.", _ShippingDriversTeam2BeDeleted.Count())));
            spedc.DriversTeam.Delete <Linq.ShippingDriversTeam, Linq2SQL.History>
                (_ShippingDriversTeam2BeDeleted, null, x => sqledc.DriversTeam.GetAt <Linq2SQL.DriversTeam>(x), (id, listName) => sqledc.ArchivingLogs.AddLog(id, listName, Extensions.UserName()),
                x => sqledc.History.AddHistoryEntry(x));
            reportProgress(new ProgressChangedEventArgs(1, "Starting SubmitChanges."));
            CAS.SharePoint.Client.SP2SQLInteroperability.Extensions.SubmitChanges(spedc, sqledc, (x, y) => reportProgress(y));
            trace("Successfully finished cleanup of the Drivers Team list.");
            reportProgress(new ProgressChangedEventArgs(1, String.Format("Finished consistency check of list Drivers Team with result {0}.", _breakingIssueEncountered ? "Failed" : "Success")));
            return(_breakingIssueEncountered);
        }
예제 #3
0
        private static bool DoShippingPoint(Linq.Entities spedc, Linq2SQL.SHRARCHIVE sqledc, Action <ProgressChangedEventArgs> reportProgress, Action <string> trace)
        {
            trace("Entering DoShippingPoint");
            IEnumerable <Linq.ShippingPoint> _ShippingPointAllCandidates = spedc.ShippingPoint.ToList <Linq.ShippingPoint>().Where <Linq.ShippingPoint>(x => x.WarehouseTitle == null);

            if (_ShippingPointAllCandidates.Count() == 0)
            {
                trace("Finished DoShippingPoint - there is no shipping point entries to be deleted.");
                return(false);
            }
            reportProgress(new ProgressChangedEventArgs(1, String.Format("ShippingPoint processing. There are {0} candidate entries to be deleted.", _ShippingPointAllCandidates.Count())));
            List <Linq.TimeSlotTimeSlot> _TimeSlotAll             = spedc.TimeSlot.ToList <Linq.TimeSlotTimeSlot>();
            List <Linq.ShippingPoint>    _ShippingPoint2BeDeleted = new List <Linq.ShippingPoint>();

            foreach (Linq.ShippingPoint _item in _ShippingPointAllCandidates)
            {
                if (!_TimeSlotAll.Where <Linq.TimeSlotTimeSlot>(x => x.TimeSlot2ShippingPointLookup == _item).Any <Linq.TimeSlotTimeSlot>())
                {
                    _ShippingPoint2BeDeleted.Add(_item);
                }
            }
            if (_ShippingPoint2BeDeleted.Count() == 0)
            {
                trace("Finished DoShippingPoint - there is no shipping point entries to be deleted.");
                return(false);
            }
            reportProgress(new ProgressChangedEventArgs(1, String.Format("There are {0} ShippingPoint entries to be deleted.", _ShippingPoint2BeDeleted.Count())));
            List <Linq.ScheduleTemplate> _ScheduleTemplateAll        = spedc.ScheduleTemplate.ToList <Linq.ScheduleTemplate>();
            List <Linq.ScheduleTemplate> _ScheduleTemplate2BeDeleted = new List <Linq.ScheduleTemplate>();

            foreach (Linq.ShippingPoint _item in _ShippingPoint2BeDeleted)
            {
                _ScheduleTemplate2BeDeleted.AddRange(_ScheduleTemplateAll.Where(z => z.ShippingPointLookupTitle == _item));
            }
            List <Linq.TimeSlotsTemplate> _TimeSlotsTemplateAll         = spedc.TimeSlotsTemplate.ToList <Linq.TimeSlotsTemplate>();
            List <Linq.TimeSlotsTemplate> _TimeSlotsTemplate22BeDeleted = new List <Linq.TimeSlotsTemplate>();

            foreach (Linq.ScheduleTemplate _item in _ScheduleTemplate2BeDeleted)
            {
                _TimeSlotsTemplate22BeDeleted.AddRange(_TimeSlotsTemplateAll.Where(z => z.ScheduleTemplateTitle == _item));
            }
            reportProgress(new ProgressChangedEventArgs(1, String.Format("There are {0} TimeSlotsTemplate entries to be deleted.", _TimeSlotsTemplate22BeDeleted.Count())));
            spedc.TimeSlotsTemplate.Delete <Linq.TimeSlotsTemplate, Linq2SQL.History>
                (_TimeSlotsTemplate22BeDeleted, null, x => sqledc.TimeSlotsTemplate.GetAt <Linq2SQL.TimeSlotsTemplate>(x), (id, listName) => sqledc.ArchivingLogs.AddLog(id, listName, Extensions.UserName()),
                x => sqledc.History.AddHistoryEntry(x));
            reportProgress(new ProgressChangedEventArgs(1, String.Format("There are {0} ScheduleTemplate entries to be deleted.", _ScheduleTemplate2BeDeleted.Count())));
            spedc.ScheduleTemplate.Delete <Linq.ScheduleTemplate, Linq2SQL.History>
                (_ScheduleTemplate2BeDeleted, null, x => sqledc.ScheduleTemplate.GetAt <Linq2SQL.ScheduleTemplate>(x), (id, listName) => sqledc.ArchivingLogs.AddLog(id, listName, Extensions.UserName()),
                x => sqledc.History.AddHistoryEntry(x));
            reportProgress(new ProgressChangedEventArgs(1, String.Format("There are {0} ShippingPoint entries to be deleted.", _ShippingPoint2BeDeleted.Count())));
            spedc.ShippingPoint.Delete <Linq.ShippingPoint, Linq2SQL.History>
                (_ShippingPoint2BeDeleted, null, x => sqledc.ShippingPoint.GetAt <Linq2SQL.ShippingPoint>(x), (id, listName) => sqledc.ArchivingLogs.AddLog(id, listName, Extensions.UserName()),
                x => sqledc.History.AddHistoryEntry(x));
            reportProgress(new ProgressChangedEventArgs(1, "Starting SubmitChanges."));
            CAS.SharePoint.Client.SP2SQLInteroperability.Extensions.SubmitChanges(spedc, sqledc, (x, y) => reportProgress(y));
            trace("Finished DoShippingPoint - cleanup of the following list TimeSlotsTemplate, ScheduleTemplate, ShippingPoint");
            return(false);
        }
예제 #4
0
        private static void ArchiveShipping(Linq.Entities spedc, Linq2SQL.SHRARCHIVE sqledc, int archivalDelay, Action <ProgressChangedEventArgs> reportProgress, Action <string> trace)
        {
            reportProgress(new ProgressChangedEventArgs(1, "Starting archive the lists: TimeSlot, AlarmsAndEvents, LoadDescription, DriversTeam, Shipping"));
            trace("Starting GoShipping");
            List <Linq.Shipping> _Shipping2Delete = spedc.Shipping.ToList <Linq.Shipping>().Where <Linq.Shipping>(x => (x.ShippingState == Linq.ShippingState.Completed ||
                                                                                                                        x.ShippingState == Linq.ShippingState.Canceled) &&
                                                                                                                  x.EndTime.IsLatter(archivalDelay)).ToList <Linq.Shipping>();

            trace(String.Format("List of Shipping loaded and contains {0} items.", _Shipping2Delete.Count));
            List <Linq.TimeSlotTimeSlot> _TimeSlot2Delete = new List <Linq.TimeSlotTimeSlot>();

            trace(String.Format("List of TimeSlotTimeSlot loaded and contains {0} items.", _Shipping2Delete.Count));
            List <Linq.AlarmsAndEvents> _AlarmsAndEvents2Delete = new List <Linq.AlarmsAndEvents>();

            trace(String.Format("List of AlarmsAndEvents loaded and contains {0} items.", _Shipping2Delete.Count));
            List <Linq.LoadDescription> _LoadDescription2Delete = new List <Linq.LoadDescription>();

            trace(String.Format("List of LoadDescription loaded and contains {0} items.", _Shipping2Delete.Count));
            List <Linq.ShippingDriversTeam> _ShippingDriversTeam2Delete = new List <Linq.ShippingDriversTeam>();

            trace(String.Format("List of ShippingDriversTeam loaded and contains {0} items.", _Shipping2Delete.Count));
            //TODO http://casas:11227/sites/awt/_layouts/listform.aspx?PageType=4&ListId={72C511B5-8B63-4DFA-AD34-133A97EBA469}&ID=4568&ContentTypeID=0x01005D39260836CE498D8E0D443AD5CAD3AC00456AB372ACF9DA41B8AE870CD1954927
            //TODO workaround to avoid usage of the reverse lookup for doubled type definition.
            List <Linq.TimeSlotTimeSlot> _TimeSlotTimeSlotAll = spedc.TimeSlot.ToList <Linq.TimeSlotTimeSlot>();;

            foreach (Linq.Shipping _shipping in _Shipping2Delete)
            {
                _TimeSlot2Delete.AddRange(_TimeSlotTimeSlotAll.Where <Linq.TimeSlotTimeSlot>(x => x.TimeSlot2ShippingIndex == _shipping));
                _AlarmsAndEvents2Delete.AddRange(_shipping.AlarmsAndEvents);
                _LoadDescription2Delete.AddRange(_shipping.LoadDescription);
                _ShippingDriversTeam2Delete.AddRange(_shipping.ShippingDriversTeam);
            }
            reportProgress(new ProgressChangedEventArgs(1, String.Format("There are {0} TimeSlot entries to be deleted.", _TimeSlot2Delete.Count)));
            spedc.TimeSlot.Delete <Linq.TimeSlotTimeSlot, Linq2SQL.History>
                (_TimeSlot2Delete, null, x => null, (id, listName) => sqledc.ArchivingLogs.AddLog(id, listName, Extensions.UserName()),
                x => sqledc.History.AddHistoryEntry(x));
            reportProgress(new ProgressChangedEventArgs(1, String.Format("There are {0} AlarmsAndEvents entries to be deleted.", _AlarmsAndEvents2Delete.Count)));
            spedc.AlarmsAndEvents.Delete <Linq.AlarmsAndEvents, Linq2SQL.History>
                (_AlarmsAndEvents2Delete, null, x => null, (id, listName) => sqledc.ArchivingLogs.AddLog(id, listName, Extensions.UserName()),
                x => sqledc.History.AddHistoryEntry(x));
            reportProgress(new ProgressChangedEventArgs(1, String.Format("There are {0} LoadDescription entries to be deleted.", _LoadDescription2Delete.Count)));
            spedc.LoadDescription.Delete <Linq.LoadDescription, Linq2SQL.History>
                (_LoadDescription2Delete, null, x => sqledc.LoadDescription.GetAt <Linq2SQL.LoadDescription>(x), (id, listName) => sqledc.ArchivingLogs.AddLog(id, listName, Extensions.UserName()),
                x => sqledc.History.AddHistoryEntry(x));
            reportProgress(new ProgressChangedEventArgs(1, String.Format("There are {0} DriversTeam entries to be deleted.", _ShippingDriversTeam2Delete.Count)));
            spedc.DriversTeam.Delete <Linq.ShippingDriversTeam, Linq2SQL.History>
                (_ShippingDriversTeam2Delete, null, x => sqledc.DriversTeam.GetAt <Linq2SQL.DriversTeam>(x), (id, listName) => sqledc.ArchivingLogs.AddLog(id, listName, Extensions.UserName()),
                x => sqledc.History.AddHistoryEntry(x));
            reportProgress(new ProgressChangedEventArgs(1, String.Format("There are {0} Shipping entries to be deleted.", _Shipping2Delete.Count)));
            spedc.Shipping.Delete <Linq.Shipping, Linq2SQL.History>
                (_Shipping2Delete, null, x => sqledc.Shipping.GetAt <Linq2SQL.Shipping>(x), (id, listName) => sqledc.ArchivingLogs.AddLog(id, listName, Extensions.UserName()),
                x => sqledc.History.AddHistoryEntry(x));
            trace("SubmitChanges for the lists: Truck, Trailer, Driver have been archived.");
            CAS.SharePoint.Client.SP2SQLInteroperability.Extensions.SubmitChanges(spedc, sqledc, (x, y) => reportProgress(y));
            reportProgress(new ProgressChangedEventArgs(1, "The lists: TimeSlot, AlarmsAndEvents, LoadDescription, DriversTeam, Shipping have been archived."));
        }
예제 #5
0
 /// <summary>
 /// Does the archiving of the Shepherd content.
 /// </summary>
 /// <param name="URL">The requested URL.</param>
 /// <param name="sqlConnectionString">The SQL connection string.</param>
 /// <param name="archivalDelay">The archival delay.</param>
 /// <param name="rowLimit">The row limit.</param>
 /// <param name="reportProgress">An action to trace progress in a log stream.</param>
 /// <param name="trace">An action to trace progress in a log stream.</param>
 public static void DoArchivingContent(string URL, string sqlConnectionString, int archivalDelay, int rowLimit, Action <ProgressChangedEventArgs> reportProgress, Action <String> trace)
 {
     reportProgress(new ProgressChangedEventArgs(1, String.Format("Starting DoArchivingContent URL: {0}, connection string: {1}, ArchivalDelay: {2}, RowLimit: {3}", URL, sqlConnectionString, archivalDelay, rowLimit)));
     trace("Establishing connection with the SP site and SQL database to execute ArchiveShipping.");
     using (Linq2SQL.SHRARCHIVE _sqledc = Linq2SQL.SHRARCHIVE.Connect2SQL(sqlConnectionString, y => trace(y)))
     {
         using (Linq.Entities _spedc = new Linq.Entities(trace, URL))
         {
             _spedc.RowLimit = rowLimit;
             ArchiveShipping(_spedc, _sqledc, archivalDelay, reportProgress, trace);
         }
     }
     trace("Establishing connection with the SP site and SQL database to execute ArchiveDictionaries .");
     using (Linq2SQL.SHRARCHIVE _sqledc = Linq2SQL.SHRARCHIVE.Connect2SQL(sqlConnectionString, y => trace(y)))
     {
         using (Linq.Entities _spedc = new Linq.Entities(trace, URL))
         {
             _spedc.RowLimit = rowLimit;
             ArchiveDictionaries(_spedc, _sqledc, archivalDelay, reportProgress, trace);
         }
     }
     trace("Establishing connection with the SP site and SQL database to execute ArchiveRouts.");
     using (Linq2SQL.SHRARCHIVE _sqledc = Linq2SQL.SHRARCHIVE.Connect2SQL(sqlConnectionString, y => trace(y)))
     {
         using (Linq.Entities _spedc = new Linq.Entities(trace, URL))
         {
             _spedc.RowLimit = rowLimit;
             ArchiveRouts(_spedc, _sqledc, archivalDelay, reportProgress, trace);
         }
     }
     trace("Establishing connection with the SP site and SQL database to execute ArchiveBusinessDescription.");
     using (Linq2SQL.SHRARCHIVE _sqledc = Linq2SQL.SHRARCHIVE.Connect2SQL(sqlConnectionString, y => trace(y)))
     {
         using (Linq.Entities _spedc = new Linq.Entities(trace, URL))
         {
             _spedc.RowLimit = rowLimit;
             ArchiveBusinessDescription(_spedc, _sqledc, archivalDelay, reportProgress, trace);
         }
     }
     trace("Establishing connection with the SP site and SQL database to execute ArchiveCarrierPerformanceReport.");
     using (Linq2SQL.SHRARCHIVE _sqledc = Linq2SQL.SHRARCHIVE.Connect2SQL(sqlConnectionString, y => trace(y)))
     {
         using (Linq.Entities _spedc = new Linq.Entities(trace, URL))
         {
             _spedc.RowLimit = rowLimit;
             ArchiveCarrierPerformanceReport(_spedc, _sqledc, archivalDelay, reportProgress, trace);
         }
     }
     //Business Description
     reportProgress(new ProgressChangedEventArgs(1, "Updating Activities Logs"));
     using (Linq2SQL.SHRARCHIVE _sqledc = Linq2SQL.SHRARCHIVE.Connect2SQL(sqlConnectionString, y => trace(y)))
         ArchivingOperationLogs.UpdateActivitiesLogs <Linq2SQL.ArchivingOperationLogs>(_sqledc, ArchivingOperationLogs.OperationName.Archiving, reportProgress);
     reportProgress(new ProgressChangedEventArgs(1, "Finished DoArchivingContent"));
 }
예제 #6
0
        private static void ArchiveCarrierPerformanceReport(Linq.Entities spedc, Linq2SQL.SHRARCHIVE sqledc, int archivalDelay, Action <ProgressChangedEventArgs> reportProgress, Action <string> trace)
        {
            //CarrierPerformanceReport
            trace("Loading the List CarrierPerformanceReport at ArchiveCarrierPerformanceReport");
            List <Linq.CarrierPerformanceReport> _CarrierPerformanceReport2BeDeleted =
                spedc.CarrierPerformanceReport.ToList <Linq.CarrierPerformanceReport>().Where <Linq.CarrierPerformanceReport>(x => x.Created.IsLatter(archivalDelay)).ToList <Linq.CarrierPerformanceReport>();

            reportProgress(new ProgressChangedEventArgs(1, String.Format("There are {0} CarrierPerformanceReport entries to be deleted.", _CarrierPerformanceReport2BeDeleted.Count)));
            spedc.CarrierPerformanceReport.Delete <Linq.CarrierPerformanceReport, Linq2SQL.History>
                (_CarrierPerformanceReport2BeDeleted, null, x => sqledc.CarrierPerformanceReport.GetAt <Linq2SQL.CarrierPerformanceReport>(x), (id, listName) => sqledc.ArchivingLogs.AddLog(id, listName, Extensions.UserName()),
                x => sqledc.History.AddHistoryEntry(x));
            trace("SubmitChanges for the list: CarrierPerformanceReport have been archived.");
            CAS.SharePoint.Client.SP2SQLInteroperability.Extensions.SubmitChanges(spedc, sqledc, (x, y) => reportProgress(y));
            reportProgress(new ProgressChangedEventArgs(1, "The list: CarrierPerformanceReport have been archived."));
        }
예제 #7
0
        private static void ArchiveBusinessDescription(Linq.Entities spedc, Linq2SQL.SHRARCHIVE sqledc, int archivalDelay, Action <ProgressChangedEventArgs> reportProgress, Action <string> trace)
        {
            //BusienssDescription
            trace("Loading the List BusienssDescription at ArchiveBusinessDescription");
            List <Linq.BusienssDescription> _BusinessDescription2BeDeleted =
                spedc.BusinessDescription.ToList <Linq.BusienssDescription>().Where <Linq.BusienssDescription>(x => x.Route.Count == 0 && x.SecurityEscortCatalog.Count == 0).ToList <Linq.BusienssDescription>();

            reportProgress(new ProgressChangedEventArgs(1, String.Format("There are {0} BusienssDescription entries to be deleted.", _BusinessDescription2BeDeleted.Count)));
            spedc.BusinessDescription.Delete <Linq.BusienssDescription, Linq2SQL.History>
                (_BusinessDescription2BeDeleted, null, x => sqledc.BusinessDescription.GetAt <Linq2SQL.BusinessDescription>(x), (id, listName) => sqledc.ArchivingLogs.AddLog(id, listName, Extensions.UserName()),
                x => sqledc.History.AddHistoryEntry(x));
            trace("SubmitChanges for the list: BusienssDescription have been archived.");
            CAS.SharePoint.Client.SP2SQLInteroperability.Extensions.SubmitChanges(spedc, sqledc, (x, y) => reportProgress(y));
            reportProgress(new ProgressChangedEventArgs(1, "The list: BusienssDescription have been archived."));
        }
예제 #8
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);
        }
예제 #9
0
 /// <summary>
 /// Runs the synchronization of the SharePoint and SQL.
 /// </summary>
 /// <param name="URL">The requested URL.</param>
 /// <param name="sqlConnectionString">The SQL connection string.</param>
 /// <param name="reportProgress">An action to trace progress in a log stream.</param>
 /// <param name="trace">An action to trace progress in a log stream.</param>
 public static void DoSynchronizationContent(string URL, string sqlConnectionString, Action <ProgressChangedEventArgs> reportProgress, Action <String> trace)
 {
     reportProgress(new ProgressChangedEventArgs(1, String.Format("Starting DoSynchronizationContent URL: {0}, connection string: {1}", URL, sqlConnectionString)));
     trace("Establishing connection with the SP site and SQL database.");
     using (Linq.Entities _edc = new Linq.Entities(trace, URL))
     {
         using (Linq2SQL.SHRARCHIVE _sqledc = Linq2SQL.SHRARCHIVE.Connect2SQL(sqlConnectionString, y => trace(y)))
         {
             Synchronizer.Synchronize <Linq2SQL.Commodity, Linq.Commodity>(_sqledc.Commodity, _edc.Commodity, (x, y) => reportProgress(y), Linq.Commodity.GetMappings(), false);
             Synchronizer.Synchronize <Linq2SQL.Warehouse, Linq.Warehouse>(_sqledc.Warehouse, _edc.Warehouse, (x, y) => reportProgress(y), Linq.Warehouse.GetMappings(), false);
             Synchronizer.Synchronize <Linq2SQL.Partner, Linq.Partner>(_sqledc.Partner, _edc.Partner, (x, y) => reportProgress(y), Linq.Partner.GetMappings(), false);
             Synchronizer.Synchronize <Linq2SQL.Currency, Linq.Currency>(_sqledc.Currency, _edc.Currency, (x, y) => reportProgress(y), Linq.Currency.GetMappings(), false);
             Synchronizer.Synchronize <Linq2SQL.FreightPayer, Linq.FreightPayer>(_sqledc.FreightPayer, _edc.FreightPayer, (x, y) => reportProgress(y), Linq.FreightPayer.GetMappings(), false);
             Synchronizer.Synchronize <Linq2SQL.BusinessDescription, Linq.BusienssDescription>(_sqledc.BusinessDescription, _edc.BusinessDescription, (x, y) => reportProgress(y), Linq.BusienssDescription.GetMappings(), false);
             Synchronizer.Synchronize <Linq2SQL.SecurityEscortRoute, Linq.SecurityEscortCatalog>(_sqledc.SecurityEscortRoute, _edc.SecurityEscortRoute, (x, y) => reportProgress(y), Linq.SecurityEscortCatalog.GetMappings(), false);
             Synchronizer.Synchronize <Linq2SQL.SealProtocolLibrary, Linq.SealProtocol>(_sqledc.SealProtocolLibrary, _edc.SealProtocolLibrary, (x, y) => reportProgress(y), Linq.SealProtocol.GetMappings(), false);
             Synchronizer.Synchronize <Linq2SQL.Country, Linq.CountryType>(_sqledc.Country, _edc.Country, (x, y) => reportProgress(y), Linq.CountryType.GetMappings(), false);
             Synchronizer.Synchronize <Linq2SQL.City, Linq.CityType>(_sqledc.City, _edc.City, (x, y) => reportProgress(y), Linq.CityType.GetMappings(), false);
             Synchronizer.Synchronize <Linq2SQL.EscortPOLibrary, Linq.EscortPO>(_sqledc.EscortPOLibrary, _edc.EscortPOLibrary, (x, y) => reportProgress(y), Linq.EscortPO.GetMappings(), false);
             Synchronizer.Synchronize <Linq2SQL.FreightPOLibrary, Linq.FreightPO>(_sqledc.FreightPOLibrary, _edc.FreightPOLibrary, (x, y) => reportProgress(y), Linq.FreightPO.GetMappings(), false);
             Synchronizer.Synchronize <Linq2SQL.Carrier, Linq.CarrierType>(_sqledc.Carrier, _edc.Carrier, (x, y) => reportProgress(y), Linq.CarrierType.GetMappings(), false);
             Synchronizer.Synchronize <Linq2SQL.SAPDestinationPlant, Linq.SAPDestinationPlant>(_sqledc.SAPDestinationPlant, _edc.SAPDestinationPlant, (x, y) => reportProgress(y), Linq.SAPDestinationPlant.GetMappings(), false);
             Synchronizer.Synchronize <Linq2SQL.ShipmentType, Linq.ShipmentType>(_sqledc.ShipmentType, _edc.ShipmentType, (x, y) => reportProgress(y), Linq.ShipmentType.GetMappings(), false);
             Synchronizer.Synchronize <Linq2SQL.TransportUnitType, Linq.TranspotUnit>(_sqledc.TransportUnitType, _edc.TransportUnitType, (x, y) => reportProgress(y), Linq.TranspotUnit.GetMappings(), false);
             Synchronizer.Synchronize <Linq2SQL.Route, Linq.Route>(_sqledc.Route, _edc.Route, (x, y) => reportProgress(y), Linq.Route.GetMappings(), false);
             Synchronizer.Synchronize <Linq2SQL.Truck, Linq.Truck>(_sqledc.Truck, _edc.Truck, (x, y) => reportProgress(y), Linq.Truck.GetMappings(), false);
             Synchronizer.Synchronize <Linq2SQL.Trailer, Linq.Trailer>(_sqledc.Trailer, _edc.Trailer, (x, y) => reportProgress(y), Linq.Trailer.GetMappings(), false);
             Synchronizer.Synchronize <Linq2SQL.Shipping, Linq.Shipping>(_sqledc.Shipping, _edc.Shipping, (x, y) => reportProgress(y), Linq.Shipping.GetMappings(), false);
             Synchronizer.Synchronize <Linq2SQL.CarrierPerformanceReport, Linq.CarrierPerformanceReport>(_sqledc.CarrierPerformanceReport, _edc.CarrierPerformanceReport, (x, y) => reportProgress(y), Linq.CarrierPerformanceReport.GetMappings(), false);
             Synchronizer.Synchronize <Linq2SQL.Market, Linq.Market>(_sqledc.Market, _edc.Market, (x, y) => reportProgress(y), Linq.Market.GetMappings(), false);
             Synchronizer.Synchronize <Linq2SQL.DestinationMarket, Linq.DestinationMarket>(_sqledc.DestinationMarket, _edc.DestinationMarket, (x, y) => reportProgress(y), Linq.DestinationMarket.GetMappings(), false);
             Synchronizer.Synchronize <Linq2SQL.Driver, Linq.Driver>(_sqledc.Driver, _edc.Driver, (x, y) => reportProgress(y), Linq.Driver.GetMappings(), false);
             Synchronizer.Synchronize <Linq2SQL.DriversTeam, Linq.ShippingDriversTeam>(_sqledc.DriversTeam, _edc.DriversTeam, (x, y) => reportProgress(y), Linq.ShippingDriversTeam.GetMappings(), false);
             Synchronizer.Synchronize <Linq2SQL.LoadDescription, Linq.LoadDescription>(_sqledc.LoadDescription, _edc.LoadDescription, (x, y) => reportProgress(y), Linq.LoadDescription.GetMappings(), false);
             Synchronizer.Synchronize <Linq2SQL.ShippingPoint, Linq.ShippingPoint>(_sqledc.ShippingPoint, _edc.ShippingPoint, (x, y) => reportProgress(y), Linq.ShippingPoint.GetMappings(), false);
             Synchronizer.Synchronize <Linq2SQL.ScheduleTemplate, Linq.ScheduleTemplate>(_sqledc.ScheduleTemplate, _edc.ScheduleTemplate, (x, y) => reportProgress(y), Linq.ScheduleTemplate.GetMappings(), false);
             Synchronizer.Synchronize <Linq2SQL.TimeSlotsTemplate, Linq.TimeSlotsTemplate>(_sqledc.TimeSlotsTemplate, _edc.TimeSlotsTemplate, (x, y) => reportProgress(y), Linq.TimeSlotsTemplate.GetMappings(), false); //TODO MP
         }
         using (Linq2SQL.SHRARCHIVE _sqledc = Linq2SQL.SHRARCHIVE.Connect2SQL(sqlConnectionString, y => trace(y)))
             CAS.SharePoint.Client.Link2SQL.ArchivingOperationLogs.UpdateActivitiesLogs <Linq2SQL.ArchivingOperationLogs>(_sqledc, CAS.SharePoint.Client.Link2SQL.ArchivingOperationLogs.OperationName.Synchronization, reportProgress);
         reportProgress(new ProgressChangedEventArgs(1, "Finished DoSynchronizationContent"));
     }
 }
예제 #10
0
        /// <summary>
        /// Does the cleanup of the lists <see cref="Linq.ScheduleTemplate"/>, <see cref="Linq.TimeSlotsTemplate"/>, <see cref="Linq.TimeSlotTimeSlot"/>.
        /// </summary>
        /// <param name="spedc">The spedc.</param>
        /// <param name="sqledc">The sqledc.</param>
        /// <param name="reportProgress">The report progress.</param>
        /// <param name="trace">The trace.</param>
        /// <returns><c>true</c> if XXXX, <c>false</c> otherwise.</returns>
        private static bool DoTimeSlotsTemplate(Linq.Entities spedc, Linq2SQL.SHRARCHIVE sqledc, Action <ProgressChangedEventArgs> reportProgress, Action <String> trace)
        {
            trace("Entering DoTimeSlotsTemplate");
            bool _ret = false;

            reportProgress(new ProgressChangedEventArgs(1, "Starting ScheduleTemplate and TimeSlotsTemplate lists processing."));
            IEnumerable <Linq.ScheduleTemplate> _ScheduleTemplate2BeDeleted  = spedc.ScheduleTemplate.ToList <Linq.ScheduleTemplate>().Where <Linq.ScheduleTemplate>(x => x.ShippingPointLookupTitle == null);
            List <Linq.TimeSlotsTemplate>       _TimeSlotsTemplateAll        = spedc.TimeSlotsTemplate.ToList <Linq.TimeSlotsTemplate>();
            List <Linq.TimeSlotsTemplate>       _TimeSlotsTemplate2BeDeleted = new List <Linq.TimeSlotsTemplate>();

            foreach (Linq.ScheduleTemplate _item in _ScheduleTemplate2BeDeleted)
            {
                _TimeSlotsTemplate2BeDeleted.AddRange(_TimeSlotsTemplateAll.Where <Linq.TimeSlotsTemplate>(x => x.ScheduleTemplateTitle == _item));
            }
            _TimeSlotsTemplate2BeDeleted.AddRange(_TimeSlotsTemplateAll.Where <Linq.TimeSlotsTemplate>(x => x.ScheduleTemplateTitle == null));
            reportProgress(new ProgressChangedEventArgs(1, String.Format("There are {0} TimeSlotsTemplate entries to be deleted.", _TimeSlotsTemplate2BeDeleted.Count)));
            spedc.TimeSlotsTemplate.Delete <Linq.TimeSlotsTemplate, Linq2SQL.History>
                (_TimeSlotsTemplate2BeDeleted, null, x => sqledc.TimeSlotsTemplate.GetAt <Linq2SQL.TimeSlotsTemplate>(x), (id, listName) => sqledc.ArchivingLogs.AddLog(id, listName, Extensions.UserName()),
                x => sqledc.History.AddHistoryEntry(x));
            reportProgress(new ProgressChangedEventArgs(1, String.Format("There are {0} ScheduleTemplate entries to be deleted.", _ScheduleTemplate2BeDeleted.Count())));
            spedc.ScheduleTemplate.Delete <Linq.ScheduleTemplate, Linq2SQL.History>
                (_ScheduleTemplate2BeDeleted, null, x => sqledc.ScheduleTemplate.GetAt <Linq2SQL.ScheduleTemplate>(x), (id, listName) => sqledc.ArchivingLogs.AddLog(id, listName, Extensions.UserName()),
                x => sqledc.History.AddHistoryEntry(x));
            //TimeSlotTimeSlot
            reportProgress(new ProgressChangedEventArgs(1, "TimeSlot processing."));
            List <Linq.TimeSlotTimeSlot> _TimeSlotAll        = spedc.TimeSlot.ToList <Linq.TimeSlotTimeSlot>().Where <Linq.TimeSlotTimeSlot>(x => x.StartTime.Value < DateTime.Now).ToList <Linq.TimeSlotTimeSlot>();
            List <Linq.TimeSlotTimeSlot> _TimeSlot3BeDeleted = (from _tsx in _TimeSlotAll
                                                                let _notUsed = _tsx.TimeSlot2ShippingIndex != null && (_tsx.TimeSlot2ShippingIndex.ShippingState == Linq.ShippingState.Canceled ||
                                                                                                                       _tsx.TimeSlot2ShippingIndex.ShippingState == Linq.ShippingState.Completed)
                                                                               where _notUsed && _tsx.StartTime.Value < DateTime.Now
                                                                               select _tsx).ToList <Linq.TimeSlotTimeSlot>();

            _TimeSlot3BeDeleted.AddRange(_TimeSlotAll.Where <Linq.TimeSlotTimeSlot>(x => x.TimeSlot2ShippingIndex == null));
            reportProgress(new ProgressChangedEventArgs(1, String.Format("There are {0} Time Slot entries to be deleted.", _TimeSlot3BeDeleted.Count())));
            spedc.TimeSlot.Delete <Linq.TimeSlotTimeSlot, Linq2SQL.History>
                (_TimeSlot3BeDeleted, null, x => null, (id, listName) => sqledc.ArchivingLogs.AddLog(id, listName, Extensions.UserName()),
                x => sqledc.History.AddHistoryEntry(x));
            reportProgress(new ProgressChangedEventArgs(1, "Starting SubmitChanges."));
            CAS.SharePoint.Client.SP2SQLInteroperability.Extensions.SubmitChanges(spedc, sqledc, (x, y) => reportProgress(y));
            trace("Successfully finished cleanup of the following lists ScheduleTemplate, TimeSlotsTemplateTimeSlotsTemplate, TimeSlotTimeSlot");
            return(_ret);
        }
예제 #11
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.");
            }
        }
예제 #12
0
        /// <summary>
        /// Archives the dictionaries.
        /// </summary>
        /// <param name="spedc">The <see cref="Linq.Entities"/> representing SharePoint application content database</param>
        /// <param name="sqledc">The <see cref="Linq2SQL.SHRARCHIVE"/> representing the SQL database containing backup of SharePoint content.</param>
        /// <param name="archivalDelay">The archival delay.</param>
        /// <param name="reportProgress">The report progress.</param>
        /// <param name="trace">The trace.</param>
        private static void ArchiveDictionaries(Linq.Entities spedc, Linq2SQL.SHRARCHIVE sqledc, int archivalDelay, Action <ProgressChangedEventArgs> reportProgress, Action <string> trace)
        {
            reportProgress(new ProgressChangedEventArgs(1, "Starting archive the lists: Truck, Trailer, Driver"));
            //Truck
            List <Linq.Truck> _Truck2MarketDeleted = spedc.Truck.ToList <Linq.Truck>().Where <Linq.Truck>(x => x.ToBeDeleted.GetValueOrDefault(false)).ToList <Linq.Truck>();

            trace(String.Format("List of Truck loaded and contains {0} items.", _Truck2MarketDeleted.Count));
            List <Linq.Truck> _Truck2BeDeleted = new List <Linq.Truck>();

            foreach (Linq.Truck _TruckItem in _Truck2MarketDeleted)
            {
                if (_TruckItem.Shipping.Count == 0 && _TruckItem.Shipping0.Count == 0)
                {
                    _Truck2BeDeleted.Add(_TruckItem);
                }
            }
            reportProgress(new ProgressChangedEventArgs(1, String.Format("There are {0} Truck entries to be deleted.", _Truck2BeDeleted.Count)));
            spedc.Truck.Delete <Linq.Truck, Linq2SQL.History>
                (_Truck2BeDeleted, null, x => sqledc.Truck.GetAt <Linq2SQL.Truck>(x), (id, listName) => sqledc.ArchivingLogs.AddLog(id, listName, Extensions.UserName()),
                x => sqledc.History.AddHistoryEntry(x));
            _Truck2MarketDeleted = null;
            _Truck2BeDeleted     = null;
            //Trailer
            List <Linq.Trailer> _Trailer2MarketDeleted = spedc.Trailer.ToList <Linq.Trailer>().Where <Linq.Trailer>(x => x.ToBeDeleted.GetValueOrDefault(false)).ToList <Linq.Trailer>();

            trace(String.Format("List of Trailer loaded and contains {0} items.", _Trailer2MarketDeleted.Count));
            List <Linq.Trailer> _Trailer2BeDeleted = new List <Linq.Trailer>();

            foreach (Linq.Trailer _TrailerItem in _Trailer2MarketDeleted)
            {
                if (_TrailerItem.Shipping.Count == 0)
                {
                    _Trailer2BeDeleted.Add(_TrailerItem);
                }
            }
            reportProgress(new ProgressChangedEventArgs(1, String.Format("There are {0} Trailer entries to be deleted.", _Trailer2BeDeleted.Count)));
            spedc.Trailer.Delete <Linq.Trailer, Linq2SQL.History>
                (_Trailer2BeDeleted, null, x => sqledc.Trailer.GetAt <Linq2SQL.Trailer>(x), (id, listName) => sqledc.ArchivingLogs.AddLog(id, listName, Extensions.UserName()),
                x => sqledc.History.AddHistoryEntry(x));
            _Trailer2MarketDeleted = null;
            _Trailer2BeDeleted     = null;
            //Driver
            List <Linq.Driver> _DriverMarketDeleted = spedc.Driver.ToList <Linq.Driver>().Where <Linq.Driver>(x => x.ToBeDeleted.GetValueOrDefault(false)).ToList <Linq.Driver>();

            trace(String.Format("List of Driver loaded and contains {0} items.", _DriverMarketDeleted.Count));
            List <Linq.Driver> _Driver2BeDeleted = new List <Linq.Driver>();

            foreach (Linq.Driver _DriverItem in _DriverMarketDeleted)
            {
                if (_DriverItem.ShippingDriversTeam.Count == 0)
                {
                    _Driver2BeDeleted.Add(_DriverItem);
                }
            }
            reportProgress(new ProgressChangedEventArgs(1, String.Format("There are {0} Driver entries to be deleted.", _Driver2BeDeleted.Count)));
            spedc.Driver.Delete <Linq.Driver, Linq2SQL.History>
                (_Driver2BeDeleted, null, x => sqledc.Driver.GetAt <Linq2SQL.Driver>(x), (id, listName) => sqledc.ArchivingLogs.AddLog(id, listName, Extensions.UserName()),
                x => sqledc.History.AddHistoryEntry(x));
            trace("SubmitChanges for the lists: Truck, Trailer, Driver have been archived.");
            CAS.SharePoint.Client.SP2SQLInteroperability.Extensions.SubmitChanges(spedc, sqledc, (x, y) => reportProgress(y));
            reportProgress(new ProgressChangedEventArgs(1, "The lists: Truck, Trailer, Driver have been archived."));
        }