Class TicketFieldResolver
Resolves fields of a ticket from a DataMiner FieldName to a third-party FieldName and vice versa.
[Serializable]
[JsonObject(MemberSerialization.OptIn)]
public class TicketFieldResolver : IManagerIdentifiableObject<Guid>, CustomDataType, DataType, ITrackLastModified
  - Inheritance
 - 
      
      TicketFieldResolver
 
- Implements
 - 
      IManagerIdentifiableObject<Guid>
 
- Extension Methods
 
Examples
Creating a default ticket field resolver:
private TicketFieldResolver CreateDefaultResolver()
{
	var resolver = TicketFieldResolver.Factory.CreateDefaultResolver();
	string error;
	var success = Helper.SetTicketFieldResolver(out error, ref resolver);
	if(!success)
	{
		throw new DataMinerException("Something went wrong during setting the TicketFieldResolver: " + error);	
	}
	return resolver;
}
Creating a custom resolver:
private TicketFieldResolver CreateCustomResolver()
{
	TicketFieldResolver resolver = TicketFieldResolver.Factory.CreateEmptyResolver("CustomResolver");
	// Specify the element that will use this ticket field resolver. Leave empty in case the resolver is not used by any element.
	resolver.ElementUsingResolver = new Skyline.DataMiner.Net.ElementID(123, 456);
	// The generated empty resolver already contains a "State" field. Remove this in case this is undesired.
	var fields = resolver.GetDataMinerFields2ThirdPartyFields();
	foreach(var fields in fields)
	{
		resolver.RemoveDataMinerField(field.Key);
		resolver.RemoveThirdPartyField(field.Value);
	}
	// Clear the custom states.
	resolver.StateResolver.Clear();
	// Clear the link fields.
	resolver.TicketLinkFields.Clear();
	// Add a "Links" field.
	resolver.TicketLinkFields.Add("Links");
	// Create a state field.
	// First, we create a StateEnum which contains the names and integer values of the states.
	StateEnum dmaState = new StateEnum();
	dmaState.EnumName = "MyStates";
	dmaState.DynamicAdd("Created", 0);
	dmaState.DynamicAdd("Started", 1);
	dmaState.DynamicAdd("Paused", 2);
	dmaState.DynamicAdd("Stopped", 3);
	dmaState.DynamicAdd( "Closed", 4);
	// We now link our custom ticket states to a DataMiner .
	// I.e. "Created" has value 0 and gets linked to .
	resolver.StateResolver.Add(0, TicketState.Open); // Created
	resolver.StateResolver.Add(1, TicketState.Open); // Started
	resolver.StateResolver.Add(2, TicketState.Open); // Paused
	resolver.StateResolver.Add(3, TicketState.Closed); // Stopped
	resolver.StateResolver.Add(4, TicketState.Closed); // Closed
	// Now we add a "State" field.
	resolver.AddOrUpdateNames(
		// Here, we add the descriptor for our "State" field.
		new TicketFieldDescriptor()
		{
			FieldDisplayName = "State",
			FieldName = "State",
			FieldType = typeof(GenericEnumEntry<int>),
			IsThirdParty = false,	// This is a DataMiner ticket field.
			IsDataMinerMaster = true,	// When a clash of this field occurs, the value set by DataMiner is used.
			Validator = new EnumValidator<int>(DmaState)
		},
		// And we link the "State" field to a third-party "Status" field.
		new TicketFieldDescriptor()
		{
			FieldDisplayName = "Status",
			FieldName = "Status",
			FieldType = typeof(string),
			IsThirdParty = true,	// This is a third-party ticket field.
			Validator = new TypeValidator<string>
		}
	);
	// Add a "User Name" field.
	resolver.AddOrUpdateNames(
		new TicketFieldDescriptor()
		{
			FieldDisplayName = "User Name",
			FieldName = "User",
			FieldType = typeof(string),
			IsThirdParty = false,	// This is a DataMiner ticket field.
			Validator = new UserValidator() // We know this is a user.
		},
		new TicketFieldDescriptor()
		{
			FieldDisplayName = "Account Number",
			FieldName = "Accnr",
			FieldType = typeof(long),
			IsThirdParty = true,	// This is a third-party ticket field.
			Validator = new TypeValidator<long>	// The third-party system uses an account number instead of a user.
		}
	);
	// Create an email field.
	resolver.AddOrUpdateNames(
		new TicketFieldDescriptor()
		{
			FieldDisplayName = "Email Address",
			FieldName = "Mail",
			FieldType = typeof(string),
			IsThirdParty = false,	// This is a DataMiner ticket field.
			Validator = new EmailAddressValidator() // We know this has to be an email address.
		},
		new TicketFieldDescriptor()
		{
			FieldDisplayName = "Internal Address",
			FieldName = "Addr",
			FieldType = typeof(string),
			IsThirdParty = true,	// This is a third-party ticket field.
			Validator = new RegexValidator()	// The third-party system uses a string, but we can validate it with a regular expression.
			{
				RegexOptions = RegexOptions.IgnoreCase | RegexOptions.SingleLine,
				RegexPattern = @"\A(?:[a-z0-9!#$%&'*+/=?^_`{|}~-]+(?:\.[a-z0-9]!#$%&'*+/=?^_`{|}~-]+)*@(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?)\Z"
			}
		}
	);
	// Add a "Quality" field.
	resolver.AddOrUpdateNames(
		new TicketFieldDescriptor()
		{
			FieldDisplayName = "Quality",
			FieldName = "Quality",
			FieldType = typeof(double),
			IsThirdParty = false,	// This is a DataMiner ticket field.
			Validator = new TypeValidator<double>() // A quality score.
		},
		new TicketFieldDescriptor()
		{
			FieldDisplayName = "Score",
			FieldName = "Score",
			FieldType = typeof(byte),
			IsThirdParty = true,	// This is a third-party ticket field.
			Validator = new TypeValidator<byte>	// The third-party system uses a byte to store this.
		}
	);
	// Save our custom ticket field resolver.
	string error;
	if(!Helper.SetTicketFieldResolver(out error, ref resolver))
	{
		throw new DataMinerException("Something went wrong during setting the TicketFieldResolver: " + error")	
	}
	return resolver;
}
  Remarks
The TicketFieldResolver contains a dictionary with all the names of the fields. Therefore, it is not allowed to have multiple TicketFieldDescriptor objects in the same TicketFieldResolver instance that share the same FieldName.
Constructors
- TicketFieldResolver()
 Initializes a new instance of the TicketFieldResolver class.
- TicketFieldResolver(Guid)
 Initializes a new instance of the TicketFieldResolver class using the specified GUID.
- TicketFieldResolver(Guid, string)
 Initializes a new instance of the TicketFieldResolver class using the specified GUID and name.
Fields
- Factory
 The ticket field resolver factory.
Properties
- DataTypeID
 Gets the data type ID.
- ElementUsingResolver
 Gets or sets the ID of the element that uses the resolver.
- ID
 Gets or sets the ID of this resolver.
- IsValid
 Gets a value indicating whether this resolver is valid.
- LastModified
 Gets or sets the last modification time.
- Module
 Gets or sets the ticket module.
- Name
 Gets or sets the name of this resolver.
- StateResolver
 Gets or sets the state resolver.
- TicketLinkFields
 Gets or sets the ticket link fields.
- TicketStateFieldDescriptor
 Gets or sets the ticket state field descriptor.
- VisualizationHints
 Gets or sets the visualization hints.
Methods
- AddOrUpdateNames(TicketFieldDescriptor, TicketFieldDescriptor)
 Adds or updates this resolver with the specified fields.
- Equals(object)
 Determines whether the specified object is equal to the current object.
- FiltersTo(TicketFieldResolver)
 Returns a value indicating whether the specified TicketFieldResolver has the same ID or name as this TicketFieldResolver object.
- FromJson(string)
 Creates a TicketFieldResolver instance of the specified JSON string.
- GetAllTicketStateGenericEnumEntries()
 Returns all GenericEnumEntries that represent a state for ticket that is linked to this TicketFieldResolver. These can be used to filter on the state field of a Ticket.
- GetAllTicketStateGenericEnumEntriesForState(TicketState)
 Returns a list of all GenericEnumEntries that represent the given state. These can be used to filter on the state field of a Ticket.
- GetDataMinerField(TicketFieldDescriptor)
 Gets the DataMiner TicketFieldDescriptor that corresponds with the specified third-party TicketFieldDescriptor.
- GetDataMinerFields2ThirdPartyFields()
 Retrieves a dictionary with the DataMiner fields serving as the keys and the third-party fields serving as the values.
- GetFieldWithName(string)
 Gets the TicketFieldDescriptor with the specified name.
- GetHashCode()
 Calculates the hash code for this object.
- GetInternalState(Ticket)
 Gets the internal state of the specified ticket.
- GetThirdPartyField(TicketFieldDescriptor)
 Gets the third-party TicketFieldDescriptor that corresponds with the specified DataMiner TicketFieldDescriptor.
- GetThirdPartyFields2DataMinerFields()
 Retrieves a dictionary with the third-party fields serving as the keys and the DataMiner fields serve as the values.
- GetTicketStateFilter(TicketState)
 Returns a Ticket filter that can be used to retrieve all Tickets linked to this TicketFieldResolver with the given state.
- RemoveDataMinerField(TicketFieldDescriptor)
 Removes the specified TicketFieldDescriptor DataMiner field from the resolver.
- RemoveThirdPartyField(TicketFieldDescriptor)
 Removes the specified TicketFieldDescriptor third-party field from the resolver.
- ToJson()
 Retrieves the JSON representation of this TicketFieldResolver object.