-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDovetailCommonFunctions.ps1
138 lines (117 loc) · 4.34 KB
/
DovetailCommonFunctions.ps1
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
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
function configure-logging()
{
$LogManager = [FChoice.Common.LogManager]
$LogManager::LogConfigFilePath = $appSettings["logConfigFilePath"];
$LogManager::Reconfigure()
$global:logger = $LogManager::GetLogger("PowerShell");
}
function log-info ([string] $message)
{
write-host "INFO: $message"
$global:logger.LogInfo($message);
}
function log-warn ([string] $message)
{
write-warning $message
$global:logger.LogWarn($message);
}
function log-debug ([string] $message)
{
write-debug $message
$global:logger.LogDebug($message);
}
function log-error ([string] $message)
{
write-host "ERROR: $message" -foregroundcolor red
$global:logger.LogError($message);
}
function create-clarify-session
{
$clarifyapp = $args[0]
$ClarifySession = $clarifyapp::Instance.CreateSession();
$ClarifySession.TruncateStringFields = "True";
return $ClarifySession
}
function create-clarify-application
{
#Load the configuration file
.\LoadConfig dovetail.config
$connectionString = $appSettings["connectionString"];
$databaseType = $appSettings["databaseType"];
[system.reflection.assembly]::LoadWithPartialName("fcsdk") > $null;
[system.reflection.assembly]::LoadWithPartialName("FChoice.Common") > $null;
[system.reflection.assembly]::LoadWithPartialName("FChoice.Toolkits.Clarify") > $null;
$config = new-object -typename System.Collections.Specialized.NameValueCollection;
$config.Add("fchoice.connectionstring",$connectionString);
$config.Add("fchoice.dbtype",$databaseType);
$config.Add("fchoice.disableloginfromfcapp", "false");
$config.Add("fchoice.nocachefile", "true");
#Create and initialize the clarifyApplication object
$ClarifyApplication = [Fchoice.Foundation.Clarify.ClarifyApplication];
#if configured to do so, turn on logging
if ($appSettings["enableLogging"] -eq $true)
{
write-debug "logging is enabled";
configure-logging;
}
if ($ClarifyApplication::IsInitialized -eq $false ){
$ClarifyApplication::initialize($config) > $null;
}
return $ClarifyApplication;
}
function display-fcsdk-version()
{
$assembly = [System.Reflection.Assembly]::LoadWithPartialName("fcsdk")
$assemblyName = $assembly.GetName()
$assemblyVersion = $assemblyName.version
"Assembly: {0} has version number of: {1}" -f $assemblyName.name, $assemblyVersion
}
function dispatch-dialogue ( $ClarifySession, [string] $dialogueId, [string] $queueName)
{
write-debug "Dispatching dialogue $dialogueId to queue $queueName.";
$dispatcherUserName = 'sa';
$dataSet = new-object FChoice.Foundation.Clarify.ClarifyDataSet $ClarifySession;
$workflowManager = new-object FChoice.Foundation.Clarify.Workflow.WorkflowManager $dataSet;
$now = [FChoice.Foundation.FCGeneric]::NOW_DATE;
$result = $workflowManager.Dispatch($dialogueId, "dialogue", $queueName, $now, $dispatcherUserName, $true);
}
function get-case-by-id([string] $id)
{
$dataSet = new-object FChoice.Foundation.Clarify.ClarifyDataSet($ClarifySession)
$caseGeneric = $dataSet.CreateGeneric("case")
$caseGeneric.AppendFilter("id_number", "Equals", $id)
$caseGeneric.Query();
$caseGeneric.Rows[0];
}
function get-caseview-by-objid([int] $objid)
{
$dataSet = new-object FChoice.Foundation.Clarify.ClarifyDataSet($ClarifySession)
$caseGeneric = $dataSet.CreateGeneric("qry_case_view")
$caseGeneric.AppendFilter("elm_objid", "Equals", $objid)
$caseGeneric.Query();
$caseGeneric.Rows[0];
}
function get-caseview-by-id([string] $id)
{
$dataSet = new-object FChoice.Foundation.Clarify.ClarifyDataSet($ClarifySession)
$caseGeneric = $dataSet.CreateGeneric("qry_case_view")
$caseGeneric.AppendFilter("id_number", "Equals", $id)
$caseGeneric.Query();
$caseGeneric.Rows[0];
}
function get-row-for-table-by-objid([string] $tableName, [int] $objid)
{
$dataSet = new-object FChoice.Foundation.Clarify.ClarifyDataSet($ClarifySession)
$generic = $dataSet.CreateGeneric($tableName)
$generic.AppendFilter("objid", "Equals", $objid)
$generic.Query();
$generic.Rows[0];
}
function get-empl-view-by-login-name([string] $loginName)
{
$dataSet = new-object FChoice.Foundation.Clarify.ClarifyDataSet($ClarifySession)
$generic = $dataSet.CreateGeneric("empl_view")
$generic.AppendFilter("login_name", "Equals", $loginName)
$generic.Query();
$generic.Rows[0];
}