Code development platform for open source projects from the European Union institutions :large_blue_circle: EU Login authentication by SMS has been phased out. To see alternatives please check here

Skip to content
Snippets Groups Projects
Select Git revision
  • 7898a6cfd19167783c84c49aace63a510395ac46
  • development default
  • bugfix/EDELIVERY-14172-domismp-accepts-requests-with-wrong-domain-header-value
  • EDELIVERY-15372-upgrade-libraries-and-plugins-and-update-httpclient-to-httpclient5
  • EDELIVERY-15377-migrate-to-angular-20
  • feature/EDELIVERY-15382-rest-api-jwt-authentication-for-dynamic-discovery-client
  • bugfix/EDELIVERY-14196-select-domain-select-resource-dropdown-should-be-order-alphabetically
  • feature/EDELIVERY-12753-sml-integration-migration-to-different-smp
  • feature/EDELIVERY-13757-extend-session-dialog-should-have-an-active-counter
  • EDELIVERY-15144-sql-update
  • bugfix/EDELIVERY-14326-ui-edit-resource-filters
  • feature/EDELIVERY-15144-domismp-system-notification-generalize-time-expiration-alerts
  • bugfix/EDELIVERY-15102-alert-is-not-appearing-when-adding-duplicated-certificate
  • bugfix/EDELIVERY-15203-small-left-grid-shows-no-data-found-for-1-2-seconds-before-loading-the-data
  • EDELIVERY-15219-search-filter-with-understore-char-does-not-work
  • bugfix/EDELIVERY-15226-certificates-error-when-trying-to-delete-certificates
  • bugfix/EDELIVERY-15224-error-when-trying-to-update-info-from-profile-page
  • bugfix/EDELIVERY-15225-emails-are-not-sent-in-domismp
  • release/5.1.x
  • feature/EDELIVERY-12746-external-secret-sharing-services-as-vaults
  • EDELIVERY-15229-upgrade-libraries-and-plugins
  • 5.1.1
  • 5.1
  • 5.1-TEST
  • 5.1-RC1
  • 5.0.1
  • 5.0
  • 5.0-RC1
  • 4.2
  • 4.2-RC1
  • 4.1.2
  • 4.1.1
  • 4.1.0
  • 4.1.0-RC1
  • 4.0.0
  • 4.0.0-RC1
  • 3.0.2
  • 3.0.1
  • 3.0.0
39 results

runUserScripts.sh

Blame
  • Code owners
    Assign users and groups as approvers for specific file changes. Learn more.
    LookupData.cs 1.78 KiB
    using System;
    using System.Collections.Generic;
    using System.Data;
    using System.Reflection;
    using Common.Logging;
    using TUGraz.VectoCore.Utils;
    
    namespace TUGraz.VectoCore.Models.Declaration
    {
    	public abstract class LookupData
    	{
    		protected LookupData()
    		{
    			Log = LogManager.GetLogger(GetType());
    			var csvFile = ReadCsvFile(ResourceId);
    			ParseData(csvFile);
    		}
    
    		[NonSerialized] protected ILog Log;
    
    		/// <summary>
    		/// Gets the resource identifier. e.g. "TUGraz.VectoCore.Resources.Declaration.Rims.csv"
    		/// </summary>
    		protected abstract string ResourceId { get; }
    
    		protected abstract void ParseData(DataTable table);
    
    		protected DataTable ReadCsvFile(string resourceId)
    		{
    			var myAssembly = Assembly.GetExecutingAssembly();
    			var file = myAssembly.GetManifestResourceStream(resourceId);
    			return VectoCSVFile.ReadStream(file);
    		}
    
    		protected void NormalizeTable(DataTable table)
    		{
    			foreach (DataColumn col in table.Columns) {
    				table.Columns[col.ColumnName].ColumnName = col.ColumnName.ToLower().Replace(" ", "");
    			}
    		}
    	}
    
    
    	public abstract class LookupData<TKey, TValue> : LookupData
    	{
    		protected Dictionary<TKey, TValue> Data = new Dictionary<TKey, TValue>();
    
    		public virtual TValue Lookup(TKey key)
    		{
    			var retVal = default(TValue);
    			if (Data.ContainsKey(key)) {
    				retVal = Data[key];
    			}
    			return retVal;
    		}
    	}
    
    	public abstract class LookupData<TKey1, TKey2, TValue> : LookupData
    	{
    		public abstract TValue Lookup(TKey1 key1, TKey2 key2);
    	}
    
    	public abstract class LookupData<TKey1, TKey2, TKey3, TValue> : LookupData
    	{
    		public abstract TValue Lookup(TKey1 key1, TKey2 key2, TKey3 key3);
    	}
    
    	public abstract class LookupData<TKey1, TKey2, TKey3, TKey4, TValue> : LookupData
    	{
    		public abstract TValue Lookup(TKey1 key1, TKey2 key2, TKey3 key3, TKey4 key4);
    	}
    }