Beispiel #1
0
        private static void MoveDataRun(Parameters p)
        {
            System.Diagnostics.Debug.Assert(p != null);

            MoveData action = p.MoveData;

            //Check the Source
            if (action.DataSource.Type == SourceType.Unknown)
            {
                throw new UnknownSourceType();
            }
            PrintOutput.PrintToOutput(action.DataSource.Description, p.Debug);

            //Check destinations
            int numValidDestinations = action.DataDestination.Test();

            if (numValidDestinations == 0)
            {
                throw new InvalidDestinations("Error: No Valid destinations found");
            }
            if (numValidDestinations != action.DataDestination.Destinations.Count)
            {
                throw new InvalidDestinations("Error: Invalid destinations found");
            }

            //create and configure the package
            DESSISPackage Extractor = new DESSISPackage(action);
            Package       pkg       = Extractor.LoadPackage();

            if (pkg == null)
            {
                throw new DeltaExtractorBuildException("Failed to Load or Build the SSIS Package");
            }

            ExecutePackageWithEvents(pkg);

            int rowCount = Convert.ToInt32(pkg.Variables["RowCount"].Value, CultureInfo.InvariantCulture);

            PrintOutput.PrintToOutput("DE extracted " + rowCount.ToString() + " rows from the Source.");
            PrintOutput.PrintToOutput("DE Package completed.");
            ETLController.CounterSet("RowsExtracted", rowCount.ToString());


            //if this is a staging extract, then call the upload sproc for each DB Destination
            //staging value defines which upsert type to use

            //IEnumerable<object> res = action.DataDestination.Destinations.Where(d => ((IDeDestination)d).Type == DestinationType.OleDb);
            foreach (object odest in action.DataDestination.Destinations)
            {
                IDeDestination dest = (IDeDestination)odest;
                if (dest.StagingBlock != null)
                {
                    if (dest.StagingBlock.Staging)
                    {
                        if (dest.DbSupportObject == null)
                        {
                            throw new DeltaExtractorBuildException("Staging support is not available for this destination");
                        }
                        IDeStagingSupport supp = (IDeStagingSupport)dest.DbSupportObject;
                        if (String.IsNullOrEmpty(dest.StagingBlock.StagingTableName))
                        {
                            if (!supp.CreateStagingTable(false))
                            {
                                throw new CouldNotCreateStagingTableException(dest.StagingBlock.StagingTableName);
                            }
                        }
                        if (!supp.UploadStagingTable(p.RunID))
                        {
                            throw new CouldNotUploadStagingTableException(dest.StagingBlock.StagingTableName);
                        }
                    }
                }
            }
        }
Beispiel #2
0
 public DESSISPackage(MoveData p, ILogger logger)
 {
     _movedata = p;
     _logger   = logger;
 }
Beispiel #3
0
 public DESSISPackage(MoveData p)
 {
     m_movedata = p;
 }