├── AltinnDesktopTool
├── App.xaml.cs
├── Resources
│ ├── Entypo.ttf
│ ├── Entypo-license.txt
│ └── WindowsIcons-license.txt
├── View
│ ├── Images
│ │ ├── Altinn.png
│ │ ├── Digdir.png
│ │ ├── altinn.ico
│ │ ├── altinnT.ico
│ │ ├── altinnT.xcf
│ │ └── a-logo-blue.png
│ ├── SearchOrganizationInformation.xaml.cs
│ ├── SearchRolesAndRightsInformation.xaml.cs
│ ├── Footer.xaml.cs
│ ├── RolesSearchResultView.xaml.cs
│ ├── MainWindow.xaml.cs
│ ├── SearchResultView.xaml.cs
│ ├── Footer.xaml
│ ├── SearchOrganizationInformation.xaml
│ ├── SearchRolesAndRightsInformation.xaml
│ ├── MainWindow.xaml
│ └── RolesSearchResultView.xaml
├── Settings.StyleCop
├── Properties
│ ├── Settings.settings
│ ├── Settings.Designer.cs
│ ├── AssemblyInfo.cs
│ ├── Resources.Designer.cs
│ └── Resources.resx
├── ViewModel
│ ├── AltinnViewModelBase.cs
│ ├── MapperProfiles
│ │ └── SearchMapperProfile.cs
│ ├── MainViewModel.cs
│ ├── FooterViewModel.cs
│ ├── ViewModelLocator.cs
│ └── RolesSearchResultViewModel.cs
├── Configuration
│ ├── IUIEnvironmentConfig.cs
│ ├── EnvironmentConfigurations.xml
│ ├── EnvironmentConfiguration.cs
│ └── EnvironmentConfigurationManager.cs
├── Model
│ ├── OfficialContactModel.cs
│ ├── PersonalContactModel.cs
│ ├── SearchType.cs
│ ├── RoleModel.cs
│ ├── SearchRolesAndRightsInformationModel.cs
│ ├── SearchOrganizationInformationModel.cs
│ ├── SearchResultModel.cs
│ ├── RolesSearchResultModel.cs
│ ├── OrganizationModel.cs
│ └── ModelBase.cs
├── Utils
│ ├── Helpers
│ │ ├── AutomapperHelper.cs
│ │ ├── BindingProxy.cs
│ │ └── ProxyConfigHelper.cs
│ ├── PubSub
│ │ ├── PubSubEventArgs.cs
│ │ ├── EventNames.cs
│ │ └── PubSub.cs
│ └── Converters
│ │ └── RadioButtonCheckedConverter.cs
├── packages.config
├── App.xaml
└── App.config
├── AltinnDesktopToolSetup
├── altinn.ico
├── AltinnDesktopToolSetup.wax
├── AltinnDesktopToolSetup.wixproj
└── Product.wxs
├── renovate.json
├── IntegrationUnitTest
├── packages.config
├── Properties
│ └── AssemblyInfo.cs
├── AltinnRestClientTest.cs
└── IntegrationUnitTest.csproj
├── RestClient
├── Settings.StyleCop
├── packages.config
├── Controllers
│ ├── IRestQueryController.cs
│ ├── ControllerContext.cs
│ ├── RestQueryControllerAttribute.cs
│ └── AltinnBaseController.cs
├── Deserialize
│ ├── OuterJson.cs
│ ├── Deserializer.cs
│ └── HalJsonConverter.cs
├── DTO
│ ├── Role.cs
│ ├── OfficialContact.cs
│ ├── HalJsonResource.cs
│ ├── Organization.cs
│ └── PersonalContact.cs
├── Properties
│ └── AssemblyInfo.cs
├── IRestQueryConfig.cs
├── Resources
│ ├── RestClientErrorCodes.cs
│ └── RestClientException.cs
├── IRestQuery.cs
└── RestClient.csproj
├── RestClient.Test
├── packages.config
├── Properties
│ └── AssemblyInfo.cs
├── RestClientExceptionTest.cs
├── RestQueryStubTest.cs
└── RestClient.Test.csproj
├── AltinnDesktopToolTest
├── packages.config
├── Configuration
│ ├── EnvironmentConfigurations.xml
│ └── EnvironmentConfigurationTest.cs
├── Properties
│ └── AssemblyInfo.cs
├── ViewModel
│ ├── RolesSearchResultModelTest.cs
│ └── SearchResultViewModelTest.cs
└── AltinnDesktopToolTest.csproj
├── README.md
├── AltinnDesktopTool.sln
├── AltinnDesktopTool.sln.DotSettings
└── .gitignore
/AltinnDesktopTool/App.xaml.cs:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/AltinnDesktopToolSetup/altinn.ico:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/altinn/altinn-desktop-tool/main/AltinnDesktopToolSetup/altinn.ico
--------------------------------------------------------------------------------
/AltinnDesktopTool/Resources/Entypo.ttf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/altinn/altinn-desktop-tool/main/AltinnDesktopTool/Resources/Entypo.ttf
--------------------------------------------------------------------------------
/AltinnDesktopTool/View/Images/Altinn.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/altinn/altinn-desktop-tool/main/AltinnDesktopTool/View/Images/Altinn.png
--------------------------------------------------------------------------------
/AltinnDesktopTool/View/Images/Digdir.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/altinn/altinn-desktop-tool/main/AltinnDesktopTool/View/Images/Digdir.png
--------------------------------------------------------------------------------
/AltinnDesktopTool/View/Images/altinn.ico:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/altinn/altinn-desktop-tool/main/AltinnDesktopTool/View/Images/altinn.ico
--------------------------------------------------------------------------------
/AltinnDesktopTool/View/Images/altinnT.ico:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/altinn/altinn-desktop-tool/main/AltinnDesktopTool/View/Images/altinnT.ico
--------------------------------------------------------------------------------
/AltinnDesktopTool/View/Images/altinnT.xcf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/altinn/altinn-desktop-tool/main/AltinnDesktopTool/View/Images/altinnT.xcf
--------------------------------------------------------------------------------
/AltinnDesktopTool/View/Images/a-logo-blue.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/altinn/altinn-desktop-tool/main/AltinnDesktopTool/View/Images/a-logo-blue.png
--------------------------------------------------------------------------------
/renovate.json:
--------------------------------------------------------------------------------
1 | {
2 | "$schema": "https://docs.renovatebot.com/renovate-schema.json",
3 | "extends": [
4 | "local>Altinn/renovate-config"
5 | ]
6 | }
7 |
--------------------------------------------------------------------------------
/AltinnDesktopTool/Resources/Entypo-license.txt:
--------------------------------------------------------------------------------
1 | Entypo (http://www.entypo.com/) is created by Daniel Bruce and released under the Creative Commons, Share Alike/Attribution license.
2 |
3 | http://creativecommons.org/licenses/by-sa/3.0/
--------------------------------------------------------------------------------
/AltinnDesktopTool/Settings.StyleCop:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | xaml
5 |
6 |
7 |
--------------------------------------------------------------------------------
/AltinnDesktopTool/Properties/Settings.settings:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
--------------------------------------------------------------------------------
/IntegrationUnitTest/packages.config:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
--------------------------------------------------------------------------------
/RestClient/Settings.StyleCop:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | deserializable
5 | Dto
6 | Json
7 |
8 |
9 |
--------------------------------------------------------------------------------
/RestClient.Test/packages.config:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/RestClient/packages.config:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
--------------------------------------------------------------------------------
/RestClient/Controllers/IRestQueryController.cs:
--------------------------------------------------------------------------------
1 | namespace RestClient.Controllers
2 | {
3 | ///
4 | /// Interface representing the controller. Inherits the IRestQuery and adds the ControllerContext.
5 | ///
6 | public interface IRestQueryController : IRestQuery
7 | {
8 | ///
9 | /// Gets or sets the controller context.
10 | ///
11 | ControllerContext Context { get; set; }
12 | }
13 | }
14 |
--------------------------------------------------------------------------------
/AltinnDesktopToolSetup/AltinnDesktopToolSetup.wax:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | AltinnDesktopTool\AltinnDesktopTool.csproj
5 |
6 |
7 |
8 |
9 |
10 | false
11 |
--------------------------------------------------------------------------------
/AltinnDesktopTool/ViewModel/AltinnViewModelBase.cs:
--------------------------------------------------------------------------------
1 | using AltinnDesktopTool.Model;
2 | using GalaSoft.MvvmLight;
3 |
4 | namespace AltinnDesktopTool.ViewModel
5 | {
6 | ///
7 | /// Base class for ViewModels
8 | ///
9 | public class AltinnViewModelBase : ViewModelBase
10 | {
11 | ///
12 | /// Gets or sets the Model object of the ViewModel class
13 | ///
14 | public virtual ModelBase Model { get; set; }
15 | }
16 | }
17 |
--------------------------------------------------------------------------------
/AltinnDesktopToolTest/packages.config:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
--------------------------------------------------------------------------------
/AltinnDesktopTool/View/SearchOrganizationInformation.xaml.cs:
--------------------------------------------------------------------------------
1 | namespace AltinnDesktopTool.View
2 | {
3 | ///
4 | /// Interaction logic for SearchOrganizationInformation.xaml
5 | ///
6 | public partial class SearchOrganizationInformation
7 | {
8 | ///
9 | /// Initializes a new instance of the SearchOrganizationInformation class.
10 | ///
11 | public SearchOrganizationInformation()
12 | {
13 | this.InitializeComponent();
14 | }
15 | }
16 | }
17 |
--------------------------------------------------------------------------------
/AltinnDesktopTool/View/SearchRolesAndRightsInformation.xaml.cs:
--------------------------------------------------------------------------------
1 | namespace AltinnDesktopTool.View
2 | {
3 | ///
4 | /// Interaction logic for SearchRolesAndRightsInformation.xaml
5 | ///
6 | public partial class SearchRolesAndRightsInformation
7 | {
8 | ///
9 | /// Initializes a new instance of the SearchRolesAndRightsInformation class.
10 | ///
11 | public SearchRolesAndRightsInformation()
12 | {
13 | this.InitializeComponent();
14 | }
15 | }
16 | }
--------------------------------------------------------------------------------
/AltinnDesktopToolTest/Configuration/EnvironmentConfigurations.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | PROD
5 | Blue
6 |
7 | /api/serviceowner/
8 |
9 | false
10 | 30
11 |
12 |
--------------------------------------------------------------------------------
/AltinnDesktopTool/Configuration/IUIEnvironmentConfig.cs:
--------------------------------------------------------------------------------
1 | namespace AltinnDesktopTool.Configuration
2 | {
3 | ///
4 | /// Configuration for User Interface
5 | ///
6 | public interface IUiEnvironmentConfig
7 | {
8 | ///
9 | /// Gets or sets the Name of environment
10 | ///
11 | string Name { get; set; }
12 |
13 | ///
14 | /// Gets or sets the Name of theme selected for this environment
15 | ///
16 | string ThemeName { get; set; }
17 | }
18 | }
19 |
--------------------------------------------------------------------------------
/AltinnDesktopTool/Model/OfficialContactModel.cs:
--------------------------------------------------------------------------------
1 | namespace AltinnDesktopTool.Model
2 | {
3 | ///
4 | /// Model for Official Contact
5 | ///
6 | public class OfficialContactModel : ModelBase
7 | {
8 | ///
9 | /// Gets or sets the Mobile number as received from source
10 | ///
11 | public string MobileNumber { get; set; }
12 |
13 | ///
14 | /// Gets or sets the Email Address as received from source
15 | ///
16 | public string EmailAddress { get; set; }
17 | }
18 | }
19 |
--------------------------------------------------------------------------------
/AltinnDesktopTool/View/Footer.xaml.cs:
--------------------------------------------------------------------------------
1 | namespace AltinnDesktopTool.View
2 | {
3 | ///
4 | /// Interaction logic for Footer.xaml
5 | ///
6 | public partial class Footer
7 | {
8 | ///
9 | /// Initializes a new instance of the Footer class.
10 | ///
11 | public Footer()
12 | {
13 | this.InitializeComponent();
14 | }
15 |
16 | private void ComboBox_SelectionChanged(object sender, System.Windows.Controls.SelectionChangedEventArgs e)
17 | {
18 |
19 | }
20 | }
21 | }
22 |
--------------------------------------------------------------------------------
/AltinnDesktopTool/View/RolesSearchResultView.xaml.cs:
--------------------------------------------------------------------------------
1 | namespace AltinnDesktopTool.View
2 | {
3 | ///
4 | /// Interaction logic for RolesSearchResultView.xaml
5 | ///
6 | public partial class RolesSearchResultView
7 | {
8 | ///
9 | /// Initializes a new instance of the RolesSearchResultView class.
10 | ///
11 | public RolesSearchResultView()
12 | {
13 | this.InitializeComponent();
14 | }
15 |
16 | private void RoleGrid_SelectionChanged(object sender, System.Windows.Controls.SelectionChangedEventArgs e)
17 | {
18 |
19 | }
20 | }
21 | }
22 |
--------------------------------------------------------------------------------
/AltinnDesktopTool/Configuration/EnvironmentConfigurations.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | PROD
5 | Blue
6 |
7 |
8 |
9 | false
10 | 30
11 |
12 |
13 | TT02
14 | Orange
15 |
16 |
17 |
18 | false
19 | 30
20 |
21 |
--------------------------------------------------------------------------------
/AltinnDesktopTool/Utils/Helpers/AutomapperHelper.cs:
--------------------------------------------------------------------------------
1 | using AltinnDesktopTool.ViewModel.MapperProfiles;
2 | using AutoMapper;
3 |
4 | namespace AltinnDesktopTool.Utils.Helpers
5 | {
6 | ///
7 | /// Helper class for AutoMapper
8 | ///
9 | public class AutoMapperHelper
10 | {
11 | ///
12 | /// Create the mapper
13 | ///
14 | /// The IMapper object
15 | public static IMapper RunCreateMaps()
16 | {
17 | // Add profiles here
18 | Mapper.Initialize(cfg =>
19 | {
20 | cfg.AddProfile();
21 | });
22 |
23 | return Mapper.Configuration.CreateMapper();
24 | }
25 | }
26 | }
27 |
--------------------------------------------------------------------------------
/RestClient/Controllers/ControllerContext.cs:
--------------------------------------------------------------------------------
1 | using Common.Logging;
2 |
3 | namespace RestClient.Controllers
4 | {
5 | ///
6 | /// The required data for the controller.
7 | ///
8 | public class ControllerContext
9 | {
10 | ///
11 | /// Gets or sets the log4net Log object, may be null.
12 | ///
13 | public ILog Log { get; set; }
14 |
15 | ///
16 | /// Gets or sets the Http wrapper for REST calls to Altinn server.
17 | ///
18 | public AltinnRestClient RestClient { get; set; }
19 |
20 | ///
21 | /// Gets or sets the base address for this controller including the controller name.
22 | ///
23 | public string ControllerBaseAddress { get; set; }
24 | }
25 | }
26 |
--------------------------------------------------------------------------------
/AltinnDesktopTool/Utils/Helpers/BindingProxy.cs:
--------------------------------------------------------------------------------
1 | using System.Windows;
2 |
3 | namespace AltinnDesktopTool.Utils.Helpers
4 | {
5 | ///
6 | /// Binding class that is used when DataContext is not available to view or context
7 | ///
8 | public class BindingProxy : Freezable
9 | {
10 | protected override Freezable CreateInstanceCore()
11 | {
12 | return new BindingProxy();
13 | }
14 |
15 | public object Data
16 | {
17 | get { return (object)GetValue(DataProperty); }
18 | set { SetValue(DataProperty, value); }
19 | }
20 |
21 | public static readonly DependencyProperty DataProperty = DependencyProperty.Register("Data", typeof(object), typeof(BindingProxy), new UIPropertyMetadata(null));
22 |
23 | }
24 | }
25 |
--------------------------------------------------------------------------------
/RestClient/Deserialize/OuterJson.cs:
--------------------------------------------------------------------------------
1 | using Newtonsoft.Json;
2 | using Newtonsoft.Json.Linq;
3 |
4 | namespace RestClient.Deserialize
5 | {
6 | ///
7 | /// Deserialization wrapper for the outer JSON object which comes with the HAL format
8 | ///
9 | public class OuterJson
10 | {
11 | ///
12 | /// Gets or sets the _links container
13 | ///
14 | [JsonProperty(PropertyName = "_links")]
15 | // ReSharper disable once InconsistentNaming
16 | public JObject _links { get; set; }
17 |
18 | ///
19 | /// Gets or sets the _embedded container
20 | ///
21 | [JsonProperty(PropertyName = "_embedded")]
22 | // ReSharper disable once InconsistentNaming
23 | public JObject _embedded { get; set; }
24 | }
25 | }
26 |
--------------------------------------------------------------------------------
/AltinnDesktopTool/View/MainWindow.xaml.cs:
--------------------------------------------------------------------------------
1 | using System.Windows;
2 | using MahApps.Metro.Controls.Dialogs;
3 |
4 | namespace AltinnDesktopTool.View
5 | {
6 | ///
7 | /// Interaction logic for MainWindow.xaml
8 | ///
9 | public partial class MainWindow
10 | {
11 | ///
12 | /// Initializes a new instance of the MainWindow class.
13 | ///
14 | public MainWindow()
15 | {
16 | this.InitializeComponent();
17 | }
18 |
19 | private async void ButtonBase_OnClick(object sender, RoutedEventArgs e)
20 | {
21 | await this.ShowMessageAsync(View.Resources.HeaderText, View.Resources.InfoText);
22 | }
23 |
24 | private void SearchResultView_Loaded(object sender, RoutedEventArgs e)
25 | {
26 |
27 | }
28 | }
29 | }
30 |
--------------------------------------------------------------------------------
/AltinnDesktopTool/Utils/PubSub/PubSubEventArgs.cs:
--------------------------------------------------------------------------------
1 | using System;
2 |
3 | namespace AltinnDesktopTool.Utils.PubSub
4 | {
5 | ///
6 | /// Defines the PubSub event arguments
7 | ///
8 | /// The event args contains an Item of this type
9 | public class PubSubEventArgs : EventArgs
10 | {
11 | ///
12 | /// Initializes a new instance of the class.
13 | ///
14 | ///
15 | /// Mandatory item of the defined type for the PubSubEventArgs
16 | ///
17 | public PubSubEventArgs(T item)
18 | {
19 | this.Item = item;
20 | }
21 |
22 | ///
23 | /// Gets or sets the argument item
24 | ///
25 | public T Item { get; set; }
26 | }
27 | }
--------------------------------------------------------------------------------
/AltinnDesktopTool/ViewModel/MapperProfiles/SearchMapperProfile.cs:
--------------------------------------------------------------------------------
1 | using AutoMapper;
2 |
3 | namespace AltinnDesktopTool.ViewModel.MapperProfiles
4 | {
5 | ///
6 | /// SearchMapperProfile class for configuring profile maps
7 | ///
8 | public class SearchMapperProfile : Profile
9 | {
10 | ///
11 | /// Initializes a new instance of the class, configures AutoMapper
12 | ///
13 | public SearchMapperProfile()
14 | {
15 | this.CreateMap();
16 | this.CreateMap();
17 | this.CreateMap();
18 | this.CreateMap();
19 | }
20 | }
21 | }
22 |
--------------------------------------------------------------------------------
/RestClient/DTO/Role.cs:
--------------------------------------------------------------------------------
1 | namespace RestClient.DTO
2 | {
3 | ///
4 | /// Data transfer object representing a role from the service owner API.
5 | ///
6 | [PluralName("Roles")]
7 | public class Role : HalJsonResource
8 | {
9 | ///
10 | /// Gets or sets the role type.
11 | ///
12 | public string RoleType { get; set; }
13 |
14 | ///
15 | /// Gets or sets the role definition id.
16 | ///
17 | public string RoleDefinitionId { get; set; }
18 |
19 | ///
20 | /// Gets or sets the role name.
21 | ///
22 | public string RoleName { get; set; }
23 |
24 | ///
25 | /// Gets or sets the role description.
26 | ///
27 | public string RoleDescription { get; set; }
28 |
29 | }
30 | }
31 |
--------------------------------------------------------------------------------
/AltinnDesktopTool/Model/PersonalContactModel.cs:
--------------------------------------------------------------------------------
1 | namespace AltinnDesktopTool.Model
2 | {
3 | ///
4 | /// Model for Personal Contact
5 | ///
6 | public class PersonalContactModel : ModelBase
7 | {
8 | ///
9 | /// Gets or sets the Contact Name (as mapped from DTO)
10 | ///
11 | public string Name { get; set; }
12 |
13 | ///
14 | /// Gets or sets the Social Security Number (as mapped from DTO)
15 | ///
16 | public string SocialSecurityNumber { get; set; }
17 |
18 | ///
19 | /// Gets or sets Mobile Number (as mapped from DTO)
20 | ///
21 | public string MobileNumber { get; set; }
22 |
23 | ///
24 | /// Gets or sets the Email address (as mapped from DTO)
25 | ///
26 | public string EmailAddress { get; set; }
27 | }
28 | }
29 |
--------------------------------------------------------------------------------
/AltinnDesktopTool/packages.config:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
--------------------------------------------------------------------------------
/AltinnDesktopTool/Model/SearchType.cs:
--------------------------------------------------------------------------------
1 | namespace AltinnDesktopTool.Model
2 | {
3 | ///
4 | /// Indicates the type of input given in the search.
5 | ///
6 | public enum SearchType
7 | {
8 | ///
9 | /// The search input is undefined. Try to find the correct type automatically.
10 | ///
11 | Smart = 0,
12 |
13 | ///
14 | /// The search input is a phone number.
15 | ///
16 | PhoneNumber = 1,
17 |
18 | ///
19 | /// The search input is an email address.
20 | ///
21 | EMail = 2,
22 |
23 | ///
24 | /// The search input is an organization number.
25 | ///
26 | OrganizationNumber = 3,
27 |
28 | ///
29 | /// The search input is a sosial security number.
30 | ///
31 | SSN = 4,
32 |
33 | ///
34 | /// The search input is unknown.
35 | ///
36 | Unknown = 5
37 | }
38 | }
--------------------------------------------------------------------------------
/RestClient/DTO/OfficialContact.cs:
--------------------------------------------------------------------------------
1 | using System;
2 |
3 | namespace RestClient.DTO
4 | {
5 | ///
6 | /// Data transfer object representing an official contact from the service owner API.
7 | ///
8 | [PluralName("OfficialContacts")]
9 | public class OfficialContact : HalJsonResource
10 | {
11 | ///
12 | /// Gets or sets the mobile number of the official contact.
13 | ///
14 | public string MobileNumber { get; set; }
15 |
16 | ///
17 | /// Gets or sets the date for the last time the mobile number was added or changed.
18 | ///
19 | public DateTime? MobileNumberChanged { get; set; }
20 |
21 | ///
22 | /// Gets or sets the email address of the official contact.
23 | ///
24 | public string EmailAddress { get; set; }
25 |
26 | ///
27 | /// Gets or sets the date for the last time the email address was added or changed.
28 | ///
29 | public DateTime? EmailAddressChanged { get; set; }
30 | }
31 | }
32 |
--------------------------------------------------------------------------------
/AltinnDesktopTool/Properties/Settings.Designer.cs:
--------------------------------------------------------------------------------
1 | //------------------------------------------------------------------------------
2 | //
3 | // This code was generated by a tool.
4 | // Runtime Version:4.0.30319.42000
5 | //
6 | // Changes to this file may cause incorrect behavior and will be lost if
7 | // the code is regenerated.
8 | //
9 | //------------------------------------------------------------------------------
10 |
11 | namespace AltinnDesktopTool.Properties {
12 |
13 |
14 | [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
15 | [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "17.7.0.0")]
16 | internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase {
17 |
18 | private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings())));
19 |
20 | public static Settings Default {
21 | get {
22 | return defaultInstance;
23 | }
24 | }
25 | }
26 | }
27 |
--------------------------------------------------------------------------------
/AltinnDesktopToolTest/Configuration/EnvironmentConfigurationTest.cs:
--------------------------------------------------------------------------------
1 | using System.Collections.Generic;
2 | using AltinnDesktopTool.Configuration;
3 | using Microsoft.VisualStudio.TestTools.UnitTesting;
4 |
5 | namespace AltinnDesktopToolTest.Configuration
6 | {
7 | ///
8 | /// Test class for unit tests of the class.
9 | ///
10 | [TestClass]
11 | public class EnvironmentConfigurationTest
12 | {
13 | ///
14 | /// Scenario:
15 | /// Access environment configurations.
16 | /// Expected Result:
17 | /// Configuration settings are loaded from the file and returned.
18 | /// Success Criteria:
19 | /// The configuration object is not null and contains at least one environment.
20 | ///
21 | [TestMethod]
22 | public void EnvironmentConfigurationsTest_LoadTest()
23 | {
24 | // Arrange
25 | // Act
26 | List configs = EnvironmentConfigurationManager.EnvironmentConfigurations;
27 |
28 | // Assert
29 | Assert.IsNotNull(configs);
30 | Assert.IsTrue(configs.Count > 0);
31 | }
32 | }
33 | }
34 |
--------------------------------------------------------------------------------
/AltinnDesktopTool/Utils/Helpers/ProxyConfigHelper.cs:
--------------------------------------------------------------------------------
1 | using System.Linq;
2 | using AltinnDesktopTool.Configuration;
3 | using RestClient;
4 |
5 | namespace AltinnDesktopTool.Utils.Helpers
6 | {
7 | ///
8 | /// Helper class for the Proxy Configuration
9 | ///
10 | public class ProxyConfigHelper
11 | {
12 | ///
13 | /// Gets the RestQueryConfig object from the configuration manager. Returns production configuration by default.
14 | ///
15 | /// The IRestQueryConfig object
16 | public static IRestQueryConfig GetConfig()
17 | {
18 | return EnvironmentConfigurationManager.EnvironmentConfigurations.FirstOrDefault(c => c.Name == "PROD");
19 | }
20 |
21 | ///
22 | /// Gets the RestQueryConfig object by name from the configuration manager.
23 | ///
24 | /// Name of the environment
25 | /// RestQueryConfig object which matches the environmentName
26 | public static IRestQueryConfig GetConfig(string environmentName)
27 | {
28 | return EnvironmentConfigurationManager.EnvironmentConfigurations.FirstOrDefault(c => c.Name == environmentName);
29 | }
30 | }
31 | }
32 |
--------------------------------------------------------------------------------
/AltinnDesktopTool/View/SearchResultView.xaml.cs:
--------------------------------------------------------------------------------
1 | using System.Windows.Controls;
2 | using System.Windows.Controls.Primitives;
3 | using System.Windows.Input;
4 |
5 | namespace AltinnDesktopTool.View
6 | {
7 | ///
8 | /// Interaction logic for SearchResultView.xaml
9 | ///
10 | public partial class SearchResultView
11 | {
12 | ///
13 | /// Initializes a new instance of the SearchResultView class.
14 | ///
15 | public SearchResultView()
16 | {
17 | this.InitializeComponent();
18 | }
19 |
20 | private void UIElement_OnPreviewMouseDown(object sender, MouseButtonEventArgs e)
21 | {
22 | CheckBox checkBox = (CheckBox)sender;
23 | if (checkBox.IsChecked ?? false)
24 | {
25 | checkBox.SetCurrentValue(ToggleButton.IsCheckedProperty, false);
26 | }
27 | else
28 | {
29 | checkBox.SetCurrentValue(ToggleButton.IsCheckedProperty, true);
30 | }
31 |
32 | e.Handled = true;
33 | }
34 |
35 | private void OrganizationGrid_SelectionChanged(object sender, SelectionChangedEventArgs e)
36 | {
37 |
38 | }
39 |
40 | private void PersonalContactsGrid_Scroll(object sender, ScrollEventArgs e)
41 | {
42 |
43 | }
44 | }
45 | }
46 |
--------------------------------------------------------------------------------
/RestClient/DTO/HalJsonResource.cs:
--------------------------------------------------------------------------------
1 | using System;
2 |
3 | namespace RestClient.DTO
4 | {
5 | ///
6 | /// Base class for Dto objects - deserializable from HAL+JSON format
7 | ///
8 | public class HalJsonResource
9 | {
10 | ///
11 | /// Initializes a new instance of the class
12 | ///
13 | public HalJsonResource()
14 | {
15 | Type t = this.GetType();
16 | if (t.IsDefined(typeof(PluralNameAttribute), false) == false)
17 | {
18 | throw new InvalidOperationException("Missing Plural name attribute on HalJsonResource class!");
19 | }
20 | }
21 | }
22 |
23 | ///
24 | /// Attribute for indicating object list name
25 | ///
26 | [AttributeUsage(AttributeTargets.Class)]
27 | public class PluralNameAttribute : Attribute
28 | {
29 | ///
30 | /// Gets the plural name
31 | ///
32 | public readonly string PluralName;
33 |
34 | ///
35 | /// Initializes a new instance of the class
36 | ///
37 | /// Plural name to be set
38 | public PluralNameAttribute(string pluralName)
39 | {
40 | this.PluralName = pluralName;
41 | }
42 | }
43 | }
44 |
--------------------------------------------------------------------------------
/RestClient/Properties/AssemblyInfo.cs:
--------------------------------------------------------------------------------
1 | using System.Reflection;
2 | using System.Runtime.InteropServices;
3 |
4 | // General Information about an assembly is controlled through the following
5 | // set of attributes. Change these attribute values to modify the information
6 | // associated with an assembly.
7 | [assembly: AssemblyTitle("RestClient")]
8 | [assembly: AssemblyDescription("")]
9 | [assembly: AssemblyConfiguration("")]
10 | [assembly: AssemblyCompany("Capgemini")]
11 | [assembly: AssemblyProduct("RestClient")]
12 | [assembly: AssemblyCopyright("Copyright © Capgemini 2016")]
13 | [assembly: AssemblyTrademark("")]
14 | [assembly: AssemblyCulture("")]
15 |
16 | // Setting ComVisible to false makes the types in this assembly not visible
17 | // to COM components. If you need to access a type in this assembly from
18 | // COM, set the ComVisible attribute to true on that type.
19 | [assembly: ComVisible(false)]
20 |
21 | // The following GUID is for the ID of the typelib if this project is exposed to COM
22 | [assembly: Guid("bf6fb931-d0c9-48a4-9e9d-15eb71b0f13e")]
23 |
24 | // Version information for an assembly consists of the following four values:
25 | //
26 | // Major Version
27 | // Minor Version
28 | // Build Number
29 | // Revision
30 | //
31 | // You can specify all the values or you can default the Build and Revision Numbers
32 | // by using the '*' as shown below:
33 | // [assembly: AssemblyVersion("1.0.*")]
34 | [assembly: AssemblyVersion("1.0.0.0")]
35 | [assembly: AssemblyFileVersion("1.0.0.0")]
36 |
--------------------------------------------------------------------------------
/AltinnDesktopToolTest/Properties/AssemblyInfo.cs:
--------------------------------------------------------------------------------
1 | using System.Reflection;
2 | using System.Runtime.InteropServices;
3 |
4 | // General Information about an assembly is controlled through the following
5 | // set of attributes. Change these attribute values to modify the information
6 | // associated with an assembly.
7 | [assembly: AssemblyTitle("AltinnDesktopToolTest")]
8 | [assembly: AssemblyDescription("")]
9 | [assembly: AssemblyConfiguration("")]
10 | [assembly: AssemblyCompany("")]
11 | [assembly: AssemblyProduct("AltinnDesktopToolTest")]
12 | [assembly: AssemblyCopyright("Copyright © 2016")]
13 | [assembly: AssemblyTrademark("")]
14 | [assembly: AssemblyCulture("")]
15 |
16 | // Setting ComVisible to false makes the types in this assembly not visible
17 | // to COM components. If you need to access a type in this assembly from
18 | // COM, set the ComVisible attribute to true on that type.
19 | [assembly: ComVisible(false)]
20 |
21 | // The following GUID is for the ID of the typelib if this project is exposed to COM
22 | [assembly: Guid("2be6ffde-ea7e-47ea-8eee-1be75869c151")]
23 |
24 | // Version information for an assembly consists of the following four values:
25 | //
26 | // Major Version
27 | // Minor Version
28 | // Build Number
29 | // Revision
30 | //
31 | // You can specify all the values or you can default the Build and Revision Numbers
32 | // by using the '*' as shown below:
33 | // [assembly: AssemblyVersion("1.0.*")]
34 | [assembly: AssemblyVersion("1.0.0.0")]
35 | [assembly: AssemblyFileVersion("1.0.0.0")]
36 |
--------------------------------------------------------------------------------
/RestClient.Test/Properties/AssemblyInfo.cs:
--------------------------------------------------------------------------------
1 | using System.Reflection;
2 | using System.Runtime.InteropServices;
3 |
4 | // General Information about an assembly is controlled through the following
5 | // set of attributes. Change these attribute values to modify the information
6 | // associated with an assembly.
7 | [assembly: AssemblyTitle("RestClient.Test")]
8 | [assembly: AssemblyDescription("")]
9 | [assembly: AssemblyConfiguration("")]
10 | [assembly: AssemblyCompany("Capgemini")]
11 | [assembly: AssemblyProduct("RestClient.Test")]
12 | [assembly: AssemblyCopyright("Copyright © Capgemini 2016")]
13 | [assembly: AssemblyTrademark("")]
14 | [assembly: AssemblyCulture("")]
15 |
16 | // Setting ComVisible to false makes the types in this assembly not visible
17 | // to COM components. If you need to access a type in this assembly from
18 | // COM, set the ComVisible attribute to true on that type.
19 | [assembly: ComVisible(false)]
20 |
21 | // The following GUID is for the ID of the typelib if this project is exposed to COM
22 | [assembly: Guid("f97e7ff9-c66b-4c94-8503-d72ed7ee459b")]
23 |
24 | // Version information for an assembly consists of the following four values:
25 | //
26 | // Major Version
27 | // Minor Version
28 | // Build Number
29 | // Revision
30 | //
31 | // You can specify all the values or you can default the Build and Revision Numbers
32 | // by using the '*' as shown below:
33 | // [assembly: AssemblyVersion("1.0.*")]
34 | [assembly: AssemblyVersion("1.0.0.0")]
35 | [assembly: AssemblyFileVersion("1.0.0.0")]
36 |
--------------------------------------------------------------------------------
/IntegrationUnitTest/Properties/AssemblyInfo.cs:
--------------------------------------------------------------------------------
1 | using System.Reflection;
2 | using System.Runtime.InteropServices;
3 |
4 | // General Information about an assembly is controlled through the following
5 | // set of attributes. Change these attribute values to modify the information
6 | // associated with an assembly.
7 | [assembly: AssemblyTitle("IntegrationUnitTest")]
8 | [assembly: AssemblyDescription("")]
9 | [assembly: AssemblyConfiguration("")]
10 | [assembly: AssemblyCompany("Capgemini")]
11 | [assembly: AssemblyProduct("IntegrationUnitTest")]
12 | [assembly: AssemblyCopyright("Copyright © Capgemini 2016")]
13 | [assembly: AssemblyTrademark("")]
14 | [assembly: AssemblyCulture("")]
15 |
16 | // Setting ComVisible to false makes the types in this assembly not visible
17 | // to COM components. If you need to access a type in this assembly from
18 | // COM, set the ComVisible attribute to true on that type.
19 | [assembly: ComVisible(false)]
20 |
21 | // The following GUID is for the ID of the typelib if this project is exposed to COM
22 | [assembly: Guid("b6215dbe-2806-49ed-91a6-7185256b1a85")]
23 |
24 | // Version information for an assembly consists of the following four values:
25 | //
26 | // Major Version
27 | // Minor Version
28 | // Build Number
29 | // Revision
30 | //
31 | // You can specify all the values or you can default the Build and Revision Numbers
32 | // by using the '*' as shown below:
33 | // [assembly: AssemblyVersion("1.0.*")]
34 | [assembly: AssemblyVersion("1.0.0.0")]
35 | [assembly: AssemblyFileVersion("1.0.0.0")]
36 |
--------------------------------------------------------------------------------
/AltinnDesktopTool/ViewModel/MainViewModel.cs:
--------------------------------------------------------------------------------
1 | using System.ComponentModel;
2 | using System.Windows;
3 | using AltinnDesktopTool.Configuration;
4 | using AltinnDesktopTool.Utils.PubSub;
5 | using GalaSoft.MvvmLight;
6 | using GalaSoft.MvvmLight.Command;
7 | using MahApps.Metro;
8 |
9 | namespace AltinnDesktopTool.ViewModel
10 | {
11 | ///
12 | /// ViewModel for MainView
13 | ///
14 | public class MainViewModel : ViewModelBase
15 | {
16 | ///
17 | /// Initializes a new instance of the MainViewModel class.
18 | ///
19 | public MainViewModel()
20 | {
21 | PubSub.RegisterEvent(EventNames.EnvironmentChangedEvent, this.EnvironmentChangedEventHandler);
22 | this.ClosingWindowCommand = new RelayCommand(this.ClosingWindowCommandHandler);
23 | }
24 |
25 | ///
26 | /// Gets or sets Closing window command
27 | ///
28 | public RelayCommand ClosingWindowCommand { get; set; }
29 |
30 | private void ClosingWindowCommandHandler(CancelEventArgs obj)
31 | {
32 | ViewModelLocator.Cleanup();
33 | }
34 |
35 | private void EnvironmentChangedEventHandler(object sender, PubSubEventArgs args)
36 | {
37 | ThemeManager.ChangeAppStyle(Application.Current, ThemeManager.GetAccent(EnvironmentConfigurationManager.ActiveEnvironmentConfiguration.ThemeName), ThemeManager.GetAppTheme("BaseLight"));
38 | }
39 | }
40 | }
--------------------------------------------------------------------------------
/RestClient/IRestQueryConfig.cs:
--------------------------------------------------------------------------------
1 | namespace RestClient
2 | {
3 | ///
4 | /// The Query configuration as required by the RestQuery component.
5 | ///
6 | public interface IRestQueryConfig
7 | {
8 | ///
9 | /// Gets or sets the base address for the REST api for the environment that this configuration is connected to.
10 | ///
11 | ///
12 | /// When the url is like: https://host/x/y/organizations/orgno and organizations is the name of the controller,
13 | /// then the base address must be https://host/x/y/ including the ending '/'.
14 | /// The BaseAddress may be changed, in which case AltinnRestClient will reconnect to new host on next call.
15 | ///
16 | string BaseAddress { get; set; }
17 |
18 | ///
19 | /// Gets or sets the ApiKey to be used by the client.
20 | ///
21 | string ApiKey { get; set; }
22 |
23 | ///
24 | /// Gets or sets the thumbprint of the certificate required to authenticate as service owner.
25 | ///
26 | string ThumbPrint { get; set; }
27 |
28 | ///
29 | /// Gets or sets a value indicating whether the client should ignore SSL errors.
30 | ///
31 | bool IgnoreSslErrors { get; set; }
32 |
33 | ///
34 | /// Gets or sets the timeout for a request in seconds.
35 | ///
36 | int Timeout { get; set; }
37 | }
38 | }
39 |
--------------------------------------------------------------------------------
/RestClient/DTO/Organization.cs:
--------------------------------------------------------------------------------
1 | using System;
2 |
3 | namespace RestClient.DTO
4 | {
5 | ///
6 | /// Data transfer object representing an organization from the service owner API.
7 | ///
8 | [PluralName("Organizations")]
9 | public class Organization : HalJsonResource
10 | {
11 | ///
12 | /// Gets or sets the name of the organization.
13 | ///
14 | public string Name { get; set; }
15 |
16 | ///
17 | /// Gets or sets the organization number.
18 | ///
19 | public string OrganizationNumber { get; set; }
20 |
21 | ///
22 | /// Gets or sets the type of organization.
23 | ///
24 | public string Type { get; set; }
25 |
26 | ///
27 | /// Gets or sets the time for the last update to the organization profile.
28 | ///
29 | public DateTime? LastChanged { get; set; }
30 |
31 | ///
32 | /// Gets or sets the time for the last profile confirmation.
33 | ///
34 | public DateTime? LastConfirmed { get; set; }
35 |
36 | ///
37 | /// Gets or sets the list of official contacts associated with the organization.
38 | ///
39 | public string OfficialContacts { get; set; }
40 |
41 | ///
42 | /// Gets or sets the list of personal contacts associated with the organization.
43 | ///
44 | public string PersonalContacts { get; set; }
45 | }
46 | }
47 |
--------------------------------------------------------------------------------
/RestClient/DTO/PersonalContact.cs:
--------------------------------------------------------------------------------
1 | using System;
2 |
3 | namespace RestClient.DTO
4 | {
5 | ///
6 | /// Data transfer object representing a personal contact from the service owner API.
7 | ///
8 | [PluralName("PersonalContacts")]
9 | public class PersonalContact : HalJsonResource
10 | {
11 | ///
12 | /// Gets or sets a unique id on the personal contact in Altinn.
13 | ///
14 | public string PersonalContactId { get; set; }
15 |
16 | ///
17 | /// Gets or sets the name of the contact.
18 | ///
19 | public string Name { get; set; }
20 |
21 | ///
22 | /// Gets or sets the social security number of the contact.
23 | ///
24 | public string SocialSecurityNumber { get; set; }
25 |
26 | ///
27 | /// Gets or sets the mobile number of the personal contact.
28 | ///
29 | public string MobileNumber { get; set; }
30 |
31 | ///
32 | /// Gets or sets the date for the last time the mobile number was added or changed.
33 | ///
34 | public DateTime? MobileNumberChanged { get; set; }
35 |
36 | ///
37 | /// Gets or sets the email address of the personal contact.
38 | ///
39 | public string EmailAddress { get; set; }
40 |
41 | ///
42 | /// Gets or sets the date for the last time the email address was added or changed.
43 | ///
44 | public DateTime? EmailAddressChanged { get; set; }
45 | }
46 | }
47 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # **Important Update: Transition from WPF Toolkit to Web Application**
2 |
3 | We are excited to announce that the WPF Client, previously utilized by Altinn Support, is transitioning to a new, modern web application.
4 |
5 | ### New Repository
6 | The WPF Toolkit repository is now archived. The new repository can be found [here.](https://github.com/Altinn/altinn-support-dashboard)
7 |
8 | ### What This Means for You
9 | The transition marks the end of maintenance for the old WPF Toolkit, as we move towards a more secure and interactive platform. This upgrade is part of our ongoing efforts to enhance user experience and ensure the highest level of security.
10 |
11 | ### Have Questions?
12 | We're here to help. If you have any questions or need further clarification, please feel free to reach out to [Espen E. Halsen](mailto:espen.elstad.halsen@digdir.no?subject=[Altinn-WPF-Archived]). We appreciate your cooperation and understanding during this transition phase.
13 |
14 | ------------------------
15 |
16 | # OUTDATED WPF client used by Altinn support
17 | Uses a public REST service to lookup contact information and roles delegated in the Altinn contact registry.
18 | ## Building
19 | Install WiX Toolset http://wixtoolset.org/
20 |
21 | Open AltinnDesktopTool.sln in Visual Studio and build the msi file.
22 |
23 | If used for upgrades, change product code and increment version numbers.
24 |
25 | ## Support
26 | The application is currently being updated / upgraded. If you have any questions or bugs, please make an issue or refer to:
27 |
28 | [Espen E. Halsen](mailto:espen.elstad.halsen@digdir.no?subject=[Altinn-WPF-Support])
29 |
30 | [Andreas C. Bjørnå](mailto:andreas.chummuenwai.bjorna@digdir.no?subject=[Altinn-WPF-Support])
31 |
--------------------------------------------------------------------------------
/AltinnDesktopTool/App.xaml:
--------------------------------------------------------------------------------
1 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
--------------------------------------------------------------------------------
/RestClient/Controllers/RestQueryControllerAttribute.cs:
--------------------------------------------------------------------------------
1 | using System;
2 |
3 | namespace RestClient.Controllers
4 | {
5 | ///
6 | /// Each class implementing IRestQueryController must have this attribute to identify it as a RestQueryController and define its name.
7 | /// The name will be used as part of the URL to identify the controller.
8 | ///
9 | [AttributeUsage(AttributeTargets.Class, AllowMultiple = true)]
10 | public class RestQueryControllerAttribute : Attribute
11 | {
12 | ///
13 | /// Initializes a new instance of the RestQueryControllerAttribute class with name and type set to null.
14 | ///
15 | public RestQueryControllerAttribute()
16 | {
17 | }
18 |
19 | ///
20 | /// Initializes a new instance of the RestQueryControllerAttribute class with a given name and supported type.
21 | ///
22 | /// The name of the controller.
23 | /// The type supported by the controller.
24 | public RestQueryControllerAttribute(string name, Type supportedType)
25 | {
26 | this.Name = name;
27 | this.SupportedType = supportedType;
28 | }
29 |
30 | ///
31 | /// Gets or sets the name identifying the controller
32 | ///
33 | public string Name { get; set; }
34 |
35 | ///
36 | /// Gets or sets the supported type for a controller.
37 | ///
38 | public Type SupportedType { get; set; }
39 |
40 | ///
41 | /// Gets or sets the controller type.
42 | ///
43 | internal Type ControllerType { get; set; }
44 | }
45 | }
46 |
--------------------------------------------------------------------------------
/AltinnDesktopTool/Model/RoleModel.cs:
--------------------------------------------------------------------------------
1 | using AltinnDesktopTool.Utils.PubSub;
2 |
3 | namespace AltinnDesktopTool.Model
4 | {
5 | public class RoleModel : ModelBase
6 | {
7 | private bool isSelected;
8 |
9 | ///
10 | /// Gets or sets the role type
11 | ///
12 | public string RoleType { get; set; }
13 |
14 | ///
15 | /// Gets or sets the role definition id
16 | ///
17 | public string RoleDefinitionId { get; set; }
18 |
19 | ///
20 | /// Gets or sets the role name
21 | ///
22 | public string RoleName { get; set; }
23 |
24 | ///
25 | /// Gets or sets the role description
26 | ///
27 | public string RoleDescription { get; set; }
28 |
29 | ///
30 | /// Gets or sets a value indicating whether an item is selected
31 | ///
32 | public bool IsSelected
33 | {
34 | get
35 | {
36 | return this.isSelected;
37 | }
38 |
39 | set
40 | {
41 | this.isSelected = value;
42 | this.RaisePropertyChanged(() => this.IsSelected);
43 | PubSub.RaiseEvent(EventNames.RoleSelectedChangedEvent, this, new PubSubEventArgs(this));
44 | }
45 | }
46 |
47 | ///
48 | /// Sets IsSelected
49 | ///
50 | /// boolean value
51 | public void SetIsSelected(bool value)
52 | {
53 | this.isSelected = value;
54 | this.RaisePropertyChanged(() => this.IsSelected);
55 | }
56 |
57 |
58 | }
59 | }
60 |
--------------------------------------------------------------------------------
/AltinnDesktopTool/Configuration/EnvironmentConfiguration.cs:
--------------------------------------------------------------------------------
1 | using RestClient;
2 |
3 | namespace AltinnDesktopTool.Configuration
4 | {
5 | ///
6 | /// Class for storing environment based configuration settings
7 | ///
8 | public class EnvironmentConfiguration : IUiEnvironmentConfig, IRestQueryConfig
9 | {
10 | ///
11 | /// Gets or sets the name of the environment that this configuration is connected to.
12 | ///
13 | public string Name { get; set; }
14 |
15 | ///
16 | /// Gets or sets the theme name for the environment that this configuration is connected to.
17 | ///
18 | public string ThemeName { get; set; }
19 |
20 | ///
21 | /// Gets or sets the api key for the environment that this configuration is connected to.
22 | ///
23 | public string ApiKey { get; set; }
24 |
25 | ///
26 | /// Gets or sets the base address for the REST api for the environment that this configuration is connected to.
27 | ///
28 | public string BaseAddress { get; set; }
29 |
30 | ///
31 | /// Gets or sets the certificate thumbprint for the environment that this configuration is connected to.
32 | ///
33 | public string ThumbPrint { get; set; }
34 |
35 | ///
36 | /// Gets or sets a value indicating whether the client should ignore SSL errors.
37 | ///
38 | public bool IgnoreSslErrors { get; set; }
39 |
40 | ///
41 | /// Gets or sets the timeout for the REST api call for the environment that this configuration is connected to.
42 | ///
43 | public int Timeout { get; set; }
44 | }
45 | }
46 |
--------------------------------------------------------------------------------
/AltinnDesktopTool/View/Footer.xaml:
--------------------------------------------------------------------------------
1 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
--------------------------------------------------------------------------------
/RestClient/Resources/RestClientErrorCodes.cs:
--------------------------------------------------------------------------------
1 | using System;
2 |
3 | namespace RestClient.Resources
4 | {
5 | ///
6 | /// All possible error codes from the REST client.
7 | ///
8 | public static class RestClientErrorCodes
9 | {
10 | ///
11 | /// The client has wrong or missing configuration values.
12 | ///
13 | public const string RestClientConfigurationError = "RestClientConfigurationError";
14 |
15 | ///
16 | /// The remote API returned something the client was unable to deserialize.
17 | ///
18 | public const string RestClientDeserialiationError = "RestClientDeserialiationError";
19 |
20 | ///
21 | /// The remote API returned a http status that the REST client is unable to handle.
22 | ///
23 | public const string RestClientUnableToHandleResponse = "RestClientUnableToHandleResponse";
24 |
25 | ///
26 | /// The remote API returned http status code 400 Bad Request.
27 | ///
28 | public const string RemoteApiReturnedStatusBadRequest = "RemoteApiReturnedStatusBadRequest";
29 |
30 | ///
31 | /// The remote API returned http status code 401 Unauthorized.
32 | ///
33 | public const string RemoteApiReturnedStatusUnauthorized = "RemoteApiReturnedStatusUnauthorized";
34 |
35 | ///
36 | /// The remote API returned http status code 403 Forbidden.
37 | ///
38 | public const string RemoteApiReturnedStatusForbidden = "RemoteApiReturnedStatusForbidden";
39 |
40 | ///
41 | /// The remote API returned http status code 404 Not Found.
42 | ///
43 | public const string RemoteApiReturnedStatusNotFound = "RemoteApiReturnedStatusNotFound";
44 |
45 | ///
46 | /// The remote API returned http status code 500 Internal Server Error.
47 | ///
48 | public const string RemoteApiReturnedStatusInternalServerError = "RemoteApiReturnedStatusInternalServerError";
49 | }
50 | }
51 |
--------------------------------------------------------------------------------
/AltinnDesktopTool/Resources/WindowsIcons-license.txt:
--------------------------------------------------------------------------------
1 | # License
2 |
3 | Please carefully understand the license and download the latest icons at ModernUIIcons.com.
4 |
5 | ## Understand Your Rights
6 | No Attribution and No Derived Works
7 | http://creativecommons.org/licenses/by-nd/3.0/ *
8 |
9 | - If your project is open source include this license file in the source.
10 | - Nothing is needed in the front facing project (UNLESS you
11 | are using any of the icons listed below in the attribution section).
12 | - Commercial use is not only allowed but encouraged. If it is an icon
13 | in the attribution list below, you still need to attribute those!
14 | - Do not distribute the entire package (I've allowed this dozens of
15 | times for open source projects, but email me first).
16 |
17 | ## Creator
18 | - Austin Andrews (@templarian)
19 |
20 | ## Contributor**
21 | - Jay Zawrotny (@JayZawrotny)
22 | - A Bunch
23 | - Oren Nachman
24 | - appbar.chevron.down
25 | - appbar.chevron.up
26 | - appbar.chevron.left
27 | - appbar.chevron.right
28 |
29 | ## Derived Works
30 | - Alex Peattie
31 | - Social: http://www.alexpeattie.com/projects/justvector_icons/
32 |
33 | ## Attribution***
34 | - Kris Vandermotten (@kvandermotten)
35 | - appbar.medical.pulse
36 | - Constantin Kichinsky (@kichinsky)
37 | - appbar.currency.rubles
38 | - appbar.currency.grivna
39 | - Massimo Savazzi (@msavazzi)
40 | - List of missing exported icons
41 | - Proletkult Graphik, from The Noun Project
42 | - appbar.draw.pen (inspired)
43 | - Olivier Guin, from The Noun Project
44 | - appbar.draw.marker
45 | - Gibran Bisio, from The Noun Project
46 | - appbar.draw.bucket
47 | Andrew Forrester, from The Noun Project
48 | - appbar.fingerprint
49 |
50 | * The license is for attribution, but this is not required.
51 | ** Developers and designers that emailed Templarian the source .design icons to be added into the package. PNGs also accepted, but may take longer to be added.
52 | *** Icons I've copied so closely you want to attribute them and are also under the CC license.
53 |
54 | Contact
55 | - http://templarian.com/
56 | - admin[@]templarian[.]com
57 |
58 | * Does not apply to copyrighted logos
59 | - Skype
60 | - Facebook
61 | - Twitter
62 | - etc...
63 |
--------------------------------------------------------------------------------
/IntegrationUnitTest/AltinnRestClientTest.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using Microsoft.VisualStudio.TestTools.UnitTesting;
3 | using RestClient;
4 |
5 | namespace IntegrationUnitTest
6 | {
7 | ///
8 | /// Test class for unit tests of the AltinnRestClient class.
9 | ///
10 | [TestClass]
11 | public class AltinnRestClientTest
12 | {
13 | private const string Baseaddress = "https://tt02.altinn.basefarm.net/";
14 |
15 | private const string Apikey = "APIKEY";
16 |
17 | private const string Thumbprint = "THUMBPRINT";
18 |
19 | ///
20 | /// Scenario:
21 | /// Perform a Get request without any inputs.
22 | /// Expected Result:
23 | /// A long list of organizations.
24 | /// Success Criteria:
25 | /// There are no exceptions.
26 | ///
27 | [TestMethod]
28 | public void GetTest_RequestUnfiltered_ListOfOrganizations()
29 | {
30 | // Arrange
31 | AltinnRestClient client = new AltinnRestClient
32 | {
33 | BaseAddress = Baseaddress,
34 | ApiKey = Apikey,
35 | Thumbprint = Thumbprint,
36 | IgnoreSslErrors = false,
37 | Timeout = 10
38 | };
39 |
40 | // Authenticate
41 | // NOTE: Altinn returns 401 even if it is validated.
42 | const string Orgno = "910021451";
43 | string uriPart = "api/serviceowner/organizations?ForceEIAuthentication";
44 | try
45 | {
46 | client.Get(uriPart);
47 | }
48 | catch (Exception ex)
49 | {
50 | Console.WriteLine(ex.Message);
51 | }
52 |
53 | // Get by orgno
54 | uriPart = "api/serviceowner/organizations/" + Orgno;
55 | string result = "N/A";
56 | try
57 | {
58 | result = client.Get(uriPart);
59 | }
60 | catch (Exception ex)
61 | {
62 | Console.WriteLine(ex.Message);
63 | }
64 |
65 | Console.WriteLine(result);
66 | }
67 | }
68 | }
69 |
--------------------------------------------------------------------------------
/AltinnDesktopTool/Utils/PubSub/EventNames.cs:
--------------------------------------------------------------------------------
1 | namespace AltinnDesktopTool.Utils.PubSub
2 | {
3 | ///
4 | /// Static class containing the registered events used
5 | ///
6 | public static class EventNames
7 | {
8 | ///
9 | /// Search event
10 | ///
11 | public static readonly string SearchResultReceivedEvent = "SearchResultReceivedEvent";
12 |
13 | ///
14 | /// Environment Changed Event
15 | ///
16 | public static readonly string EnvironmentChangedEvent = "EnvironmentChangedEvent";
17 |
18 | ///
19 | /// Search StartedEvent
20 | ///
21 | public static readonly string SearchStartedEvent = "SearchStartedEvent";
22 |
23 | ///
24 | /// Organization Selected Changed Event
25 | ///
26 | public static readonly string OrganizationSelectedChangedEvent = "OrganizationSelectedChangedEvent";
27 |
28 | ///
29 | /// Organization Selected Changed All Event
30 | ///
31 | public static readonly string OrganizationSelectedAllChangedEvent = "OrganizationSelectedAllChangedEvent";
32 |
33 | ///
34 | /// Role Selected Changed Event
35 | ///
36 | public static readonly string RoleSelectedChangedEvent = "RoleSelectedChangedEvent";
37 |
38 | ///
39 | /// Role Selected Changed All Event
40 | ///
41 | public static readonly string RoleSelectedAllChangedEvent = "RoleSelectedAllChangedEvent";
42 |
43 | ///
44 | /// Tab Selected Changed Event
45 | ///
46 | public static readonly string TabItemChangedEvent = "TabItemChangedEvent";
47 |
48 | ///
49 | /// Role Search Event
50 | ///
51 | public static readonly string RoleSearchResultReceivedEvent = "RoleSearchResultReceivedEvent";
52 |
53 | ///
54 | /// Role Search Started Event
55 | ///
56 | public static readonly string RoleSearchStartedEvent = "RoleSearchStartedEvent";
57 | }
58 | }
59 |
--------------------------------------------------------------------------------
/AltinnDesktopTool/Model/SearchRolesAndRightsInformationModel.cs:
--------------------------------------------------------------------------------
1 | using System.Windows.Media;
2 |
3 | namespace AltinnDesktopTool.Model
4 | {
5 | public class SearchRolesAndRightsInformationModel : ModelBase
6 | {
7 | private string subjectSearchText;
8 | private string reporteeSearchText;
9 | private string labelText;
10 | private Brush labelBrush;
11 |
12 | ///
13 | /// Gets or sets the text to be displayed as feedback from the search.
14 | ///
15 | public string LabelText
16 | {
17 | get
18 | {
19 | return this.labelText;
20 | }
21 |
22 | set
23 | {
24 | this.labelText = value;
25 | this.RaisePropertyChanged(() => this.LabelText);
26 | }
27 | }
28 |
29 | ///
30 | /// Gets or sets the brush used to define the look of the label foreground color.
31 | ///
32 | public Brush LabelBrush
33 | {
34 | get
35 | {
36 | return this.labelBrush;
37 | }
38 |
39 | set
40 | {
41 | this.labelBrush = value;
42 | this.RaisePropertyChanged(() => this.LabelBrush);
43 | }
44 | }
45 |
46 | ///
47 | /// Gets or sets the subject search text.
48 | ///
49 | public string SubjectSearchText
50 | {
51 | get
52 | {
53 | return this.subjectSearchText;
54 | }
55 |
56 | set
57 | {
58 | this.subjectSearchText = value;
59 | this.RaisePropertyChanged(() => this.SubjectSearchText);
60 | }
61 | }
62 |
63 | ///
64 | /// Gets or sets the reportee search text.
65 | ///
66 | public string ReporteeSearchText
67 | {
68 | get
69 | {
70 | return this.reporteeSearchText;
71 | }
72 |
73 | set
74 | {
75 | this.reporteeSearchText = value;
76 | this.RaisePropertyChanged(() => this.ReporteeSearchText);
77 | }
78 | }
79 | }
80 | }
81 |
--------------------------------------------------------------------------------
/AltinnDesktopTool/Properties/AssemblyInfo.cs:
--------------------------------------------------------------------------------
1 | using System.Reflection;
2 | using System.Runtime.InteropServices;
3 | using System.Windows;
4 |
5 | // General Information about an assembly is controlled through the following
6 | // set of attributes. Change these attribute values to modify the information
7 | // associated with an assembly.
8 | [assembly: AssemblyTitle("Altinn Toolkit")]
9 | [assembly: AssemblyDescription("")]
10 | [assembly: AssemblyConfiguration("")]
11 | [assembly: AssemblyCompany("")]
12 | [assembly: AssemblyProduct("Altinn Toolkit")]
13 | [assembly: AssemblyCopyright("Copyright © Altinn 2023")]
14 | [assembly: AssemblyTrademark("")]
15 | [assembly: AssemblyCulture("")]
16 |
17 | // Setting ComVisible to false makes the types in this assembly not visible
18 | // to COM components. If you need to access a type in this assembly from
19 | // COM, set the ComVisible attribute to true on that type.
20 | [assembly: ComVisible(false)]
21 |
22 | //In order to begin building localizable applications, set
23 | //CultureYouAreCodingWith in your .csproj file
24 | //inside a . For example, if you are using US english
25 | //in your source files, set the to en-US. Then uncomment
26 | //the NeutralResourceLanguage attribute below. Update the "en-US" in
27 | //the line below to match the UICulture setting in the project file.
28 | [assembly: ThemeInfo(
29 | ResourceDictionaryLocation.None, //where theme specific resource dictionaries are located
30 | //(used if a resource is not found in the page,
31 | // or application resource dictionaries)
32 | ResourceDictionaryLocation.SourceAssembly //where the generic resource dictionary is located
33 | //(used if a resource is not found in the page,
34 | // app, or any theme specific resource dictionaries)
35 | )]
36 |
37 | // Version information for an assembly consists of the following four values:
38 | //
39 | // Major Version
40 | // Minor Version
41 | // Build Number
42 | // Revision
43 | //
44 | // You can specify all the values or you can default the Build and Revision Numbers
45 | // by using the '*' as shown below:
46 | // [assembly: AssemblyVersion("1.0.*")]
47 | [assembly: AssemblyVersion("1.0.0.0")]
48 | [assembly: AssemblyFileVersion("1.0.0.0")]
49 |
--------------------------------------------------------------------------------
/AltinnDesktopTool/Model/SearchOrganizationInformationModel.cs:
--------------------------------------------------------------------------------
1 | using System.ComponentModel.DataAnnotations;
2 | using System.Windows.Media;
3 | using AltinnDesktopTool.Properties;
4 |
5 | namespace AltinnDesktopTool.Model
6 | {
7 | ///
8 | /// This model holds the data required to perform a search and details about the label that displays the result of the search.
9 | ///
10 | public class SearchOrganizationInformationModel : ModelBase
11 | {
12 | private string searchText;
13 | private string labelText;
14 | private Brush labelBrush;
15 |
16 | ///
17 | /// Gets or sets the text to be displayed as feedback from the search.
18 | ///
19 | public string LabelText
20 | {
21 | get
22 | {
23 | return this.labelText;
24 | }
25 |
26 | set
27 | {
28 | this.labelText = value;
29 | this.RaisePropertyChanged(() => this.LabelText);
30 | }
31 | }
32 |
33 | ///
34 | /// Gets or sets the brush used to define the look of the label foreground color.
35 | ///
36 | public Brush LabelBrush
37 | {
38 | get
39 | {
40 | return this.labelBrush;
41 | }
42 |
43 | set
44 | {
45 | this.labelBrush = value;
46 | this.RaisePropertyChanged(() => this.LabelBrush);
47 | }
48 | }
49 |
50 | ///
51 | /// Gets or sets the search text.
52 | ///
53 | [Required(ErrorMessageResourceType = typeof(Resources), ErrorMessageResourceName = "SearchOrganizationInformationModel_SearchText_You_must_enter_a_string_")]
54 | public string SearchText
55 | {
56 | get
57 | {
58 | return this.searchText;
59 | }
60 |
61 | set
62 | {
63 | this.searchText = value;
64 | this.RaisePropertyChanged(() => this.SearchText);
65 | this.ValidateModelProperty(value, "SearchText");
66 | }
67 | }
68 |
69 | ///
70 | /// Gets or sets the search type indicating what the user is searching for.
71 | ///
72 | public SearchType SearchType { get; set; }
73 | }
74 | }
--------------------------------------------------------------------------------
/AltinnDesktopTool/Utils/PubSub/PubSub.cs:
--------------------------------------------------------------------------------
1 | using System.Collections.Generic;
2 |
3 | namespace AltinnDesktopTool.Utils.PubSub
4 | {
5 | ///
6 | /// Defines the handler
7 | ///
8 | /// The View Type
9 | /// The Sender
10 | /// The Arguments
11 | public delegate void PubSubEventHandler(object sender, PubSubEventArgs e);
12 |
13 | ///
14 | /// Class to register and raise events between views
15 | ///
16 | /// The View Type
17 | public static class PubSub
18 | {
19 | private static Dictionary> events =
20 | new Dictionary>();
21 |
22 | ///
23 | /// Adds a new event
24 | ///
25 | /// The event name
26 | /// The event handler
27 | public static void AddEvent(string name, PubSubEventHandler handler)
28 | {
29 | if (!events.ContainsKey(name))
30 | {
31 | events.Add(name, handler);
32 | }
33 | }
34 |
35 | ///
36 | /// Raises a new event
37 | ///
38 | /// The name of the event
39 | /// The object sender of the event
40 | /// The arguments
41 | public static void RaiseEvent(string name, object sender, PubSubEventArgs args)
42 | {
43 | if (events.ContainsKey(name) && events[name] != null)
44 | {
45 | events[name](sender, args);
46 | }
47 | }
48 |
49 | ///
50 | /// Registers an event
51 | ///
52 | /// The event name
53 | /// The event handler
54 | public static void RegisterEvent(string name, PubSubEventHandler handler)
55 | {
56 | if (events.ContainsKey(name))
57 | {
58 | events[name] += handler;
59 | }
60 | else
61 | {
62 | events.Add(name, handler);
63 | }
64 | }
65 |
66 | ///
67 | /// Clears the registered events
68 | ///
69 | public static void ClearEvents()
70 | {
71 | events = new Dictionary>();
72 | }
73 | }
74 | }
75 |
--------------------------------------------------------------------------------
/AltinnDesktopTool/ViewModel/FooterViewModel.cs:
--------------------------------------------------------------------------------
1 | using System.Collections.ObjectModel;
2 | using System.Linq;
3 | using System.Windows.Input;
4 |
5 | using AltinnDesktopTool.Configuration;
6 | using AltinnDesktopTool.Utils.PubSub;
7 |
8 | using GalaSoft.MvvmLight;
9 | using GalaSoft.MvvmLight.Command;
10 |
11 | namespace AltinnDesktopTool.ViewModel
12 | {
13 | ///
14 | /// ViewModel class, container for Environment change related components
15 | ///
16 | public class FooterViewModel : ViewModelBase
17 | {
18 | ///
19 | /// Initializes a new instance of the class.
20 | /// ViewModel for Footer view
21 | ///
22 | public FooterViewModel()
23 | {
24 | this.ChangeEnvironmentCommand = new RelayCommand(this.ChangeEnvironmentHandler);
25 |
26 | this.EnvironmentNames = new ObservableCollection(EnvironmentConfigurationManager.EnvironmentConfigurations.Select(c => c.Name).ToList());
27 | this.SelectedEnvironment = EnvironmentConfigurationManager.ActiveEnvironmentConfiguration.Name;
28 |
29 | PubSub.AddEvent(EventNames.EnvironmentChangedEvent, this.EnvironmentChangedEventHandler);
30 | }
31 |
32 | ///
33 | /// Environment changed event
34 | ///
35 | public event PubSubEventHandler EnvironmentChangedEventHandler;
36 |
37 | ///
38 | /// Gets or sets the Selected environment name
39 | ///
40 | public string SelectedEnvironment { get; set; }
41 |
42 | ///
43 | /// Gets or sets the available environment names
44 | ///
45 | public ObservableCollection EnvironmentNames { get; set; }
46 |
47 | ///
48 | /// Gets a command which will define a behavior on Change environment event
49 | ///
50 | public ICommand ChangeEnvironmentCommand { get; private set; }
51 |
52 | ///
53 | /// Event handler for the ChangeEnvironment command. Sets the active environment configuration and raises EnvironmentChanged event.
54 | ///
55 | public void ChangeEnvironmentHandler()
56 | {
57 | EnvironmentConfigurationManager.ActiveEnvironmentConfiguration = EnvironmentConfigurationManager.EnvironmentConfigurations.Single(c => c.Name == this.SelectedEnvironment);
58 | PubSub.RaiseEvent(EventNames.EnvironmentChangedEvent, this, new PubSubEventArgs(this.SelectedEnvironment));
59 | }
60 | }
61 | }
62 |
--------------------------------------------------------------------------------
/AltinnDesktopToolSetup/AltinnDesktopToolSetup.wixproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | Debug
5 | x86
6 | 3.10
7 | 18fd8a01-a620-4c49-9214-389ce758ce87
8 | 2.0
9 | AltinnToolkitInstaller
10 | Package
11 | $(MSBuildExtensionsPath32)\Microsoft\WiX\v3.x\Wix.targets
12 | $(MSBuildExtensionsPath)\Microsoft\WiX\v3.x\Wix.targets
13 |
14 |
15 | bin\$(Configuration)\
16 | obj\$(Configuration)\
17 | Debug
18 |
19 |
20 | bin\$(Configuration)\
21 | obj\$(Configuration)\
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 | AltinnDesktopTool
33 | {11bcd26a-9604-4b02-bccf-f85c693f685f}
34 | True
35 | True
36 | Binaries;Content;Satellites
37 | INSTALLFOLDER
38 |
39 |
40 |
41 |
42 | $(WixExtDir)\WixUIExtension.dll
43 | WixUIExtension
44 |
45 |
46 |
47 |
55 |
--------------------------------------------------------------------------------
/RestClient/IRestQuery.cs:
--------------------------------------------------------------------------------
1 | using System.Collections.Generic;
2 | using RestClient.DTO;
3 |
4 | namespace RestClient
5 | {
6 | ///
7 | /// Interface representing the Client Proxy for accessing the service owner Altinn REST server interface.
8 | ///
9 | public interface IRestQuery
10 | {
11 | ///
12 | /// Fetches a list of objects from the given URL location.
13 | ///
14 | /// The type of data object (DTO) which must be a subclass of to be returned.
15 | /// The url to send to Altinn.
16 | /// The found object or null if not found.
17 | ///
18 | /// Controller is identified by the controller having [RestQueryController(SupportedType=T)] defined with a matching T type.
19 | ///
20 | IList GetByLink(string url) where T : HalJsonResource;
21 |
22 | ///
23 | /// Search for a list of objects by filtering on a given name value pair.
24 | /// The possible values name value pairs depends on the controller being called.
25 | /// The controller is identified by the type T.
26 | ///
27 | /// The type of objects to be retrieved. This also determines the controller to call.
28 | /// The name value pair filter
29 | /// A list of objects, empty or null if none found
30 | IList Get(KeyValuePair filter) where T : HalJsonResource;
31 |
32 | ///
33 | /// Fetches a object by a given link (url).
34 | /// This is useful where a link is returned in a previous call.
35 | ///
36 | /// The type of object to be retrieved.
37 | /// The id of the object to retrieve
38 | /// An object, possibly null if none found
39 | T Get(string id) where T : HalJsonResource;
40 |
41 | ///
42 | /// Perform a REST API request based on the pattern: {baseAddress}/{controller}?{key1}={value1}&{key2}={value2}.
43 | ///
44 | /// The type of object the controller should attempt to deserialize the json response into.
45 | /// The filter values for the search.
46 | /// A list of instances of the expected type.
47 | IList Get(List> filter) where T : HalJsonResource;
48 | }
49 | }
50 |
--------------------------------------------------------------------------------
/RestClient/Deserialize/Deserializer.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using Newtonsoft.Json;
4 | using Newtonsoft.Json.Linq;
5 | using RestClient.DTO;
6 | using RestClient.Resources;
7 |
8 | namespace RestClient.Deserialize
9 | {
10 | ///
11 | /// Class for deserializing HAL+JSON format
12 | ///
13 | public class Deserializer
14 | {
15 | private static readonly string ErrorOnDeserialization = "Error while deserializing Json data";
16 |
17 | ///
18 | /// Deserializes a list of Typed objects from HAL+JSON format.
19 | /// Type T should have HalJsonResource as base class
20 | ///
21 | /// type T
22 | /// Input string to deserialize
23 | /// Typed list of T
24 | public static List DeserializeHalJsonResourceList(string json) where T : HalJsonResource
25 | {
26 | List resources;
27 |
28 | try
29 | {
30 | OuterJson outerResource = JsonConvert.DeserializeObject(json);
31 | JObject innerObjectJson = outerResource._embedded;
32 |
33 | PluralNameAttribute attribute = (PluralNameAttribute)Attribute.GetCustomAttribute(typeof(T), typeof(PluralNameAttribute));
34 |
35 | JToken resource = innerObjectJson[attribute.PluralName.ToLower()];
36 | resources = JsonConvert.DeserializeObject>(resource.ToString(), new HalJsonConverter());
37 | }
38 | catch (Exception e)
39 | {
40 | throw new RestClientException(ErrorOnDeserialization, RestClientErrorCodes.RestClientDeserialiationError, e);
41 | }
42 |
43 | return resources;
44 | }
45 |
46 | ///
47 | /// Deserializes a Typed object from HAL+JSON format
48 | /// Type T should have HalJsonResource as base class
49 | ///
50 | /// type T
51 | /// Input string in json format
52 | /// Instance of type T
53 | public static T DeserializeHalJsonResource(string json) where T : HalJsonResource
54 | {
55 | T resource;
56 |
57 | try
58 | {
59 | resource = JsonConvert.DeserializeObject(json, new HalJsonConverter());
60 | }
61 | catch (Exception e)
62 | {
63 | throw new RestClientException(ErrorOnDeserialization, RestClientErrorCodes.RestClientDeserialiationError, e);
64 | }
65 |
66 | return resource;
67 | }
68 | }
69 | }
70 |
--------------------------------------------------------------------------------
/AltinnDesktopTool/View/SearchOrganizationInformation.xaml:
--------------------------------------------------------------------------------
1 |
12 |
13 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
--------------------------------------------------------------------------------
/AltinnDesktopTool/Model/SearchResultModel.cs:
--------------------------------------------------------------------------------
1 | using System.Collections.ObjectModel;
2 | using AltinnDesktopTool.Utils.PubSub;
3 |
4 | namespace AltinnDesktopTool.Model
5 | {
6 | ///
7 | /// Search Result Model
8 | ///
9 | public class SearchResultModel : ModelBase
10 | {
11 | private ObservableCollection resultCollection;
12 |
13 | private bool emptyMessageVisibility;
14 |
15 | private string infoText = string.Empty;
16 | private bool selectAllChecked;
17 |
18 | ///
19 | /// Gets or sets a value indicating whether the Info text is visible in the result grid
20 | ///
21 | public bool EmptyMessageVisibility
22 | {
23 | get
24 | {
25 | return this.emptyMessageVisibility;
26 | }
27 |
28 | set
29 | {
30 | this.emptyMessageVisibility = value;
31 | this.RaisePropertyChanged(() => this.EmptyMessageVisibility);
32 | this.InfoText = value ? View.Resources.NoDataText : string.Empty;
33 | }
34 | }
35 |
36 | ///
37 | /// Gets or sets the Info text shown in the result grid
38 | ///
39 | public string InfoText
40 | {
41 | get
42 | {
43 | return this.infoText;
44 | }
45 |
46 | set
47 | {
48 | this.infoText = value;
49 | this.RaisePropertyChanged(() => this.InfoText);
50 | }
51 | }
52 |
53 | ///
54 | /// Gets or sets the Result collection presented in the Organization grid
55 | ///
56 | public ObservableCollection ResultCollection
57 | {
58 | get
59 | {
60 | return this.resultCollection;
61 | }
62 |
63 | set
64 | {
65 | this.resultCollection = value;
66 | this.RaisePropertyChanged(() => this.ResultCollection);
67 | this.EmptyMessageVisibility = (this.resultCollection == null) || (this.resultCollection.Count == 0);
68 | }
69 | }
70 |
71 | ///
72 | /// Gets or sets a value indicating whether all items are checked or not
73 | ///
74 | public bool SelectAllChecked
75 | {
76 | get
77 | {
78 | return this.selectAllChecked;
79 | }
80 |
81 | set
82 | {
83 | this.selectAllChecked = value;
84 | this.RaisePropertyChanged(() => this.SelectAllChecked);
85 | PubSub.RaiseEvent(EventNames.OrganizationSelectedAllChangedEvent, this, new PubSubEventArgs(this));
86 | }
87 | }
88 |
89 | ///
90 | /// Sets SelectAllChecked
91 | ///
92 | /// boolean value
93 | public void SetSelectAllChecked(bool value)
94 | {
95 | this.selectAllChecked = false;
96 | this.RaisePropertyChanged(() => this.SelectAllChecked);
97 | }
98 | }
99 | }
--------------------------------------------------------------------------------
/AltinnDesktopTool/App.config:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 |
48 |
49 |
50 |
51 |
52 |
53 |
54 |
55 |
56 |
57 |
58 |
59 |
60 |
61 |
62 |
63 |
64 |
65 |
66 |
67 |
68 |
69 |
70 |
71 |
72 |
73 |
74 |
75 |
76 |
77 |
78 |
--------------------------------------------------------------------------------
/AltinnDesktopTool/View/SearchRolesAndRightsInformation.xaml:
--------------------------------------------------------------------------------
1 |
10 |
11 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
--------------------------------------------------------------------------------
/AltinnDesktopTool/Model/RolesSearchResultModel.cs:
--------------------------------------------------------------------------------
1 | using AltinnDesktopTool.Utils.PubSub;
2 | using System.Collections.ObjectModel;
3 |
4 | namespace AltinnDesktopTool.Model
5 | {
6 | ///
7 | /// Roles Search Result Model
8 | ///
9 | public class RolesSearchResultModel : ModelBase
10 | {
11 | private ObservableCollection resultCollection;
12 |
13 | private bool emptyMessageVisibility;
14 |
15 | private string infoText = string.Empty;
16 | private bool rolesSelectAllChecked;
17 |
18 | ///
19 | /// Gets or sets a value indicating whether the Info text is visible in the result grid
20 | ///
21 | public bool EmptyMessageVisibility
22 | {
23 | get
24 | {
25 | return this.emptyMessageVisibility;
26 | }
27 |
28 | set
29 | {
30 | this.emptyMessageVisibility = value;
31 | this.RaisePropertyChanged(() => this.EmptyMessageVisibility);
32 | this.InfoText = value ? View.Resources.NoDataText : string.Empty;
33 | }
34 | }
35 |
36 | ///
37 | /// Gets or sets the Info text shown in the result grid
38 | ///
39 | public string InfoText
40 | {
41 | get
42 | {
43 | return this.infoText;
44 | }
45 |
46 | set
47 | {
48 | this.infoText = value;
49 | this.RaisePropertyChanged(() => this.InfoText);
50 | }
51 | }
52 |
53 | ///
54 | /// Gets or sets the Result collection presented in the role grid
55 | ///
56 | public ObservableCollection ResultCollection
57 | {
58 | get
59 | {
60 | return this.resultCollection;
61 | }
62 |
63 | set
64 | {
65 | this.resultCollection = value;
66 | this.RaisePropertyChanged(() => this.ResultCollection);
67 | this.EmptyMessageVisibility = (this.resultCollection == null) || (this.resultCollection.Count == 0);
68 | }
69 | }
70 |
71 | ///
72 | /// Gets or sets a value indicating whether all items are checked or not
73 | ///
74 | public bool RolesSelectAllChecked
75 | {
76 | get
77 | {
78 | return this.rolesSelectAllChecked;
79 | }
80 |
81 | set
82 | {
83 | this.rolesSelectAllChecked = value;
84 | this.RaisePropertyChanged(() => this.RolesSelectAllChecked);
85 | PubSub.RaiseEvent(EventNames.RoleSelectedAllChangedEvent, this, new PubSubEventArgs(this));
86 | }
87 | }
88 |
89 | ///
90 | /// Sets RolesSelectAllChecked
91 | ///
92 | /// boolean value
93 | public void SetSelectAllChecked(bool value)
94 | {
95 | this.rolesSelectAllChecked = false;
96 | this.RaisePropertyChanged(() => this.RolesSelectAllChecked);
97 | }
98 | }
99 | }
100 |
--------------------------------------------------------------------------------
/AltinnDesktopTool/Properties/Resources.Designer.cs:
--------------------------------------------------------------------------------
1 | //------------------------------------------------------------------------------
2 | //
3 | // This code was generated by a tool.
4 | // Runtime Version:4.0.30319.42000
5 | //
6 | // Changes to this file may cause incorrect behavior and will be lost if
7 | // the code is regenerated.
8 | //
9 | //------------------------------------------------------------------------------
10 |
11 | namespace AltinnDesktopTool.Properties {
12 | using System;
13 |
14 |
15 | ///
16 | /// A strongly-typed resource class, for looking up localized strings, etc.
17 | ///
18 | // This class was auto-generated by the StronglyTypedResourceBuilder
19 | // class via a tool like ResGen or Visual Studio.
20 | // To add or remove a member, edit your .ResX file then rerun ResGen
21 | // with the /str option, or rebuild your VS project.
22 | [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "17.0.0.0")]
23 | [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
24 | [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
25 | internal class Resources {
26 |
27 | private static global::System.Resources.ResourceManager resourceMan;
28 |
29 | private static global::System.Globalization.CultureInfo resourceCulture;
30 |
31 | [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
32 | internal Resources() {
33 | }
34 |
35 | ///
36 | /// Returns the cached ResourceManager instance used by this class.
37 | ///
38 | [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
39 | internal static global::System.Resources.ResourceManager ResourceManager {
40 | get {
41 | if (object.ReferenceEquals(resourceMan, null)) {
42 | global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("AltinnDesktopTool.Properties.Resources", typeof(Resources).Assembly);
43 | resourceMan = temp;
44 | }
45 | return resourceMan;
46 | }
47 | }
48 |
49 | ///
50 | /// Overrides the current thread's CurrentUICulture property for all
51 | /// resource lookups using this strongly typed resource class.
52 | ///
53 | [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
54 | internal static global::System.Globalization.CultureInfo Culture {
55 | get {
56 | return resourceCulture;
57 | }
58 | set {
59 | resourceCulture = value;
60 | }
61 | }
62 |
63 | ///
64 | /// Looks up a localized string similar to You must enter a string..
65 | ///
66 | internal static string SearchOrganizationInformationModel_SearchText_You_must_enter_a_string_ {
67 | get {
68 | return ResourceManager.GetString("SearchOrganizationInformationModel_SearchText_You_must_enter_a_string_", resourceCulture);
69 | }
70 | }
71 | }
72 | }
73 |
--------------------------------------------------------------------------------
/AltinnDesktopTool/Utils/Converters/RadioButtonCheckedConverter.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Globalization;
3 | using System.Windows.Data;
4 |
5 | namespace AltinnDesktopTool.Utils.Converters
6 | {
7 | ///
8 | /// This is a class that can convert an enum value to a string or boolean and back.
9 | /// The intended use is related to binding of an enum to a set of radio buttons and their checked property.
10 | ///
11 | public class RadioButtonCheckedConverter : IValueConverter
12 | {
13 | ///
14 | /// Convert from an enum to a boolean or string.
15 | ///
16 | /// The value to be converted.
17 | /// The type to convert to. Limited to boolean and string.
18 | /// The parameter value to compare with. Used if target type is a boolean, not for string.
19 | /// Input is not used. String compare is using instead.
20 | /// A boolean or string with with the input value converted.
21 | public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
22 | {
23 | if (!targetType.IsAssignableFrom(typeof(bool)) && !targetType.IsAssignableFrom(typeof(string)))
24 | {
25 | throw new ArgumentException("RadioButtonCheckedConverter can only convert to boolean or string.");
26 | }
27 |
28 | if (targetType == typeof(string))
29 | {
30 | return value.ToString();
31 | }
32 |
33 | return string.Compare(value.ToString(), (string)parameter, StringComparison.InvariantCultureIgnoreCase) == 0;
34 | }
35 |
36 | ///
37 | /// Convert a string or boolean back into an enum.
38 | ///
39 | /// The value to convert into an enum.
40 | /// The enum type to convert into.
41 | /// The value to compare with if input type is a boolean. Used to determine if value should be true or false.
42 | /// Not used.
43 | /// The value converted into an enum of the given type.
44 | public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
45 | {
46 | if (!targetType.IsAssignableFrom(typeof(bool)) && !targetType.IsAssignableFrom(typeof(string)))
47 | {
48 | throw new ArgumentException("RadioButtonCheckedConverter can only convert back value from a string or a boolean.");
49 | }
50 |
51 | if (!targetType.IsEnum)
52 | {
53 | throw new ArgumentException("RadioButtonCheckedConverter can only convert value to an Enum Type.");
54 | }
55 |
56 | string s = value as string;
57 | if (s != null)
58 | {
59 | return Enum.Parse(targetType, s, true);
60 | }
61 |
62 | // We have a boolean, as for binding to a checkbox. we use parameter
63 | if ((bool)value)
64 | {
65 | return Enum.Parse(targetType, (string)parameter, true);
66 | }
67 |
68 | return Binding.DoNothing;
69 | }
70 | }
71 | }
72 |
--------------------------------------------------------------------------------
/AltinnDesktopToolTest/ViewModel/RolesSearchResultModelTest.cs:
--------------------------------------------------------------------------------
1 | using AltinnDesktopTool.Model;
2 | using AltinnDesktopTool.Utils.Helpers;
3 | using AltinnDesktopTool.ViewModel;
4 | using AutoMapper;
5 | using log4net;
6 | using Microsoft.VisualStudio.TestTools.UnitTesting;
7 | using Moq;
8 | using RestClient;
9 | using System;
10 | using System.Windows.Forms;
11 |
12 | namespace AltinnDesktopToolTest.ViewModel
13 | {
14 | ///
15 | /// Test class for unit tests of the class.
16 | ///
17 | [TestClass]
18 | public class RolesSearchResultModelTest
19 | {
20 | private static IMapper mapper;
21 |
22 | ///
23 | /// Gets or sets the test context for the current test.
24 | ///
25 | public TestContext TestContext { get; set; }
26 |
27 | ///
28 | /// Initialize the test class. This ensures that has been properly configured for all test methods and
29 | /// that logic performs actual mapping instead of having the mapping mocked.
30 | ///
31 | /// The current for the test class.
32 | [ClassInitialize]
33 | public static void ClassInit(TestContext context)
34 | {
35 | mapper = AutoMapperHelper.RunCreateMaps();
36 | }
37 |
38 | ///
39 | /// Scenario:
40 | /// Runs the CopyToClipboardExcelFormatHandler of the RolesSearchResultViewModel object.
41 | /// Expected Result:
42 | /// The text on the clipboard has the correct excel format.
43 | /// Success Criteria:
44 | /// The text on the clipboard matches the hardcoded "expectedResult" string.
45 | ///
46 | [TestMethod]
47 | [TestCategory("ViewModel")]
48 | public void RolesSearchResultModelTest_CopyToExcel_TextInExcelFormat()
49 | {
50 | // Arrange
51 | Mock logger = new Mock();
52 |
53 | Mock query = new Mock();
54 |
55 | string expectedResult = "6\tAccounting employee\tAltinn\tAccess to accounting related forms and services" + Environment.NewLine +
56 | "4\tAccess manager\tAltinn\tAdministration of access" + Environment.NewLine;
57 |
58 | RolesSearchResultViewModel rolesSearchResultViewModel = new RolesSearchResultViewModel(logger.Object, mapper, query.Object);
59 |
60 | RoleModel roleModel1 = new RoleModel
61 | {
62 | RoleDefinitionId = "6",
63 | RoleDescription = "Access to accounting related forms and services",
64 | RoleName = "Accounting employee",
65 | RoleType = "Altinn",
66 | IsSelected = true
67 | };
68 |
69 | RoleModel roleModel2 = new RoleModel
70 | {
71 | RoleDefinitionId = "4",
72 | RoleDescription = "Administration of access",
73 | RoleName = "Access manager",
74 | RoleType = "Altinn",
75 | IsSelected = true
76 | };
77 |
78 | rolesSearchResultViewModel.Model.ResultCollection.Add(roleModel1);
79 | rolesSearchResultViewModel.Model.ResultCollection.Add(roleModel2);
80 |
81 | // Act
82 | rolesSearchResultViewModel.CopyRolesToClipboardExcelFormatHandler();
83 |
84 | // Assert
85 | Assert.AreEqual(expectedResult, Clipboard.GetText());
86 | }
87 |
88 | }
89 | }
90 |
--------------------------------------------------------------------------------
/AltinnDesktopTool/Model/OrganizationModel.cs:
--------------------------------------------------------------------------------
1 | using System.Collections.ObjectModel;
2 | using AltinnDesktopTool.Utils.PubSub;
3 |
4 | namespace AltinnDesktopTool.Model
5 | {
6 | ///
7 | /// Model for Organization
8 | ///
9 | public class OrganizationModel : ModelBase
10 | {
11 | private ObservableCollection officalContactsCollection;
12 |
13 | private ObservableCollection personalContactsCollection;
14 | private bool isSelected;
15 |
16 | ///
17 | /// Gets or sets the Organization Name (as mapped from DTO)
18 | ///
19 | public string Name { get; set; }
20 |
21 | ///
22 | /// Gets or sets the Organization Number (as mapped from DTO)
23 | ///
24 | public string OrganizationNumber { get; set; }
25 |
26 | ///
27 | /// Gets or sets the Organization Type (AS, ANS etc) (as mapped from DTO)
28 | ///
29 | public string Type { get; set; }
30 |
31 | ///
32 | /// Gets or sets the Link to official contacts (as mapped from DTO)
33 | ///
34 | public string OfficialContacts { get; set; }
35 |
36 | ///
37 | /// Gets or sets the Link to personal contacts (as mapped from DTO)
38 | ///
39 | public string PersonalContacts { get; set; }
40 |
41 | ///
42 | /// Gets or sets the Collection of Official Contacts, populate this to automatically update view
43 | ///
44 | public ObservableCollection OfficalContactsCollection
45 | {
46 | get
47 | {
48 | return this.officalContactsCollection;
49 | }
50 |
51 | set
52 | {
53 | this.officalContactsCollection = value;
54 | this.RaisePropertyChanged();
55 | }
56 | }
57 |
58 | ///
59 | /// Gets or sets the Collection of Personal Contacts, populate this to automatically update view
60 | ///
61 | public ObservableCollection PersonalContactsCollection
62 | {
63 | get
64 | {
65 | return this.personalContactsCollection;
66 | }
67 |
68 | set
69 | {
70 | this.personalContactsCollection = value;
71 | this.RaisePropertyChanged();
72 | }
73 | }
74 |
75 | ///
76 | /// Gets or sets a value indicating whether an item is selected
77 | ///
78 | public bool IsSelected
79 | {
80 | get
81 | {
82 | return this.isSelected;
83 | }
84 |
85 | set
86 | {
87 | this.isSelected = value;
88 | this.RaisePropertyChanged(() => this.IsSelected);
89 | PubSub.RaiseEvent(EventNames.OrganizationSelectedChangedEvent, this, new PubSubEventArgs(this));
90 | }
91 | }
92 |
93 | ///
94 | /// Sets IsSelected
95 | ///
96 | /// boolean value
97 | public void SetIsSelected(bool value)
98 | {
99 | this.isSelected = value;
100 | this.RaisePropertyChanged(() => this.IsSelected);
101 | }
102 | }
103 | }
104 |
--------------------------------------------------------------------------------
/AltinnDesktopTool/Configuration/EnvironmentConfigurationManager.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Xml.Linq;
5 |
6 | namespace AltinnDesktopTool.Configuration
7 | {
8 | ///
9 | /// Manages the application environment configuration settings
10 | ///
11 | public class EnvironmentConfigurationManager
12 | {
13 | private const string ConfigPath = "Configuration\\EnvironmentConfigurations.xml";
14 | private static List configurationList;
15 |
16 | private static EnvironmentConfiguration activeEnvironmentConfiguration;
17 |
18 | ///
19 | /// Returns the configuration settings
20 | ///
21 | public static List EnvironmentConfigurations => configurationList ?? (configurationList = LoadEnvironmentConfigurations());
22 |
23 | ///
24 | /// Gets or sets active environment configuration. Default: prod
25 | ///
26 | public static EnvironmentConfiguration ActiveEnvironmentConfiguration
27 | {
28 | get
29 | {
30 | if (activeEnvironmentConfiguration == null)
31 | {
32 | LoadEnvironmentConfigurations();
33 | }
34 |
35 | return activeEnvironmentConfiguration;
36 | }
37 |
38 | set
39 | {
40 | activeEnvironmentConfiguration = value;
41 | }
42 | }
43 |
44 | private static List LoadEnvironmentConfigurations()
45 | {
46 | XElement xmlDoc = XElement.Load(ConfigPath);
47 | IEnumerable configs = from config in xmlDoc.Descendants("EnvironmentConfiguration")
48 | select
49 | new EnvironmentConfiguration
50 | {
51 | Name = config?.Element("name")?.Value,
52 | ThemeName = config?.Element("themeName")?.Value,
53 | ApiKey = config?.Element("apiKey")?.Value,
54 | BaseAddress = config?.Element("baseAddress")?.Value,
55 | ThumbPrint = config?.Element("thumbprint")?.Value,
56 | IgnoreSslErrors = ParseBool(config?.Element("ignoreSslErrors")?.Value),
57 | Timeout = ParseInt(config?.Element("timeout")?.Value)
58 | };
59 | IEnumerable environmentConfigurations = configs as IList ?? configs.ToList();
60 | activeEnvironmentConfiguration = environmentConfigurations.Single(c => c.Name == "PROD");
61 | return environmentConfigurations.ToList();
62 | }
63 |
64 | private static int ParseInt(string value)
65 | {
66 | int ret;
67 | return value == null ? 0 : int.TryParse(value, out ret) ? ret : 0;
68 | }
69 |
70 | private static bool ParseBool(string value)
71 | {
72 | bool ret;
73 | return value != null && (bool.TryParse(value, out ret) && ret);
74 | }
75 | }
76 | }
77 |
--------------------------------------------------------------------------------
/RestClient/Deserialize/HalJsonConverter.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Reflection;
4 | using Newtonsoft.Json;
5 | using Newtonsoft.Json.Linq;
6 | using RestClient.DTO;
7 |
8 | namespace RestClient.Deserialize
9 | {
10 | ///
11 | /// Converter class for HAL+Json format
12 | ///
13 | public class HalJsonConverter : JsonConverter
14 | {
15 | ///
16 | /// Checks if the given
17 | /// is HalJsonResource
18 | ///
19 | /// Object type
20 | /// True if its an organization else false
21 | public static bool IsHalJsonResource(Type objectType)
22 | {
23 | return typeof(HalJsonResource).IsAssignableFrom(objectType);
24 | }
25 |
26 | ///
27 | /// Writes the given as JSON
28 | ///
29 | /// The JSON writer
30 | /// Value to be written
31 | /// The JSON serializer
32 | /// Not implemented
33 | public override void WriteJson(JsonWriter writer, object value, JsonSerializer serializer)
34 | {
35 | throw new NotImplementedException();
36 | }
37 |
38 | ///
39 | /// Reads HalJsonResource from JSON
40 | ///
41 | /// The JSON reader
42 | /// The type (child of HalJsonResource)
43 | /// The existing value
44 | /// The JSON serializer
45 | /// The read object
46 | public override object ReadJson(JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer)
47 | {
48 | JToken obj = JToken.ReadFrom(reader);
49 | object ret = JsonConvert.DeserializeObject(obj.ToString(), objectType, new JsonConverter[] { });
50 |
51 | //TODO:: deserialize _embedded
52 |
53 | // Deserialize _links
54 | if (obj["_links"] == null || !obj["_links"].HasValues)
55 | {
56 | return ret;
57 | }
58 |
59 | using (IEnumerator> enumeratorEmbedded = ((JObject)obj["_links"]).GetEnumerator())
60 | {
61 | while (enumeratorEmbedded.MoveNext())
62 | {
63 | string rel = enumeratorEmbedded.Current.Key;
64 |
65 | foreach (PropertyInfo property in objectType.GetProperties())
66 | {
67 | bool attribute = property.Name.Equals(rel, StringComparison.InvariantCultureIgnoreCase);
68 |
69 | if (attribute)
70 | {
71 | property.SetValue(ret, obj["_links"][rel]["href"].ToString());
72 | }
73 | }
74 | }
75 | }
76 |
77 | return ret;
78 | }
79 |
80 | ///
81 | /// Checks if the given
82 | /// can be converted to HalJsonResource
83 | ///
84 | /// Type to be checked
85 | /// Can be converted to HalJsonResource
86 | public override bool CanConvert(Type objectType)
87 | {
88 | return IsHalJsonResource(objectType);
89 | }
90 | }
91 | }
92 |
--------------------------------------------------------------------------------
/AltinnDesktopTool.sln:
--------------------------------------------------------------------------------
1 |
2 | Microsoft Visual Studio Solution File, Format Version 12.00
3 | # Visual Studio Version 17
4 | VisualStudioVersion = 17.7.34031.279
5 | MinimumVisualStudioVersion = 10.0.40219.1
6 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "AltinnDesktopTool", "AltinnDesktopTool\AltinnDesktopTool.csproj", "{11BCD26A-9604-4B02-BCCF-F85C693F685F}"
7 | EndProject
8 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "AltinnDesktopToolTest", "AltinnDesktopToolTest\AltinnDesktopToolTest.csproj", "{2BE6FFDE-EA7E-47EA-8EEE-1BE75869C151}"
9 | EndProject
10 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "RestClient", "RestClient\RestClient.csproj", "{BF6FB931-D0C9-48A4-9E9D-15EB71B0F13E}"
11 | EndProject
12 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "RestClient.Test", "RestClient.Test\RestClient.Test.csproj", "{F97E7FF9-C66B-4C94-8503-D72ED7EE459B}"
13 | EndProject
14 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "IntegrationUnitTest", "IntegrationUnitTest\IntegrationUnitTest.csproj", "{B6215DBE-2806-49ED-91A6-7185256B1A85}"
15 | EndProject
16 | Project("{930C7802-8A8C-48F9-8165-68863BCCD9DD}") = "AltinnDesktopToolSetup", "AltinnDesktopToolSetup\AltinnDesktopToolSetup.wixproj", "{18FD8A01-A620-4C49-9214-389CE758CE87}"
17 | ProjectSection(ProjectDependencies) = postProject
18 | {BF6FB931-D0C9-48A4-9E9D-15EB71B0F13E} = {BF6FB931-D0C9-48A4-9E9D-15EB71B0F13E}
19 | EndProjectSection
20 | EndProject
21 | Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{22CC999D-5C00-46F7-A209-A6D8F9E7757B}"
22 | ProjectSection(SolutionItems) = preProject
23 | AltinnDesktopTool.sln.DotSettings = AltinnDesktopTool.sln.DotSettings
24 | Settings.StyleCop = Settings.StyleCop
25 | EndProjectSection
26 | EndProject
27 | Global
28 | GlobalSection(SolutionConfigurationPlatforms) = preSolution
29 | Debug|Any CPU = Debug|Any CPU
30 | Release|Any CPU = Release|Any CPU
31 | EndGlobalSection
32 | GlobalSection(ProjectConfigurationPlatforms) = postSolution
33 | {11BCD26A-9604-4B02-BCCF-F85C693F685F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
34 | {11BCD26A-9604-4B02-BCCF-F85C693F685F}.Debug|Any CPU.Build.0 = Debug|Any CPU
35 | {11BCD26A-9604-4B02-BCCF-F85C693F685F}.Release|Any CPU.ActiveCfg = Release|Any CPU
36 | {11BCD26A-9604-4B02-BCCF-F85C693F685F}.Release|Any CPU.Build.0 = Release|Any CPU
37 | {2BE6FFDE-EA7E-47EA-8EEE-1BE75869C151}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
38 | {2BE6FFDE-EA7E-47EA-8EEE-1BE75869C151}.Debug|Any CPU.Build.0 = Debug|Any CPU
39 | {2BE6FFDE-EA7E-47EA-8EEE-1BE75869C151}.Release|Any CPU.ActiveCfg = Release|Any CPU
40 | {2BE6FFDE-EA7E-47EA-8EEE-1BE75869C151}.Release|Any CPU.Build.0 = Release|Any CPU
41 | {BF6FB931-D0C9-48A4-9E9D-15EB71B0F13E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
42 | {BF6FB931-D0C9-48A4-9E9D-15EB71B0F13E}.Debug|Any CPU.Build.0 = Debug|Any CPU
43 | {BF6FB931-D0C9-48A4-9E9D-15EB71B0F13E}.Release|Any CPU.ActiveCfg = Release|Any CPU
44 | {BF6FB931-D0C9-48A4-9E9D-15EB71B0F13E}.Release|Any CPU.Build.0 = Release|Any CPU
45 | {F97E7FF9-C66B-4C94-8503-D72ED7EE459B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
46 | {F97E7FF9-C66B-4C94-8503-D72ED7EE459B}.Debug|Any CPU.Build.0 = Debug|Any CPU
47 | {F97E7FF9-C66B-4C94-8503-D72ED7EE459B}.Release|Any CPU.ActiveCfg = Release|Any CPU
48 | {F97E7FF9-C66B-4C94-8503-D72ED7EE459B}.Release|Any CPU.Build.0 = Release|Any CPU
49 | {B6215DBE-2806-49ED-91A6-7185256B1A85}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
50 | {B6215DBE-2806-49ED-91A6-7185256B1A85}.Debug|Any CPU.Build.0 = Debug|Any CPU
51 | {B6215DBE-2806-49ED-91A6-7185256B1A85}.Release|Any CPU.ActiveCfg = Release|Any CPU
52 | {B6215DBE-2806-49ED-91A6-7185256B1A85}.Release|Any CPU.Build.0 = Release|Any CPU
53 | {18FD8A01-A620-4C49-9214-389CE758CE87}.Debug|Any CPU.ActiveCfg = Debug|x86
54 | {18FD8A01-A620-4C49-9214-389CE758CE87}.Release|Any CPU.ActiveCfg = Release|x86
55 | EndGlobalSection
56 | GlobalSection(SolutionProperties) = preSolution
57 | HideSolutionNode = FALSE
58 | EndGlobalSection
59 | EndGlobal
60 |
--------------------------------------------------------------------------------
/AltinnDesktopTool/ViewModel/ViewModelLocator.cs:
--------------------------------------------------------------------------------
1 | /*
2 | In App.xaml:
3 |
4 |
6 |
7 |
8 | In the View:
9 | DataContext="{Binding Source={StaticResource Locator}, Path=ViewModelName}"
10 |
11 | You can also use Blend to do all this with the tool's support.
12 | See http://www.galasoft.ch/mvvm
13 | */
14 |
15 | using AltinnDesktopTool.Utils.Helpers;
16 | using AltinnDesktopTool.Utils.PubSub;
17 | using GalaSoft.MvvmLight;
18 | using GalaSoft.MvvmLight.Ioc;
19 | using Common.Logging;
20 | using Microsoft.Practices.ServiceLocation;
21 | using RestClient;
22 |
23 | namespace AltinnDesktopTool.ViewModel
24 | {
25 | ///
26 | /// This class contains static references to all the view models in the
27 | /// application and provides an entry point for the bindings.
28 | ///
29 | public class ViewModelLocator
30 | {
31 | ///
32 | /// Initializes a new instance of the ViewModelLocator class.
33 | ///
34 | public ViewModelLocator()
35 | {
36 | ServiceLocator.SetLocatorProvider(() => SimpleIoc.Default);
37 |
38 | // Logging
39 | SimpleIoc.Default.Register(() => LogManager.GetLogger(this.GetType())); // ILog
40 |
41 | // AutoMapper
42 | SimpleIoc.Default.Register(AutoMapperHelper.RunCreateMaps); // IMapper
43 |
44 | // View models
45 | SimpleIoc.Default.Register();
46 | SimpleIoc.Default.Register();
47 | SimpleIoc.Default.Register();
48 | SimpleIoc.Default.Register();
49 | SimpleIoc.Default.Register();
50 | SimpleIoc.Default.Register();
51 |
52 | // Proxy
53 | SimpleIoc.Default.Register(() => new RestQuery(ProxyConfigHelper.GetConfig(), ServiceLocator.Current.GetInstance()));
54 | }
55 |
56 | ///
57 | /// Gets the MainViewModel
58 | ///
59 | public ViewModelBase Main => ServiceLocator.Current.GetInstance();
60 |
61 | ///
62 | /// Gets the SearchOrganizationInformationViewModel
63 | ///
64 | public SearchOrganizationInformationViewModel SearchOrganizationInformationViewModel => ServiceLocator.Current.GetInstance();
65 |
66 | ///
67 | /// Gets the SearchRolesAndRightsInformationViewModel
68 | ///
69 | public SearchRolesAndRightsInformationViewModel SearchRolesAndRightsInformationViewModel => ServiceLocator.Current.GetInstance();
70 |
71 |
72 | ///
73 | /// Gets the SearchResultViewModel
74 | ///
75 | public SearchResultViewModel SearchResultViewModel => ServiceLocator.Current.GetInstance();
76 |
77 | ///
78 | /// Gets the SearchResultViewModel
79 | ///
80 | public RolesSearchResultViewModel RolesSearchResultViewModel => ServiceLocator.Current.GetInstance();
81 |
82 | ///
83 | /// Gets the FooterViewModel
84 | ///
85 | public FooterViewModel FooterViewModel => ServiceLocator.Current.GetInstance();
86 |
87 | ///
88 | /// Dispose allocated resources here
89 | ///
90 | public static void Cleanup()
91 | {
92 | PubSub