-
Notifications
You must be signed in to change notification settings - Fork 1
/
AbsLookupInfo.cs
66 lines (55 loc) · 1.97 KB
/
AbsLookupInfo.cs
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
using CRMPluginUtils;
using Microsoft.Xrm.Sdk;
using Microsoft.Xrm.Sdk.Query;
using System;
namespace MicrosoftDynamicsCRMPlugin
{
public abstract class AbsLookupInfo
{
private int resultIndex;
private string contactNumber;
private bool exactMatch;
private QueryExpression queryExpression;
private FilterExpression getFilterExpression(ConditionExpression[] conditionArray)
{
FilterExpression filter = new FilterExpression();
filter.FilterOperator = LogicalOperator.Or;
foreach (ConditionExpression conditionExpression in conditionArray)
filter.AddCondition(conditionExpression);
return filter;
}
protected bool match(string telephone)
{
if (String.IsNullOrEmpty(contactNumber)) return true;
if (String.IsNullOrEmpty(telephone)) return false;
return PhoneMatchHelper.TelephoneMatches(contactNumber, telephone, exactMatch, GeneralConfiguration.MaxCompareLength);
}
protected void configureQueryExpression(string entityName, ConditionExpression[] conditionArray)
{
queryExpression.EntityName = entityName;
queryExpression.ColumnSet = getColumns();
queryExpression.Criteria = getFilterExpression(conditionArray);
}
protected ConditionExpression createCondition(string attributeName, ConditionOperator conditionOperator, object[] values)
{
return new ConditionExpression(attributeName, conditionOperator, values);
}
protected abstract ColumnSet getColumns();
public AbsLookupInfo(int resultIndex, string contactNumber, bool exactMatch)
{
this.resultIndex = resultIndex;
this.contactNumber = contactNumber;
this.exactMatch = exactMatch;
this.queryExpression = new QueryExpression();
}
public abstract ContactInfo ProcessEntity(Entity entity);
public int ResultIndex
{
get { return resultIndex; }
}
public QueryExpression QueryExpression
{
get { return queryExpression; }
}
}
}