示例#1
0
        private SourceList <T> GetList <T>(DbCommand cmd, DbTrans dbTran)
            where T : Entity
        {
            try
            {
                using (ISourceReader reader = dbProvider.ExecuteReader(cmd, dbTran))
                {
                    SourceList <T>            list    = new SourceList <T>();
                    FastCreateInstanceHandler creator = DataUtils.GetFastInstanceCreator(typeof(T));

                    while (reader.Read())
                    {
                        T entity = (T)creator();
                        entity.SetAllValues(reader);
                        entity.Attach();
                        list.Add(entity);
                    }

                    reader.Close();

                    return(list);
                }
            }
            catch
            {
                throw;
            }
        }
示例#2
0
 public void Process(IDataItemWrapper <SourceContext> item)
 {
     _sourceReader.Read(item.Item);
     if (_sourceReader.IsEnd)
     {
         item.Stop();
     }
 }
示例#3
0
        private ArrayList <TResult> GetListResult <TResult>(DbCommand cmd, DbTrans dbTran)
        {
            try
            {
                using (ISourceReader reader = dbProvider.ExecuteReader(cmd, dbTran))
                {
                    ArrayList <TResult> list = new ArrayList <TResult>();

                    if (typeof(TResult) == typeof(object[]))
                    {
                        while (reader.Read())
                        {
                            List <object> objs = new List <object>();
                            for (int row = 0; row < reader.FieldCount; row++)
                            {
                                objs.Add(reader.GetValue(row));
                            }

                            TResult result = (TResult)(objs.ToArray() as object);
                            list.Add(result);
                        }
                    }
                    else
                    {
                        while (reader.Read())
                        {
                            list.Add(reader.GetValue <TResult>(0));
                        }
                    }

                    reader.Close();

                    return(list);
                }
            }
            catch
            {
                throw;
            }
        }
示例#4
0
        public bool Do(string[] args)
        {
            var startedTime = DateTime.Now;

            var clientOptions = _clientOptionsService.Map(args);

            var readContext = _sourceReader.Read(clientOptions.SourceFileName, clientOptions.CompressionMode);

            var parallelCompressionContext = _parallelCompressionService.Run(clientOptions.CompressionMode,
                                                                             Environment.ProcessorCount, readContext);

            var calculationWorkFinishedSrc = new CancellationTokenSource();

            var writeContext = _destinationWriter.Write(clientOptions.DestinationFileName, clientOptions.CompressionMode,
                                                        parallelCompressionContext, calculationWorkFinishedSrc.Token);

            _threadService.WaitThreadsCompletion(parallelCompressionContext.Threads);

            calculationWorkFinishedSrc.Cancel();

            writeContext.ProcessingThread.Join();

            var failed = readContext.ExceptionSource.IsCancellationRequested ||
                         parallelCompressionContext.ExceptionSource.IsCancellationRequested ||
                         writeContext.ExceptionSource.IsCancellationRequested;

            if (failed)
            {
                _outcomeService.Failed(clientOptions);
            }
            else
            {
                _outcomeService.CompletedSuccessfully(clientOptions, startedTime);
            }

            return(!failed);
        }