Exemplo n.º 1
0
        public void Start()
        {
            Logger.Write(null, LogMessageTypes.Debug, "sss RedshiftService Start()");

            indexSize.Clear();
            var dbChunk = new DbChunk(Settings.Current.Building.BuilderConnectionString);

            chunksIndexes = dbChunk.SplitChunks(Settings.Current.Building.Id.Value, SizeOfSet);

            foreach (var index in chunksIndexes.Values)
            {
                if (!indexSize.ContainsKey(index))
                {
                    indexSize.Add(index, 0);
                }

                indexSize[index] = indexSize[index] + 1;
            }

            if (Settings.Current.Builder.IsLead && Settings.Current.Building.DestinationEngine.Database == Database.Redshift)
            {
                if (saver != null)
                {
                    saver.DoWork             -= saver_DoWork;
                    saver.RunWorkerCompleted -= saver_RunWorkerCompleted;
                    saver.Dispose();
                    saver = null;
                }

                saver = new BackgroundWorker {
                    WorkerSupportsCancellation = true
                };
                saver.DoWork             += saver_DoWork;
                saver.RunWorkerCompleted += saver_RunWorkerCompleted;
                saver.RunWorkerAsync();
                Logger.Write(null, LogMessageTypes.Debug, "sss saver_DoWork");
            }
        }