public UpgradeInfo Upgrade(String channel) { var node = Session["Node"] as Node; if (node == null) { throw new ApiException(402, "节点未登录"); } // 默认Release通道 if (!Enum.TryParse <NodeChannels>(channel, true, out var ch)) { ch = NodeChannels.Release; } if (ch < NodeChannels.Release) { ch = NodeChannels.Release; } // 找到所有产品版本 var list = NodeVersion.GetValids(ch); // 应用过滤规则 var pv = list.FirstOrDefault(e => e.Match(node)); if (pv == null) { return(null); } //if (pv == null) throw new ApiException(509, "没有升级规则"); WriteHistory("自动更新", true, node, $"channel={ch} => [{pv.ID}] {pv.Version} {pv.Source} {pv.Executor}"); return(new UpgradeInfo { Version = pv.Version, Source = pv.Source, Executor = pv.Executor, Force = pv.Force, Description = pv.Description, }); }
public UpgradeInfo Upgrade(String channel, String token) { var node = DecodeToken(token, Setting.Current.TokenSecret); if (node == null) { throw new ApiException(402, "节点未登录"); } // 默认Release通道 if (!Enum.TryParse <NodeChannels>(channel, true, out var ch)) { ch = NodeChannels.Release; } if (ch < NodeChannels.Release) { ch = NodeChannels.Release; } // 找到所有产品版本 var list = NodeVersion.GetValids(ch); // 应用过滤规则,使用最新的一个版本 var pv = list.Where(e => e.Match(node)).OrderByDescending(e => e.Version).FirstOrDefault(); if (pv == null) { return(null); } //if (pv == null) throw new ApiException(509, "没有升级规则"); WriteHistory(node, "自动更新", true, $"channel={ch} => [{pv.ID}] {pv.Version} {pv.Source} {pv.Executor}"); return(new UpgradeInfo { Version = pv.Version, Source = pv.Source, Executor = pv.Executor, Force = pv.Force, Description = pv.Description, }); }
public UpgradeInfo Upgrade(String channel, String token) { var node = DecodeToken(token, Setting.Current.TokenSecret); if (node == null) { throw new ApiException(402, "节点未登录"); } // 默认Release通道 if (!Enum.TryParse <NodeChannels>(channel, true, out var ch)) { ch = NodeChannels.Release; } if (ch < NodeChannels.Release) { ch = NodeChannels.Release; } // 找到所有产品版本 var list = NodeVersion.GetValids(ch); // 应用过滤规则,使用最新的一个版本 var pv = list.Where(e => e.Match(node)).OrderByDescending(e => e.Version).FirstOrDefault(); if (pv == null) { return(null); } //if (pv == null) throw new ApiException(509, "没有升级规则"); var url = pv.Version; if (!url.StartsWithIgnoreCase("http://", "https://")) { var uri = Request.GetRawUrl().ToString(); var p = uri.IndexOf('/', "https://".Length); if (p > 0) { uri = uri[..p];