Help
  • Explore Community
  • Get Started
  • Ask the Community
  • How-To & Best Practices
  • Contact Support
Notifications
Login / Register
Community
Community
Notifications
close
  • Forums
  • Knowledge Center
  • Events & Webinars
  • Ideas
  • Blogs
Help
Help
  • Explore Community
  • Get Started
  • Ask the Community
  • How-To & Best Practices
  • Contact Support
Login / Register
Sustainability
Sustainability

We Value Your Feedback!
Could you please spare a few minutes to share your thoughts on Cloud Connected vs On-Premise Services. Your feedback can help us shape the future of services.
Learn more about the survey or Click here to Launch the survey
Schneider Electric Services Innovation Team!

Does anyone have a code snippet on how to use HistoryItemReader

SmartConnector Forum

Schneider Electric support forum about SmartConnector applications for integration of other building management systems (BMS) into EcoStruxure Building Operation.

cancel
Turn on suggestions
Auto-suggest helps you quickly narrow down your search results by suggesting possible matches as you type.
Showing results for 
Show  only  | Search instead for 
Did you mean: 
  • Home
  • Schneider Electric Community
  • EcoStruxure Building
  • SmartConnector
  • SmartConnector Forum
  • Does anyone have a code snippet on how to use HistoryItemReader
Options
  • Mark Topic as New
  • Mark Topic as Read
  • Float this Topic for Current User
  • Bookmark
  • Subscribe
  • Mute
  • Printer Friendly Page
Invite a Co-worker
Send a co-worker an invite to the portal.Just enter their email address and we'll connect them to register. After joining, they will belong to the same company.
You have entered an invalid email address. Please re-enter the email address.
This co-worker has already been invited to the Exchange portal. Please invite another co-worker.
Please enter email address
Send Invite Cancel
Invitation Sent
Your invitation was sent.Thanks for sharing Exchange with your co-worker.
Send New Invite Close
Top Experts
User Count
JeffBowman
Sisko JeffBowman Sisko
164
ardak
ardak Schneider Alumni (Retired)
34
sesa180908_brid
Commander sesa180908_brid Commander
34
mike_meirovitz
Commander mike_meirovitz
21
View All

Invite a Colleague

Found this content useful? Share it with a Colleague!

Invite a Colleague Invite
Solved Go to Solution
Back to SmartConnector Forum
Solved
sesa180961_brid
Lieutenant sesa180961_brid Lieutenant
Lieutenant

Posted: ‎2017-02-02 06:57 AM

0 Likes
7
834
  • Mark as New
  • Bookmark
  • Subscribe
  • Mute
  • Permalink
  • Print
  • Email to a Friend
  • Report Inappropriate Content

Link copied. Please paste this link to share this article on your social media post.

‎2017-02-02 06:57 AM

Does anyone have a code snippet on how to use HistoryItemReader


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!

Tags (3)
  • Tags:
  • ews
  • historyitemreader
  • historyitems
Reply
  • All forum topics
  • Previous Topic
  • Next Topic

Accepted Solutions
Adam_Summers
Lt. Commander Adam_Summers Lt. Commander
Lt. Commander

Posted: ‎2017-02-02 07:07 AM

0 Likes
4
752
  • Mark as New
  • Bookmark
  • Subscribe
  • Mute
  • Permalink
  • Print
  • Email to a Friend
  • Report Inappropriate Content

Link copied. Please paste this link to share this article on your social media post.

‎2017-02-02 07:07 AM

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++;

                    }

                }

            }

See Answer In Context

Reply
Replies 7
sesa180908_brid
Commander sesa180908_brid Commander
Commander

Posted: ‎2017-02-02 07:01 AM

0 Likes
1
752
  • Mark as New
  • Bookmark
  • Subscribe
  • Mute
  • Permalink
  • Print
  • Email to a Friend
  • Report Inappropriate Content

Link copied. Please paste this link to share this article on your social media post.

‎2017-02-02 07:01 AM

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.

Reply
Adam_Summers
Lt. Commander Adam_Summers Lt. Commander
Lt. Commander

Posted: ‎2017-02-02 07:07 AM

0 Likes
4
753
  • Mark as New
  • Bookmark
  • Subscribe
  • Mute
  • Permalink
  • Print
  • Email to a Friend
  • Report Inappropriate Content

Link copied. Please paste this link to share this article on your social media post.

‎2017-02-02 07:07 AM

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++;

                    }

                }

            }

Reply
sesa180908_brid
Commander sesa180908_brid Commander
Commander

Posted: ‎2017-02-02 07:16 AM

0 Likes
1
752
  • Mark as New
  • Bookmark
  • Subscribe
  • Mute
  • Permalink
  • Print
  • Email to a Friend
  • Report Inappropriate Content

Link copied. Please paste this link to share this article on your social media post.

‎2017-02-02 07:16 AM

Adam,

Could this be the HTTPs issue with SBO and EWS rather than an authentication issue?  Although perhaps I'm splitting hairs. 

Reply
Adam_Summers
Lt. Commander Adam_Summers Lt. Commander
Lt. Commander

Posted: ‎2017-02-02 07:21 AM

0 Likes
0
752
  • Mark as New
  • Bookmark
  • Subscribe
  • Mute
  • Permalink
  • Print
  • Email to a Friend
  • Report Inappropriate Content

Link copied. Please paste this link to share this article on your social media post.

‎2017-02-02 07:21 AM

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!

Reply
sesa180961_brid
Lieutenant sesa180961_brid Lieutenant
Lieutenant

Posted: ‎2017-02-02 07:40 AM

0 Likes
1
752
  • Mark as New
  • Bookmark
  • Subscribe
  • Mute
  • Permalink
  • Print
  • Email to a Friend
  • Report Inappropriate Content

Link copied. Please paste this link to share this article on your social media post.

‎2017-02-02 07:40 AM

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?

Reply
sesa180961_brid
Lieutenant sesa180961_brid Lieutenant
Lieutenant

Posted: ‎2017-02-02 07:42 AM

0 Likes
0
752
  • Mark as New
  • Bookmark
  • Subscribe
  • Mute
  • Permalink
  • Print
  • Email to a Friend
  • Report Inappropriate Content

Link copied. Please paste this link to share this article on your social media post.

‎2017-02-02 07:42 AM

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?

Reply
sesa180961_brid
Lieutenant sesa180961_brid Lieutenant
Lieutenant

Posted: ‎2017-02-02 12:31 PM

0 Likes
0
752
  • Mark as New
  • Bookmark
  • Subscribe
  • Mute
  • Permalink
  • Print
  • Email to a Friend
  • Report Inappropriate Content

Link copied. Please paste this link to share this article on your social media post.

‎2017-02-02 12:31 PM

Found it. I use ExtractHistoryItemIds() method in EwsClient to get the History Item Ids from an AS.

Reply
Preview Exit Preview

never-displayed

You must be signed in to add attachments

never-displayed

 
To The Top!

Forums

  • APC UPS Data Center Backup Solutions
  • EcoStruxure IT
  • EcoStruxure Geo SCADA Expert
  • Metering & Power Quality
  • Schneider Electric Wiser

Knowledge Center

Events & webinars

Ideas

Blogs

Get Started

  • Ask the Community
  • Community Guidelines
  • Community User Guide
  • How-To & Best Practice
  • Experts Leaderboard
  • Contact Support
Brand-Logo
Subscribing is a smart move!
You can subscribe to this board after you log in or create your free account.
Forum-Icon

Create your free account or log in to subscribe to the board - and gain access to more than 10,000+ support articles along with insights from experts and peers.

Register today for FREE

Register Now

Already have an account? Login

Terms & Conditions Privacy Notice Change your Cookie Settings © 2025 Schneider Electric

This is a heading

With achievable small steps, users progress and continually feel satisfaction in task accomplishment.

Usetiful Onboarding Checklist remembers the progress of every user, allowing them to take bite-sized journeys and continue where they left.

of