in

SharePoint Blogs

The Best Place for SharePoint-related Blogs

Michael Lotter's little view of the big world of SharePoint and InfoPath

September 2007 - Posts

  • Creating a Event Log and Event Log Source for InfoPath Forms .NET code

    Whenever working with a client that wants to build custom .NET code around there InfoPath forms I've always found it useful creating a new Event Log.  In most cases a new Event Source would also be created for each new form that's created.  Doing this gives the ability to easily identify what errors are occurring in the custom .NET code and which form is causing it.   The code written to accomplish this is pretty straight forward and was originally done several years ago.  The only drawback was it didn't read from a file to get its information but was hard coded in the code instead.  It wasn't a big deal for most clients because the developers were creating the forms and they just updated Event Log program during the process.  Several days ago there was a need to make the program usable for Administrators without the need of a recompile each time a new form was deployed.

    With not having much time to think about it I decided to build a XML file as the source and have the console application load the xml file and bind it to a Class.  The addition of this extra functionality wasn't drastic and it actually only needed a new Class, three new additional lines of code and modification of some of the original code. 

    By no means do I profess to be a .NET coding expert and I'm sure there is better ways of doing this but below is how it was done.

    The code was written with Visual Studio 2005 and in VB.NET.  It was done this way because of the client requirements.  If somebody would like the example in C# please email me and I can post a C# version.

    The code was built in a VB.NET Console application and the project was named "CreateEventLogSource" and the code file was also named "CreateEventLogSource".

    The Class that was used for binding to XML was created as a XSD and then converted to .NET Class with the XSD.EXE tool.  Information on the XSD.EXE tool can be found at the following link. http://msdn2.microsoft.com/en-us/library/x6c1kb0s.aspx

    While building the XSD file I also modified it manually set the properties "minOccurs" to "0" and "maxOccurs" to "unbounded" and this can be seen below.  You can also do this by using the properties window for the "EventLogSourceItem" Element in the second ComplexType box.

    The XML file was based off the XSD and built in Visual Studio.  This was accomplished by copying the XSD to the "C:\Program Files\Microsoft Visual Studio 8\Xml\Schemas" directory.  Then adding a new XML file to the project and adding a new line with the property "xmlns=http://tempuri.org/EventLogSource.xsd" as seen below.  By doing this it gave me IntelliSense for building the rest of my xml document.  The http://tempuri.org/EventLogSource.xsd appeared in the drop down list once "xmlns=" was typed.

    The code module for the project had the following "Imports"

    and defined fields.

    The code between the "Try Catch" statement was the following.

    As you can see by reading the code the XML file is being added to a "StreamReader", "XmlSerializer" is being created based of the Class that was created from the XSD file and XML content is bound to the Class created from the XSD file. 

    The Event Log object is then created and the data records are looped through with "For Each" statement.  Inside the "For Each" statement it first verifies if the entry already exist and if so it then reads the next record.  If it doesn't exist the necessary properties are set and event source and log is created. Then it writes a new entry to the log and writes a message to the console application screen verifying the completion.

    Once it's done reading all the data it then writes to the console application screen with the last messages and pauses for a response.

    The "Catch" and "Finally" sections are very straight forward and shown below.

    As you can see it is pretty straight forward code and nothing fancy and last thing that I did to make even more user friendly was create a deployment project that creates a MSI for deploying the EXE and XML file.

    As always any feedback is welcome on how to do something better or easier.

    Cheers.

  • NYC SharePoint User Group

    Next week I'll be heading back up to Newark, NJ area to continue my InfoPath 2007/InfoPath Forms Services project and since the NYC SharePoint User Group is meeting next week with my good friend Jason Medero speaking on "Information Rights Management & MOSS 2007" I decided to attend.  This should be a really good user group meeting and I'm hoping to meet some new SharePoint/InfoPath colleagues.  This will be my second time going into the city and I'm hoping I won't get lost this time and make it to the meeting on time.  All the information about the user group meeting is listed below.

    NYC SharePoint User Group
    10/3/2007  5:30 PM - Microsoft Office - 1290 6th Ave. (51st/52nd)

    NEXT NYC SHAREPOINT USER GROUP: Wednesday, October 3

    Jason Medero, Microsoft MVP will present on "Information Rights Management & MOSS 2007"

    MOSS 2007 is known for its Enterprise Content Management capabilities, but what about when the content leaves the MOSS 2007 environment.  How is the content protected once it leaves the MOSS 2007 environment?  This is where Information Rights Management (IRM) and its tight integration with MOSS 2007 becomes very valuable.  IRM's integration with MOSS 2007 enables administrators to wrap a digital envelope around their digital content.  Once the content is protected inside MOSS 2007 consumers of this content may have specific rights to the content in regards to printing, forwarding or copying this sensitive content.  These restrictions are attached to this content no matter where the content lives or is transported.  This session will cover what IRM is and how it is used in conjunction with MOSS 2007 to provide protection for your sensitive information that is living within your MOSS 2007 environment.

    The meeting will start at 5:30 PM with an opportunity to network with your colleagues in other companies

    and free food compliments of CorasWorks.

    For immediate registration: http://cts.vresp.com/c/?CorasWorks/60fca31a06/d10eefe32c/d0cf740dc8/id=121070

    For additional information, directions & other details, visit the NYC SPUG website: http://cts.vresp.com/c/?CorasWorks/60fca31a06/d10eefe32c/b9b69b1445

    Each month follows the format below.  Here's the agenda for this month:

    5:30 PM

    Eat & Greet

    Networking

    Free Food & Drink

    Courtesy of this month's sponsor:

    CorasWorks

    6:00 PM

    The News

    Breaking SharePoint News

    NYC SPUG Advisors deliver the latest SharePoint news

    6:15 PM

    Tip Talk

    Fast ideas for getting more
    out of SharePoint

    "Information Rights Management
    & MOSS 2007"
    Jason Medero, Microsoft MVP

    7:15 PM

    Wrap Up

    Announcements/Giveaways

    Door Prizes courtesy of: B&R Business Solutions & Microsoft

    **Building Security Requirements: You can expect to have some difficulty & delay getting up to the meeting room if you arrive late. We recommend bringing a copy of your meeting registration confirmation notice with you.

     

  • Random Date calculation formats

    After doing the date calculations, it got me thinking on how some of the other formatting would work and below are some of my random thoughts.  Its not much but just wanted to share it because it might help somebody starting out with SharePoint date calculations.

    The value that I used for "Start Time" was 09/17/2007 and the blod date is the output and the reset is the calculation.

    Changing the Month 

    September 2007  =TEXT([Start Time],"mmmm")&" "&TEXT([Start Time],"yyyy")

    Sep 2007  =TEXT([Start Time],"mmm")&" "&TEXT([Start Time],"yyyy")

    09 2007  =TEXT([Start Time],"mm")&" "&TEXT([Start Time],"yyyy")

    9 2007  =TEXT([Start Time],"m")&" "&TEXT([Start Time],"yyyy")

     

    Changing the Month and Year 

    September 07  =TEXT([Start Time],"mmmm")&" "&TEXT([Start Time],"yy")

    Sep 07  =TEXT([Start Time],"mmm")&" "&TEXT([Start Time],"yy")

    09 07  =TEXT([Start Time],"mm")&" "&TEXT([Start Time],"yy")

    9 07  =TEXT([Start Time],"m")&" "&TEXT([Start Time],"yy")

     

    Changing the Day

    September Monday 2007  =TEXT([Start Time],"mmmm")&" "&TEXT([Start Time],"dddd")&" "&TEXT([Start Time],"yyyy")

    September Mon 2007  =TEXT([Start Time],"mmmm")&" "&TEXT([Start Time],"ddd")&" "&TEXT([Start Time],"yyyy")

    September 17 2007  =TEXT([Start Time],"mmmm")&" "&TEXT([Start Time],"dd")&" "&TEXT([Start Time],"yyyy")

     

    Date Format 

    Monday September 17th, 2007   =TEXT([Start Time],"dddd")&" "&TEXT([Start Time],"mmmm")&" "&TEXT([Start Time],"d")&"th, "&TEXT([Start Time],"yyyy")

     

    Quarter Calculation 

    1st Quarter 2007, 2nd Quarter 2007, 3rd Quarter 2007 or 4th Quarter 2007

    =IF(AND(MONTH([Start Time])>=1,MONTH([Start Time])<=3),"1st Quarter"&" "&YEAR([Start Time]),IF(AND(MONTH([Start Time])>3,MONTH([Start Time])<=6),"2nd Quarter"&" "&YEAR([Start Time]),IF(AND(MONTH([Start Time])>6,MONTH([Start Time])<=9),"3rd Quarter"&" "&YEAR([Start Time]),IF(AND(MONTH([Start Time])>9,MONTH([Start Time])<=12),"4th Quarter"&" "&YEAR([Start Time])))))

    Posted Sep 20 2007, 04:46 PM by mlotter with 11 comment(s)
    Filed under:
  • SharePoint 2007 Product Comparison download

    Over the last few weeks I had several different people ask me what were the differences between SharePoint 2007 Standard and SharePoint 2007 Enterprise and unfortunately I didn't know.  All the clients that I've had in the past all wanted SharePoint 2007 Enterprise because they wanted either Excel Services or BDC so it was never a problem.  I got tired not knowing the answer, so I found this nice document on the Microsoft Office site that explains everything.

     http://office.microsoft.com/en-us/sharepointserver/HA101978031033.aspx

    The Excel document compares the Windows SharePoint Services 3.0, SharePoint Portal Server 2003, Office SharePoint Server 2007 for Search, Office Forms Server 2007, Office SharePoint Server 2007 Standard CAL and Office SharePoint Server 2007 Enterprise CAL or for Internet Site products in the categories of Collaboration, Portal, Search, Content Management, Business Process and Forms, Business Intelligence, Management and Platform.

    Posted Sep 20 2007, 03:26 PM by mlotter with 1 comment(s)
    Filed under:
  • Example of MOSS calculation fields for Month-Year and Quarter-Year from date column

    Recently I was asked to create new Monthly and Quarterly DVWPs for the "Time Card Management" template.  One of the tasks was to create new columns for the Month and Quarter for DVWPs to group the information by. The Year value was tacked on the end to allow for separate year grouping. Below are the formulas for the columns.

    Month-Year

    =MONTH([Start Time])&"-"&YEAR([Start Time])

    Quarter-Year

    =IF(AND(MONTH([Start Time])>=1,MONTH([Start Time])<=3),"1"&" "&YEAR([Start Time]),IF(AND(MONTH([Start Time])>3,MONTH([Start Time])<=6),"2"&" "&YEAR([Start Time]),IF(AND(MONTH([Start Time])>6,MONTH([Start Time])<=9),"3"&" "&YEAR([Start Time]),IF(AND(MONTH([Start Time])>9,MONTH([Start Time])<=12),"4"&" "&YEAR([Start Time])))))

    The calculation for the Quarter column was a little tricky because I wanted to determine what Quarter the month was in but I was able to accomplish it by using the SharePoint help and the below blog entry from Mark Kruger.

    http://www.sharepointblogs.com/mkruger/archive/2007/06/26/howto-using-sharepoint-calculated-columns-to-display-a-list-item-as-quot-x-quot-days-old.aspx

    The SharePoint help helped with the fundamentals and Mark Kruger blog entry helped with the syntax for the Quarter calculation.  Since Mark's entry helped me figure out my problem I figured I would post my calculations hoping it would do the same for someone else.

    Cheers

    Posted Sep 06 2007, 04:36 PM by mlotter with 3 comment(s)
    Filed under:

Need SharePoint Training? Attend a SharePoint Bootcamp!

Posts (c) their respective authors. Everything else (c) 2007 SharePoint Experts