コード例 #1
0
ファイル: EntityExtension.cs プロジェクト: ShyAlon/DeepDev
 public static ProjectUserType GetUserType(this User user, Project project, UIBuildItContext db)
 {
     using (MiniProfiler.Current.Step("Get user type for " + user.Name))
     {
         if (project == null) // Not associated with a project
         {
             return ProjectUserType.Owner;
         }
         if (project.Owner == null)
         {
             // Creator becomes owner
             return ProjectUserType.Owner;
         }
         if (user.Id == project.Owner.Id)
         {
             return ProjectUserType.Owner;
         }
         var projectUsers = (from pu in db.ProjectUsers
                             where pu.UserMail == user.Email && pu.ProjectId == project.Id
                             select pu).ToList();
         if (projectUsers == null || projectUsers.Count == 0)
         {
             return ProjectUserType.None;
         }
         var result = ProjectUserType.None;
         foreach (var pu in projectUsers)
         {
             result |= pu.UserType;
         }
         return result;
     }
 }
コード例 #2
0
ファイル: GanttRow.cs プロジェクト: ShyAlon/DeepDev
        internal static ICollection<GanttRow> GenerateRows(Project project, UIBuildItContext db)
        {
            _rows = new List<GanttRow>();
            var milestones = (from m in db.Milestones.AsNoTracking()
                             where m.ParentId == project.Id
                             select m).ToList();
            foreach(var m in milestones)
            {
                var row = new GanttRow() { id = (int)m.HashIndex(), parent = 0, progress = 0, duration = 0, text = m.Name };
                _rows.Add(row);

                var sprintSpans = AddSprintRows(m, db);
                var taskSpans = AddExecutionUnitTasks(m, db);
                var start = (sprintSpans.Item1 < taskSpans.Item1) ? sprintSpans.Item1: taskSpans.Item1;
                row.start_date = start.ToString("dd-MM-yyyy");
                var end = (sprintSpans.Item2 > taskSpans.Item2) ? sprintSpans.Item2 : taskSpans.Item2;
                row.duration = 0;// (int)(end - start).TotalHours / hoursPerDay;
            }

            return _rows;
        }
コード例 #3
0
 private bool AuthorizeRequest(HttpControllerContext context)
 {
     bool authorized = false;
     if (context.Request.Headers.Contains("Authorization"))
     {
         var tokenValue = context.Request.Headers.GetValues("Authorization");
         if (tokenValue.Count() == 1)
         {
             var value = tokenValue.FirstOrDefault();
             //Token validation logic here
             //set authorized variable accordingly
             using(UIBuildItContext db = new UIBuildItContext())
             {
                 Token = db.Tokens.FirstOrDefault(t => t.Text == value);
                 authorized = Token != null && Token.Expiration > DateTime.UtcNow;
                 if(Token != null)
                 {
                     context.Request.Properties.Add("user", db.Users.FirstOrDefault(u =>u.Id == Token.UserId));
                 }
             }
         }
     }
     return authorized;
 }
コード例 #4
0
ファイル: GanttRow.cs プロジェクト: ShyAlon/DeepDev
        private static Tuple<DateTime, DateTime> AddTaskTasks(Task s, List<Task> tasks, UIBuildItContext db)
        {
            var result = new List<string>();
            DateTime start = DateTime.MaxValue;
            DateTime end = DateTime.MinValue;
            var children = (from t in tasks where t.ParentType == "Task" && t.ParentId == s.Id select t).ToList();
            if (children.Count == 0)
            {
                return new Tuple<DateTime, DateTime>(s.StartTime, s.EndTime);
            }
            else
            {
                foreach (var c in children)
                {
                    if (c.StartTime > new DateTime(1950, 1, 1) && c.EndTime < new DateTime(2222, 1, 1))
                    {
                        var row = new GanttRow(c);
                        _rows.Add(row);
                        row.parent = (int)s.HashIndex();
                        if (start < c.StartTime)
                        {
                            start = c.StartTime;
                        }
                        if (end < c.EndTime)
                        {
                            end = c.EndTime;
                        }
                        var times = AddTaskTasks(c, tasks, db);
                        if (start > times.Item1)
                        {
                            start = times.Item1;
                        }
                        if (end < times.Item2)
                        {
                            end = times.Item2;
                        }
                    }
                }
            }

            return new Tuple<DateTime,DateTime>(start, end);
        }
コード例 #5
0
ファイル: GanttRow.cs プロジェクト: ShyAlon/DeepDev
 private static Tuple<DateTime, DateTime> AddSprintRows(Milestone m, UIBuildItContext db)
 {
     DateTime start = DateTime.MaxValue;
     DateTime end = DateTime.MinValue;
     var sprints = (from s in db.Sprints.AsNoTracking()
                       where s.ParentId == m.Id
                       select s).ToList();
     foreach(var s in sprints)
     {
         var times = AddExecutionUnitTasks(s, db);
         if (times.Item1 > new DateTime(1950, 1, 1) && times.Item1 != DateTime.MaxValue && times.Item2 < new DateTime(2222, 1, 1) && times.Item2 != DateTime.MinValue)
         {
             var row = new GanttRow(s);
             _rows.Add(row);
             row.start_date = times.Item1.ToString("dd-MM-yyyy");
             row.duration = 0;// (int)(times.Item2 - times.Item1).TotalHours / hoursPerDay;
             row.parent = (int)m.HashIndex();
             if (start > times.Item1)
             {
                 start = times.Item1;
             }
             if (end < times.Item2)
             {
                 end = times.Item2;
             }
         }
     }
     return new Tuple<DateTime, DateTime>(start, end);
 }
コード例 #6
0
ファイル: GanttRow.cs プロジェクト: ShyAlon/DeepDev
        private static Tuple<DateTime, DateTime> AddExecutionUnitTasks(Item i, UIBuildItContext db)
        {
            DateTime start = DateTime.MaxValue;
            DateTime end = DateTime.MinValue;
            var tasks = i is Milestone ?
                (from s in db.Tasks.AsNoTracking()
                 where s.ContainerType == ContainerType.Milestone && s.ContainerID == i.Id
                 select s).ToList()
                           : (from s in db.Tasks.AsNoTracking()
                              where s.ContainerType == ContainerType.Sprint && s.ContainerID == i.Id
                              select s).ToList();
            var topLevel = (from t in tasks where t.ParentType != "Task" select t).ToList();
            foreach (var s in topLevel)
            {
                var times = AddTaskTasks(s, tasks, db);
                if (times.Item1 > new DateTime(1950, 1, 1) && times.Item1 != DateTime.MaxValue && times.Item2 < new DateTime(2222, 1, 1) && times.Item2 != DateTime.MinValue)
                {
                    if (s.StartTime > new DateTime(1950, 1, 1) && s.EndTime < new DateTime(2222, 1, 1))
                    {
                        var row = new GanttRow(s);
                        row.parent = (int)i.HashIndex();
                        _rows.Add(row);
                        if (s.StartTime < start)
                        {
                            start = s.StartTime;
                        }
                        if (s.EndTime > end)
                        {
                            end = s.EndTime;
                        }
                        if (start > times.Item1)
                        {
                            start = times.Item1;
                        }
                        if (end < times.Item2)
                        {
                            end = times.Item2;
                        }
                    }
                }
            }

            return new Tuple<DateTime, DateTime>(start, end);
        }
コード例 #7
0
ファイル: EntityExtension.cs プロジェクト: ShyAlon/DeepDev
 public static bool IsSystemEngineer(this User user, Project project, UIBuildItContext db)
 {
     return user.IsOwner(project) ||
         (ProjectUserType.SystemEngineer & user.GetUserType(project, db)) == ProjectUserType.SystemEngineer;
 }
コード例 #8
0
ファイル: EntityExtension.cs プロジェクト: ShyAlon/DeepDev
 public static bool IsProductManager(this User user, Project project, UIBuildItContext db)
 {
     return user.IsOwner(project) ||
         (ProjectUserType.ProductManager & user.GetUserType(project, db)) == ProjectUserType.ProductManager;
 }