Beispiel #1
0
        public void InserterTest()
        {
            PipeLineContext c = new PipeLineContext();

            c.PathToSourceFile      = @"C:\Users\C51188\Documents\CSAHC_Tradedetails_20180228\blabla.txt";
            c.ConnectionString      = @"Data Source=NLGSPIDCS34019\S0QRMSN;Initial Catalog=QRM_TDM_DMT_LIQ_DEV_DWH;Integrated Security=True;Connect Timeout=30;Encrypt=False;TrustServerCertificate=True;ApplicationIntent=ReadWrite;MultiSubnetFailover=False";
            c.FieldDelimiter        = '|';
            c.DestinationTableName  = "MurexTradeDetails";
            c.IsSuggestingDataTypes = false;
            c.LinesToScan           = 2000;
            ConcurrentQueue <List <string> > RowsCollection = new ConcurrentQueue <List <string> >();
            SourceFileReader        Reader     = new SourceFileReader(c, RowsCollection);
            Inserter                Writer     = new Inserter(c, RowsCollection);
            DestinationTableCreator TableMaker = new DestinationTableCreator(c);

            Reader.ReadFinished += Writer.StopWriting;

            Writer.FinishedWriting += IsDone;

            TableMaker.CreateTable();
            Reader.StartReading();
            Writer.CreateConcurrentWriter();
            Writer.CreateConcurrentWriter();

            while (!Done)
            {
                Thread.Sleep(2000);
            }
        }
Beispiel #2
0
#pragma warning disable S3241 // Methods should not return values that are never used
        private async Task StartFileTransfer()
#pragma warning restore S3241 // Methods should not return values that are never used
        {
            //build staging table
            if (!Context.IsAppendingDataToExistingTable)
            {
                DestinationTableCreator TableMaker = new DestinationTableCreator(Context);
                TableMaker.CreateTable();
            }

            //create buffer
            ConcurrentQueue <List <string> > Queu = new ConcurrentQueue <List <string> >();
            //create threads to transfer file
            SourceFileReader Reader = new SourceFileReader(Context, Queu);
            Inserter         Writer = new Inserter(Context, Queu);

            Writer.done             = false;
            Reader.ReadFinished    += Writer.StopWriting;
            Writer.FinishedWriting += OnWriterFinishing;

            // start everything up and monitor for finish
            Reader.StartReading();
            for (int i = 0; i < NumberOfWriterThreads; i++)
            {
                Writer.CreateConcurrentWriter();
            }

            await Task.Run(() =>
            {
                while (NumberOfWriterThreads > NumberOfFinishedThreads)
                {
                    Task.Delay(1000).Wait();
                }
            });


            btnStartTransfer.Enabled = true;
            OnLoadStageOneFinished();
        }