Previous Next

Thread: Having issues coming up with a way to store date and time separately in c# from an eventlog

Last post 04-20-2008 1:35 AM by Trike. 0 replies.

Average Rating Rate It (5)

RSS

Page 1 of 1 (1 items)

Sort Posts:

  • 04-20-2008, 1:35 AM

    • Trike
    • Not Ranked
    • Joined on 04-03-2008, 6:59 PM
    • Posts 1

    Having issues coming up with a way to store date and time separately in c# from an eventlog

     

    I'll apologize first hand that i'm new to C# and programming in general.

    What I am trying to build, is a benchmark console app that reads from an eventlog. Every time an event with a specific eventid is logged, is when the process has been finished.

     What I'm doing currently is converting the TIMEGENERATED into a real type. I'm taking each event record and taking the difference from the next event record to get a processed time. My query looks like this.

    @"SELECT ALL TO_REAL(TO_TIME(TimeGenerated)) FROM barcode.evt Where  SourceName='Service' AND eventid=7";

    I cycle through the record set and store each object into an array. Then I do the calculations in the array.

    Currently I have a bug. This will only work for a single day. The query converts the time of each event to secs. Once I get to 12:00am of the next day. The conversion becomes 0secs. My results end up becoming a negative number.

     Now, I have just about everything re-written in an attempt to store the time and date separately and do my calculations that way.

     Where I'm running into a problem is how to split up the date and time in one pass. My original thought process was to take the TimeGenerated data from logparser and split it up after I pulled it out of the record set. But I don't know how to convert the TimeGenerated into date and time separately.

    I'm not sure how to convert the timestamp data and split up the date and time after I have it in a separate array. And or I'm not structuring my query correctly. Currently this is what I have:

    @"SELECT ALL TimeGenerated FROM barcode.evt Where SourceName='Service' AND eventid=7"

    I'm not sure what the correct approach would be. I could loop through the record set again, with a different query, but that will create too much overhead. As I'll be dealing with around 100,000 records.

    Another option would be to store the timestamp data into an array as a string then attempt to parse the time or date in the array, but I haven't thought this one through all the way and not sure how to implement this approach yet.

    As I said earlier, I'm a beginner learning how to program in C#. Just looking for some direction on an approach to take. I've spent countless hours over the past few weeks putting this together, I feel I am very close

    Any help is greatly appreciated.

    Sorry for the very long post, I'm trying to be as detailed as I can.

    Thank you!

Page 1 of 1 (1 items)
Page view counter