Beispiel #1
0
        public static List <PALMStrategy> StrategiesByAttorney(QuantApp.Kernel.User attorney)
        {
            string    tableName    = "PALM_Strategies";
            string    searchString = "AttorneyID LIKE '" + attorney.ID + "'";
            string    targetString = null;
            DataTable _dataTable   = QuantApp.Kernel.Database.DB["CloudApp"].GetDataTable(tableName, targetString, searchString);

            DataRowCollection rows = _dataTable.Rows;

            List <PALMStrategy> result = new List <PALMStrategy>();

            if (rows.Count != 0)
            {
                foreach (DataRow row in rows)
                {
                    string userID     = GetValue <string>(row, "UserID");
                    int    strategyID = GetValue <int>(row, "StrategyID");
                    string attorneyID = GetValue <string>(row, "AttorneyID");

                    result.Add(new PALMStrategy(Instrument.FindInstrument(strategyID) as Strategy, QuantApp.Kernel.User.FindUser(userID), QuantApp.Kernel.User.FindUser(attorneyID)));
                }
            }

            return(result);
        }
Beispiel #2
0
        public static PALMStrategy AddStrategy(QuantApp.Kernel.User user, QuantApp.Kernel.User attorney, Strategy strategy)
        {
            string    tableName    = "PALM_Strategies";
            string    searchString = "UserID LIKE '" + user.ID + "' AND StrategyID = " + strategy.ID;
            string    targetString = null;
            DataTable _dataTable   = QuantApp.Kernel.Database.DB["CloudApp"].GetDataTable(tableName, targetString, searchString);

            DataRowCollection rows = _dataTable.Rows;

            if (rows.Count != 0)
            {
                throw new Exception("Strategy exists.");
            }

            else
            {
                DataRow r = _dataTable.NewRow();

                r["UserID"]     = user.ID;
                r["AttorneyID"] = attorney.ID;
                r["StrategyID"] = strategy.ID;
                r["Master"]     = 1;

                rows.Add(r);
                QuantApp.Kernel.Database.DB["CloudApp"].UpdateDataTable(_dataTable);

                return(new PALMStrategy(strategy, user, user));
            }
        }
        public IActionResult Group(string groupid)
        {
            string userId = this.User.QID();

            if (userId == null)
            {
                return(null);
            }

            QuantApp.Kernel.User  user  = QuantApp.Kernel.User.FindUser(userId);
            QuantApp.Kernel.Group group = QuantApp.Kernel.Group.FindGroup(groupid);

            if (group == null)
            {
                return(BadRequest(new { Data = "Group not found" }));
            }

            AccessType ac = group.Permission(null, user);

            if (ac != AccessType.Denied)
            {
                return(Ok(new {
                    ID = group.ID,
                    Name = group.Name,
                    ParentID = group.Parent == null ? null : group.Parent.ID,
                    Description = group.Description
                }));
            }

            return(BadRequest(new { Data = "Group access denied" }));
        }
		public ActionResult UploadFile(string groupid)
		{
            string userId = this.User.QID();
            if (userId == null)
                return Unauthorized();

            QuantApp.Kernel.User quser = QuantApp.Kernel.User.FindUser(userId);
			try
			{
                foreach(var file in Request.Form.Files)
                {
                    if (file.Length > 0)
                    {
                        string fileName = ContentDispositionHeaderValue.Parse(file.ContentDisposition).FileName.Trim('"');
                        {
                            
                            MemoryStream outStream = new MemoryStream();
                            file.CopyTo(outStream);

                            byte[] data = outStream.ToArray();
                            string fid = System.Guid.NewGuid().ToString();
                            DateTime dt = DateTime.Now;
                            FileRepository.AddFile(fid, fileName, data, file.ContentType, dt, userId, groupid);
                        }
                    }
                }
				return Json("Upload Successful.");
			}
			catch (System.Exception ex)
			{
				return Json("Upload Failed: " + ex.Message);
			}
		}
Beispiel #5
0
        public static FilePermission File(string id)
        {
            //_fileRepositoryDataTable = null;

            //DataRowCollection rows = FileRepositoryDataTable.Rows;

            string searchString = "ID = '" + id + "'";
            string targetString = null;

            _fileRepositoryDataTable = Database.DB["CloudApp"].GetDataTable(_fileReposityTableName, targetString, searchString);
            DataRowCollection rows = _fileRepositoryDataTable.Rows;

            //var lrows = from lrow in new LINQList<DataRow>(rows)
            //            where (string)lrow["Id"] == id
            //            select lrow;

            if (rows.Count != 0)
            {
                foreach (DataRow row in rows)
                {
                    string name = (string)row["Name"];
                    // string description = (string)row["Description"];
                    string type               = (string)row["Type"];
                    string userid             = (string)row["UserID"];
                    QuantApp.Kernel.User user = QuantApp.Kernel.User.FindUser(userid);
                    DateTime             date = (DateTime)row["Timestamp"];
                    byte[] data               = System.Convert.FromBase64String((string)row["Data"]);
                    // FilePermission file = new FilePermission(id, name, description, type, date, user, data);
                    FilePermission file = new FilePermission(id, name, date, user, data, type);
                    return(file);
                }
            }
            return(null);
        }
Beispiel #6
0
        public static List <PALMPending> GetPendingAll(QuantApp.Kernel.User user)
        {
            string    tableName    = "PALM_Pending";
            string    searchString = "UserID LIKE '" + user.ID + "'";
            string    targetString = null;
            DataTable _dataTable   = QuantApp.Kernel.Database.DB["CloudApp"].GetDataTable(tableName, targetString, searchString);

            DataRowCollection rows = _dataTable.Rows;

            List <PALMPending> ret = new List <PALMPending>();

            if (rows.Count != 0)
            {
                foreach (DataRow row in rows)
                {
                    string userID     = GetValue <string>(row, "UserID");
                    int    strategyID = GetValue <int>(row, "StrategyID");
                    string attorneyID = GetValue <string>(row, "AttorneyID");

                    string   provider       = GetValue <string>(row, "Provider");
                    string   accountID      = GetValue <string>(row, "AccountID");
                    DateTime submissionDate = GetValue <DateTime>(row, "SubmissionDate");
                    DateTime creationDate   = GetValue <DateTime>(row, "CreationDate");

                    ret.Add(new PALMPending(strategyID == -1 ? null : Instrument.FindInstrument(strategyID) as Strategy, QuantApp.Kernel.User.FindUser(userID), QuantApp.Kernel.User.FindUser(attorneyID), provider, accountID, submissionDate, creationDate));
                }
            }

            return(ret);
        }
        public ActionResult SubGroups(string groupid, bool aggregated)
        {
            string userId = this.User.QID();

            if (userId == null)
            {
                return(null);
            }

            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 <Group>  sgroups = role.SubGroups(aggregated);
            List <object> jres    = new List <object>();

            foreach (Group group in sgroups)
            {
                jres.Add(new
                {
                    ID          = group.ID,
                    Name        = group.Name,
                    Description = group.Description,
                    ParentID    = group.Parent == null ? null : group.Parent.ID
                });
            }

            return(Ok(jres));
        }
Beispiel #8
0
        public ActionResult AddPermission(string groupid, string email, int accessType)
        {
            if (email == null)
            {
                return(Ok(new { Data = "User not found..." }));
            }

            string userid = "QuantAppSecure_" + email.ToLower().Replace('@', '.').Replace(':', '.');

            QuantApp.Kernel.User user = QuantApp.Kernel.User.FindUser(userid);

            if (user != null)
            {
                QuantApp.Kernel.Group group = QuantApp.Kernel.Group.FindGroup(groupid);
                if (group == null)
                {
                    group = QuantApp.Kernel.Group.FindGroup(groupid.Replace("_WorkSpace", ""));
                }

                if (group == null)
                {
                    group = QuantApp.Kernel.Group.CreateGroup(groupid, groupid);
                }


                group.Add(user, typeof(QuantApp.Kernel.User), (AccessType)accessType);

                return(Ok(new { Data = "ok" }));
            }

            return(Ok(new { Data = "User not found..." }));
        }
Beispiel #9
0
        public static List <Instrument> GetBookmarks(QuantApp.Kernel.User user)
        {
            string    tableName    = "PALM_Bookmarks";
            string    searchString = "UserID LIKE '" + user.ID + "'";
            string    targetString = null;
            DataTable _dataTable   = QuantApp.Kernel.Database.DB["CloudApp"].GetDataTable(tableName, targetString, searchString);

            DataRowCollection rows = _dataTable.Rows;

            List <Instrument> ret = new List <Instrument>();

            if (rows.Count != 0)
            {
                foreach (DataRow row in rows)
                {
                    string userID       = GetValue <string>(row, "UserID");
                    int    instrumentID = GetValue <int>(row, "InstrumentID");

                    Instrument ins = Instrument.FindInstrument(instrumentID);
                    ret.Add(ins);
                }
            }

            return(ret);
        }
Beispiel #10
0
        public ActionResult UserApp(string id)
        {
            string userId = this.User.QID();

            if (userId == null)
            {
                return(null);
            }

            QuantApp.Kernel.User user = QuantApp.Kernel.User.FindUser(userId);

            QuantApp.Kernel.User quser = QuantApp.Kernel.User.FindUser(id);

            List <object> jres = new List <object>();

            foreach (QuantApp.Kernel.Group group in QuantApp.Kernel.Group.MasterGroups())
            {
                if (!group.Name.StartsWith("Personal: "))
                {
                    AccessType accessType = group.Permission(null, quser);

                    jres.Add(
                        new
                    {
                        ID         = group.ID,
                        Name       = group.Name,
                        Permission = accessType.ToString()
                    }
                        );
                }
            }


            return(Ok(new { FirstName = quser.FirstName, LastName = quser.LastName, Groups = jres }));
        }
        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);
        }
Beispiel #12
0
        public ActionResult SubGroupsApp(string groupid, bool aggregated)
        {
            string userId = this.User.QID();

            if (userId == null)
            {
                return(null);
            }

            QuantApp.Kernel.User  user = QuantApp.Kernel.User.FindUser(userId);
            QuantApp.Kernel.Group role = QuantApp.Kernel.Group.FindGroup(groupid);

            List <Group> sgroups = role.SubGroups(aggregated);



            List <object> jres = new List <object>();

            foreach (Group group in sgroups)
            {
                AccessType ac = group.Permission(null, user);
                if (ac != AccessType.Denied)
                {
                    jres.Add(new
                    {
                        ID          = group.ID,
                        Name        = group.Name,
                        Description = group.Description,
                        Permission  = ac.ToString(),
                    });
                }
            }

            return(Ok(jres));
        }
Beispiel #13
0
        public async Task <IActionResult> RawData(string type)
        {
            string userId = this.User.QID();

            if (userId == null)
            {
                return(Unauthorized());
            }

            QuantApp.Kernel.User quser = QuantApp.Kernel.User.FindUser(userId);

            if (userId != null)
            {
                if (quser == null)
                {
                    QuantApp.Kernel.User.ContextUser = new QuantApp.Kernel.UserData();
                }
                else
                {
                    QuantApp.Kernel.User.ContextUser = quser.ToUserData();
                }
            }
            else
            {
                QuantApp.Kernel.User.ContextUser = new QuantApp.Kernel.UserData();
            }

            M   m   = M.Base(type);
            var res = m.RawEntries();

            QuantApp.Kernel.User.ContextUser = new QuantApp.Kernel.UserData();

            return(Ok(res));
        }
        public ActionResult SetPermission(string userid, string groupid, int accessType)
        {
            string userId = this.User.QID();

            if (userId == null)
            {
                return(null);
            }

            QuantApp.Kernel.User  user  = QuantApp.Kernel.User.FindUser(userid);
            QuantApp.Kernel.Group group = QuantApp.Kernel.Group.FindGroup(groupid);
            if (group == null)
            {
                group = QuantApp.Kernel.Group.FindGroup(groupid.Replace("_Workflow", ""));
            }

            if (group == null)
            {
                group = QuantApp.Kernel.Group.CreateGroup(groupid, groupid);
            }

            group.Add(user, typeof(QuantApp.Kernel.User), (AccessType)accessType);

            return(Ok(new { Data = "ok" }));
        }
Beispiel #15
0
        public async Task <IActionResult> Data(string type)
        {
            string userId = this.User.QID();

            if (userId == null)
            {
                return(Unauthorized());
            }

            QuantApp.Kernel.User quser = QuantApp.Kernel.User.FindUser(userId);

            if (quser == null)
            {
                return(Unauthorized());
            }

            QuantApp.Kernel.User.ContextUser = quser.ToUserData();

            // if (userId != null)
            // {
            //     if(quser == null)
            //         QuantApp.Kernel.User.ContextUser = new QuantApp.Kernel.UserData();
            //     else
            //         QuantApp.Kernel.User.ContextUser = quser.ToUserData();
            // }
            // else
            //     QuantApp.Kernel.User.ContextUser = new QuantApp.Kernel.UserData();

            M   m   = M.Base(type);
            var res = m.KeyValues();

            QuantApp.Kernel.User.ContextUser = new QuantApp.Kernel.UserData();

            return(Ok(res));
        }
Beispiel #16
0
        public async Task <IActionResult> Save(string type)
        {
            string userId = this.User.QID();

            if (userId == null)
            {
                return(Unauthorized());
            }

            QuantApp.Kernel.User quser = QuantApp.Kernel.User.FindUser(userId);
            if (quser == null)
            {
                return(Unauthorized());
            }

            QuantApp.Kernel.User.ContextUser = quser.ToUserData();

            M m = M.Base(type);

            m.Save();

            QuantApp.Kernel.User.ContextUser = new QuantApp.Kernel.UserData();

            return(Ok(new { Result = "saved" }));
        }
Beispiel #17
0
        public static void AddBookmark(QuantApp.Kernel.User user, Instrument instrument)
        {
            string    tableName    = "PALM_Bookmarks";
            string    searchString = "UserID LIKE '" + user.ID + "' AND InstrumentID = " + instrument.ID;
            string    targetString = null;
            DataTable _dataTable   = QuantApp.Kernel.Database.DB["CloudApp"].GetDataTable(tableName, targetString, searchString);

            DataRowCollection rows = _dataTable.Rows;

            if (rows.Count != 0)
            {
                throw new Exception("Bookmark exists.");
            }

            else
            {
                DataRow r = _dataTable.NewRow();

                r["UserID"]       = user.ID;
                r["InstrumentID"] = instrument.ID;

                rows.Add(r);
                QuantApp.Kernel.Database.DB["CloudApp"].UpdateDataTable(_dataTable);
            }
        }
Beispiel #18
0
        public ActionResult UsersApp()
        {
            string userId = this.User.QID();

            if (userId == null)
            {
                return(null);
            }

            QuantApp.Kernel.User user = QuantApp.Kernel.User.FindUser(userId);

            List <object> jres = new List <object>();

            foreach (Utils.User usr in UserRepository.RetrieveUsers())
            {
                string id = usr.TenantName;
                QuantApp.Kernel.User quser = QuantApp.Kernel.User.FindUser(id);
                if (quser != null)
                {
                    jres.Add(new { ID = quser.ID, FirstName = quser.FirstName, LastName = quser.LastName, Email = quser.Email });
                }
            }

            return(Ok(jres));
        }
        public IActionResult Users(string groupid)
        {
            string userId = this.User.QID();

            if (userId == null)
            {
                return(null);
            }

            QuantApp.Kernel.User  user = QuantApp.Kernel.User.FindUser(userId);
            QuantApp.Kernel.Group role = QuantApp.Kernel.Group.FindGroup(groupid);

            if (role == null)
            {
                role = QuantApp.Kernel.Group.FindGroup(groupid.Replace("_Workflow", ""));
            }

            if (role == null)
            {
                role = QuantApp.Kernel.Group.CreateGroup(groupid, groupid);
            }

            List <IPermissible> users = role.Master.List(QuantApp.Kernel.User.CurrentUser, typeof(QuantApp.Kernel.User), false);

            List <object> jres = new List <object>();

            foreach (QuantApp.Kernel.User user_mem in users)
            {
                QuantApp.Kernel.User quser = QuantApp.Kernel.User.FindUser(user_mem.ID);

                if (quser != null)
                {
                    var ac  = role.Permission(null, user_mem);
                    var exp = role.Expiry(null, user_mem);

                    if (quser.ID != "System")
                    {
                        jres.Add(new
                        {
                            ID         = quser.ID,
                            FirstName  = quser.FirstName,
                            LastName   = quser.LastName,
                            Email      = quser.Email,
                            Permission = ac.ToString(),
                            Expiry     = new { year = exp.Year, month = exp.Month, day = exp.Day },
                            MetaData   = quser.MetaData,
                        });
                    }
                }
                else
                {
                    role.Remove(user_mem);
                }
            }

            return(Ok(jres));
        }
Beispiel #20
0
 public FilePermission(string id, string name, DateTime timestamp, QuantApp.Kernel.User owner, byte[] data, string type)
 {
     this.ID        = id;
     this.Name      = name;
     this.Timestamp = timestamp;
     this.Owner     = owner;
     this.Data      = data;
     this.Type      = type;
 }
Beispiel #21
0
 public PALMPending(Strategy strategy, QuantApp.Kernel.User user, QuantApp.Kernel.User attorney, string provider, string accountid, DateTime submissionDate, DateTime creationDate)
 {
     this.Strategy       = strategy;
     this.User           = user;
     this.Attorney       = attorney;
     this.Provider       = provider;
     this.AccountID      = accountid;
     this.SubmissionDate = submissionDate;
     this.CreationDate   = creationDate;
 }
        public ActionResult UserData(string id, string groupid, bool aggregated)
        {
            string userId = this.User.QID();

            if (userId == null)
            {
                return(null);
            }

            QuantApp.Kernel.User user = QuantApp.Kernel.User.FindUser(userId);

            QuantApp.Kernel.User quser = QuantApp.Kernel.User.FindUser(id);

            QuantApp.Kernel.Group role = QuantApp.Kernel.Group.FindGroup(groupid);

            if (role == null)
            {
                return(null);
            }

            List <Group> sgroups = role.SubGroups(aggregated);


            List <object> jres = new List <object>();

            var lastLogin = UserRepository.LastUserLogin(id);

            foreach (QuantApp.Kernel.Group group in sgroups)
            {
                if (!group.Name.StartsWith("Personal: "))
                {
                    AccessType accessType = group.Permission(null, quser);

                    jres.Add(
                        new
                    {
                        ID         = group.ID,
                        Name       = group.Name,
                        Permission = accessType.ToString()
                    }
                        );
                }
            }

            return(Ok(new {
                ID = quser.ID,
                Email = quser.Email,
                Permission = role.Permission(null, quser).ToString(),
                MetaData = quser.MetaData,
                FirstName = quser.FirstName,
                LastName = quser.LastName,
                LastLogin = lastLogin,
                Groups = jres
            }));
        }
Beispiel #23
0
        public string EditGroupApp(string id, string name, string description, string planID, string profile, string apps, string stripeApiKey, string colordark, string parentid, string url, string dashboard, string redirect)
        {
            try
            {
                string userId = this.User.QID();
                if (userId == null)
                {
                    return(null);
                }

                QuantApp.Kernel.User user       = QuantApp.Kernel.User.FindUser(userId);
                QuantApp.Kernel.User publicUser = QuantApp.Kernel.User.FindUser("anonymous");

                Group parent = string.IsNullOrWhiteSpace(parentid) ? null : QuantApp.Kernel.Group.FindGroup(parentid);

                Group group = string.IsNullOrWhiteSpace(id) ? QuantApp.Kernel.Group.CreateGroup(name) : QuantApp.Kernel.Group.FindGroup(id);

                if (parent != null && string.IsNullOrWhiteSpace(id))
                {
                    group.Parent = parent;
                }

                if (parent == null)
                {
                    group.Add(user, typeof(QuantApp.Kernel.User), AccessType.Write);
                    group.Add(publicUser, typeof(QuantApp.Kernel.User), AccessType.Denied);
                }

                group.Name = name;

                string des = description.Trim().Replace("_&l;_", "<").Replace("_&r;_", ">");
                if (!string.IsNullOrWhiteSpace(des) && des[des.Length - 1] == '\x0006')
                {
                    des = des.Substring(0, des.Length - 2);
                }
                group.Description = des;

                GroupRepository.Set(group, "Profile", profile);


                GroupRepository.Set(group, "URL", url);

                return("ok");
            }
            catch (Exception e)
            {
                Console.WriteLine(e);
            }
            return("error");
        }
        public async Task <IActionResult> UserData(string groupid, string type)
        {
            string userId = this.User.QID();

            if (userId == null)
            {
                return(Unauthorized());
            }

            QuantApp.Kernel.User quser = QuantApp.Kernel.User.FindUser(userId);

            QuantApp.Kernel.Group group = QuantApp.Kernel.Group.FindGroup(groupid);

            return(Ok(Newtonsoft.Json.JsonConvert.DeserializeObject(quser.GetData(group, type))));
        }
Beispiel #25
0
        public static void RemoveBookmark(QuantApp.Kernel.User user, Instrument instrument)
        {
            string    tableName    = "PALM_Bookmarks";
            string    searchString = "UserID LIKE '" + user.ID + "' AND InstrumentID = " + instrument.ID;
            string    targetString = null;
            DataTable _dataTable   = QuantApp.Kernel.Database.DB["CloudApp"].GetDataTable(tableName, targetString, searchString);

            DataRowCollection rows = _dataTable.Rows;

            if (rows.Count != 0)
            {
                rows[0].Delete();
                QuantApp.Kernel.Database.DB["CloudApp"].UpdateDataTable(_dataTable);
            }
        }
        public ActionResult EditSubGroup([FromBody] EditSubGroupClass data)
        {
            string userId = this.User.QID();

            if (userId == null)
            {
                return(null);
            }

            QuantApp.Kernel.User user = QuantApp.Kernel.User.FindUser(userId);

            Group group = QuantApp.Kernel.Group.FindGroup(data.ID);

            group.Name        = data.Name;
            group.Description = data.Description;

            return(Ok(new { Data = "ok" }));
        }
        public async Task <IActionResult> Logout()
        {
            string key = Request.Cookies["coflows"];

            if (key != null)
            {
                var outk = "";
                if (sessionKeys.ContainsKey(key))
                {
                    sessionKeys.Remove(key, out outk);
                }

                var _outk = "";
                if (revSessionKeys.ContainsKey(outk))
                {
                    revSessionKeys.Remove(outk, out _outk);
                }
            }

            Response.Cookies.Delete("coflows");
            Response.Cookies.Append("coflows", "", new CookieOptions()
            {
                Expires = DateTime.Now.AddMonths(-24)
            });

            try
            {
                string userName = this.User.QID();
                if (userName != null)
                {
                    QuantApp.Kernel.User quser = QuantApp.Kernel.User.FindUser(userName);
                    quser.SetSecure(false);
                }
            }
            finally
            {
                await HttpContext.SignOutAsync(CookieAuthenticationDefaults.AuthenticationScheme);
            }



            return(Ok());
        }
        public async Task <IActionResult> Logout()
        {
            try
            {
                string userName = this.User.QID();
                if (userName != null)
                {
                    QuantApp.Kernel.User quser = QuantApp.Kernel.User.FindUser(userName);
                    quser.SetSecure(false);
                }
            }
            finally
            {
                await HttpContext.SignOutAsync(CookieAuthenticationDefaults.AuthenticationScheme);
            }

            Response.Cookies.Delete("coflows");

            return(Ok());
        }
Beispiel #29
0
        public static Dictionary <string, FilePermission> FilesByUser(string userID)
        {
            //_fileRepositoryDataTable = null;
            //DataTable table = DataTable;
            //DataRowCollection rows = FileRepositoryDataTable.Rows;

            string searchString = "UserID = '" + userID + "'";
            string targetString = null;

            _fileRepositoryDataTable = Database.DB["CloudApp"].GetDataTable(_fileReposityTableName, targetString, searchString);
            DataRowCollection rows = _fileRepositoryDataTable.Rows;


            //var lrows = from lrow in new LINQList<DataRow>(rows)
            //            where (string)lrow["UserID"] == userID
            //            orderby (DateTime)lrow["Timestamp"] descending
            //            select lrow;

            Dictionary <string, FilePermission> result = new Dictionary <string, FilePermission>();

            if (rows.Count != 0)
            {
                foreach (DataRow row in rows)
                {
                    string id   = (string)row["ID"];
                    string name = (string)row["Name"];
                    // string description = (string)row["Description"];
                    string type               = (string)row["Type"];
                    string userid             = (string)row["UserID"];
                    QuantApp.Kernel.User user = QuantApp.Kernel.User.FindUser(userid);
                    DateTime             date = (DateTime)row["Timestamp"];
                    byte[] data               = System.Convert.FromBase64String((string)row["Data"]);
                    // FilePermission file = new FilePermission(id, name, description, type, date, user, data);
                    Console.WriteLine("----- FILE: " + name);
                    FilePermission file = new FilePermission(id, name, date, user, data, type);
                    result.Add((string)row["ID"], file);
                }
            }

            return(result);
        }
        public ActionResult AddPermission(string groupid, string email, int accessType, int year = 9999, int month = 12, int day = 31)
        {
            if (email == null)
            {
                return(BadRequest(new { Data = "User not found..." }));
            }

            try
            {
                var testAccesss = (AccessType)accessType;
            }
            catch
            {
                return(BadRequest(new { Data = "accessType needs to be an integer between -2 and 2" }));
            }

            string userid = "QuantAppSecure_" + email.ToLower().Replace('@', '.').Replace(':', '.');

            QuantApp.Kernel.User user = QuantApp.Kernel.User.FindUser(userid);

            if (user != null)
            {
                QuantApp.Kernel.Group group = QuantApp.Kernel.Group.FindGroup(groupid);
                if (group == null)
                {
                    group = QuantApp.Kernel.Group.FindGroup(groupid.Replace("_Workflow", ""));
                }

                if (group == null)
                {
                    group = QuantApp.Kernel.Group.CreateGroup(groupid, groupid);
                }


                group.Add(user, typeof(QuantApp.Kernel.User), (AccessType)accessType, new DateTime(year, month, day));

                return(Ok(new { Data = "ok" }));
            }

            return(BadRequest(new { Data = "User not found..." }));
        }