Ejemplo n.º 1
0
 public void SetData()
 {
     projectsContainer = RedMineManager.Get <ProjectsContainer>("/projects.json");
     projectsGroups    = ProjectsContainer.GetProjectsGroupId();
     projectsItems     = ProjectsContainer.GetProjectsItemsId(projectsContainer);
     mAdapter          = new ExpandableListViewAdapter(this, projectsGroups, projectsItems, projectsContainer.projects);
     RunOnUiThread(() => LVProjects.SetAdapter(mAdapter));
 }
Ejemplo n.º 2
0
        public static Dictionary <int, List <int> > GetProjectsItemsId(ProjectsContainer projectContainer)
        {
            var result = new Dictionary <int, List <int> >();

            foreach (var project in projectContainer.projects)
            {
                var query = from r in projectContainer.projects
                            where r.parent != null && r.parent.id == project.id
                            select r.id;
                result.Add(project.id, query.ToList());
            }
            return(result);
        }
Ejemplo n.º 3
0
        protected override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);
            SetContentView(Resource.Layout.new_project_layout);
            projects = RedMineManager.Get <ProjectsContainer>("/projects.json");

            toolbar = FindViewById <Toolbar>(Resource.Id.toolbar);
            toolbar.SetTitle(Resource.String.NewProject);
            SetSupportActionBar(toolbar);

            SupportActionBar.SetHomeAsUpIndicator(Resource.Drawable.ic_arrow_back_white_18dp);
            SupportActionBar.SetDisplayHomeAsUpEnabled(true);

            ImageView BSubmit = new ImageView(this);

            BSubmit.SetImageResource(Resource.Drawable.ic_save_white_18dp);

            LinearLayout LLControls = FindViewById <LinearLayout>(Resource.Id.right_controls);

            LLControls.AddView(BSubmit);

            ETName         = FindViewById <EditText>(Resource.Id.name);
            ETIdentifier   = FindViewById <EditText>(Resource.Id.identifier);
            ETHomePage     = FindViewById <EditText>(Resource.Id.home_page);
            CBIsPublic     = FindViewById <CheckBox>(Resource.Id.is_public);
            SParent        = FindViewById <Spinner>(Resource.Id.parent);
            ETDescrtiption = FindViewById <EditText>(Resource.Id.description);

            BSubmit.Click += BSubmit_Click;

            var query = from r in projects.projects
                        select r.name;

            List <string> parents = new List <string> {
                "None"
            };

            parents.AddRange(query.ToList());

            var parentAdapter = new ArrayAdapter(this, Android.Resource.Layout.SimpleDropDownItem1Line, parents);

            SParent.Adapter = parentAdapter;
            SParent.SetSelection(parentAdapter.GetPosition("None"));
        }
Ejemplo n.º 4
0
        public void SettingUpViews()
        {
            PDLoading = new ProgressDialog(this);
            PDLoading.SetTitle(Resources.GetString(Resource.String.LoadingAllRequiredData));
            PDLoading.SetMessage(Resources.GetString(Resource.String.PleaseWait));
            PDLoading.Show();
            Thread loadAllData = new Thread(() =>
            {
                usersContainer    = RedMineManager.Get <UsersContainer>("/users.json?nometa=1&limit=100");
                projectsContainer = RedMineManager.Get <ProjectsContainer>("/projects.json?nometa=1&limit=100");
                issuesContainer   = RedMineManager.Get <IssuesContainer>("/issues.json?nometa=1&limit=100");
                foreach (var issue in issuesContainer.issues)
                {
                    issue.timeEntries = RedMineManager.Get <List <IssuesContainer.TimeEntry> >("/issues/" + issue.id + "/time_entries.json?nometa=1", "time_entries");
                    foreach (var timeEntry in issue.timeEntries)
                    {
                        issue.spent_hours += timeEntry.hours;
                    }
                }
                foreach (var project in projectsContainer.projects)
                {
                    project.memberships = RedMineManager.Get <List <Membership> >("/projects/" + project.id + "/memberships.json?nometa=1", "memberships");
                }
                //formating data for adapters and setting dates
                var usersQuery = from user in usersContainer.users
                                 select user.firstname + " " + user.lastname;
                List <string> usersForAdapter = new List <string>()
                {
                    "None"
                };
                usersForAdapter.AddRange(usersQuery.ToList());
                var projectsQuery = from project in projectsContainer.projects
                                    select project.name;
                List <string> projectsForAdapter = new List <string>()
                {
                    "None"
                };
                projectsForAdapter.AddRange(projectsQuery.ToList());
                var issuesQuery = from issue in issuesContainer.issues
                                  select issue.subject;
                List <string> issuesForAdapter = new List <string>()
                {
                    "None"
                };
                issuesForAdapter.AddRange(issuesQuery.ToList());
                dates             = new List <DateTime>();
                DateTime currDate = DateTime.Now;
                for (int i = 0; i < 24; i++)
                {
                    dates.Add(currDate.AddMonths(-i));
                }

                var monthQuery = from date in dates
                                 select date.ToString(@"MMMM yyyy", CultureInfo.CurrentCulture);
                List <string> monthsForAdapter = new List <string>()
                {
                    "None"
                };
                monthsForAdapter.AddRange(monthQuery.ToList());
                //creating adapters for spinners
                var userAdapter    = new ArrayAdapter(this, Android.Resource.Layout.SimpleDropDownItem1Line, usersForAdapter);
                var monthAdapter   = new ArrayAdapter(this, Android.Resource.Layout.SimpleDropDownItem1Line, monthsForAdapter);
                var projectAdapter = new ArrayAdapter(this, Android.Resource.Layout.SimpleDropDownItem1Line, projectsForAdapter);
                var issuesAdapter  = new ArrayAdapter(this, Android.Resource.Layout.SimpleSpinnerDropDownItem, issuesForAdapter);

                RunOnUiThread(() =>
                {
                    SFilterByUser.Adapter    = userAdapter;
                    SFilterByProject.Adapter = projectAdapter;
                    SFilterByMonth.Adapter   = monthAdapter;
                    SFilterByIssue.Adapter   = issuesAdapter;
                });
                //When project selected, set only this project`s issues for issue spinner
                SFilterByProject.ItemSelected += delegate
                {
                    var issueAdapterQuery = from issue in issuesContainer.issues
                                            where issue.project.name == SFilterByProject.SelectedItem.ToString()
                                            select issue.subject;
                    issuesAdapter.Clear();
                    issuesAdapter.Add("None");
                    issuesAdapter.AddAll(issueAdapterQuery.ToList());
                };
                SFilterByUser.ItemSelected += delegate
                {
                    if (SFilterByUser.SelectedItem.ToString() != "None")
                    {
                        //When user selected set only projects, which user involved
                        var projectQuery = from project in projectsContainer.projects
                                           from membership in project.memberships
                                           where membership?.user?.name == SFilterByUser.SelectedItem.ToString()
                                           select project.name;
                        projectAdapter.Clear();
                        projectAdapter.Add("None");
                        projectAdapter.AddAll(projectQuery.ToList());

                        //Also set issues, where user assigned to
                        var issueQuery = from issue in issuesContainer.issues
                                         where issue?.assigned_to?.name == SFilterByUser.SelectedItem.ToString()
                                         select issue.subject;
                        issuesAdapter.Clear();
                        issuesAdapter.Add("None");
                        issuesAdapter.AddAll(issueQuery.ToList());
                    }
                };

                CBClosed.CheckedChange += delegate
                {
                    RunOnUiThread(() => PDLoading.Show());
                    Thread innerThread = new Thread(() =>
                    {
                        if (CBClosed.Checked)
                        {
                            issuesContainer = RedMineManager.Get <IssuesContainer>("/issues.json?nometa=1&limit=100&status_id=*");
                        }
                        else
                        {
                            issuesContainer = RedMineManager.Get <IssuesContainer>("/issues.json?nometa=1&limit=100");
                        }
                        var issueQuery = from issue in issuesContainer.issues
                                         select issue.subject;

                        foreach (var issue in issuesContainer.issues)
                        {
                            issue.timeEntries = RedMineManager.Get <List <IssuesContainer.TimeEntry> >("/issues/" + issue.id + "/time_entries.json?nometa=1", "time_entries");
                            foreach (var timeEntry in issue.timeEntries)
                            {
                                issue.spent_hours += timeEntry.hours;
                            }
                        }

                        RunOnUiThread(() =>
                        {
                            issuesAdapter.Clear();
                            issuesAdapter.Add("None");
                            issuesAdapter.AddAll(issueQuery.ToList());
                            PDLoading.Hide();
                        });
                    });
                    SFilterByIssue.SetSelection(0);
                    SFilterByMonth.SetSelection(0);
                    SFilterByProject.SetSelection(0);
                    SFilterByUser.SetSelection(0);
                    innerThread.Start();
                };

                //Click for applying filter
                BApplyFilter.Click += delegate
                {
                    if (SFilterByUser.SelectedItem.ToString() != "None")
                    {
                        var userQuery = from user in usersContainer.users
                                        where user.firstname + " " + user.lastname == SFilterByUser.SelectedItem.ToString()
                                        select user;
                        usersContainer.users = userQuery.ToList();
                        var projectQuery     = from project in projectsContainer.projects
                                               from membership in project.memberships
                                               where membership?.user?.name == SFilterByUser.SelectedItem.ToString()
                                               select project;
                        projectsContainer.projects = projectQuery.ToList();
                        var issueQuery             = from issue in issuesContainer.issues
                                                     where issue.assigned_to?.name == SFilterByUser.SelectedItem.ToString()
                                                     select issue;
                        issuesContainer.issues = issueQuery.ToList();
                    }
                    if (SFilterByMonth.SelectedItem.ToString() != "None")
                    {
                        var query = from date in dates
                                    where date.ToString(@"MMMM yyyy") == SFilterByMonth.SelectedItem.ToString()
                                    from issue in issuesContainer.issues
                                    where DateTime.Parse(issue.created_on).Month == date.Month
                                    select issue;
                        issuesContainer.issues = query.ToList();
                    }
                    if (SFilterByProject.SelectedItem.ToString() != "None")
                    {
                        var issueQuery = from issue in issuesContainer.issues
                                         where issue.project.name == SFilterByProject.SelectedItem.ToString()
                                         select issue;
                        issuesContainer.issues = issueQuery.ToList();
                        var projectQuery       = from project in projectsContainer.projects
                                                 where project.name == SFilterByProject.SelectedItem.ToString()
                                                 select project;
                        projectsContainer.projects = projectQuery.ToList();
                    }
                    if (SFilterByIssue.SelectedItem.ToString() != "None")
                    {
                        var query = from issue in issuesContainer.issues
                                    where issue.subject == SFilterByIssue.SelectedItem.ToString()
                                    select issue;
                        issuesContainer.issues = query.ToList();
                    }
                    SetView();
                };
                RunOnUiThread(() => PDLoading.Hide());
            });

            loadAllData.Start();
        }