示例#1
0
        /// <summary>合并</summary>
        public void Merge(frmIndexSubmissionPresenter presenter, MergeContext context)
        {
            LoadFromApiService(false, false);
            var souceTable = LoadMergeSource(context);

            MergeSourceToTarget(context, souceTable);
        }
示例#2
0
        /// <summary>批量提交</summary>
        public void BatchSubmit(frmIndexSubmissionPresenter presenter, bool parallel, bool retry)
        {
            var context = this.Context;

            LoadFromApiService(false, true);
            var title = string.Empty;

            if (retry)
            {
                context.Splash = presenter.WorkItem.Services.Get <ISplashService>();
                context.ResetProgress();
                context.Move();
                title = "重新提交成果数据...";
            }
            else
            {
                this.Context          = context = new IndexSubmissionContext();
                context.View          = presenter.View;
                context.Splash        = presenter.WorkItem.Services.Get <ISplashService>();
                context.WorkItem      = presenter.WorkItem;
                context.Values        = new ConcurrentQueue <SubmissionProduct>();
                context.FailureValues = new ConcurrentQueue <SubmissionProduct>();
                context.ResetProgress();
                context.ProgressChanged += presenter.View.HandleProgressChanged;
                context.AppDataService   = GetService <IAppDataServiceWrapper>();
                context.AppDataService.ResetServiceUrl();
                context.IndexerService = GetService <IIndexerService>();
                context.IndexerService.As <IApiServiceWrapper>().ResetServiceUrl();
                LoadProducts(context);
                title = "正在提交成果数据...";
            }
            var products = context.Values.ToArray();

            context.View.PopuldateProducts(products);
            context.StartProgress(title, products.Length);
            if (parallel)
            {
                context.Values.AsParallel <SubmissionProduct>()
                .ForAll(product => UploadProduct(context, product));
            }
            else
            {
                while (context.Values.Count > 0)
                {
                    SubmissionProduct product;
                    if (!context.Values.TryDequeue(out product))
                    {
                        continue;
                    }
                    UploadProduct(context, product);
                }
            }
            context.FinishProgress("提交成果数据完成");
        }