Exemplo n.º 1
0
        public void ProcessRequest(HttpContext context)
        {
            BaseProgress progress = (BaseProgress)context.Session["progress"];

            if (progress == null)
            {
                progress = new BaseProgress();
            }

            string json = JsonConvert.SerializeObject(progress);

            context.Response.Write(json);
        }
Exemplo n.º 2
0
        /// <summary>
        /// Construct a HttpDownloader with given task and configurations.
        /// </summary>
        /// <param name="task">Download task, must with HttpTarget.</param>
        /// <param name="folderProvider">Folder provider must not be null.</param>
        /// <param name="cacheProvider">Cache provider must not be null.</param>
        /// <param name="bufferProvider">Buffer provider must not be null.</param>
        public HttpDownloader(
            DownloadTask task,
            IFolderProvider folderProvider,
            ICacheStorageProvider cacheProvider,
            IBufferProvider bufferProvider
            ) : base(task)
        {
            Ensure.That(task.Target is HttpTarget, null,
                        opts => opts.WithMessage($"type of {nameof(task.Target)} must be {nameof(HttpTarget)}")
                        ).IsTrue();
            Ensure.That(folderProvider, nameof(folderProvider)).IsNotNull();
            Ensure.That(cacheProvider, nameof(cacheProvider)).IsNotNull();
            Ensure.That(bufferProvider, nameof(bufferProvider)).IsNotNull();

            this.folderProvider = folderProvider;
            this.cacheProvider  = cacheProvider;
            this.bufferProvider = bufferProvider;

            Progress = new BaseProgress();
            Speed    = SharedSpeedCalculatorFactory.NewSpeedCalculator();
            Progress.ProgressChanged += (sender, arg) => Speed.CurrentValue = Progress.DownloadedSize;
        }
Exemplo n.º 3
0
        protected void Wizard1_FinishButtonClick(object sender, WizardNavigationEventArgs e)
        {
            Session["progress"] = new BaseProgress();
            SetMappings();
            //Start Processing
            TableProcessorNS.TableProcessor tp = new TableProcessorNS.TableProcessor();
            tp.Progress = (BaseProgress)Session["progress"];

            string inputFileName  = Session["InputFileName"].ToString().Trim();
            string outputFileName = Path.Combine(Path.GetDirectoryName(inputFileName), TextBoxOutputFileName.Text);

            tp.InputDatabase          = DatabaseAdapterFactory.CreateReader(Path.GetExtension(inputFileName), CheckBoxEditMode.Checked);
            tp.InputDatabase.FileName = inputFileName;
            tp.InputDatabase.Connect(inputFileName);
            List <string> tables = (List <string>)Session["tables"];

            tp.tableName = tables[0];
            List <string> modules = (List <string>)Session["Modules"];

            tp.SetRecordProcessor(Server.MapPath(Path.Combine("Modules", modules[0])));

            tp.InputFieldNamesMap = TableProcessor.DeserializeFieldsMap((string)Session["Mappings"]);



            //If Edit mode - copy original and open for wrtiting
            if (CheckBoxEditMode.Checked)
            {
                tp.OutputDatabase = DatabaseAdapterFactory.CreateWriter(Path.GetExtension(outputFileName));
                tp.ProcessMode    = ProcessMode.pmEdit;
            }

            tp.OutputDatabase.FileName = outputFileName;

            Thread run = new Thread(new ThreadStart(tp.Process));

            run.Start();
            Response.Write("Process started");
        }