Ejemplo n.º 1
0
        /// <summary>インポート共通処理</summary>
        /// <typeparam name="TModel">Model</typeparam>
        /// <typeparam name="TIdentity">Id特定方法</typeparam>
        /// <param name="importer">インポーター</param>
        /// <param name="setting">取込設定</param>
        /// <param name="importSuccessPostAction">取込成功後のクリア処理など メッセージ表示より前に実施する項目</param>
        /// <returns></returns>
        protected bool DoImport <TModel, TIdentity>(Import.CsvImporter <TModel, TIdentity> importer,
                                                    ImportSetting setting,
                                                    Action importSuccessPostAction = null)
            where TModel : class, new()
        {
            using (var form = ApplicationContext.Create(nameof(PH9907)))
            {
                var screen = form.GetAll <PH9907>().First();
                var result = screen.ConfirmImportSetting(ParentForm, importer, setting);
                if (result != DialogResult.OK)
                {
                    DispStatusMessage(Constants.MsgInfCancelProcess, "インポート");
                    return(false);
                }
                importer.ErrorLogPath = setting.GetErrorLogPath();
            }
            ImportResult res   = null;
            DialogResult pgres = DialogResult.None;

            NLogHandler.WriteDebug(this, $"{typeof(TModel).Name}:インポート処理開始");
            try
            {
                pgres = ProgressDialog.Start(ParentForm, async(cancel, progress) =>
                                             res = await importer.ImportAsync(setting.ImportFileName,
                                                                              (Import.ImportMethod)setting.ImportMode, cancel, progress),
                                             true, SessionKey);
            }
            catch (Exception ex)
            {
                NLogHandler.WriteErrorLog(this, ex.InnerException, SessionKey);
            }
            NLogHandler.WriteDebug(this, $"{typeof(TModel).Name}:インポート処理終了");
            var importResult = false;

            if (pgres == DialogResult.Cancel)
            {
                DispStatusMessage(Constants.MsgInfCancelProcess, "インポート");
            }
            else if (pgres == DialogResult.Abort)
            {
                DispStatusMessage(Constants.MsgErrImportErrorWithoutLog);
            }
            else if (res != null)
            {
                var message = XmlMessenger.GetMessageInfo(res.GetMessageId());
                if (message.Category == MessageCategory.Information)
                {
                    importSuccessPostAction?.Invoke();
                    DispStatusMessage(message);
                    importResult = true;
                }
                else
                {
                    ShowWarningDialog(message.ID);
                }
            }
            return(importResult);
        }
Ejemplo n.º 2
0
        protected void ShowWarningDialog(string messageId, params string[] args)
        {
            var message = XmlMessenger.GetMessageInfo(messageId, args);

            if (IsWarningRequired)
            {
                this.Confirmed(message.ShowMessageBox(ParentForm));
            }
            DispStatusMessage(message);
        }
Ejemplo n.º 3
0
 protected void DispStatusMessage(string messageId, params string[] args)
 {
     try
     {
         DispStatusMessage(XmlMessenger.GetMessageInfo(messageId, args));
     }
     catch (Exception)
     {
     }
 }
Ejemplo n.º 4
0
        protected DialogResult ShowConfirmDialogYesNoCancel(string messageId, params string[] args)
        {
            if (!IsConfirmRequired)
            {
                return(DialogResult.No);
            }
            var message = XmlMessenger.GetMessageInfo(messageId, args);
            var result  = message.ShowMessageBox(ParentForm);

            this.Confirmed(result);
            return(result);
        }
Ejemplo n.º 5
0
        protected bool ShowConfirmDialog(string messageId, params string[] args)
        {
            if (!IsConfirmRequired)
            {
                return(true);
            }

            var message = XmlMessenger.GetMessageInfo(messageId, args);
            var result  = message.ShowMessageBox(ParentForm);

            this.Confirmed(result);
            return(result == DialogResult.Yes);
        }
Ejemplo n.º 6
0
 private string GetMesasge(string id, params string[] args)
 {
     return(XmlMessenger.GetMessageInfo(id, args)?.Text);
 }
Ejemplo n.º 7
0
 protected void DispStatusMessage(string messageId, params string[] args)
 => DispStatusMessage(XmlMessenger.GetMessageInfo(messageId, args));