private static IEnumerable <SetVersion <T> > InternalGetAllItems() { var preRet = new List <SetVersion <T> >(); if (App.Current.Orchestrator?.Person?.Locator == null) { return(preRet); } if (SetVersion <T> .CanBrowse()) { preRet = SetVersion <T> .All().ToList(); if (SetVersion <T> .CanModify()) { preRet.Add(new SetVersion <T> { Code = Constants.CURRENT_LIVE_WORKSET_TAG, Id = Constants.CURRENT_LIVE_WORKSET_TAG, Name = "Workset", IsPublic = true, IsLocked = false, IsCurrent = !preRet.Any(i => i.IsCurrent) }); } } else { preRet = SetVersion <T> .Where(i => i.IsPublic).ToList(); } preRet = preRet.OrderBy(i => i.TimeStamp).Reverse().ToList(); return(preRet); }
public virtual object GetById(string id) { if (!SetVersion <T> .CanBrowse()) { throw new AuthenticationException("User is not authorized to download."); } var sw = new Stopwatch(); try { sw.Start(); var preRet = SetVersion <T> .Get(id); sw.Stop(); Log.Add <T>($"SetVersion : GetById [{id}] OK ({sw.ElapsedMilliseconds} ms)"); return(preRet); } catch (Exception e) { sw.Stop(); Log.Add <T>(e, $"SetVersion: GetById [{id}] ERR ({sw.ElapsedMilliseconds} ms)"); throw; } }
public virtual IActionResult WebApiDownloadWorkspace(string code) { if (!SetVersion <T> .CanBrowse()) { throw new AuthenticationException("User is not authorized to download."); } return(GetZipPackage(code)); }
public virtual object GetStatus() { if (!SetVersion <T> .CanBrowse()) { throw new AuthenticationException("User is not authorized to download."); } var preret = new { count = Count() }; return(preret); }
public virtual object SetCurrent(string id) { if (!SetVersion <T> .CanBrowse()) { throw new AuthenticationException("User is not authorized."); } var sw = new Stopwatch(); try { sw.Start(); var probe = SetVersion <T> .Get(id); if (probe == null) { throw new InvalidDataException("Invalid ID."); } if (probe.IsCurrent) { return(probe); } var allCurrentSets = SetVersion <T> .Where(i => i.IsCurrent); foreach (var setVersion in allCurrentSets) { if (!setVersion.IsCurrent) { continue; } setVersion.IsCurrent = false; setVersion.Save(); } probe.IsCurrent = true; probe = SetVersion <T> .Get(probe.Save().Id); sw.Stop(); Log.Add <T>($"SetVersion : SetCurrent [{id}] OK ({sw.ElapsedMilliseconds} ms)"); return(probe); } catch (Exception e) { sw.Stop(); Log.Add <T>(e, $"SetVersion: SetCurrent [{id}] ERR ({sw.ElapsedMilliseconds} ms): {e.Message}"); throw; } }