Beispiel #1
0
        public static void CreateDownload(WorkerPayload payload)
        {

            SaveFileDialog sfd = new SaveFileDialog();
            sfd.Filter = Translations.ExcelFiles + " (*.xlsx)|*.xlsx";
            sfd.DefaultExt = ".xlsx";
            sfd.FileName = payload.FileName;

            if (sfd.ShowDialog() == DialogResult.OK)
            {
                payload.FileName = sfd.FileName;
                BackgroundWorker worker = new BackgroundWorker();
                worker.DoWork += worker_DoWork;
                worker.RunWorkerAsync(payload);
            }
        }
Beispiel #2
0
        private void StepCategory_Load(object sender, EventArgs e)
        {
            if (!DesignMode)
            {
                Localizer.TranslateControl(this);


                Dictionary<int, Disease> diseases = new Dictionary<int, Disease>();
                foreach (var distro in options.DistrosCm)
                    if (!diseases.ContainsKey(distro.Disease.Id))
                        diseases.Add(distro.Disease.Id, distro.Disease);
                foreach (var distro in options.DistrosPc)
                    if (!diseases.ContainsKey(distro.Disease.Id))
                        diseases.Add(distro.Disease.Id, distro.Disease);

                if (diseases.Count == 0)
                    DoNext();

                foreach (var disease in diseases.Values.OrderBy(d => d.DisplayName))
                {
                    var index = tblNewUnits.RowStyles.Add(new RowStyle { SizeType = SizeType.AutoSize });
                    var lblName = new H3bLabel { AutoSize = true, Text = disease.DisplayName, Margin = new Padding(0, 5, 10, 5) };
                    tblNewUnits.Controls.Add(lblName, 0, index);

                    var lnk = new H3Link { Text = Translations.DownloadImportFile, Margin = new Padding(0, 5, 10, 5) };
                    tblNewUnits.Controls.Add(lnk, 1, index);
                    lnk.ClickOverride += () =>
                    {
                        List<IHaveDynamicIndicatorValues> forms = new List<IHaveDynamicIndicatorValues>();
                        if (disease.DiseaseType == "CM")
                            forms = options.DistrosCm.Where(d => d.Disease.Id == disease.Id).Cast<IHaveDynamicIndicatorValues>().ToList();
                        else
                            forms = options.DistrosPc.Where(d => d.Disease.Id == disease.Id).Cast<IHaveDynamicIndicatorValues>().ToList();
                        DistroImporter importer = new DistroImporter();
                        importer.SetType(disease.Id);
                        var payload = new WorkerPayload
                        {
                            FileName = Util.CleanFilename(disease.DisplayName) + "_" + options.SplitType.ToString() + DateTime.Now.ToString("yyyyMMdd") + ".xlsx",
                            Importer = importer,
                            Forms = forms
                        };
                        CreateDownload(payload);
                    };
                    var lnk2 = new H3Link { Text = Translations.UploadImportFile, Margin = new Padding(0, 5, 10, 5) };
                    tblNewUnits.Controls.Add(lnk2, 2, index);
                    lnk2.ClickOverride += () =>
                    {
                        Upload(disease);
                    };
                }
            }
        }
Beispiel #3
0
        private void Upload(Disease disease)
        {
            List<IHaveDynamicIndicatorValues> forms = new List<IHaveDynamicIndicatorValues>();
            if (disease.DiseaseType == "CM")
                forms = options.DistrosCm.Where(d => d.Disease.Id == disease.Id).Cast<IHaveDynamicIndicatorValues>().ToList();
            else
                forms = options.DistrosPc.Where(d => d.Disease.Id == disease.Id).Cast<IHaveDynamicIndicatorValues>().ToList();
            DistroImporter importer = new DistroImporter();
            importer.SetType(disease.Id);
            var payload = new WorkerPayload
            {
                Importer = importer,
                Forms = forms, 
                DiseaseType = disease.DiseaseType
            };
            OpenFileDialog ofd = new OpenFileDialog();
            ofd.Filter = Translations.ExcelFiles + " (*.xlsx)|*.xlsx";
            ofd.DefaultExt = ".xlsx";

            if (ofd.ShowDialog() == DialogResult.OK)
            {
                OnSwitchStep(new WorkingStep(Translations.ImportingFile));
                payload.FileName = ofd.FileName;
                BackgroundWorker importerWorker = new BackgroundWorker();
                importerWorker.DoWork += importerWorker_DoWork;
                importerWorker.RunWorkerCompleted += importerWorker_RunWorkerCompleted;
                importerWorker.RunWorkerAsync(payload);
            }
        }