Technical stuff you probably wouldn't understand.

Rather than cluttering up other blogs with my musings, I made my own.

Monday, May 22, 2006

Infopath "The file is in use by another application or user."

Interesting error... Confusing... Not at all helpful or accurate. What to do?

  1. This issue is not consistant across all users.
    1. One user with the issue is on XP Pro, sp1
    2. Another without the issues is on XP Pro, sp2... need to investigate.

Related threads:
  1. microsoft.infopath via google groups - Unresolved

Infopath Security - Certificates

Seems like creating a certificate for your managed code will be the way to go. I'm retracing my steps and will document the process here. Note that I'm using VS2005 and Infopath 2003 sp2:

  1. MSDN Article
  2. Certmgr in C:\Program Files\Microsoft Visual Studio 8\SDK\v2.0\Bin
    1. One tool for visualizing your certificates.
  3. Certificate Management Console
    1. This is a more comprehensive tool for managing certificates.
    2. Infopath requires (it seems) your certificate to be in the Personal section.
  4. Keep it secret, keep it safe. Really. Once you create your key and start deploying signed documents that use it, you MUST have a safe and secure location to store it.
    1. Export the key, put it on a cd and lock it up.
    2. If you want to develop on another machine, you'll need to install this key. You cannot simply recreate a key with the same name. Keep it safe.
    3. As an example using Infopath and a Sharepoint Forms lib:
      1. You publish an IP form with your new cert.
      2. Users create forms (they accept the certificate), and save the forms.
      3. You lose the cert, and create a new one.
      4. You republish the form with the new certificate.
      5. A new user tries to open an old form, created with the old certificate. At best, you've got a confusing situation, since you now have two certificates with the same name, but different keys. One doc uses the old, another uses the new.
I guess that's it.

Thursday, May 04, 2006

Infopath Timer

I found some good tips on this issue, and built a little bit-o code to make a timer for a detail record. Needs to be broken down into reusable classes, but the concept is usable as-is.

I'll clear it and shoot the code. Psudo-code to follow.

Note: Infopath SP1, using VB.Net Form Code.

1) Add the following fields to the level of your doc that can be timed. (For example if you have a heder with multiple details, you may want to start a timer at each detail item, so each would need these fields):
  • TimerRunning, Boolean, False
  • TimerStartTime, DateTime
  • ElapsedDuration, Decimal
2) Add a button control, and and click "Edit Form Code" to create an event.

  • Test e.Source.selectSingleNode("ActTimerRunning").text = "true". Then true, the timer is running for this item, and the stop and accumulate code executes
    • Turn the timer flag to off
    • Calculate Elapsed time by comparing the current system time to our timer flag
e.Source.selectSingleNode("ActTimerRunning").text = "false"
ldc_elapsed = Math.Round(System.DateTime.Now().Subtract(Iso8601ToDate(e.Source.selectSingleNode("ActStopDateTime").text)).TotalHours, 2) ' Calc elapsed and Round to two decimal places.


ldc_currentActDuration = CType(e.Source.selectSingleNode("ActDuration").text, Decimal)
e.Source.selectSingleNode("ActDuration").text = (ldc_currentActDuration + ldc_elapsed).ToString
e.Source.selectSingleNode("ActStopDateTime").text = DateToIso8601(DateTime.Now)

  • Timer is not running, exec Start Timer logic
    • e.Source.selectSingleNode("ActTimerRunning").text = "true"
    • e.Source.selectSingleNode("ActStopDateTime").text = DateToIso8601(DateTime.Now)



) Date Util functions for Infopath VB.Net
These two functions allow you to convert dates to/from infopath friendly date formats. (Note, this date format is an ISO standard imposed by the XML Consortium, not by MS or Infopath).

Private Function Iso8601ToDate(ByVal iso8601Date As String) As DateTime

Dim provider As IFormatProvider

If (iso8601Date Is DBNull.Value) Then

Throw New ArgumentNullException("iso8601Date")
End If


Return DateTime.ParseExact(iso8601Date, "yyyy-MM-ddTHH:mm:ss", provider)


End Function


Private Function DateToIso8601(ByVal adtdateTime As DateTime) As String


Return adtdateTime.ToString("yyyy-MM-ddTHH:mm:ss")


End Function

Boring computer stuff...

Some may find it boring, others, with time on their hands or issues similar to mine may find the discussions mildy amusing.

/bob