public async Task <bool> UpdateFiles() { QueryResults = null; HitItems.Clear(); FileItems.Clear(); if (Group != null) { var api = IndexApiClient.Create(cts.Token); var results = await api.GetFiles(Group); if (results is FileInfo[] entries) { foreach (var entry in entries.OrderBy(x => x.Path.ToUpperInvariant())) { FileItems.Add(new FileItem(entry.Fid, entry.Path, entry.Size, !Unchecked.Contains(entry.Fid))); } return(true); } else { return(false); } } else { return(true); } }
public async Task <string> Execute() { try { QueryResults = null; HitItems.Clear(); Fid = -1; Path = " "; NotifyOfChange("Path"); Contents.Clear(); var svc = new IndexService(cts.Token); QueryResults = await svc.FindTextAsync(Group, QueryText); ProcessQueryResults(); return(null); } catch (TaskCanceledException) { return(string.Empty); } catch (AggregateException e) when(e.InnerExceptions[0] is TaskCanceledException) { return(string.Empty); } catch (AggregateException e) { var sb = new StringBuilder(); foreach (var x in e.InnerExceptions) { if (sb.Length > 0) { sb.AppendLine(); } sb.Append(x.Message); Exception y = x; while ((y = y.InnerException) != null) { sb.AppendLine(); sb.Append(y.Message); #if DEBUG sb.AppendFormat(" {0}", y.GetType().FullName); if (y is System.Net.Sockets.SocketException s) { sb.AppendFormat(" SocketErrorCode={0}", s.SocketErrorCode.ToString()); } #endif } } return(sb.ToString()); } catch (Exception e) { return(e.Message); } }
public void Clear() { QueryText = string.Empty; NotifyOfChange("QueryText"); QueryResults = null; HitItems.Clear(); Fid = -1; Path = " "; NotifyOfChange("Path"); Contents.Clear(); foreach (var f in FileItems) { f.HitRows = 0; } NotifyOfChange("FileItems"); }
public void OnFileCheckChanged() { foreach (var f in FileItems) { if (f.Check) { if (Unchecked.Contains(f.Fid)) { Unchecked.Remove(f.Fid); } } else if (!Unchecked.Contains(f.Fid)) { Unchecked.Add(f.Fid); } } if (QueryResults == null || QueryResults.Count == 0) { return; } HitItems.Clear(); ProcessQueryResults(); }