Exemplo n.º 1
0
        public object GetView3dUserDataFilter(TaskProjectModel filter)
        {
            List <User> list = new List <User>();

            if (filter == null)
            {
                return(list);
            }

            string[] taskProjectTuple = filter.list.Select(x => x.taskName + "|" + x.projectName).ToArray();

            using (SwarmData context = new SwarmData())
            {
                list = context.Sessions.Include("CodeFiles")
                       .Where(s => s.Started >= new DateTime(2018, 12, 25, 0, 0, 0))
                       .Where(s => s.CodeFiles.Count() > 0)
                       .Where(s => s.DeveloperName != null && s.DeveloperName.Trim() != String.Empty)
                       .Where(s => s.TaskName != null && s.TaskName.Trim() != String.Empty)
                       .Where(s => s.ProjectName != null && s.ProjectName.Trim() != String.Empty)
                       .Where(s => taskProjectTuple.Contains(s.TaskName + "|" + s.ProjectName))
                       .GroupBy(s => s.DeveloperName)
                       .Select(s => s.FirstOrDefault())
                       .OrderByDescending(s => s.Started)
                       .Select(s => new User
                {
                    userName    = s.DeveloperName,
                    taskName    = s.TaskName,
                    projectName = s.ProjectName
                }).ToList();
            }

            return(list);
        }
Exemplo n.º 2
0
        public ActionResult Recalculate()
        {
            using (SwarmData context = new SwarmData())
            {
                List <Session> distinctTask      = context.Sessions.GroupBy(d => new { d.TaskName }).Select(g => g.FirstOrDefault()).ToList();
                string[]       distinctTaskNames = distinctTask.Select(t => t.TaskName).ToArray();

                foreach (string taskName in distinctTaskNames)
                {
                    List <Session> taskSessions = context.Sessions.Where(x => x.TaskName.Equals(taskName)).ToList();

                    double totalMiliTask = 0;

                    foreach (Session session in taskSessions)
                    {
                        if (session.Finished != null)
                        {
                            TimeSpan diff = (DateTime)session.Finished - session.Started;

                            totalMiliTask += diff.TotalMilliseconds;
                        }
                    }

                    //TODO: review logic later, data model changes
                    foreach (Session task in context.Sessions.Where(t => t.TaskName.Equals(taskName)))
                    {
                        task.TaskTotalSessionTime = TimeSpan.FromMilliseconds(totalMiliTask);
                    }
                }

                context.SaveChanges();
            }

            return(RedirectToAction("Index"));
        }
Exemplo n.º 3
0
        public object GetView3dTaskProjectDataFilter()
        {
            List <TaskProjectModel.TaskProject> list = new List <TaskProjectModel.TaskProject>();

            using (SwarmData context = new SwarmData())
            {
                list = context.Sessions.Include("CodeFiles")
                       .Where(s => s.Started >= new DateTime(2018, 12, 25, 0, 0, 0))

                       .Where(s => s.TaskName.Trim().ToLower() != "jhjh".ToLower())
                       .Where(s => s.TaskName.Trim().ToLower() != "Tarefa genérica V2".ToLower())
                       .Where(s => s.TaskName.Trim().ToLower() != "Atividades".ToLower())
                       .Where(s => s.TaskName.Trim().ToLower() != "Contencioso".ToLower())
                       .Where(s => s.TaskName.Trim().ToLower() != "Tarefa generica v2".ToLower())
                       .Where(s => s.TaskName.Trim().ToLower() != "Generic task v2".ToLower())
                       .Where(s => s.TaskName.Trim().ToLower() != "Reload Test".ToLower())
                       .Where(s => s.TaskName.Trim().ToLower() != "PN Event_Id Test".ToLower())

                       .Where(s => s.CodeFiles.Count() > 0)
                       .Where(s => s.DeveloperName != null && s.DeveloperName.Trim() != String.Empty)
                       .Where(s => s.TaskName != null && s.TaskName.Trim() != String.Empty)
                       .Where(s => s.ProjectName != null && s.ProjectName.Trim() != String.Empty)
                       .GroupBy(s => s.TaskName)
                       .Select(s => s.FirstOrDefault())
                       .OrderByDescending(s => s.Started)
                       .Select(s => new TaskProjectModel.TaskProject
                {
                    taskName    = s.TaskName,
                    projectName = s.ProjectName
                }).ToList();
            }

            return(list);
        }
 public IEnumerable <dynamic> GetDistinctProjects()
 {
     using (SwarmData context = new SwarmData())
     {
         return(context.Sessions.GroupBy(s => s.ProjectName).Select(s => s.FirstOrDefault()).OrderBy(s => s.ProjectName).Select(s => new { key = s.Id, value = s.ProjectName }).ToList());
     }
 }
        public List <ElementModel.Element> GetSessionVisualization(string id)
        {
            ElementModel    model        = new ElementModel();
            List <PathNode> pnCollection = new List <PathNode>();

            using (SwarmData context = new SwarmData())
            {
                pnCollection = context.PathNodes
                               .Where(pn => pn.Session.Id.ToString() == id).OrderBy(pn => pn.Created).ToList();
            }

            //load nodes
            foreach (PathNode pn in pnCollection)
            {
                model.ElementCollection.Add(new ElementModel.Element()
                {
                    data = new ElementModel.Data()
                    {
                        id        = pn.Id.ToString(),
                        parent_id = pn.Parent_Id.ToString(),
                        method    = pn.Method,
                        nodeinfo  = new ElementModel.NodeInfo()
                        {
                            name_space = pn.Namespace,
                            type       = pn.Type,
                            method     = pn.Method,
                            returntype = pn.ReturnType,
                            origin     = pn.Origin,
                            created    = pn.Created.ToShortDateString()
                        }
                    }
                });
            }

            //load edges
            List <ElementModel.Element> edgesCollection = new List <ElementModel.Element>();

            foreach (ElementModel.Element element in model.ElementCollection)
            {
                if (element.data.parent_id == Guid.Empty.ToString())
                {
                    continue;
                }

                edgesCollection.Add(new ElementModel.Element()
                {
                    data = new ElementModel.Data()
                    {
                        id     = element.data.id + "-" + element.data.id,
                        source = element.data.parent_id,
                        target = element.data.id
                    }
                });
            }

            model.ElementCollection.AddRange(edgesCollection);

            return(model.ElementCollection);
        }
Exemplo n.º 6
0
        //TODO: review later, probaly delete
        //public List<PathNode> MountTreeByType(List<PathNode> pnCollection)
        //{
        //    List<PathNode> tree = new List<PathNode>();

        //    List<PathNode> roots = pnCollection.Where(pn => pn.Parent_Id == Guid.Empty).ToList();

        //    tree.AddRange(roots);

        //    foreach (PathNode root in roots)
        //    {
        //        foreach (PathNode child in pnCollection.Where(pn => pn.Parent_Id == root.Id).ToList())
        //        {
        //            if (tree.Any(pn => pn.Type == child.Type))
        //                continue;

        //            tree.Add(child);

        //            PathNode parent = tree
        //        }
        //    }
        //}

        public List <ElementModel.Element> GetTaskVisualization(string id)
        {
            ElementModel      model        = new ElementModel();
            List <PathNode>   pnCollection = new List <PathNode>();
            List <Breakpoint> bCollection  = new List <Breakpoint>();

            using (SwarmData context = new SwarmData())
            {
                var    sessionFilter = context.Sessions.Where(s => s.Id.ToString() == id).Select(s => new { TaskName = s.TaskName, ProjectName = s.ProjectName }).FirstOrDefault();
                Guid[] sessionIds    = context.Sessions.Where(s => s.TaskName == sessionFilter.TaskName && s.ProjectName == sessionFilter.ProjectName).Select(s => s.Id).ToArray();

                pnCollection = context.PathNodes.Where(pn => sessionIds.Contains(pn.Session.Id)).GroupBy(pn => pn.Type).Select(pn => pn.FirstOrDefault()).OrderBy(pn => pn.Created).ToList();
                bCollection  = context.Breakpoints.Where(b => sessionIds.Contains(b.Session.Id)).GroupBy(b => new { b.Namespace, b.Type, b.LineNumber }).Select(b => b.FirstOrDefault()).ToList();
            }

            NodeColor nodeColor = new NodeColor(bCollection);

            //load nodes
            foreach (PathNode pn in pnCollection)
            {
                model.ElementCollection.Add(new ElementModel.Element()
                {
                    data = new ElementModel.Data()
                    {
                        id        = pn.Id.ToString(),
                        parent_id = model.ElementCollection.Count() == 0 ? null : model.ElementCollection.Last().data.id,
                        method    = pn.Type + " - " + bCollection.Where(b => b.Type == pn.Type).Count().ToString(),
                        size      = bCollection.Where(b => b.Type == pn.Type).Count() + 10,
                        color     = nodeColor.GetColor(pn.Type)
                    }
                });
            }

            //load edges
            List <ElementModel.Element> edgesCollection = new List <ElementModel.Element>();

            foreach (ElementModel.Element element in model.ElementCollection)
            {
                if (String.IsNullOrWhiteSpace(element.data.parent_id))
                {
                    continue;
                }

                edgesCollection.Add(new ElementModel.Element()
                {
                    data = new ElementModel.Data()
                    {
                        id     = element.data.id + "-" + element.data.id,
                        source = element.data.parent_id,
                        target = element.data.id
                    }
                });
            }

            model.ElementCollection.AddRange(edgesCollection);

            return(model.ElementCollection);
        }
Exemplo n.º 7
0
        public List <PharoSessionModel> GetAll()
        {
            List <PharoSessionModel> sessionModelCollection = new List <PharoSessionModel>();

            using (SwarmData context = new SwarmData())
            {
                sessionModelCollection = context.PharoSessions.Select(s => new PharoSessionModel
                {
                    Id          = s.Id,
                    Description = s.Description,
                    Started     = s.Started,
                    Finished    = s.Finished
                }).ToList();

                return(sessionModelCollection);
            }
        }
Exemplo n.º 8
0
        public IEnumerable <TaskGridModel> GetTaskGrid()
        {
            using (SwarmData context = new SwarmData())
            {
                List <Session> distinctTask    = context.Sessions.GroupBy(d => new { d.ProjectName, d.TaskName }).Select(g => g.FirstOrDefault()).ToList();
                Guid[]         distinctTaskIds = distinctTask.Select(t => t.Id).ToArray();

                return(context.Sessions.Where(d => distinctTaskIds.Contains(d.Id)).Select(t => new TaskGridModel
                {
                    Identifier = t.Id.ToString(),
                    ProjectName = t.ProjectName,
                    Name = t.TaskName,
                    Description = t.TaskDescription,
                    Action = t.TaskAction,
                    Created = t.TaskCreated
                }).ToList());
            }
        }
Exemplo n.º 9
0
        public View GetView3dData(SessionFilterModel filter)
        {
            View view = new View {
                sessions = new List <Session>(), groups = new List <Group>()
            };

            if (filter == null)
            {
                return(view);
            }

            Guid[] idsList = filter.list.Select(x => Guid.Parse(x.id)).ToArray();

            using (SwarmData context = new SwarmData())
            {
                var sessions = context.Sessions
                               .Where(s => idsList.Contains(s.Id))
                               .OrderBy(s => s.Started)
                               .Select(s => s.Id)
                               .ToList();

                view.groups = context.CodeFiles
                              .Where(c => sessions.Contains(c.Session.Id))
                              .OrderBy(c => c.Created)
                              .AsEnumerable()
                              .Select(c => new { pathOnly = System.IO.Path.GetDirectoryName(c.Path).ToLower() })
                              .Distinct()
                              .Select((po, i) => new Group {
                    groupId = i, maxIndexWidthQuantity = 0, path = po.pathOnly
                })
                              .ToList();

                view.sessions = getSessions(context.Sessions
                                            .Include("CodeFiles")
                                            .Include("Breakpoints")
                                            .Include("Events")
                                            .Include("PathNodes")
                                            .Where(s => sessions.Contains(s.Id))
                                            .OrderBy(s => s.Started).ToList(),
                                            view.groups);
            }

            return(view);
        }
 public IEnumerable <SessionGridModel> GetSessionGrid()
 {
     using (SwarmData context = new SwarmData())
     {
         return(context.Sessions.OrderByDescending(s => s.Started).Select(s => new SessionGridModel
         {
             Identifier = s.Id,
             TaskName = s.TaskName,
             TaskAction = s.TaskAction,
             TaskProjectName = s.ProjectName,
             DeveloperName = s.DeveloperName,
             Started = s.Started,
             Finished = s.Finished,
             BreakpointCount = s.Breakpoints.Count,
             EventCount = s.Events.Count,
             PathNodeCount = s.PathNodes.Count
         }).ToList());
     }
 }
Exemplo n.º 11
0
        public object GetView3dSessionDataFilter(UserModel filter)
        {
            List <SessionFilter> list = new List <SessionFilter>();

            if (filter == null)
            {
                return(list);
            }

            string[] tuplesFilter = filter.list.Select(x => x.userName + "|" + x.taskName + "|" + x.projectName).ToArray();

            using (SwarmData context = new SwarmData())
            {
                var sessions = context.Sessions
                               .Where(s => s.Started >= new DateTime(2018, 12, 25, 0, 0, 0))
                               .Where(s => s.DeveloperName != null && s.DeveloperName.Trim() != String.Empty)
                               .Where(s => s.TaskName != null && s.TaskName.Trim() != String.Empty)
                               .Where(s => s.ProjectName != null && s.ProjectName.Trim() != String.Empty)
                               .Where(s => tuplesFilter.Contains(s.DeveloperName + "|" + s.TaskName + "|" + s.ProjectName))
                               .Select(s => s.Id)
                               .ToList();

                list = context.Sessions
                       .Include("CodeFiles")
                       .Include("Breakpoints")
                       .Include("Events")
                       .Include("PathNodes")
                       .Where(s => s.CodeFiles.Count() > 0)
                       .Where(s => sessions.Contains(s.Id))
                       .OrderByDescending(s => s.Started)
                       .AsEnumerable()
                       .Select((s, i) => new SessionFilter
                {
                    sessionId       = s.Id.ToString(),
                    name            = String.Format("{0:dd/MM/yyyy HH:mm:ssZ}", s.Started),
                    breakpointCount = s.Breakpoints.Count,
                    eventCount      = s.Events.Where(e => e.EventKind == "StepInto" || e.EventKind == "StepOver" || e.EventKind == "BreakpointHitted").Count()
                }).ToList();
            }

            return(list);
        }
Exemplo n.º 12
0
            public async System.Threading.Tasks.Task ProcessPosting()
            {
                await System.Threading.Tasks.Task.Run(() =>
                {
                    lock (PostSessionList)
                    {
                        using (SwarmData context = new SwarmData())
                        {
                            while (PostSessionList.Count > 0)
                            {
                                PharoSession session = PostSessionList.Dequeue();

                                if (session == null)
                                {
                                    continue;
                                }

                                if (session.Id == new Guid("00000000-0000-0000-0000-000000000000"))
                                {
                                    continue;
                                }

                                PharoSession original = context.PharoSessions.FirstOrDefault(s => s.Id == session.Id);

                                if (original == null)
                                {
                                    context.PharoSessions.Add(session);
                                }
                                else
                                {
                                    context.Entry(original).CurrentValues.SetValues(session);
                                }

                                context.SaveChanges();
                            }
                        }
                    }
                });
            }
Exemplo n.º 13
0
        public string GetView3dSourceCode(string originalId)
        {
            string sourceCode = "Something wrong on process source code search.";

            if (String.IsNullOrWhiteSpace(originalId))
            {
                return(sourceCode + " Original Id is null or empty.");
            }

            using (SwarmData context = new SwarmData())
            {
                CodeFile codeFile = context.CodeFiles.Include("Session").Where(c => c.Id.ToString() == originalId).FirstOrDefault();
                sourceCode = codeFile.Content;

                if (String.IsNullOrWhiteSpace(sourceCode))
                {
                    return("No source code found.");
                }

                sourceCode = ProcessUnzipString(codeFile.Session.Description, sourceCode);
            }

            return(sourceCode);
        }
        public List <SessionModel> GetAll()
        {
            List <SessionModel> sessionModelCollection = new List <SessionModel>();

            using (SwarmData context = new SwarmData())
            {
                sessionModelCollection = context.Sessions.Select(s => new SessionModel
                {
                    Id              = s.Id,
                    Description     = s.Description,
                    Started         = s.Started,
                    Finished        = s.Finished,
                    TaskName        = s.TaskName,
                    TaskDescription = s.TaskDescription,
                    TaskAction      = s.TaskAction,
                    TaskCreated     = s.TaskCreated,
                    ProjectName     = s.ProjectName,
                    DeveloperName   = s.DeveloperName,
                    Breakpoints     = s.Breakpoints.Select(b => new BreakpointModel
                    {
                        Id             = b.Id,
                        BreakpointKind = b.BreakpointKind,
                        Created        = b.Created,
                        LineNumber     = b.LineNumber ?? 0,
                        LineOfCode     = b.LineOfCode,
                        Namespace      = b.Namespace,
                        Origin         = b.Origin,
                        Type           = b.Type
                    }).ToList(),
                    CodeFiles = s.CodeFiles.Select(c => new CodeFileModel
                    {
                        Id      = c.Id,
                        Path    = c.Path,
                        Content = c.Content,
                        Created = c.Created
                    }).ToList(),
                    Events = s.Events.Select(e => new EventModel
                    {
                        Id              = e.Id,
                        CharEnd         = e.CharEnd ?? 0,
                        CharStart       = e.CharStart ?? 0,
                        Created         = e.Created,
                        Detail          = e.Detail,
                        EventKind       = e.EventKind,
                        LineNumber      = e.LineNumber ?? 0,
                        LineOfCode      = e.LineOfCode,
                        Method          = e.Method,
                        MethodKey       = e.MethodKey,
                        MethodSignature = e.MethodSignature,
                        Namespace       = e.Namespace,
                        Type            = e.Type,
                        TypeFullPath    = e.TypeFullPath
                    }).ToList(),
                    PathNodes = s.PathNodes.Select(p => new PathNodeModel
                    {
                        Id         = p.Id,
                        Created    = p.Created,
                        Type       = p.Type,
                        Namespace  = p.Namespace,
                        Hash       = p.Hash,
                        Method     = p.Method,
                        Origin     = p.Origin,
                        Parameters = p.Parameters.Select(pp => new PathNodeParameterModel
                        {
                            Id    = pp.Id,
                            Name  = pp.Name,
                            Type  = pp.Type,
                            Value = pp.Value
                        }).ToList(),
                        Parent     = p.Parent,
                        Parent_Id  = p.Parent_Id,
                        ReturnType = p.ReturnType
                    }).ToList()
                }).ToList();

                return(sessionModelCollection);
            }
        }
            public async System.Threading.Tasks.Task ProcessPosting()
            {
                await System.Threading.Tasks.Task.Run(() =>
                {
                    lock (PostSessionList)
                    {
                        using (SwarmData context = new SwarmData())
                        {
                            while (PostSessionList.Count > 0)
                            {
                                Session session = PostSessionList.Dequeue();

                                if (session == null)
                                {
                                    continue;
                                }

                                if (session.Id == new Guid("00000000-0000-0000-0000-000000000000"))
                                {
                                    continue;
                                }

                                Session original = context.Sessions
                                                   .Include("Breakpoints")
                                                   .Include("Events")
                                                   .Include("PathNodes")
                                                   .Include("CodeFiles")
                                                   .FirstOrDefault(s => s.Id == session.Id);

                                if (original == null)
                                {
                                    context.Sessions.Add(session);
                                }
                                else
                                {
                                    context.Entry(original).CurrentValues.SetValues(session);

                                    if (session.Breakpoints != null)
                                    {
                                        foreach (Breakpoint item in session.Breakpoints)
                                        {
                                            if (!original.Breakpoints.Any(x => x.Id == item.Id))
                                            {
                                                original.Breakpoints.Add(item);
                                            }
                                        }
                                    }

                                    if (session.CodeFiles != null)
                                    {
                                        foreach (CodeFile item in session.CodeFiles)
                                        {
                                            if (!original.CodeFiles.Any(x => x.Id == item.Id))
                                            {
                                                original.CodeFiles.Add(item);
                                            }
                                        }
                                    }

                                    if (session.Events != null)
                                    {
                                        foreach (Event item in session.Events)
                                        {
                                            if (!original.Events.Any(x => x.Id == item.Id))
                                            {
                                                original.Events.Add(item);
                                            }
                                        }
                                    }

                                    if (session.PathNodes != null)
                                    {
                                        foreach (PathNode item in session.PathNodes)
                                        {
                                            if (!original.PathNodes.Any(x => x.Id == item.Id))
                                            {
                                                original.PathNodes.Add(item);
                                            }
                                        }
                                    }
                                }

                                context.SaveChanges();
                            }
                        }
                    }
                });
            }