예제 #1
0
 private void btnSave_Click_1(object sender, EventArgs e)
 {
     if (!model.IsValid())
     {
         MessageBox.Show(Translations.ValidationError, Translations.ValidationErrorTitle);
         return;
     }
     model.UserDefinedName = model.DisplayName;
     bindingSource1.EndEdit();
     DiseaseRepository r = new DiseaseRepository();
     int userid = ApplicationData.Instance.GetUserId();
     r.Save(model, userid);
     OnSave(model);
     this.Close();
 }
예제 #2
0
 void importerWorker_DoWork(object sender, DoWorkEventArgs e)
 {
     try
     {
         int userId = ApplicationData.Instance.GetUserId();
         WorkerPayload payload = (WorkerPayload)e.Argument;
         ImportResult result = payload.Importer.UpdateData(payload.FileName, userId, payload.Forms);
         if (result.WasSuccess)
         {
             DiseaseRepository repo = new DiseaseRepository();
             if (payload.DiseaseType == "CM")
                 repo.Save(result.Forms.Cast<DiseaseDistroCm>().ToList(), userId);
             else
                 repo.Save(result.Forms.Cast<DiseaseDistroPc>().ToList(), userId);
         }
         e.Result = result;
     }
     catch (Exception ex)
     {
         Logger log = new Logger();
         log.Error("Error updating distribution forms during split. SplitDistro:importerWorker_DoWork. ", ex);
         throw;
     }
 }