I'm trying to figure out how to access values in an object through an API, but am having no luck. There is some documentation, but not a lot. I'm able to access some information, but what I'm looking for exists in a keyword field in a database that the software is using. I am able to print out the object type, but not the values in the actual object.
Here's my code:
public class Test
{
public static ServiceConnection ConnectToDocuWare(Uri uri, string userName, string passWord)
{
return ServiceConnection.Create(uri, userName, passWord);
}
static void Main()
{
var userName;
var passWord;
var uri;
var conn = ConnectToDocuWare(uri, userName, passWord);
var org = conn.Organizations[0];
var fileCabinets = org.GetFileCabinetsFromFilecabinetsRelation().FileCabinet;
var fileCabinet = fileCabinets.SingleOrDefault(x => x.Name == "someValue");
string documentID = "1";
int DWID = int.Parse(documentID);
string FCID = fileCabinet.Id;
var dialogInfoItems = fileCabinet.GetDialogInfosFromDialogsRelation();
var dialog = dialogInfoItems.Dialog.SingleOrDefault(x => x.DisplayName == "Some Value").GetDialogFromSelfRelation();
var DocResults = RunQuery(dialog, documentID);
foreach (Document doc in DocResults.Items)
{
var item = doc.GetDocumentFromSelfRelation();
foreach (var itemInfo in item.Fields)
{
if (itemInfo.ItemElementName.ToString() == "Keywords")
{
Console.WriteLine(itemInfo.Item);
}
}
}
Console.ReadLine();
}
public static DocumentsQueryResult RunQuery(Dialog dialog, string DWDocID)
{
var q = new DialogExpression()
{
Operation = DialogExpressionOperation.And,
Condition = new List<DialogExpressionCondition>()
{
DialogExpressionCondition.Create("DWDOCID", DWDocID),
},
Count = 100,
SortOrder = new List<SortedField>
{
SortedField.Create("DWSTOREDATETIME", SortDirection.Desc)
}
};
var queryResult = dialog.GetDocumentsResult(q);
return queryResult;
}
}
This just outputs the object type. I've tried to use a foreach loop to output everything in the ItemInfo.Item object, but I get this error: Foreach statement cannot operate on variables of type 'object' because 'object' does not contain a public definition for 'GetEnumerator'
Essentially I'm trying to access the values in the keyword field to use later.