Quantcast
Channel: OSIsoft Users Community
Viewing all articles
Browse latest Browse all 1120

Getting C# To Return HTML Tags and PI Data As HTML Code

$
0
0

Hello Fellow PI Users:

 

I want to extract time stamps and values from a PI Tag and display it in an ASP.net web page. Utilizing PISDK here is what I have worked out so far:

 

Target page contains:

        <table>
            <%:theResultsList("SINUSOID") %> //# I want table rows of 'SINUSOID' data to load here.
        </table>

The code behind page contains this function:

        public string theResultsList(string theTagName)
        {
            var _pisdk = new PISDK.PISDK();
            PISDK.Server piServer = _pisdk.Servers["PIServerNameHere"];
            piServer.Open();
            PISDK.PIPoint mypoint = piServer.PIPoints[theTagName];
            string theEnvelopePlease = "";
            string startTime;
            string endTime;
            PISDK.PIValues myResultsList;

            startTime = "*-1.5h";
            endTime = "*";

            myResultsList = mypoint.Data.RecordedValues(startTime, endTime, BoundaryTypeConstants.btAuto);
            foreach (PISDK.PIValue myCurrentValue in myResultsList)
            {
                theEnvelopePlease = theEnvelopePlease + "<tr><td>" + myCurrentValue.TimeStamp.LocalDate.ToString() + "</td><td>" + myCurrentValue.Value.ToString() + "</td></tr>";
            }
            piServer.Close();
            return theEnvelopePlease;
        }

The trouble is the response back looks just like this in the browser:
<tr><td>10/8/2014 12:41:44 PM</td><td>65.85915</td></tr><tr><td>10/8/2014 1:33:17 PM</td><td>86.35349</td></tr><tr><td>10/8/2014 2:08:47 PM</td><td>95.08834</td></tr><tr><td>10/8/2014 2:11:44 PM</td><td>95.08834</td></tr>
 

When I go to view source, it looks like this:

        <table>
            <tr><td>10/8/2014 12:41:44 PM</td><td>65.85915</td></tr><tr><td>10/8/2014 1:33:17 PM</td><td>86.35349</td></tr><tr><td>10/8/2014 2:08:47 PM</td><td>95.08834</td></tr><tr><td>10/8/2014 2:11:44 PM</td><td>95.08834</td></tr>
        </table>

I want it to look like this:

10/8/2014 12:41:44 PM    65.85915
10/8/2014 1:33:17 PM    86.35349
10/8/2014 2:08:47 PM    95.08834
10/8/2014 2:11:44 PM    95.08834


To get it to look like this the function needs to return the results as HTML code containing PI Data. My Question is how do I tell C# to explicitly treat the returned string data as html code? Or is there a better way to get this working by using a DataGridView or some other ASP.net tool? Advise on how to fix this or try something else is appreciated.


Viewing all articles
Browse latest Browse all 1120

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>