Exemple #1
0
        public List <ulong> GetHigherRegion(ulong id, uint project)
        {
            // all users form id to the top, and direct subs of superior

            List <ulong> highers = Trust.GetUplinkIDs(id, project); // works for loops

            highers.AddRange(Trust.GetAdjacentIDs(id, project));

            highers.Remove(id); // remove target


            return(highers);
        }
Exemple #2
0
        public override void Init()
        {
            Profiles.ProfileUpdate += new ProfileUpdateHandler(Profile_Update);
            Trust.GuiUpdate        += new LinkGuiUpdateHandler(Trust_Update);
            Core.KeepDataGui       += new KeepDataHandler(Core_KeepData);

            OpProfile profile = Profiles.GetProfile(UserID);

            if (profile == null)
            {
                DisplayLoading();
            }
            else
            {
                Profile_Update(profile);
            }

            // have to set twice (init document?) for page to show up
            if (GuiUtils.IsRunningOnMono())
            {
                if (profile == null)
                {
                    DisplayLoading();
                }
                else
                {
                    Profile_Update(profile);
                }
            }

            List <ulong> ids = new List <ulong>();

            ids.AddRange(Trust.GetUplinkIDs(UserID, ProjectID));

            foreach (ulong id in ids)
            {
                Profiles.Research(id);
            }
        }
Exemple #3
0
        private void ReloadGoals()
        {
            TreeMap.Clear();
            GoalTree.Nodes.Clear();

            List <ulong> uplinks = Trust.GetUplinkIDs(View.UserID, View.ProjectID);

            uplinks.Add(View.UserID);

            // show all branches
            if (!MineOnly.Checked)
            {
                GoalNode root = CreateNode(Head);
                LoadNode(root);
                GoalTree.Nodes.Add(root);

                ExpandPath(root, uplinks);
            }

            // show only our branch
            else if (Head != null)
            {
                foreach (ulong id in uplinks)
                {
                    OpPlan plan = Plans.GetPlan(id, true);

                    if (plan != null && plan.GoalMap.ContainsKey(Head.Ident))
                    {
                        foreach (PlanGoal goal in plan.GoalMap[Head.Ident])
                        {
                            if (goal.Person == View.UserID)
                            {
                                GoalNode root = CreateNode(goal);
                                LoadNode(root);
                                InsertSubNode(GoalTree.virtualParent, root);
                                root.Expand();
                            }
                        }
                    }
                }
            }

            Reselect();
        }
Exemple #4
0
        public override void Init()
        {
            Trust.GuiUpdate  += new LinkGuiUpdateHandler(Trust_Update);
            Plans.PlanUpdate += new PlanUpdateHandler(Plans_Update);

            Core.KeepDataGui += new KeepDataHandler(Core_KeepData);


            splitContainer1.Height = Height - toolStrip1.Height;

            MainPanel.Init(this);


            // research highers for assignments
            List <ulong> ids = Trust.GetUplinkIDs(UserID, ProjectID);

            foreach (ulong id in ids)
            {
                Plans.Research(id);
            }


            RefreshAssigned();
        }
Exemple #5
0
        private void RefreshGoalCombo()
        {
            GoalComboItem prevItem = GoalCombo.SelectedItem as GoalComboItem;

            int prevSelectedID = 0;

            if (prevItem != null)
            {
                prevSelectedID = prevItem.ID;
            }

            GoalCombo.Items.Clear();

            GoalCombo.Items.Add(new GoalComboItem("None", 0));

            // go up the chain looking for goals which have been assigned to this person
            // at root goal is the title of the goal


            List <PlanGoal> rootList = new List <PlanGoal>();
            List <int>      assigned = new List <int>();

            // foreach self & higher
            List <ulong> ids = Trust.GetUplinkIDs(UserID, ProjectID);

            ids.Add(UserID);

            foreach (ulong id in ids)
            {
                OpPlan plan = Plans.GetPlan(id, true);

                if (plan == null)
                {
                    continue;
                }

                // goals we have been assigned to
                foreach (List <PlanGoal> list in plan.GoalMap.Values)
                {
                    foreach (PlanGoal goal in list)
                    {
                        if (goal.Project != ProjectID)
                        {
                            break;
                        }

                        if (goal.Person == UserID && !assigned.Contains(goal.Ident))
                        {
                            assigned.Add(goal.Ident);
                        }

                        if (goal.BranchDown == 0)
                        {
                            if (!goal.Archived)
                            {
                                rootList.Add(goal);
                            }
                        }
                    }
                }
            }

            // update combo
            GoalComboItem prevSelected = null;

            foreach (PlanGoal goal in rootList)
            {
                if (assigned.Contains(goal.Ident))
                {
                    GoalComboItem item = new GoalComboItem(goal.Title, goal.Ident);

                    if (goal.Ident == prevSelectedID)
                    {
                        prevSelected = item;
                    }

                    GoalCombo.Items.Add(item);
                }
            }

            if (prevSelected != null)
            {
                GoalCombo.SelectedItem = prevSelected;
            }
            else
            {
                GoalCombo.SelectedIndex = 0;
            }
        }
Exemple #6
0
        private void RefreshTemplates()
        {
            Templates.Clear();

            // list chain of command first
            List <ulong> highers = Links.GetUplinkIDs(Core.UserID, 0);

            highers.Reverse();
            highers.Add(Links.LocalTrust.UserID);

            // list higher level users, indent also
            // dont repeat names using same template+
            int space = 0;

            foreach (ulong id in highers)
            {
                ProfileTemplate add = GetTemplate(id);

                if (add == null || add.Hash == null)
                {
                    continue;
                }

                foreach (ProfileTemplate template in TemplateCombo.Items)
                {
                    if (Utilities.MemCompare(add.Hash, template.Hash))
                    {
                        continue;
                    }
                }

                for (int i = 0; i < space; i++)
                {
                    add.User = "******" + add.User;
                }

                TemplateCombo.Items.Add(add);

                space += 4;
            }

            // sort rest alphabetically
            List <ProfileTemplate> templates = new List <ProfileTemplate>();

            // read profile header file
            Profiles.ProfileMap.LockReading(delegate()
            {
                foreach (ulong id in Profiles.ProfileMap.Keys)
                {
                    ProfileTemplate add = GetTemplate(id);

                    if (add == null || add.Hash == null)
                    {
                        continue;
                    }

                    bool dupe = false;

                    foreach (ProfileTemplate template in TemplateCombo.Items)
                    {
                        if (Utilities.MemCompare(add.Hash, template.Hash))
                        {
                            dupe = true;
                        }
                    }

                    foreach (ProfileTemplate template in templates)
                    {
                        if (Utilities.MemCompare(add.Hash, template.Hash))
                        {
                            dupe = true;
                        }
                    }

                    if (!dupe)
                    {
                        templates.Add(add);
                    }
                }
            });

            // add space between chain items and other items
            if (TemplateCombo.Items.Count > 0 && templates.Count > 0)
            {
                TemplateCombo.Items.Add(new ProfileTemplate(true, false));
            }

            templates.Sort();
            foreach (ProfileTemplate template in templates)
            {
                TemplateCombo.Items.Add(template);
            }

            // select local template
            ProfileTemplate local = GetTemplate(Core.UserID);

            if (local != null)
            {
                foreach (ProfileTemplate template in TemplateCombo.Items)
                {
                    if (Utilities.MemCompare(local.Hash, template.Hash))
                    {
                        TemplateCombo.SelectedItem = template;
                        break;
                    }
                }
            }
        }
Exemple #7
0
        public void GetAssignedGoals(ulong target, uint project, List <PlanGoal> roots, List <PlanGoal> archived)
        {
            List <PlanGoal> tempRoots    = new List <PlanGoal>();
            List <PlanGoal> tempArchived = new List <PlanGoal>();

            List <int> assigned = new List <int>();

            // foreach self & higher
            List <ulong> ids = Trust.GetUplinkIDs(target, project);

            ids.Add(target);

            foreach (ulong id in ids)
            {
                OpPlan plan = GetPlan(id, true);

                if (plan == null)
                {
                    continue;
                }

                // apart of goals we have been assigned to

                foreach (List <PlanGoal> list in plan.GoalMap.Values)
                {
                    foreach (PlanGoal goal in list)
                    {
                        if (goal.Project != project)
                        {
                            break;
                        }

                        if (goal.Person == target && !assigned.Contains(goal.Ident))
                        {
                            assigned.Add(goal.Ident);
                        }

                        if (goal.BranchDown == 0)
                        {
                            if (goal.Archived)
                            {
                                tempArchived.Add(goal);
                            }
                            else
                            {
                                tempRoots.Add(goal);
                            }
                        }
                    }
                }
            }

            foreach (PlanGoal goal in tempArchived)
            {
                if (assigned.Contains(goal.Ident))
                {
                    archived.Add(goal);
                }
            }

            foreach (PlanGoal goal in tempRoots)
            {
                if (assigned.Contains(goal.Ident))
                {
                    roots.Add(goal);
                }
            }
        }