public KeyValuePair <string, string>?ParseRequest <T>(Dictionary <string, List <string> > requestData) where T : Data <T> { if (!requestData.ContainsKey(Mutator.CommonMetadataKeys.Set)) { return(null); } var code = requestData[Mutator.CommonMetadataKeys.Set].FirstOrDefault(); if (code == Constants.CURRENT_LIVE_WORKSET_TAG) { return(null); } var set = SetVersion <T> .GetByCode(code); if (!SetVersion <T> .CanBrowse()) { throw new AuthenticationException("User is not authorized to browse sets."); } if (set == null) { throw new InvalidFilterCriteriaException($"[{code}]: Invalid code."); } var suffix = SetVersion <T> .GetByCode(code).SetTag; return(new KeyValuePair <string, string>(Mutator.CommonMetadataKeys.Set, suffix)); }
public static SetVersion <T> PushFromWorkset(string id) { var isNew = id == "new" || id == Constants.CURRENT_LIVE_WORKSET_TAG; SetVersion <T> probe; if (isNew) { var code = DateTime.Now.ToString("yyyyMMdd-HHmmss"); probe = new SetVersion <T> { Code = "BKP" + code, Name = "Backup:" + code }; } else { probe = Get(id); if (probe == null) { throw new Exception($"Version {id} not found."); } } try { probe.ItemCount = Data <T> .Count(); probe.Save(); Info <T> .Settings.Adapter.CopySet(Constants.CURRENT_LIVE_WORKSET_TAG, CollectionTag(probe.Id), true); var log = new Log <T> { ReferenceId = probe.Id, AuthorLocator = Current.Orchestrator?.Person?.Locator, Action = "PUSH", Type = Log.Constants.Type.VERSIONING, Message = $"Workset pushed to Version [{probe.Code}] ({probe.Name}): {probe.ItemCount} items copied" }; log.Save(); return(probe); } catch (Exception e) { throw e; } }