Example #1
0
        private void Import()
        {
            ClearStatusMessage();
            try
            {
                ImportSetting importSetting = null;
                var           task          = Util.GetMasterImportSettingAsync(Login, ImportFileType.IgnoreKana);
                ProgressDialog.Start(ParentForm, task, false, SessionKey);
                importSetting = task.Result;

                var definition = new IgnoreKanaFileDefinition(new DataExpression(ApplicationControl));
                definition.ExcludeCategoryIdField.GetModelsByCode = val =>
                {
                    CategoriesResult result = null;
                    ServiceProxyFactory.LifeTime(factory =>
                    {
                        var categoryMaster = factory.Create <CategoryMasterClient>();
                        result             = categoryMaster.GetByCode(SessionKey, CompanyId, ExcludeCategoryType, val);
                    });
                    if (result.ProcessResult.Result)
                    {
                        return(result.Categories
                               .ToDictionary(c => c.Code));
                    }
                    return(new Dictionary <string, Category>());
                };

                var importer = definition.CreateImporter(m => m.Kana);
                importer.UserId      = Login.UserId;
                importer.UserCode    = Login.UserCode;
                importer.CompanyId   = CompanyId;
                importer.CompanyCode = Login.CompanyCode;
                importer.LoadAsync   = async() => await GetListAsync();

                importer.RegisterAsync = async unitOfWork => await RegisterForImportAsync(unitOfWork);

                var importResult = DoImport(importer, importSetting);
                if (!importResult)
                {
                    return;
                }
                IgnoreKanaList.Clear();
                Task <List <IgnoreKana> > loadTask = GetListAsync();
                Clear(true, false);
                ProgressDialog.Start(ParentForm, loadTask, false, SessionKey);
                IgnoreKanaList.AddRange(loadTask.Result);

                grdExcludeKanaList.DataSource = new BindingSource(IgnoreKanaList, null);
            }
            catch (Exception ex)
            {
                Debug.Fail(ex.ToString());
                NLogHandler.WriteErrorLog(this, ex, SessionKey);
                ShowWarningDialog(MsgErrImportErrorWithoutLog);
            }
        }
Example #2
0
        private void Delete()
        {
            if (!ValidateChildren())
            {
                return;
            }

            List <IgnoreKana> reloaded = null;

            try
            {
                if (!ShowConfirmDialog(MsgQstConfirmDelete))
                {
                    DispStatusMessage(MsgInfProcessCanceled);
                    return;
                }

                CountResult deleteResult = null;
                Task        task         = ServiceProxyFactory.LifeTime(async factory =>
                {
                    var service  = factory.Create <IgnoreKanaMasterClient>();
                    deleteResult = await service.DeleteAsync(SessionKey, CompanyId, CurrentEntry.Kana);

                    if ((deleteResult?.ProcessResult.Result ?? false) && deleteResult.Count > 0)
                    {
                        reloaded = await GetListAsync();
                        IgnoreKanaList.Clear();
                        Clear(true, withStatus: false);
                        IgnoreKanaList.AddRange(reloaded);

                        grdExcludeKanaList.DataSource = new BindingSource(IgnoreKanaList, null);
                        DispStatusMessage(MsgInfDeleteSuccess);
                    }
                    else
                    {
                        ShowWarningDialog(MsgErrDeleteError);
                    }
                });
                ProgressDialog.Start(ParentForm, task, false, SessionKey);
            }
            catch (Exception ex)
            {
                Debug.Fail(ex.ToString());
                ShowWarningDialog(MsgErrDeleteError);
                NLogHandler.WriteErrorLog(this, ex, SessionKey);
            }
        }
Example #3
0
        private void txtKana_Validated(object sender, EventArgs e)
        {
            try
            {
                ClearStatusMessage();
                string converted = txtKana.Text.Trim();

                IgnoreKana target = IgnoreKanaList.FirstOrDefault(k => k.Kana == converted);
                if (target != null)
                {
                    SetIgnoreKanaEntry(target);
                    BaseContext.SetFunction03Enabled(true);
                }
            }
            catch (Exception ex)
            {
                Debug.Fail(ex.ToString());
                NLogHandler.WriteErrorLog(this, ex, SessionKey);
            }
        }
Example #4
0
        private void PB1501_Load(object sender, EventArgs e)
        {
            try
            {
                SetScreenName();
                var loadTask = new List <Task>();
                if (Company == null)
                {
                    loadTask.Add(LoadCompanyAsync());
                }
                if (ApplicationControl == null)
                {
                    loadTask.Add(LoadApplicationControlAsync());
                }
                loadTask.Add(LoadControlColorAsync());
                loadTask.Add(LoadFunctionAuthorities(MasterImport, MasterExport));

                Task <List <IgnoreKana> > loadListTask = GetListAsync();
                loadListTask.ContinueWith(task => IgnoreKanaList.AddRange(task.Result));
                loadTask.Add(loadListTask);

                ProgressDialog.Start(ParentForm, Task.WhenAll(loadTask), false, SessionKey);

                var expression = new DataExpression(ApplicationControl);
                txtKana.MaxLength = expression.IgnoreKanaLength;

                InitializeKanaGrid();
                grdExcludeKanaList.DataSource = new BindingSource(IgnoreKanaList, null);
                Clear(true);
            }
            catch (Exception ex)
            {
                Debug.Fail(ex.ToString());
                NLogHandler.WriteErrorLog(this, ex, SessionKey);
            }
        }
Example #5
0
        private void Register()
        {
            if (!ValidateChildren())
            {
                return;
            }

            if (!ValidateEntries())
            {
                return;
            }

            ZeroLeftPaddingWithoutValidated();

            if (!ShowConfirmDialog(MsgQstConfirmSave))
            {
                DispStatusMessage(MsgInfProcessCanceled);
                return;
            }

            IgnoreKana        kana     = CreateModified();
            List <IgnoreKana> reloaded = null;
            IgnoreKanaResult  result   = null;

            try
            {
                kana.CompanyId = CompanyId;
                kana.UpdateBy  = Login.UserId;

                Task task = ServiceProxyFactory.LifeTime(async factory =>
                {
                    var service = factory.Create <IgnoreKanaMasterClient>();
                    result      = await service.SaveAsync(SessionKey, kana);
                });
                ProgressDialog.Start(ParentForm, task, false, SessionKey);
            }
            catch (Exception ex)
            {
                Debug.Fail(ex.ToString());
                ShowWarningDialog(MsgErrSaveError);
                NLogHandler.WriteErrorLog(this, ex, SessionKey);
            }

            if ((result?.ProcessResult.Result ?? false) && result.IgnoreKana != null)
            {
                var task = Task.Run(async() =>
                {
                    reloaded = await GetListAsync();
                });
                ProgressDialog.Start(ParentForm, task, false, SessionKey);
                IgnoreKanaList.Clear();
                Clear(true, withStatus: false);
                IgnoreKanaList.AddRange(reloaded);
                grdExcludeKanaList.DataSource = new BindingSource(IgnoreKanaList, null);
                DispStatusMessage(MsgInfSaveSuccess);
            }
            else
            {
                ShowWarningDialog(MsgErrSaveError);
            }
        }
Example #6
0
 private bool IsNewEntry()
 {
     return(!IgnoreKanaList.Contains(CurrentEntry));
 }