Ejemplo n.º 1
0
        /// <summary>
        /// TODO: Delete this when admin screens done!
        /// </summary>
        public static void TempInit()
        {
            AllProjects t3 = new AllProjects();

            if (t3.Count == 0)
            {
                t3.Add(new Project {
                    Id = Guid.NewGuid(), Description = "Test Project", Active = true
                });
                t3.Save();
            }

            AllTasks t1 = new AllTasks();

            if (t1.Count == 0)
            {
                t1.Add(new Task {
                    Id = Guid.NewGuid(), ProjectId = t3[0].Id, Description = "Test Task 1", Active = true
                });
                t1.Save();
            }

            AllUserTaskAccess t5 = new AllUserTaskAccess();

            if (t5.Count == 0)
            {
                t5.Add(new UserTaskAccess {
                    ProjectId = t3[0].Id, TaskId = t1[0].Id, UserId = new AllUsers()[0].UserId
                });
                t5.Save();
            }
        }
Ejemplo n.º 2
0
        private ProjectNode AddProject(string path)
        {
            var project = _loader.LoadProject(path);
            var node    = new ProjectNode(path, project);

            AllProjects.Add(project);
            AllProjectNodes.Add(node);

            return(node);
        }
        public async Task <bool> PopulateFromDir()
        {
            AllProjects.Clear();
            var allSlnFiles = await GetAllFilesByExentions(TargetDirectory);

            foreach (var cur in allSlnFiles)
            {
                if (!_solutionFileCache.ContainsKey(cur))
                {
                    _solutionFileCache.Add(cur, new SolutionFile(cur));
                }
                AllProjects.Add(_solutionFileCache[cur]);
            }
            Reporter.Report(AllProjects.Count + " projects found in directory.");
            return(true);
        }
Ejemplo n.º 4
0
        /// <summary>
        /// Loads all available projects and selects last opened project.
        /// </summary>
        public void LoadAll()
        {
            ClientUI.ShowProgress("Loading...");

            if (File.Exists("client.json"))
            {
                var config = JsonConvert.DeserializeObject <ClientSettings>(File.ReadAllText("client.json"));

                var done = 0;
                foreach (var project in config.Projects)
                {
                    var projInst = Project.OpenWorkingCopy(project.Address, project.Name, project.RootDir);
                    projInst.Authority = new ProjectAuthority
                    {
                        ProjectName = project.Name,
                        Username    = project.Username,
                        AccessToken = PasswordHasher.Hash(project.Username, project.Password)
                    };

                    Javascript.Run("addProject('" + project.Name + "');");

                    projInst.Refresh(delegate
                    {
                        var diff = projInst.BuildDiff();

                        Javascript.Run("setChangeCount('" + project.Name + "', " + diff.Length + ");");

                        AllProjects.Add(projInst);

                        done++;

                        if (done == config.Projects.Length)
                        {
                            // select
                            if (!string.IsNullOrEmpty(config.Selected))
                            {
                                Select(config.Selected); // this will also hide the progress
                            }
                            else
                            {
                                ClientUI.HideProgress();
                            }
                        }
                    });
                }
            }
        }
Ejemplo n.º 5
0
        public void ModifyEntity(Project project)
        {
            ProjectDTO projectDTO = AllProjects.Where <ProjectDTO>(x => x.ID == project.ID).FirstOrDefault();

            if (projectDTO == null)
            {
                projectDTO = new ProjectDTO()
                {
                    ID         = project.ID,
                    Name       = project.Name,
                    Contractor = project.Contractor == null ? null :
                                 new CompanyDTO {
                        ID = project.Contractor.ID, Name = project.Contractor.Name
                    },
                    Customer = new CompanyDTO {
                        ID = project.Customer.ID, Name = project.Customer.Name
                    },
                    Priority   = project.Priority,
                    EndProject = project.EndProject
                };
                AllProjects.Add(projectDTO);
            }
            else
            {
                AllProjects.Remove(projectDTO);
                projectDTO = new ProjectDTO()
                {
                    ID         = project.ID,
                    Name       = project.Name,
                    Contractor = project.Contractor == null ? null :
                                 new CompanyDTO {
                        ID = project.Contractor.ID, Name = project.Contractor.Name
                    },
                    Customer = new CompanyDTO {
                        ID = project.Customer.ID, Name = project.Customer.Name
                    },
                    EndProject = project.EndProject
                };
                AllProjects.Add(projectDTO);
            }
        }
Ejemplo n.º 6
0
 public void LoadOneProject(string path)
 {
     AllProjects.Add(_loader.LoadProject(path));
 }
Ejemplo n.º 7
0
        public static List <ValidationMessage> SaveProject(
            ValidatableParameter <string> projectId,
            ValidatableParameter <string> details,
            ValidatableParameter <bool> active
            )
        {
            List <ValidationMessage> errors = new List <ValidationMessage>();

            Guid projId = Guid.Empty;

            try
            {
                projId = new Guid(projectId.Value);
            }
            catch (FormatException)
            {
                errors.Add(new ValidationMessage {
                    MessageText = "Project Id must be in the format dddddddd-dddd-dddd-dddd-dddddddddddd", Source = projectId.Source
                });
            }

            if (string.IsNullOrEmpty(details.Value) || details.Value.Trim().Length == 0)
            {
                errors.Add(new ValidationMessage {
                    MessageText = "Project Name must be supplied", Source = details.Source
                });
            }
            else
            {
                //check for existing name with different id (name already in use)
                Project existItem = AllProjects.GetForName(details.Value);
                if (existItem != null && existItem.Id != projId)
                {
                    errors.Add(new ValidationMessage {
                        MessageText = string.Format("Project Name is already in use by project with Id {0}", existItem.Id.ToString()), Source = details.Source
                    });
                }
            }

            //perform update if no errors
            if (errors.Count == 0)
            {
                AllProjects items   = new AllProjects();
                Project     newItem = new Project {
                    Id = projId, Description = details.Value, Active = active.Value
                };
                if (projId == Guid.Empty)
                {
                    newItem.Id = Guid.NewGuid(); //set id
                    items.Add(newItem);
                }
                else
                {
                    Project existItem = items.Where(i => i.Id == projId).Single();
                    items.Remove(existItem);
                    items.Add(newItem);
                }

                items.Save();
            }

            return(errors);
        }
Ejemplo n.º 8
0
 /// <summary>
 /// Add a Project to the list in the databse
 /// </summary>
 /// <param name="item"></param>
 /// <returns></returns>
 public static void Add(Project item)
 {
     AllProjects.Add(item);
 }
Ejemplo n.º 9
0
        private async Task GetProjectsAsync()
        {
            List <TimesheetEntry> timesheetEntries;

            ShownProjectsCollection.Clear();
            AllProjects.Clear();

            //Get all entries with a project ID
            using (var ctx = new DatabaseDir.Database())
                //Get entries
                timesheetEntries = ctx.TimesheetEntries.Include(ts => ts.vismaEntries.Select(ve => ve.LinkedRate)).ToList();

            //Convert to projects
            foreach (TimesheetEntry timesheetEntry in timesheetEntries)
            {
                //Filter empty project IDs
                if (string.IsNullOrWhiteSpace(timesheetEntry.ProjectID))
                {
                    continue;
                }

                //Filter timesheets with no "Arbejde" types
                if (timesheetEntry.vismaEntries.Where(x => x.LinkedRate.Type == "Arbejde").ToList().Count() == 0)
                {
                    continue;
                }

                //Filter if a period is specified
                if (SelectedWeek > 0 && SelectedYear > 0)
                {
                    DateTime from = DateHelper.WeekNumToDateTime(SelectedWeek, SelectedYear, 0);
                    DateTime to   = DateHelper.WeekNumToDateTime(SelectedWeek, SelectedYear, 6);

                    if (timesheetEntry.Date < from || timesheetEntry.Date > to)
                    {
                        continue; //Then skip
                    }
                }

                //Initalize
                double normalHours   = 0;
                double overtimeHours = 0;

                //Sum up hours from the entry
                foreach (VismaEntry vismaEntry in timesheetEntry.vismaEntries)
                {
                    //Filter non "Arbejde" (work) types
                    if (vismaEntry.LinkedRate.Type != "Arbejde")
                    {
                        continue;
                    }

                    //Sum overtime hours
                    if (vismaEntry.LinkedRate.Name == "Normal")
                    {
                        if (vismaEntry.Value > 0)
                        {
                            normalHours += vismaEntry.Value;
                        }
                    }
                    else
                    {
                        overtimeHours += vismaEntry.Value;
                    }
                }

                //Add time to project
                if (!AllProjects.Where(p => p.ProjectID == timesheetEntry.ProjectID).ToList().Any())
                {
                    //If project is not already listed
                    AllProjects.Add(new Project(timesheetEntry.ProjectID, normalHours, overtimeHours));
                }
                else
                {
                    //Else add hours to existing
                    Project SelectedProject = AllProjects.Where(p => p.ProjectID == timesheetEntry.ProjectID).FirstOrDefault();
                    SelectedProject.TotalNormalHours   += normalHours;
                    SelectedProject.TotalOverTimeHours += overtimeHours;
                }
            }
            AllProjects.Sort((x, y) => string.Compare(x.ProjectID, y.ProjectID));
            FiltherProjects();
        }