Exemplo n.º 1
0
        public void TaskImplementation()
        {
            _logger.LogDebug("** Performing unzip task");
            var localTemp = string.Empty;

            localTemp = StaticUtilities.GetDataPath();

            ZipFile.ExtractToDirectory(localTemp + "\\" + CurrentSessionParams.LocalDirName + "\\" + CurrentSessionParams.FileName + ".zip", localTemp + "\\" + CurrentSessionParams.LocalDirName, true);
        }
Exemplo n.º 2
0
        public AppRunner(IServiceCollection serviceCollection)
        {
            ConfigureServices(serviceCollection);
            Services = serviceCollection.BuildServiceProvider();

            //Logger = Services.GetRequiredService<ILoggerFactory>().CreateLogger<AppRunner>();
            var loggerFactory = Services.GetRequiredService <ILoggerFactory>();

            //configure NLog
            loggerFactory.AddNLog(new NLogProviderOptions {
                CaptureMessageTemplates = true, CaptureMessageProperties = true
            });
            loggerFactory.ConfigureNLog(StaticUtilities.GetDataPath() + "/nlog.config");
        }
Exemplo n.º 3
0
        public void TaskImplementation()
        {
            //https://stackoverflow.com/questions/41552052/download-file-using-rx-reactive-programming/41552295

            return;

            using (var client = new WebClient())
            {
                var localTemp = "";
                //var left=Console.CursorLeft;
                //var top=Console.CursorTop;
                // fake as if you are a browser making the request.
                client.Headers.Add("User-Agent", "Mozilla/4.0 (compatible; MSIE 8.0)");

                localTemp = StaticUtilities.GetDataPath();

                //var result=DownloadFileHelper.DownloadFileTaskAsync(ConstUrl.FinancialStatementDataSetBaseUrl + "2017q3.zip", localTemp + "Data\\");

                var progressChangedObservable = Observable.FromEventPattern <DownloadProgressChangedEventHandler, DownloadProgressChangedEventArgs>(
                    h => client.DownloadProgressChanged += h,
                    h => client.DownloadProgressChanged -= h
                    );

                var downloadCompletedObservable = Observable.FromEventPattern <AsyncCompletedEventHandler, AsyncCompletedEventArgs>(
                    h => client.DownloadFileCompleted += h,
                    h => client.DownloadFileCompleted -= h
                    );

                progressChangedObservable.Select(ep => ep.EventArgs)
                .Subscribe(dpcea =>
                {
                    //Console.SetCursorPosition(left,top);
                    //Console.WriteLine($"{dpcea.ProgressPercentage}% complete. {dpcea.TotalBytesToReceive - dpcea.ProgressPercentage} bytes received. {dpcea.TotalBytesToReceive} bytes to receive.");
                });

                downloadCompletedObservable.Select(ep => ep.EventArgs)
                .Subscribe(_ => Console.WriteLine("Download file complete."));


                client.DownloadFileAsync(new Uri(ConstUrl.FinancialStatementDataSetBaseUrl + CurrentSessionParams.FileName + ".zip"), localTemp + CurrentSessionParams.LocalDirName + "\\" + CurrentSessionParams.FileName + ".zip");
                // // wait for the current thread to complete, since the an async action will be on a new thread.
                while (client.IsBusy)
                {
                }
            }
        }
Exemplo n.º 4
0
        public void OnProcessing(FeedDataSet Feed)
        {
            var localTemp = StaticUtilities.GetDataPath() + "\\" + CurrentSessionParams.LocalDirName + "\\" + CurrentSessionParams.FilesToExtract[Feed];

            if (File.Exists(localTemp))
            {
                //var observableCharactersSeq=Observable.Using<char,StreamReader>(()=>new StreamReader(new FileStream(localTemp,FileMode.Open)),
                //                    s=>(from c in s.ReadToEnd().ToCharArray() select c).ToObservable(NewThreadScheduler.Default));

                if (FeedDataSet.SUB == Feed)   //this needs to be removed later
                {
                    File.ReadLines(localTemp)
                    .Skip(1)
                    .ToObservable()
                    .ObserveOn(Scheduler.Default)
                    .Subscribe(l => OnLineProcessing(l, Feed), onError: OnError, onCompleted: OnImportFinished);
                }
            }
            else
            {
                Console.WriteLine("path Not Found");
            }
        }