私は現在、AT Web サービス API ( https://webservices5.autotask.net/ATServices/1.5/atws.asmx ) を使用して、AutoTask 実装のためにいくつかのことをコーディングしています。何かを行うには、基本的に、最初にすべてのピックリスト値について AT にクエリを実行する必要があります。これはかなり簡単ですが、親の値「IssueType」に簡単にリンクできるように、すべての「SubIssueTypes」を分離する方法を理解するのに苦労しています。
各 PickList をディクショナリに入れ、そのディクショナリをアプリケーション内の ComboBox のソースにしています。SubIssueTypes を実行する最善の方法がわからないことを除いて、これはうまく機能します。各 IssueType には複数の SubIssueType がリンクされていますが、AT はすべての SubIssueType を同じ PickList に配置しています。
「pValue.parentValue」が現在選択されている IssueType 値と一致する値のみを表示する独自の ComboBox にすべての SubIssueTypes を配置するにはどうすればよいですか?
public static Dictionary<string, Resource> ResourcesById = new Dictionary<string, Resource>();
public static Dictionary<string, Account> AccountsById = new Dictionary<string, Account>();
public static Dictionary<string, string> ResourcesIdByName = new Dictionary<string, string>();
public static Dictionary<string, string> AccountsIdByName = new Dictionary<string, string>();
public static Dictionary<string, string> AccountsNameById = new Dictionary<string, string>();
public static Dictionary<string, string> StatusIdByName = new Dictionary<string, string>();
public static Dictionary<string, string> StatusNameById = new Dictionary<string, string>();
public static Dictionary<string, string> IssueType = new Dictionary<string, string>();
public static Dictionary<string, string> SubIssueType = new Dictionary<string, string>();
public static Dictionary<string, Tuple<string, string>> SubIssueLabel = new Dictionary<string, Tuple<string, string>>();
public static Dictionary<Tuple<string, string>, string> SubIssueValue = new Dictionary<Tuple<string, string>, string>();
public static Dictionary<string, string> Priority = new Dictionary<string, string>();
public static Dictionary<string, string> Source = new Dictionary<string, string>();
public static Dictionary<string, string> ServiceLevelAgreement = new Dictionary<string, string>();
public static Dictionary<string, string> TicketType = new Dictionary<string, string>();
public static Dictionary<string, string> QueueNameById = new Dictionary<string, string>();
public static Dictionary<string, string> QueueIdByName = new Dictionary<string, string>();
public static Dictionary<string, string> AssignedResourceRole = new Dictionary<string, string>();
public static Dictionary<string, string> AssignedResource = new Dictionary<string, string>();
public static Dictionary<string, string> AllocationCode = new Dictionary<string, string>();
public static Dictionary<string, string> ResourcesNameById = new Dictionary<string, string>();
public static void Preload()
{
var client = new SoapClient().Admin();
AutotaskIntegrations ati = new AutotaskIntegrations();
Field[] fieldInfo = client.GetFieldInfo(ati, "Ticket");
foreach (var item in fieldInfo)
{
if (item.IsPickList)
{
foreach (var pValue in item.PicklistValues)
{
switch (item.Name)
{
case "Status":
StatusIdByName.Add(pValue.Label, pValue.Value);
StatusNameById.Add(pValue.Value, pValue.Label);
break;
case "IssueType":
IssueType.Add(pValue.Label, pValue.Value);
break;
case "SubIssueType":
SubIssueLabel.Add(pValue.Label, new Tuple<string, string>(pValue.parentValue, pValue.Value));
SubIssueValue.Add(new Tuple<string, string>(pValue.parentValue, pValue.Value), pValue.Label);
break;
case "Priority":
Priority.Add(pValue.Label, pValue.Value);
break;
case "Source":
Source.Add(pValue.Label, pValue.Value);
break;
case "ServiceLevelAgreementID":
ServiceLevelAgreement.Add(pValue.Label, pValue.Value);
break;
case "TicketType":
TicketType.Add(pValue.Label, pValue.Value);
break;
case "QueueID":
QueueNameById.Add(pValue.Value, pValue.Label);
QueueIdByName.Add(pValue.Label, pValue.Value);
break;
case "AllocationCodeID":
AllocationCode.Add(pValue.Label, pValue.Value);
break;
case "AssignedResourceID":
AssignedResource.Add(pValue.Label, pValue.Value);
break;
case "AssignedResourceRoleID":
AssignedResourceRole.Add(pValue.Label, pValue.Value);
break;
}
}
}
}
}
現在、ほとんどの PickList -> Dictionaries を使用して、ソースを辞書として指定するだけです。
private void FillCombos()
{
AutoTaskData.Preload();
AutoTaskData.ResourcesIdByName.Add("", "clear");
ResourceBox.ItemsSource = AutoTaskData.ResourcesIdByName;
AutoTaskData.QueueIdByName.Add("", "clear");
QueueBox.ItemsSource = AutoTaskData.QueueIdByName;
AutoTaskData.StatusIdByName.Add("", "clear");
StatusBox.ItemsSource = AutoTaskData.StatusIdByName;
}
XAML:
<ComboBox x:Name="QueueBox" SelectedValuePath="Value" DisplayMemberPath="Key" SelectionChanged="QueueBox_SelectionChanged" />
<TextBlock Margin="5,10,10,0">Resource</TextBlock>
<ComboBox x:Name="ResourceBox" SelectedValuePath="Value" DisplayMemberPath="Key" SelectionChanged="ResourceBox_SelectionChanged" />
<TextBlock Margin="5,10,10,0">Status</TextBlock>
<ComboBox x:Name="StatusBox" SelectedValuePath="Value" DisplayMemberPath="Key" />
ただし、これらはすべて 1 つの辞書にあり、「pValue.ParentValue」変数 (つまり、辞書キーの最初のタプル) に一致する IssueType が選択されている場合にのみ値を表示する必要があるため、これは明らかに SubIssueType では機能しません。または値)。おそらくタプルは行くべき道ではありませんが、これに最適な実装が何であるかはわかりません。