Exemple #1
0
        public static int WordCount(DAM.Model.System system)
        {
            int count = 2;

            foreach (var c in system.Params)
            {
                count += 6;
            }
            foreach (var c in system.Objects)
            {
                count += 4;
                foreach (var p in c.Params)
                {
                    count += 4;
                }
            }
            foreach (var c in system.Users)
            {
                count += 4;
                foreach (var p in c.Params)
                {
                    count += 4;
                }
            }
            return(count);
        }
Exemple #2
0
        public async static Task SaveSystem(DAM.Model.System system)
        {
            int?tmpID = null;
            int ID;

            while (tmpID == null)
            {
                tmpID = await AddSystem(system.Name);
            }
            ID = Convert.ToInt32(tmpID);

            foreach (DAM.Model.Param p in system.Params)
            {
                await AddParam(p.ID, p.Name, p.Value, "System", ID);
            }

            foreach (DAM.Model.Object o in system.Objects)
            {
                await Add(o.ID, o.Name, "Object");

                foreach (DAM.Model.Param p in o.Params)
                {
                    await AddParam(p.ID, p.Name, p.Value, "Object", o.ID);
                }
            }
            foreach (DAM.Model.User u in system.Users)
            {
                await Add(u.ID, u.Name, "User");

                foreach (DAM.Model.Param p in u.Params)
                {
                    await AddParam(p.ID, p.Name, p.Value, "User", u.ID);
                }
            }
        }
Exemple #3
0
        public static string[,] GetAccessMatrix(DAM.Model.System system)
        {
            Dictionary <Tuple <string, int>, string> AccessMatrix = new Dictionary <Tuple <string, int>, string>();

            string[,] matrix = new string[system.Users.Count + 1, system.Objects.Count + 1];
            int i = 1;

            foreach (int c in system.Objects.Select(f => f.ID).Distinct())
            {
                matrix[0, i] = c.ToString();
                i++;
            }
            i = 1;
            foreach (string c in system.Users.Select(f => f.Name).Distinct())
            {
                matrix[i, 0] = c;
                i++;
            }
            i = 1;
            foreach (DAM.Model.User u in system.Users)
            {
                matrix[i, 0] = u.Name;

                for (int j = 1; j < system.Objects.Count; j++)
                {
                    string t = string.Concat(u.Params.Where(f => f.ID == Convert.ToInt32(matrix[0, j])).Select(f => f.Value));
                    matrix[i, j] = string.IsNullOrEmpty(t) ? "-" : t.ToString();
                }
            }
            return(matrix);
        }
Exemple #4
0
        public static string[, ] GetAccessMatrix(DAM.Model.System system)
        {
            Dictionary <Tuple <string, int>, string> AccessMatrix = new Dictionary <Tuple <string, int>, string> ();

            string[, ] matrix = new string[system.Users.Count + 1, system.Objects.Count + 1];
            int i = 1;

            foreach (int c in system.Objects.Select(f => f.ID).Distinct())
            {
                matrix[0, i] = c.ToString();
                i++;
            }
            i = 1;
            foreach (string c in system.Users.Select(f => f.Name).Distinct())
            {
                matrix[i, 0] = c;
                i++;
            }
            i = 1;
            foreach (DAM.Model.User u in system.Users)
            {
                matrix[i, 0] = u.Name;

                for (int j = 1; j < system.Objects.Count; j++)
                {
                    string t = string.Concat(u.Params.Where(f => f.ID == Convert.ToInt32(matrix[0, j])).Select(f => f.Value));
                    matrix[i, j] = string.IsNullOrEmpty(t) ? "-" : t.ToString();
                }
            }

            //     List<KeyValuePair<int, string>> Access = new List<KeyValuePair<int, string>>();
            //     foreach(DAM.Model.Param p in u.Params)
            //     {
            //         Access.Add(new KeyValuePair<int, string>(p.ID, p.Value));
            //         j++;
            //     }
            //     // for(DAM.Model.Object o in system.Objects)
            //     // {

            //     //     j++;
            //     // }
            //     i++;
            // }

            // for(i = 0; i < system.Users.Count; i++)
            // {
            //     for(int j = 0; j < system.Objects.Count; i++)
            //     {
            //         KeyValuePair<int, string> Access = new KeyValuePair<int, string>();
            //         foreach(DAM.Model.Param p in )
            //         matrix[i+1,j+1] =
            //     }
            // }

            // foreach(int c in system.AccessMatrix.Keys.Select(f=>f.Item2).Distinct())
            // {
            //     //matrix[0, i] = system.Objects.Where(f => f.ID == c).FirstOrDefault().Name;
            //     matrix[0, i] = c.ToString();
            //     i++;
            // }
            // i = 1;
            // foreach(string c in system.AccessMatrix.Keys.Select(f=>f.Item1).Distinct())
            // {
            //     matrix[i, 0] = c;i++;
            // }

            // for(i = 0; i < system.Users.Count; i++)
            // {
            //     for(int j = 0; j<system.Objects.Count; j++)
            //     {
            //         matrix[i+1, j+1] = system.AccessMatrix.ContainsKey(new Tuple<string, int>(matrix[i+1, 0], Convert.ToInt32(matrix[0,j+1])))
            //             ? system.AccessMatrix[new Tuple<string, int>(matrix[i+1, 0], Convert.ToInt32(matrix[0, j+1]))]
            //             : "-";
            //     }
            // }
            // for(i = 1; i < system.Objects.Count; i++)
            // {
            //     matrix[0, i] = system.Objects.Where(f => f.ID == Convert.ToInt32(matrix[0, i])).FirstOrDefault().Name;
            // }//foreach (SystemUser u in system.Users)
            // //{
            // //    matrix[i, 0] = u.Name;
            // //    i++;
            // //}
            // //i = 1;
            // //foreach (SystemObject o in system.Objects)
            // //{
            // //    matrix[0, i] = o.Name;
            // //    int j = 1;
            // //    foreach (SystemUser u in system.Users)
            // //    {
            // //        if (u.Params.Any(f => f.ID == o.ID))
            // //            matrix[j, 1] = u.Params.Where(f => f.ID == o.ID).Select(f => f.Value).Aggregate((k, next) => k + next);
            // //        j++;
            // //    }
            // //}
            return(matrix);
        }