- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
Link copied. Please paste this link to share this article on your social media post.
My objective is to obtain trend logs on an AS using SmartConnector.
1. Does anyone have a code snippet on how to use HistoryItemReader?
2. Does EwsServerDateAdapter.HistoryItems get me all the trend logs available on an AS or ES?
Thank you!
Accepted Solutions
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
Link copied. Please paste this link to share this article on your social media post.
Hi Maneesh,
I take this approach, using a retry method since we have some problems with Authentication caused by SBO!
var fails = 0;
var maxRetries = 5;
using (var historyItemReader = new HistoryItemReader
{
HistoryItemsToRead = <YOUR LIST OF TREND LOG IDS>,
EwsEndpoint = EndpointAddress,
UserName = UserName,
Password = Password,
TimeFrom = <START DATE>,
TimeTo = <END DATE>
})
{
//SBO is not good with the authentication from SmartConnector you often need a couple of retries!
while (fails < maxRetries)
{
try
{
var dataRead = historyItemReader.ReadData();
if (dataRead.Success)
{
foreach (var historyItem in dataRead.DataRead)
{
CheckCancellationToken();
//DO WHAT EVER YOU WANT WITH THE HISTORYITEM OBJECT
}
}
else
{
Logger.LogError("Failed to read log items");
}
break;
}
catch (ApplicationException historyApplicationException)
{
Logger.LogError(LogCategory.Processor, historyApplicationException);
fails++;
}
}
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
Link copied. Please paste this link to share this article on your social media post.
I'll try to get a sample out later but I wanted to clarify one part of your question.
The EwsServerDataAdapter is used for SmartConnector EWS servers and not SOAP based servers (like an AS or ES).
The HistoryItemReader is used for SOAP based servers.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
Link copied. Please paste this link to share this article on your social media post.
Hi Maneesh,
I take this approach, using a retry method since we have some problems with Authentication caused by SBO!
var fails = 0;
var maxRetries = 5;
using (var historyItemReader = new HistoryItemReader
{
HistoryItemsToRead = <YOUR LIST OF TREND LOG IDS>,
EwsEndpoint = EndpointAddress,
UserName = UserName,
Password = Password,
TimeFrom = <START DATE>,
TimeTo = <END DATE>
})
{
//SBO is not good with the authentication from SmartConnector you often need a couple of retries!
while (fails < maxRetries)
{
try
{
var dataRead = historyItemReader.ReadData();
if (dataRead.Success)
{
foreach (var historyItem in dataRead.DataRead)
{
CheckCancellationToken();
//DO WHAT EVER YOU WANT WITH THE HISTORYITEM OBJECT
}
}
else
{
Logger.LogError("Failed to read log items");
}
break;
}
catch (ApplicationException historyApplicationException)
{
Logger.LogError(LogCategory.Processor, historyApplicationException);
fails++;
}
}
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
Link copied. Please paste this link to share this article on your social media post.
Adam,
Could this be the HTTPs issue with SBO and EWS rather than an authentication issue? Although perhaps I'm splitting hairs.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
Link copied. Please paste this link to share this article on your social media post.
Yes perhaps! Although I have issues with and without proxy server configuration and also when using http and https! A retry method seems to work just fine and a second attempt almost always works!
Thought it was worth pointing it out for Maneesh anyway. You have the detail in the release notes Bug #348 should anyone want the full explanation!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
Link copied. Please paste this link to share this article on your social media post.
Thanks for the code on HistoryItemReader.
The reason I was thinking of using EwsServerDataAdapter is to get HistoryItems' Ids from the AS to pass to the HistoryItemReader.
Assuming that I have to get the HistoryItems Ids, what would be the way to do it?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
Link copied. Please paste this link to share this article on your social media post.
The reason I was thinking of using EwsServerDataAdapter is to get HistoryItems' Ids from the AS to pass to the HistoryItemReader.
Assuming that I have to get the HistoryItems Ids from an AS, what would be the way to do it?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
Link copied. Please paste this link to share this article on your social media post.
Found it. I use ExtractHistoryItemIds() method in EwsClient to get the History Item Ids from an AS.

