public async Task<IActionResult> Files(string groupid) { string userId = this.User.QID(); if (userId == null) return Unauthorized(); QuantApp.Kernel.User user = QuantApp.Kernel.User.FindUser(userId); QuantApp.Kernel.Group role = QuantApp.Kernel.Group.FindGroup(groupid); if(role == null) return BadRequest(new { Data = "Group not found "}); List<object> jres = new List<object>(); List<IPermissible> files = role.List(user, typeof(FilePermission), false); foreach (FilePermission file_mem in files) { FilePermission file = FileRepository.File(file_mem.ID); if (file != null) jres.Add(new { ID = file.ID, Name = file.Name, Owner = file.Owner.FirstName + " " + file.Owner.LastName, Size = file.Size, Date = (file.Timestamp.ToString("yyyy/MM/dd")), Type = file.Type, Permission = (int)role.Permission(null, file_mem) }); else role.Remove(file_mem); } return Ok(jres); }
/// <summary> /// Function: Add an object /// </summary> /// <param name="data">object to be added</param> public string Add(object data) { lock (editLock) { if (data == null) { Console.WriteLine("M not null"); return(null); } if (group == null) { group = Group.FindGroup(ID); } if (group != null && !string.IsNullOrEmpty(QuantApp.Kernel.User.ContextUser.ID) && group.List(QuantApp.Kernel.User.CurrentUser, typeof(QuantApp.Kernel.User), false).Count > 0) { var permission = group.PermissionContext(); if (permission != AccessType.Write) { return(null); } } var invKey = data; if (!singularity_inverse.ContainsKey(invKey)) { string key = System.Guid.NewGuid().ToString(); singularity.TryAdd(key, data); singularity_inverse.TryAdd(invKey, key); if (singularity.Count != singularity_inverse.Count) { Console.WriteLine("ERROR"); } EntryChange change = new EntryChange() { Command = 1, ID = key, Data = data, MID = ID, Type = data.GetType().ToString(), Assembly = data.GetType().Assembly.GetName().Name }; changes.Add(change); var data_str = ""; if ( data.GetType().ToString().ToLower() == "system.string" || data.GetType().ToString().ToLower() == "newtonsoft.json.linq.jobject" || (data is string) ) { string filtered_string = data.ToString().Replace((char)27, '"').Replace((char)26, '\''); if (filtered_string.StartsWith("\"") && filtered_string.EndsWith("\"")) { filtered_string = filtered_string.Substring(1, filtered_string.Length - 2).Replace("\\\"", "\""); } data_str = filtered_string; } else { data_str = Newtonsoft.Json.JsonConvert.SerializeObject(data); } RTDMessage.CRUDMessage crud = new RTDMessage.CRUDMessage() { TopicID = ID, ID = key, Type = RTDMessage.CRUDType.Create, Class = CRUDClass, Value = data_str, ValueType = data.GetType() == typeof(System.Dynamic.ExpandoObject) || data.GetType() == typeof(System.Dynamic.DynamicObject) ? typeof(string).ToString() : data.GetType().ToString(), ValueAssembly = data.GetType().Assembly.GetName().Name }; RTDEngine.Send(new RTDMessage() { Type = RTDMessage.MessageType.CRUD, Content = crud }); if (add_fdb.Count > 0) { foreach (var func in add_fdb.Values.ToList()) { if (_dic.ContainsKey(func)) { try { (_dic[func] as MCallback)(key, data); } catch {} } } } return(key); } if (singularity.Count != singularity_inverse.Count) { Console.WriteLine("ERROR"); } return(null); } }