Technical stuff you probably wouldn't understand.

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

Thursday, March 29, 2007

My Favorite FireFox AddIns

Just a list of links. This is kind of a selfish post, as I can use this to install the add-ons from one page.
That's it.

Labels: ,

Thursday, August 10, 2006

Providing feedback for textbox controls using Datawindow.Net


 

Microsoft

Feedback

Note, this blog post was delivered via Microsoft Word 2007 using it’s new Blog publishing feature.


 

8/10/2006


 


 


 


 


 


 


 


 


 


 


 

http://www.codeproject.com/aspnet/TextBoxCounter.asp?df=100&forumid=247992&exp=0&select=1393971


 

http://www.dmxzone.com/forum/topic.asp?topic_id=21084

Wednesday, June 28, 2006

Sharepoint document uploads with support for versioning.

This post is a continuation/addition to the post by Erika Ehrli

I successfully implemented the sample, and with some small modifications came up with an enhancment to allow the document to be uploaded from a stream instead of a file on the file system.

One tidbit that I added to my client app was to pass the credentials from the client to the web service. Now when I call iMJContactWebService.UploadDocumentToSharePoint my credentials are passed on.

...
iMJContactWebService = New wsMJ_ContactServices.Service
iMJContactWebService.Credentials = System.Net.CredentialCache.DefaultCredentials ' see Setting credentials http://support.microsoft.com/default.aspx?scid=kb;en-us;813834
...

Heres the modified ws code:


Public Function UploadDocumentToSharePoint(ByRef asDocName As String, ByVal asdocumentContents As String) As String
' 20060601 R.Chauvin bob_chauvin@yahoo.com
' adapted from http://blogs.msdn.com/erikaehrli/archive/2006/05/04/SharePointUploadHelper.aspx?CommentPosted=true#commentmessage
Dim svcDocLoader As DocumentLoader.SPFiles = New DocumentLoader.SPFiles()
svcDocLoader.PreAuthenticate = True
svcDocLoader.Credentials = CredentialCache.DefaultCredentials

'Dim strPath As String = asdocumentContents
'Dim strFile As String = strPath.Substring(strPath.LastIndexOf("\\") + 1)
Dim strDestination As String = _sharepointDocumentLibrary
If as_doclibpath = "" Then as_doclibpath = _sharepointDocumentLibrary

Dim binFile() As [Byte] = System.Text.Encoding.UTF8.GetBytes(asdocumentContents)

Dim result As String = svcDocLoader.UploadDocument(asDocName, binFile, strDestination)
asDocName = strDestination & "/" & asDocName

Return (result)

End Function

Finally, I needed to modify the WSCheckout sample webservice from Microsoft to allow for document updates as well as adds. After some research, I found the WSS v2 SDK had all the methods laid out for the SPFile class, including the Add method with it's optional overwrite parameter.

After a simple change (with some enhanced return value code), the method now Adds and Updates to the document library. If you have enabled versioning in the sharepoint document library, updates will create a new version of the file.


public string UploadDocument(string fileName, byte[] fileContents, string targetFolder)
{

string ls_Return, ls_fileURL;
bool lb_Found = false;

if (fileContents == null)
{
return "Null Attachment";
}
try
{
SPFolder folder = targetWebSite.GetFolder(targetFolder);
ls_fileURL = targetFolder + '\\' + fileName;

try
{
SPFile file = GetFile(ls_fileURL);
lb_Found = true;
}
catch (Exception ex)
{
// file not found exception

} //try

if (lb_Found)
{
SPFile newFile = folder.Files.Add(fileName, fileContents, true);
ls_Return = newFile.Title + "; Updated " + newFile.TimeCreated.ToLongDateString(); //+ "; guid=" + newFile.UniqueID();;
}
else
{
SPFile newFile = folder.Files.Add(fileName, fileContents);
ls_Return = newFile.Title + "; Created " + newFile.TimeLastModified.ToLongDateString(); //+ "; guid=" + newFile.UniqueID();;

}


return ls_Return;
}
catch (System.Exception ee)
{
return "Exception: " + ee.Message + "; " + ee.Source;
}
}


Thanks again to Erika Ehril for getting me started...

Friday, June 16, 2006

VSTO v2 and v3, Cypress, Version Compatability?

I'm just starting to review these apps. Some starting points:

) My current environment includes:
  • Office 2003
  • VSTO 2005 for Office 2003
  • Outlook 2003 Add-in
  • Infopath 2003 forms with managed code.
  • Infopath 2007 Beta

) The "preferred"MSDN Newsgroup for VSTO Questions.

) When I try to install the Cypress release, the installer complains with:
"The Microsoft Office InfoPath 2003 Toolkit for Visual Studio 2005 must be uninstalled."

) I have posted to the newsgroup trying to verify that I wont loose compatability with my Office 2003 development efforts. The initial feedback indicates that cypress is NOT backward compatable..

Wednesday, June 14, 2006

This is MUST HAVE in your toolbox. C# to VB.Net

Check out this site http://www.KamalPatel.net/ .

The C# to VB.NET saved me many hours. Many thanks Kamal Patel!

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