public AssignmentDetailWindow(int personId, int projectId)
        {
            DbSet <TimeTrack> timeTracksDBSet = intimeDb.TimeTracks;

            WindowStartupLocation = WindowStartupLocation.CenterScreen;
            InitializeComponent();

            List <TimeTrack> timetracksList = (from TimeTrack in timeTracksDBSet
                                               where TimeTrack.ProjectId == projectId
                                               where TimeTrack.PersonId == personId
                                               select TimeTrack).ToList();

            List <TimeTrackViewModel> dataGridTimeTracks = new List <TimeTrackViewModel>();

            foreach (TimeTrack timeTrack in timetracksList)
            {
                TimeTrackViewModel timetrackvm = new TimeTrackViewModel();
                timetrackvm.WorkDate = ((DateTime)timeTrack.WorkDate).ToShortDateString();


                timetrackvm.WorkTime = TimeTracker.ToString(TimeSpan.FromTicks((long)timeTrack.WorkTime));

                dataGridTimeTracks.Add(timetrackvm);
            }

            CollectionViewSource itemCollectionViewSource;

            itemCollectionViewSource        = (CollectionViewSource)(FindResource("ItemCollectionViewSource"));
            itemCollectionViewSource.Source = dataGridTimeTracks;
            this.Show();
        }
Exemplo n.º 2
0
        protected virtual void OnGUI()
        {
            float width  = Screen.width * 0.3f;
            float height = Screen.height * 0.05f;

            GUI.skin.box.fontSize = 24;

            GUI.Box(new Rect(width * 0.5f, 0, width, height), fps.ToString());
            GUI.Box(new Rect(width * 0.5f, height, width, height), timeTracker.ToString());
        }
Exemplo n.º 3
0
        /*-------------------------------------------------------------- POPOLARE CONTENUTI --------------------------------------------------------------*/

        private void PopulateSelectedAssignment(ListBoxItem listBoxAssignment)
        {
            Project currentProject = (Project)listBoxAssignment.Tag;

            // PROPRIETA' DEL PROGETTO
            ProjectName.Text = currentProject.ProjectName;
            Customer.Text    = currentProject.Customer;
            if (currentProject.ProjectAssignedTime != null)
            {
                TimeSpan timespan = TimeSpan.FromTicks((long)currentProject.ProjectAssignedTime);
                EstimatedTime.Text = TimeTracker.ToString(timespan);
            }
            else
            {
                EstimatedTime.Text = "";
            }
            // TO DO: TEMPO TOTALE
            if (currentProject.DateCreation != null)
            {
                CreationDate.Text = ((DateTime)currentProject.DateCreation).ToShortDateString();
            }
            else
            {
                CreationDate.Text = "";
            }
            // TO DO: TRACCIA: Sì / NO
            AssignmentDescription.Text = currentProject.Description;

            DbSet <TimeTrack> timeTracksDBSet = intimeDb.TimeTracks;

            // TUTTI I TIMETRACK DEL PROGETTO
            List <TimeTrack> timetracksList = (from TimeTrack in timeTracksDBSet
                                               where TimeTrack.ProjectId == currentProject.Id
                                               where TimeTrack.PersonId == currentUser.Id
                                               select TimeTrack).ToList();

            long personTotalTicks = 0;

            foreach (TimeTrack track in timetracksList) // calcola il tempo totale della persona
            {
                personTotalTicks += (long)track.WorkTime;
            }
            TotalWorkTime.Text = TimeTracker.ToString(TimeSpan.FromTicks(personTotalTicks));

            // LISTA TIMETRACKS DATAGRID

            List <TimeTrackViewModel> dataGridTimeTracks = new List <TimeTrackViewModel>();

            foreach (TimeTrack timeTrack in timetracksList)
            {
                TimeTrackViewModel timetrackvm = new TimeTrackViewModel();
                timetrackvm.WorkDate = ((DateTime)timeTrack.WorkDate).ToShortDateString();


                timetrackvm.WorkTime = TimeTracker.ToString(TimeSpan.FromTicks((long)timeTrack.WorkTime));

                dataGridTimeTracks.Add(timetrackvm);
            }

            CollectionViewSource itemCollectionViewSource;

            itemCollectionViewSource        = (CollectionViewSource)(FindResource("ItemCollectionViewSource"));
            itemCollectionViewSource.Source = dataGridTimeTracks;
        }
        /*-------------------------------------------------------------- POPOLARE CONTENUTI --------------------------------------------------------------*/

        private void PopulateSelectedProject(ListBoxItem listBoxProject)
        {
            DbSet <TimeTrack>  timeTracksDBSet  = intimeDb.TimeTracks;
            DbSet <Assignment> AssignmentsDBSet = intimeDb.Assignments;

            selectedProject = (Project)listBoxProject.Tag;


            // POPOLA LA DATAGRID

            // seleziona tutti gli assignment per un progetto
            List <Assignment> assignmentList = (from Assignment in AssignmentsDBSet
                                                where Assignment.ProjectId == selectedProject.Id
                                                select Assignment).ToList();

            List <AssignmentForDataGrid> dataGridAssignments = new List <AssignmentForDataGrid>();

            long projectTotalTicks = 0; // serve per il tempo totale del progetto

            foreach (Assignment assignment in assignmentList)
            {
                int personId = assignment.PersonId;

                List <TimeTrack> timetracksList = (from TimeTrack in timeTracksDBSet // seleziona tutti i timetrack di UNA persona per IL progetto selezionato
                                                   where TimeTrack.ProjectId == selectedProject.Id
                                                   where TimeTrack.PersonId == personId
                                                   select TimeTrack).ToList();

                long personTotalTicks = 0;
                foreach (TimeTrack track in timetracksList) // calcola il tempo totale della persona
                {
                    personTotalTicks += (long)track.WorkTime;
                }
                projectTotalTicks += personTotalTicks;

                // LISTA ASSIGNMENTS
                AssignmentForDataGrid assignmentForDataGrid = new AssignmentForDataGrid(); // creazione Assignment per DataGrid

                assignmentForDataGrid.name     = assignment.Person.PersonName;
                assignmentForDataGrid.time     = TimeTracker.ToString(TimeSpan.FromTicks(personTotalTicks));
                assignmentForDataGrid.active   = assignment.Active;
                assignmentForDataGrid.personId = assignment.PersonId;
                dataGridAssignments.Add(assignmentForDataGrid);
            }

            // COMBOBOX: FILTRO LISTA PERSONE
            GetPeopleListInComboBox(assignmentList);

            // PROPRIETà DEL PROGETTO (GROUPBOX)

            TotalWorkTime.Text = TimeTracker.ToString(TimeSpan.FromTicks(projectTotalTicks));

            ProjectName.Text = selectedProject.ProjectName; // not null
            Customer.Text    = selectedProject.Customer;    // null
            Description.Text = selectedProject.Description; // null

            if (selectedProject.ProjectAssignedTime != null)
            {
                TimeSpan timespan = TimeSpan.FromTicks((long)selectedProject.ProjectAssignedTime);
                EstimatedTime.Text = TimeTracker.ToString(timespan);
            } // null
            else
            {
                EstimatedTime.Text = "";
            }

            if (selectedProject.DueDate != null)
            {
                DueDate.Text = ((DateTime)selectedProject.DueDate).ToShortDateString();
            } // null
            else
            {
                DueDate.Text = "";
            }

            if (selectedProject.DateCreation != null)
            {
                CreationDate.Text = ((DateTime)selectedProject.DateCreation).ToShortDateString();
            } // null
            else
            {
                CreationDate.Text = "";
            }

            if (selectedProject.Active)    // not null
            {
                Active.Text = "Sì";
            } // not null
            else
            {
                Active.Text = "No";
            }

            // BINDING
            CollectionViewSource itemCollectionViewSource;

            itemCollectionViewSource        = (CollectionViewSource)(FindResource("ItemCollectionViewSource"));
            itemCollectionViewSource.Source = dataGridAssignments;
        }