Beispiel #1
0
        /// <summary>
        /// Initializes a new instance of the MainViewModel class.
        /// </summary>
        /// <param name="windowService">
        /// The window service
        /// </param>
        /// <param name="addinService">
        /// The add-in service
        /// </param>
        /// <param name="settingsService">
        /// The settings service
        /// </param>
        public MainViewModel(IWindowService windowService, IAddinService addinService, ISettingsService settingsService)
        {
            this.windowService = windowService;

            var projects = settingsService.GetProjects();
            var projectModel = projects.FirstOrDefault();

            var tt = addinService.TaskTrackers.First();
            var qs = tt.GenerateQuerySettings();

            if (!projects.Any())
            {
                projectModel = new ProjectModel("Demo project", tt.Id);
                var ss = new SecureString();
                ss.AppendChar('H');
                ss.AppendChar('e');
                ss.AppendChar('l');
                ss.AppendChar('l');
                ss.AppendChar('o');

                var testSettings = new Dictionary<string, SecureString>
                {
                    { "SomeKey1", ss },
                    { "SomeKey2", ss }
                };

                var projectSettings1 = new SettingsModel(projectModel.InternalUrn, testSettings);
                settingsService.SaveProject(projectModel, projectSettings1);
            }

            var projectSettings2 = settingsService.GetProjectSettings(projectModel);
            this.Tasks = new ObservableCollection<ITaskModel>(tt.GetAssignedToUser(projectModel, projectSettings2));

            settingsService.SaveProject(projectModel);
        }
Beispiel #2
0
        /// <summary>
        /// Loads the projects
        /// </summary>
        /// <param name="applicationRoot">
        /// The root element
        /// </param>
        private void LoadProjects(XElement applicationRoot)
        {
            var projectModels = new List<IProjectModel>();
            var projectRoot = applicationRoot.Element(ProjectsRootElementName);
            if (projectRoot != null)
            {
                foreach (var project in projectRoot.Elements(ProjectElementName))
                {
                    var id = project.Attribute(IdAttributeName);
                    var name = project.Attribute(NameAttributeName);
                    var taskTrackerId = project.Attribute(TaskTrackerIdAttributeName);

                    if (id != null && name != null && taskTrackerId != null)
                    {
                        var model = new ProjectModel(id.Value, name.Value, taskTrackerId.Value);
                        projectModels.Add(model);
                        var projectSettings = this.GetPreferences(project, id.Value);
                        this.projectSettings.Add(new SettingsModel(model.InternalUrn, projectSettings));
                    }
                }

                this.projects = projectModels;
            }
        }