/// <summary> /// 保存编译好的服务组件或视图运行时代码或应用的第三方组件 /// </summary> /// <param name="asmName"> /// 服务or视图 eg: sys.HelloService or sys.CustomerView /// 应用 eg: sys.Newtonsoft.Json.dll,注意应用前缀防止不同app冲突 /// </param> /// <param name="asmData">已压缩</param> /// <param name="platform">仅适用于应用的第三方组件</param> internal static async ValueTask UpsertAssemblyAsync(MetaAssemblyType type, string asmName, byte[] asmData, DbTransaction txn, AssemblyPlatform platform = AssemblyPlatform.Common) { byte modelType; if (type == MetaAssemblyType.Application) { modelType = (byte)platform; } else if (type == MetaAssemblyType.Service) { modelType = (byte)ModelType.Service; } else if (type == MetaAssemblyType.View) { modelType = (byte)ModelType.View; } else { throw new ArgumentException("Not supported MetaAssemblyType"); } using var cmd = SqlStore.Default.MakeCommand(); cmd.Connection = txn.Connection; cmd.Transaction = txn; BuildDeleteMetaCommand(cmd, (byte)type, asmName); BuildInsertMetaCommand(cmd, (byte)type, asmName, modelType, asmData, true); await cmd.ExecuteNonQueryAsync(); }
internal static async ValueTask DeleteAssemblyAsync(MetaAssemblyType type, string asmName, DbTransaction txn) { using var cmd = SqlStore.Default.MakeCommand(); cmd.Connection = txn.Connection; cmd.Transaction = txn; BuildDeleteMetaCommand(cmd, (byte)type, asmName); await cmd.ExecuteNonQueryAsync(); }