예제 #1
0
파일: GoalPanel.cs 프로젝트: nandub/DeOps
        bool CheckGoal(ulong higher, PlanGoal goal)
        {
            // if only branch
            if (MineOnly.Checked && View.UserID != goal.Person)
            {
                if (!Trust.IsHigher(View.UserID, goal.Person, View.ProjectID) && // show only if person is higher than self
                    !Trust.IsLower(View.UserID, goal.Person, View.ProjectID))    // or is lower than self
                {
                    return(false);
                }
            }

            // only subordinates can have goals assigned
            if (!Trust.IsLower(higher, goal.Person, View.ProjectID))
            {
                return(false);
            }

            return(true);
        }
예제 #2
0
파일: PlanService.cs 프로젝트: nandub/DeOps
        private void Cache_FileAquired(OpVersionedFile file)
        {
            OpPlan prevPlan = GetPlan(file.UserID, false);

            OpPlan newPlan = new OpPlan(file);

            PlanMap.SafeAdd(newPlan.UserID, newPlan);

            if (file.UserID == Core.UserID)
            {
                LocalPlan = newPlan;
            }

            if ((newPlan == LocalPlan) || (prevPlan != null && prevPlan.Loaded)) // if loaded, reload
            {
                LoadPlan(newPlan.UserID);
            }


            // update subs
            if (Network.Established)
            {
                List <LocationData> locations = new List <LocationData>();

                Trust.ProjectRoots.LockReading(delegate()
                {
                    foreach (uint project in Trust.ProjectRoots.Keys)
                    {
                        if (newPlan.UserID == Core.UserID || Trust.IsHigher(newPlan.UserID, project))
                        {
                            Trust.GetLocsBelow(Core.UserID, project, locations);
                        }
                    }
                });

                Store.PublishDirect(locations, newPlan.UserID, ServiceID, DataTypeFile, newPlan.File.SignedHeader);
            }


            // see if we need to update our own goal estimates
            if (newPlan.UserID != Core.UserID && LocalPlan != null)
            {
                Trust.ProjectRoots.LockReading(delegate()
                {
                    foreach (uint project in Trust.ProjectRoots.Keys)
                    {
                        if (Trust.IsLower(Core.UserID, newPlan.UserID, project)) // updated plan must be lower than us to have an effect
                        {
                            foreach (int ident in LocalPlan.GoalMap.Keys)
                            {
                                if (!newPlan.Loaded)
                                {
                                    LoadPlan(newPlan.UserID);
                                }

                                // if updated plan part of the same goal ident, re-estimate our own goals, incorporating update's changes
                                if (newPlan.GoalMap.ContainsKey(ident) || newPlan.ItemMap.ContainsKey(ident))
                                {
                                    foreach (PlanGoal goal in LocalPlan.GoalMap[ident])
                                    {
                                        int completed = 0, total = 0;

                                        GetEstimate(goal, ref completed, ref total);

                                        if (completed != goal.EstCompleted || total != goal.EstTotal)
                                        {
                                            goal.EstCompleted = completed;
                                            goal.EstTotal     = total;

                                            if (RunSaveLocal == 0) // if countdown not started, start
                                            {
                                                RunSaveLocal = SaveInterval;
                                            }
                                        }
                                    }
                                }
                            }
                        }
                    }
                });
            }


            Core.RunInGuiThread(PlanUpdate, newPlan);

            if (Core.NewsWorthy(newPlan.UserID, 0, false))
            {
                Core.MakeNews(ServiceIDs.Plan, "Plan updated by " + Core.GetName(newPlan.UserID), newPlan.UserID, 0, false);
            }
        }