Пример #1
0
        private void SearchByName(string query)
        {
            if (String.IsNullOrWhiteSpace(query))
            {
                Projects = new ObservableCollection <Project>(AllProjects);
                Bindings.Update();
                return;
            }
            var results = AllProjects.Where(x =>
                                            x.AppName.ToLower().Contains(query.ToLower()) ||
                                            x.Description.ToLower().Contains(query.ToLower()));

            if (CategoryButton.IsChecked)
            {
                FilterByCategory(collection: results);
            }
            else
            {
                Sort(collection: results);
            }

            Microsoft.AppCenter.Analytics.Analytics.TrackEvent("Projects: Search",
                                                               new Dictionary <string, string> {
                { "Query", query },
            }
                                                               );
        }
Пример #2
0
 public IEnumerable<Project> GetProjects(string wildcardPattern)
 {
     wildcardPattern = $"^{wildcardPattern}$";
     var regex = new Regex(wildcardPattern
         .Replace(".", "\\.")
         .Replace("*", ".*"));
     return AllProjects.Where(x => regex.IsMatch(x.Name));
 }
Пример #3
0
        public IEnumerable <IDotNetProjectInstance> GetProjectsUnderSolutionFolder(IDotNetSolutionFolder solutionFolder)
        {
            var solutionFolderSection = SlnFile.GetSolutionFolderSection();
            var parentId = solutionFolder.Id;
            var childIds = solutionFolderSection.Properties.Where(p => p.Value == parentId)
                           .Select(p => p.Key)
                           .ToImmutableHashSet();

            return(AllProjects.Where(p => childIds.Contains(p.Id)));
        }
Пример #4
0
        public void FiltherProjects()
        {
            if (!string.IsNullOrWhiteSpace(SearchProject)) //If something is entered then filter
            {
                ShownProjectsCollection = new BindableCollection <Project>(AllProjects.Where(p => string.IsNullOrWhiteSpace(p.ProjectID) ? false : p.ProjectID.Contains(SearchProject)).ToList());
            }
            else //Else show all elements
            {
                ShownProjectsCollection = new BindableCollection <Project>(AllProjects.ToList());
            }

            NotifyOfPropertyChange(() => ShownProjectsCollection);
        }
Пример #5
0
        public void SaveChangedProjects()
        {
            foreach (Project prj in AllProjects.Where(prj => prj.Changed))
            {
                _loader.SaveProject(prj, prj.FullPath);
            }

            // REVIEW: aggregate to solution

            //if (_externalModules.Changed)
            //	SaveExternalModules();
            //if (_ignoredValidations.Changed)
            //	SaveIgnoredValidations();
        }
Пример #6
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);
            }
        }
Пример #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);
        }
Пример #8
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();
        }