/// <summary> /// 保存表单(新增、修改) /// </summary> /// <param name="keyValue">主键值</param> /// <param name="entity">实体对象</param> /// <returns></returns> public void SaveForm(string keyValue, AppPackageEntity entity) { try { service.SaveForm(keyValue, entity); } catch (Exception) { throw; } }
public ActionResult SaveForm(string keyValue, AppPackageEntity entity) { packagebll.SaveForm(keyValue, entity); return(Success("操作成功。")); }
public async Task <(AppInfo appInfo, UploadStatusType status)> Upload(Application application) { try { // Blob にパッケージを保存 CloudBlobContainer container = blobClient.GetContainerReference(PackageContainerName); await container.CreateIfNotExistsAsync(); var appPackageName = GetAppPackageName(application); var appPackageId = $"{appPackageName}_{application.AppPackage.Name}"; CloudBlockBlob blockBlob_upload = container.GetBlockBlobReference(appPackageId); await blockBlob_upload.UploadFromFileAsync(application.AppPackage); // 依存ファイルを保存 var dependencyIds = new List <string>(); foreach (var dep in application.Dependencies) { var parent = System.IO.Directory.GetParent(dep.Path); var architecture = SupportedArchitectureHelper.StringToSupportedArchitectureType(parent.Name); var dependencyId = $"{appPackageName}_{architecture}_{dep.Name}"; dependencyIds.Add(dependencyId); CloudBlockBlob depBlockBlob = container.GetBlockBlobReference(dependencyId); await depBlockBlob.UploadFromFileAsync(dep); } // Table にバージョンごとのパッケージのデータを保存 { CloudTable table = tableClient.GetTableReference(PackageContainerName); await table.CreateIfNotExistsAsync(); // Create the TableOperation object that inserts the customer entity. var appPackageEntity = new AppPackageEntity(application.Name, application.Version.ToString()) { Developer = application.DeveloperName, Name = application.Name, AppVersion = application.Version, AppPackageId = appPackageId, DependencyIds = dependencyIds, SupportedArchitecture = application.SupportedArchitecture }; TableOperation insertOperation = TableOperation.InsertOrReplace(appPackageEntity); // Execute the insert operation. await table.ExecuteAsync(insertOperation); } var isNewlyUploaded = true; AppInfo appInfo; // appinfo テーブルにパッケージのデータを保存 { CloudTable appInfoTable = tableClient.GetTableReference(AppInfoTableName); await appInfoTable.CreateIfNotExistsAsync(); // SupportedArchitecture は最新のものに設定 var appInfoEntry = new AppInfoEntity(application.Name) { Description = "", Developer = application.DeveloperName, SupportedArchitecture = application.SupportedArchitecture }; // すでにデータが保存されているかどうかチェック TableOperation retrieveOperation = TableOperation.Retrieve <AppInfoEntity>(application.Name, ""); TableResult retrievedResult = await appInfoTable.ExecuteAsync(retrieveOperation); AppInfoEntity updateEntity = (AppInfoEntity)retrievedResult.Result; if (updateEntity == null) { appInfoEntry.CreateAt = DateTime.Now; } else { appInfoEntry.CreateAt = updateEntity.CreateAt; appInfoEntry.Description = updateEntity.Description; appInfoEntry.AppVersions = updateEntity.AppVersions; isNewlyUploaded = false; } if (appInfoEntry.AppVersions == null) { appInfoEntry.AppVersions = new HashSet <AppVersion>(); } appInfoEntry.AppVersions.Add(application.Version); TableOperation insertOperation = TableOperation.InsertOrReplace(appInfoEntry); await appInfoTable.ExecuteAsync(insertOperation); appInfo = appInfoEntry.ConvertToAppInfo(); } if (isNewlyUploaded) { return(appInfo, UploadStatusType.NewlyUploaded); } else { return(appInfo, UploadStatusType.Updated); } } catch (Exception e) { Console.WriteLine(e.ToString()); return(null, UploadStatusType.NetworkError); } }
public async Task <bool> DeleteApplication(string appName, string version) { try { Application application; // Application の情報を取得 { CloudTable table = tableClient.GetTableReference(PackageContainerName); TableOperation retrieveOperation = TableOperation.Retrieve <AppPackageEntity>(appName, version); // Execute the retrieve operation. TableResult retrievedResult = await table.ExecuteAsync(retrieveOperation); // Print the phone number of the result. if (retrievedResult.Result == null) { return(false); } var appPackageEntity = (AppPackageEntity)retrievedResult.Result; application = appPackageEntity.ConvertToApplication(); } // appinfo テーブルからパッケージの情報を削除 { CloudTable appInfoTable = tableClient.GetTableReference(AppInfoTableName); // すでにデータが保存されているかどうかチェック TableOperation retrieveOperation = TableOperation.Retrieve <AppInfoEntity>(application.Name, ""); TableResult retrievedResult = await appInfoTable.ExecuteAsync(retrieveOperation); AppInfoEntity appInfoEntity = (AppInfoEntity)retrievedResult.Result; if (appInfoEntity != null) { appInfoEntity.AppVersions?.Remove(application.Version); TableOperation insertOperation = TableOperation.InsertOrReplace(appInfoEntity); await appInfoTable.ExecuteAsync(insertOperation); } } // バージョンごとのパッケージのデータを削除 { CloudTable appPackageTable = tableClient.GetTableReference(PackageContainerName); TableOperation retrieveOperation = TableOperation.Retrieve <AppPackageEntity>(application.Name, application.Version.ToString()); TableResult retrievedResult = await appPackageTable.ExecuteAsync(retrieveOperation); AppPackageEntity appPackageEntity = (AppPackageEntity)retrievedResult.Result; if (appPackageEntity != null) { TableOperation deleteOperation = TableOperation.Delete(appPackageEntity); await appPackageTable.ExecuteAsync(deleteOperation); } } // app package を削除 var appPackage = await DeleteBrob(application.AppPackageId); foreach (var depId in application.DependencyIds) { var dep = await DeleteBrob(depId); } return(true); } catch (Exception e) { return(false); } }