private async Task <bool> HasValueAsync(ImporterSetting setting, CancellationToken token = default(CancellationToken)) { var query = @" SELECT 1 WHERE EXISTS ( SELECT * FROM [dbo].[ImporterSetting] s WHERE s.Id = s.Id"; if (setting.Id != 0) { query += @" AND s.Id = @Id"; } else { query += @" AND s.CompanyId = @CompanyId AND s.FormatId = @FormatId AND s.Code = @Code"; } query += @" )"; return((await dbHelper.ExecuteAsync <int?>(query, setting, token)).HasValue); }
public Task <ImporterSetting> SaveAsync(ImporterSetting setting, CancellationToken token = default(CancellationToken)) { var query = @" MERGE INTO ImporterSetting AS target USING (SELECT @CompanyId CompanyId , @FormatId FormatId , @Code Code ) As source ON ( target.CompanyId = source.CompanyId AND target.FormatId = source.FormatId AND target.Code = source.Code ) WHEN MATCHED THEN UPDATE SET Code = @Code ,Name = @Name ,InitialDirectory = @InitialDirectory ,StartLineCount = @StartLineCount ,IgnoreLastLine = @IgnoreLastLine ,AutoCreationCustomer = @AutoCreationCustomer ,PostAction = @PostAction ,UpdateBy = @UpdateBy ,UpdateAt = GETDATE() WHEN NOT MATCHED THEN INSERT ( CompanyId, FormatId, Code, Name, InitialDirectory, EncodingCodePage, StartLineCount, IgnoreLastLine, AutoCreationCustomer, PostAction, CreateBy, CreateAt, UpdateBy, UpdateAt) VALUES (@CompanyId, @FormatId, @Code, @Name, @InitialDirectory, @EncodingCodePage, @StartLineCount, @IgnoreLastLine, @AutoCreationCustomer, @PostAction, @CreateBy, GETDATE(),@UpdateBy, GETDATE()) OUTPUT inserted.*; "; return(dbHelper.ExecuteAsync <ImporterSetting>(query, setting, token)); }
public Task <IEnumerable <ImporterSetting> > GetAsync(ImporterSetting setting, CancellationToken token = default(CancellationToken)) { var query = @" SELECT * FROM ImporterSetting WHERE Id = Id"; if (setting.Id != 0) { query += @" AND Id = @Id"; } else { query += @" AND CompanyId = @CompanyId"; } if (setting.FormatId != 0) { query += @" AND FormatId = @FormatId"; } if (!string.IsNullOrWhiteSpace(setting.Code)) { query += @" AND Code = @Code"; } query += @" ORDER BY CompanyId ASC , FormatId ASC , Code ASC"; return(dbHelper.GetItemsAsync <ImporterSetting>(query, setting, token)); }
public async Task <IEnumerable <ImporterSettingDetail> > GetAsync(ImporterSetting setting, CancellationToken token = default(CancellationToken)) { var byId = setting.Id != 0; var hasValue = await HasValueAsync(setting, token); var query = ""; if (hasValue) { query = @" SELECT d.* , s.[UpdateAt] [ImporterSettingUpdateAt] , b.[FieldName] , b.[ImportDivision] [BaseImportDivision] , b.[AttributeDivision] [BaseAttributeDivision] , b.[TargetColumn] FROM [dbo].[ImporterSettingDetail] d INNER JOIN [dbo].[ImporterSetting] s ON s.[Id] = d.[ImporterSettingId] INNER JOIN [dbo].[ImporterSettingBase] b ON b.[Sequence] = d.[Sequence] AND b.[FormatId] = s.[FormatId] WHERE d.[ImporterSettingId] = d.[ImporterSettingId]"; if (byId) { query += @" AND s.[Id] = @Id"; } else { query += @" AND s.[CompanyId] = @CompanyId AND s.[FormatId] = @FormatId AND s.[Code] = @Code"; } query += @" ORDER BY d.[ImporterSettingId] ASC , d.[Sequence] ASC"; } else { query = @" SELECT 0 [ImporterSettingId] , b.[Sequence] , b.[FieldName] , b.[ImportDivision] [BaseImportDivision] , b.[AttributeDivision] [BaseAttributeDivision] , b.[TargetColumn] FROM [dbo].[ImporterSettingBase] b WHERE b.[FormatId] = @FormatId ORDER BY b.[FormatId] ASC , b.[Sequence] ASC"; } return(await dbHelper.GetItemsAsync <ImporterSettingDetail>(query, setting, token)); }
public async Task <ImporterSetting> SaveAsync(ImporterSetting setting, CancellationToken token = default(CancellationToken)) { using (var scope = transactionScopeBuilder.Create()) { var result = await addImporterSettingQueryProcessor.SaveAsync(setting, token); result.Details = new List <ImporterSettingDetail>(); foreach (var x in setting.Details) { x.ImporterSettingId = result.Id; result.Details.Add(await addImporterSettingDetailQueryProcessor.SaveAsync(x, token)); } scope.Complete(); return(result); } }
private async Task SaveImporterSettingAsync() { var header = new ImporterSetting(); header.CompanyId = CompanyId; header.Code = txtPatternNumber.Text; header.Name = txtPatternName.Text.Trim(); header.FormatId = FormatId; header.InitialDirectory = txtInitialDirectory.Text.Trim(); header.StartLineCount = Convert.ToInt32(nmbStartLineCount.Value); if (rdoNoAction.Checked) { header.PostAction = 0; } else if (rdoDelete.Checked) { header.PostAction = 1; } else if (rdoAddDate.Checked) { header.PostAction = 2; } header.IgnoreLastLine = cbxIgnoreLastLine.Checked ? 1 : 0; header.UpdateBy = Login.UserId; header.UpdateAt = updateAt; header.CreateBy = Login.UserId; var details = PrepareSaveImporterSettingDetail(); ImporterSettingAndDetailResult result = null; await ServiceProxyFactory.DoAsync <ImporterSettingServiceClient>(async client => result = await client.SaveAsync(SessionKey, header, details.ToArray())); if (result == null || result.ImporterSetting == null || result.ImporterSettingDetail == null) { ShowWarningDialog(MsgErrSaveError); return; } Clear(); DispStatusMessage(MsgInfSaveSuccess); }
private async Task LoadImporterSettingAsync(string code) { await ServiceProxyFactory.LifeTime(async factory => { var service = factory.Create <ImporterSettingServiceClient>(); if (!string.IsNullOrEmpty(code)) { var result = await service.GetHeaderByCodeAsync(SessionKey, CompanyId, FormatId, code); if (result.ImporterSetting != null) { Invoke(new System.Action(() => { ImporterSetting = result.ImporterSetting; txtFilePath.Text = ImporterSetting.InitialDirectory; lblName.Text = ImporterSetting.Name; txtFilePath.Enabled = !LimitAccessFolder; txtFilePath.ReadOnly = LimitAccessFolder; btnFilePath.Enabled = true; txtPatternNo.Enabled = false; btnNumberSearch.Enabled = false; if (!LimitAccessFolder) { ActiveControl = txtFilePath; txtFilePath.Focus(); } ClearStatusMessage(); errorFlag = 0; BaseContext.SetFunction05Enabled(false); })); Modified = false; } else { ImporterSetting = new ImporterSetting(); txtPatternNo.Clear(); lblName.Clear(); txtFilePath.Clear(); errorFlag = 1; Modified = true; BaseContext.SetFunction05Enabled(true); ShowWarningDialog(MsgWngNotRegistPatternNo, code); } } }); }
public async Task <int> Delete(ImporterSetting setting, CancellationToken token) => await importSettingProcessor.DeleteAsync(setting.Id, token);
public async Task <ImporterSetting> Save(ImporterSetting setting, CancellationToken token) => await importSettingProcessor.SaveAsync(setting, token);
public async Task <IEnumerable <ImporterSettingDetail> > GetDetail(ImporterSetting setting, CancellationToken token) => (await importSettingDetailProcessor.GetAsync(setting, token)).ToArray();
public async Task <ImporterSettingAndDetailResult> SaveAsync(string SessionKey, ImporterSetting ImpSetting, ImporterSettingDetail[] ImpSettingDetail) { return(await authorizationProcessor.DoAuthorizeAsync(SessionKey, async token => { ImpSetting.Details = new List <ImporterSettingDetail>(ImpSettingDetail); var result = await importSettingProcessor.SaveAsync(ImpSetting, token); return new ImporterSettingAndDetailResult { ProcessResult = new ProcessResult { Result = true }, ImporterSetting = result, ImporterSettingDetail = result.Details.ToArray(), }; }, logger)); }
public async Task <ActionResult <IEnumerable <ImporterSetting> > > GetHeader(ImporterSetting setting, CancellationToken token) => (await importSettingProcessor.GetAsync(setting, token)).ToArray();
public async Task <IEnumerable <ImporterSettingDetail> > GetAsync(ImporterSetting setting, CancellationToken token = default(CancellationToken)) => await importerSettingDetailQueryProcessor.GetAsync(setting, token);
public Processor(ICondition condition, ImporterSetting setting) { m_condition = condition; m_setting = setting; }