public IHttpActionResult DeleteUpgrade(Guid Id) => Json(UpgradeService.TryCatchAction( action: m => { var cacheUser = GetCacheUser; //获取缓存判断 if (!cacheUser.IsAdministrator) { throw new Exception("id:权限操作不足"); } else { return(m.DeleteUpgradeFile(Id)); } }));
public IHttpActionResult GetUpgradeTaskList([FromBody] GridRequestsModel grid) => Json(UpgradeService.TryCatchAction( action: m => { grid.CheckNotNull("grid"); var cacheUser = GetCacheUser; //查询条件 GridRequests request = new GridRequests(grid); //添加默认排序,只有排序未设置的情况下生效 request.AddDefaultSortCondition(new SortCondition("CreatedTime", ListSortDirection.Descending)); //获取查询集合 Expression <Func <UpgradeLog, bool> > predicate = FilterHelper.GetExpression <UpgradeLog>(request.FilterGroup); var data = m.UpgradeLogQueryable.ToPage <UpgradeLog, UpgradeLogOutDto>(predicate, request.PageCondition); return(new OperationResult(OperationResultType.Success, "获取数据成功", data)); }));
public IHttpActionResult EditUpgradeTasks([FromBody] params EditUpgradeTask[] dynamics) => Json(UpgradeService.TryCatchAction(action: m => { dynamics.CheckNotNullOrEmpty("dynamics"); return(UpgradeService.EditUpgradeLog(dynamics)); }));
public IHttpActionResult DeleteUpgrateTask([FromBody] params Guid[] ids) => Json(UpgradeService.TryCatchAction( action: m => { ids.CheckNotNullOrEmpty("Ids"); var cacheUser = GetCacheUser; return(m.DeleteUpgradeLog(cacheUser, ListOrganizeId.ToArray(), ids)); }));
public async Task <IHttpActionResult> AddUpgradeTasks(Guid UpgradeId, [FromBody] params string[] packs) => Json(await UpgradeService.TryCatchAction(async m => { UpgradeId.CheckNotEmpty("UpgradeId"); packs.CheckNotNullOrEmpty("packs"); var cacheUser = GetCacheUser; // 获取升级包 var _upgradepack = m.UpgradePackageQueryable.FirstOrDefault(mt => mt.Id == UpgradeId); // 获取升级主机信息 var _hosts = HostService.HostQueryable.Where(xm => packs.Contains(xm.RegPackage)).ToList(); var _failNoIn = packs.Except(_hosts.Select(x => x.RegPackage).ToArray()); List <UpgradeLog> upgrades = new List <UpgradeLog>(); if (_upgradepack != null) { StringBuilder builder = new StringBuilder(); for (int n = 0; n < _hosts.Count; n++) { if (n == _hosts.Count - 1) { builder.Append(_hosts[n].RegPackage); } else { builder.Append($"{_hosts[n].RegPackage},"); } } using (HttpClient ht = new HttpClient()) { string baseUrl = string.Format("http://127.0.0.1:2500/Wcf/AddUpgradeTask?itype={0}", 1); HttpContent httpContent = new ByteArrayContent(_upgradepack.Datas); httpContent.Headers.Add("packes", builder.ToString()); var response = await ht.PostAsync(baseUrl, httpContent); var result = await response.Content.ReadAsStringAsync(); Root dresult = JsonConvert.DeserializeObject <Root>(result); List <UpgradeTask> tasks = dresult.NewIng; List <UpgradeLog> upgradeLogs = new List <UpgradeLog>(); foreach (var ob in tasks) { upgradeLogs.Add(new UpgradeLog { Id = ob.Id, CreatedTime = DateTime.Now, CreatorUserId = cacheUser.UserName, Organize_Id = _hosts.FirstOrDefault(xx => xx.RegPackage == ob.RegPack).Organize_Id, CompleteTime = null, Packet = $"{_upgradepack.PackName}&{_upgradepack.Version}", State = 1, //计划中 Content = $"Host:[{ob.RegPack}]=>{_upgradepack.Version}" //这个地方不要改 }); } dresult.Being.AddRange(_failNoIn); return(m.AddUpgradeLog(dresult.Being.ToArray(), upgradeLogs.ToArray())); } } else { return(new OperationResult(OperationResultType.ValidError, $"未找到升级包=={UpgradeId}==")); } }));