Beispiel #1
0
 /// <summary>
 /// СЮДА МЫ ПОПАДАЕМ ПОСЛЕ ТОГО, КАК БЫЛА ЗАВЕРШЕНА ПЕРЕДАЧА ФАЙЛА И ЗАКРЫТА ФОРМА МАСТЕРА ИМПОРТА
 /// </summary>
 private void ImportExamination_ExecuteCompleted(object sender, ActionBaseEventArgs e)
 {
     if (importWizard != null)
     {
         importWizard.Dispose();
         importWizard = null;
     }
 }
Beispiel #2
0
        /// <summary>
        /// !!! ВСЕ ЭТО НАДО ПЕРЕДЕЛАТЬ КАК ЗДЕСЬ --> http://www.devexpress.com/Support/Center/Example/Details/E1487
        /// </summary>
        private void ImportExamination_Execute(object sender, EventArgs e)
        {
            importPatient = null;
            importExamination = null;
            isImportCompleted = false;
            importWizard = null;
            showWelcomePage = true;

               OpenFileDialog openFileDialog = new OpenFileDialog()
            {
                CheckFileExists = true,
                Multiselect = true, //false,
                CheckPathExists = true,
                Filter = GetDialogFilter(), //CaptionHelper.GetLocalizedText("CustomFomrsMessages", "importFileDialogFileter"),
                Title = CaptionHelper.GetLocalizedText("CustomFomrsMessages", "importFiledialogTitle")
            };

            if (openFileDialog.ShowDialog() == DialogResult.OK)
            {
                //importFileFullName = openFileDialog.FileName;

                var importFiles= openFileDialog.FileNames;

                int totalFiles = importFiles.Count();
                int currentNumber = 0;

                foreach (string file in importFiles)
                {
                    if (importWizard != null)
                    {
                        if (importWizard.Canceled == true)  return;
                    }
                    currentNumber++;
                    importFileFullName = file;
                    // находим модуль по расширению файла
                    string extension = Path.GetExtension(importFileFullName);
                    dynamicModule = GetModuleByAssociationAttributeFileExtension(extension);

                    if (dynamicModule == null)
                    {
                        string error = String.Format(CaptionHelper.GetLocalizedText("CustomFomrsMessages", "FileImportError"), importFileFullName);
                        string desctiption = CaptionHelper.GetLocalizedText("CustomFomrsMessages", "ImportModuleError");

                        XtraMessageBox.Show(String.Format("{0}\n{1}",error, desctiption),"",MessageBoxButtons.OK, MessageBoxIcon.Error);
                        continue;
                        //return;
                    }

                    XElement header = null;
                    // получаем данные пациента из файла
                    try { header = dynamicModule.DoVerb(VerboseCommand.ExtractData, importFileFullName) as XElement; }
                    catch (Exception ex)
                    {
                        if (ex.Message == "ExaminationImportNoPatientDataFound")
                        {
                            header = null;
                            //XtraMessageBox.Show(CaptionHelper.GetLocalizedText("Exceptions", "ExaminationImportNoPatientDataFound"));
                        }
                        else
                        {
                            string error = String.Format(CaptionHelper.GetLocalizedText("CustomFomrsMessages", "FileImportError"), importFileFullName);
                            string desctiption = CaptionHelper.GetLocalizedText("Exceptions", "ExaminationImportWrongFileType");

                            XtraMessageBox.Show(String.Format("{0}\n{1}", error, desctiption),"",MessageBoxButtons.OK, MessageBoxIcon.Error);

                            isImportCompleted = false;
                            continue;
                            //return;
                        }
                    }

                    importData = CreateImportData(header);

                    //проверяем дату
                    if (importData.StartExaminationDateTime == DateTime.MinValue)
                    {// если дату из файла извлеч не удалось то ставим дату создания файла
                        FileInfo info = new FileInfo(importFileFullName);
                        importData.StartExaminationDateTime = info.CreationTime;
                    }

                    // Запускаем мастер импорта обследования в БД
                    importWizard = new ImportWizardForm();
                    string fullName = String.Format("{0} {1} {2}", importData.LastName, importData.FirstName, importData.MiddleName);

                    string title = String.Format("{0} ({1}/{2})", importFileFullName, currentNumber, totalFiles);

                    importWizard.SetTitle(title);

                    importWizard.SetMessage(string.Format(CaptionHelper.GetLocalizedText("CustomFomrsMessages", "ImportPatientCaptionSearch"), fullName), 1);
                    importWizard.SetMessage(CaptionHelper.GetLocalizedText("CustomFomrsMessages", "ImportPatientClosiestMatch"), 2);
                    importWizard.isLocalized = true;

                    // Коллекция пациентов для мастера импорта
                    XPCollection patientsCollection = (XPCollection)Application.MainWindow.View.ObjectSpace.CreateCollection(typeof(IPatient));

                    importWizard.WelcomePage.Visible = (showWelcomePage == true);// скрываем страницу приветствия если она уже показывалась

                    importWizard.DisplayPatientCollection(patientsCollection, fullName);
                    importWizard.WizardControl.NextClick += new WizardCommandButtonClickEventHandler(importWizardControl_NextClick);
                    importWizard.WizardControl.SelectedPageChanging += new WizardPageChangingEventHandler(importWizardControl_SelectedPageChanging);

                    importWizard.WizardControl.CustomizeCommandButtons += (o,a) =>
                    {
                        if (currentNumber != totalFiles)
                        {// если файл не последний
                            CompletionWizardPage page = a.Page as CompletionWizardPage;
                            if (page != null)
                            {// см. Предложение #4587
                                page.AllowCancel = true;
                                page.ProceedText = CaptionHelper.GetLocalizedText("CustomFomrsMessages", "DataImportMasterProceed");
                                a.FinishButton.Text = a.NextButton.Text; //"Далее >";
                            }
                        }
                    };

                    importWizard.WizardControl.CancelClick += (o, a) =>
                    {

                    };
                    importWizard.WizardCompleted += (args) =>
                    {
                        isImportCompleted = args;
                    };
                    importWizard.ShowDialog();
                }
            }
        }