public async override Task <IEnumerable <DockerContainerItem> > GetItemsAsync(bool forceRefresh = false) { //登录 await WebApiUtils.EnsureLogin(client, siteItem); //获取容器列表 var items = await WebApiUtils.GetContainerItems(client, siteItem); //退出登录 await WebApiUtils.Logout(client, siteItem); return(items); }
async Task ExecuteRefreshCommand() { IsBusy = true; BusyText = "正在刷新..."; try { //登录 await WebApiUtils.EnsureLogin(client, SiteItem); var newItem = await WebApiUtils.GetContainerInfo(client, SiteItem, DockerContainerItem.Id); JsonConvert.PopulateObject(JsonConvert.SerializeObject(newItem), DockerContainerItem); OnPropertyChanged(nameof(DockerContainerItem)); //退出登录 await WebApiUtils.Logout(client, SiteItem); } catch (Exception ex) { DependencyService.Get <IMessage>().LongAlert("启动容器失败,原因:" + ex.Message); } IsBusy = false; }
async Task ExecuteStartCommand() { IsBusy = true; BusyText = "正在启动容器..."; try { //登录 await WebApiUtils.EnsureLogin(client, SiteItem); await WebApiUtils.StartContainer(client, SiteItem, DockerContainerItem); //退出登录 await WebApiUtils.Logout(client, SiteItem); DependencyService.Get <IMessage>().LongAlert("启动容器成功!"); } catch (Exception ex) { DependencyService.Get <IMessage>().LongAlert("启动容器失败,原因:" + ex.Message); } IsBusy = false; //刷新 await ExecuteRefreshCommand(); }