public async Task <ZipFileSettings> GetZipFileSettingsAsync(string settingId) { var dic = new Dictionary <int, ZipFileSettings>(); await this.Connection.QueryAsync <ZipFileSettings, ImageSource, ZipFileSettings>( this.getZipFileSettingsSql(settingId), (z, i) => { ZipFileSettings entry = null; if (!dic.TryGetValue(z.ID.Value, out entry)) { dic.Add(z.ID.Value, z); entry = z; } entry.ImageSources.Add(i); return(entry); }, new { ID = settingId }, splitOn : "IMAGE_SOURCE_PATH" ); return(dic.Values.ToList().FirstOrDefault()); }
/// <summary> /// zipファイル設定を保存します。 /// </summary> /// <param name="settings">保存するzipファイル設定を表すZipFileSettings。</param> /// <returns>zipファイル設定IDを表すlong?。</returns> private long?saveZipSettings(ZipFileSettings settings) { using (var da = new ZipFileSettingsRepository()) { using (var tran = da.BeginTransaction()) { try { var id = da.Save(settings); if (!id.HasValue) { tran.Rollback(); return(null); } tran.Commit(); return(id); } catch (Exception ex) { tran.Rollback(); throw; } } } }
/// <summary> /// 作成するzipファイルの設定を保存します。 /// </summary> /// <param name="zipFile">保存するzipファイル設定を表すZipFileSettings。</param> /// <returns>zipファイルの設定IDを表すlong?</returns> public long?SaveZipSettings(ZipFileSettings zipFile) { zipFile.InsertDate = DateTime.Now; this.Connection.Execute(this.getSaveZipSettingsSql(), new { EXTRACT_FOLDER = zipFile.ImageFilesExtractedFolder.Value, FOLDER_NAME_SEQ = zipFile.FolderNameSequenceDigit.Value, FOLDER_NAME_TEMPLATE = zipFile.FolderNameTemplate.Value, FILE_NAME_TEMPLATE = zipFile.FileNameTemplate.Value, INSERT_DATE = zipFile.InsertDate }); return(this.getAutoNumber("ZIP_FILE_SETTINGS")); }
/// <summary> /// zipファイルの作成を開始します。 /// </summary> /// <param name="settings">zipファイル設定を表すZipFileSettings。</param> /// <param name="appSettings">アプリの設定を表すIImaZipCoreProto01Settings。</param> /// <returns>zipファイルの作成開始Task。</returns> public Task StartCreateZipAsync(ZipFileSettings settings, IImaZipCoreProto01Settings appSettings) { var zipId = this.saveZipSettings(settings); if (!zipId.HasValue) { return(Task.CompletedTask); } // ZipBookCreator起動 Process.Start(new ProcessStartInfo() { UseShellExecute = true, FileName = Path.Combine(AssemblyUtility.GetExecutingPath(), appSettings.CreatorExeFileName), Arguments = zipId.Value.ToString() }); return(Task.CompletedTask); }
/// <summary>ZipFileSettingsを保存します。</summary> /// <param name="settings">保存するZipFileSettings。</param> /// <returns>保存したZipFileSettingsのIDを表すlong?。</returns> public long?Save(ZipFileSettings settings) { settings.InsertDate = DateTime.Now; this.Connection.Execute(this.getSaveZipSettingsSql(), new { EXTRACT_FOLDER = settings.ImageFilesExtractedFolder.Value, FOLDER_NAME_SEQ = settings.FolderNameSequenceDigit.Value, FOLDER_NAME_TEMPLATE = settings.FolderNameTemplate.Value, FILE_NAME_TEMPLATE = settings.FileNameTemplate.Value, INSERT_DATE = settings.InsertDate }); var id = this.getAutoNumber("ZIP_FILE_SETTINGS"); this.saveImageSources(settings.ImageSources, id); return(id); }
/// <summary>IDを指定してZipFileSettingsを取得します。</summary> /// <param name="id">ZipFileSettingsのIDを表す文字列。</param> /// <returns>IDを指定して取得したZipFileSettings。</returns> public ZipFileSettings GetById(string id) { var dic = new Dictionary <int, ZipFileSettings>(); this.Connection.Query <ZipFileSettings, ImageSource, ZipFileSettings>( this.createGetByIdSql(id), (z, i) => { ZipFileSettings entry = null; if (!dic.TryGetValue(z.ID.Value, out entry)) { dic.Add(z.ID.Value, z); entry = z; } entry.ImageSources.Add(i); return(entry); }, new { ID = id }, splitOn: "IMAGE_SOURCE_PATH"); return(dic.Values.ToList().FirstOrDefault()); }