private void ImportJuridicalPersonality() { ClearStatusMessage(); try { ImportSetting importSetting = null; var task = Util.GetMasterImportSettingAsync(Login, ImportFileType.JuridicalPersonality); ProgressDialog.Start(ParentForm, task, false, SessionKey); importSetting = task.Result; var definition = new JuridicalPersonalityFileDefinition(new DataExpression(ApplicationControl)); 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 LoadJuridicalPersonalityAsync(); importer.RegisterAsync = async unitOfWork => await RegisterForImportAsync(unitOfWork); var importResult = DoImport(importer, importSetting); if (!importResult) { return; } txtKana.Clear(); this.ActiveControl = txtKana; Modified = false; JuridicalPersonalityList.Clear(); var loadTask = LoadJuridicalPersonalityAsync(); ProgressDialog.Start(ParentForm, loadTask, false, SessionKey); JuridicalPersonalityList.AddRange(loadTask.Result); grdRemoveJuridicalPersonality.DataSource = new BindingSource(JuridicalPersonalityList, null); } catch (Exception ex) { Debug.Fail(ex.ToString()); NLogHandler.WriteErrorLog(this, ex, SessionKey); ShowWarningDialog(MsgErrImportErrorWithoutLog); } }
private async Task <bool> SaveKana() { List <JuridicalPersonality> newList = null; var succeeded = true; await ServiceProxyFactory.LifeTime(async factory => { var service = factory.Create <JuridicalPersonalityMasterClient>(); var juridical = new JuridicalPersonality(); juridical.CompanyId = CompanyId; juridical.UpdateBy = Login.UserId; juridical.CreateBy = Login.UserId; juridical.Kana = txtKana.Text.Trim(); JuridicalPersonalityResult result = await service.SaveAsync(SessionKey, juridical); if (!result.ProcessResult.Result) { succeeded = false; return; } else if (result.JuridicalPersonality != null) { newList = await LoadJuridicalPersonalityAsync(); txtKana.Clear(); } else { newList = await LoadJuridicalPersonalityAsync(); succeeded = false; } }); if (newList != null) { grdRemoveJuridicalPersonality.Rows.Clear(); JuridicalPersonalityList.AddRange(newList); grdRemoveJuridicalPersonality.DataSource = new BindingSource(JuridicalPersonalityList, null); } return(succeeded); }
private void PB1701_Load(object sender, EventArgs e) { SetScreenName(); try { var loadTask = new List <Task>(); if (ApplicationControl == null) { loadTask.Add(LoadApplicationControlAsync()); } loadTask.Add(LoadControlColorAsync()); if (Company == null) { loadTask.Add(LoadCompanyAsync()); } if (Authorities == null) { loadTask.Add(LoadFunctionAuthorities(MasterImport, MasterExport)); } var loadGridTask = LoadJuridicalPersonalityAsync(); loadGridTask.ContinueWith(task => JuridicalPersonalityList.AddRange(task.Result)); loadTask.Add(loadGridTask); ProgressDialog.Start(ParentForm, Task.WhenAll(loadTask), false, SessionKey); CreateGridTemplate(); grdRemoveJuridicalPersonality.DataSource = new BindingSource(JuridicalPersonalityList, null); Modified = false; this.ActiveControl = txtKana; BaseContext.SetFunction05Enabled(Authorities[MasterImport]); BaseContext.SetFunction06Enabled(Authorities[MasterExport]); } catch (Exception ex) { Debug.Fail(ex.ToString()); NLogHandler.WriteErrorLog(this, ex, SessionKey); } }
private void DeleteKana() { List <JuridicalPersonality> newList = null; CountResult deleteResult = null; var succeeded = false; var task = ServiceProxyFactory.LifeTime(async factory => { var service = factory.Create <JuridicalPersonalityMasterClient>(); deleteResult = await service.DeleteAsync(SessionKey, CompanyId, txtKana.Text); succeeded = deleteResult.ProcessResult.Result && deleteResult.Count > 0; if (!deleteResult.ProcessResult.Result) { return; } newList = await LoadJuridicalPersonalityAsync(); }); ProgressDialog.Start(ParentForm, task, false, SessionKey); if (succeeded) { DispStatusMessage(MsgInfDeleteSuccess); txtKana.Clear(); } else { ShowWarningDialog(MsgErrDeleteError); } if (newList != null) { grdRemoveJuridicalPersonality.Rows.Clear(); JuridicalPersonalityList.AddRange(newList); grdRemoveJuridicalPersonality.DataSource = new BindingSource(JuridicalPersonalityList, null); } }