Showing C# log info continiously in InfoPath - InfoPath Dev
in

InfoPath Dev

Showing C# log info continiously in InfoPath

Last post 10-31-2005 07:25 AM by Matt Faus. 11 replies.
Page 1 of 1 (12 items)
Sort Posts: Previous Next
  • 10-20-2005 01:56 AM

    Showing C# log info continiously in InfoPath

    Hi,

    i have developed an application that submits pictures, documents, custom areas to SharePoint using web services.

    the users click a button and the form they have filled out (repeating file attachments, repeating sections etc) are submitted to sharepoint picture galleries/ document lists / custom lists.

    this works fine, but to keep the user from re-pressing the custom button that uploads data, i write current status information to a status window below the button.

    this window however is only updated when i send back events to the user (like a confirm button or alert).

    this is ofcourse logical, but makes the loggin very lacking -so to speak :-)

    two things i would like to achieve:
    • How do i change the appearance of the custom button after key-press (greying it out, or writing something like "Processing.. please wait". or even better disables the button until processing is finished?
    • What event could i use to enforce that script progress is written to the status window at regular intervals (without using alerts etc)


    Hope this made sense, else ill be happy to elaborate ;-)

    thx
    //AndersR
  • 10-20-2005 06:33 AM In reply to

    Re: Showing C# log info continiously in InfoPath

    Hi Anders,

    For the button, did you try conditional formatting to disable your button whenever a node in the schema was flagged to "false" (for example) when that button is clicked?
    For your second issue, did you try to use the Task Pane?

    Regards,

    Franck Dauché
  • 10-20-2005 12:16 PM In reply to

    Re: Showing C# log info continiously in InfoPath

    Hi Franck

    thanx for your replies

    About the conditional formatting: im quite new to InfoPath (worked with it a week straight, but feeling still feeling more comfy in VS.NET that i have worked with for years, than in InfoPath ;), could you explain what setup you had in mind?

    As i see it it would require that i can access the button throught the button click EventArgs -is that possible?


    Ahh the task pane... Didnt think of that!
    I worked with that before in word, but will it give me better functionality as a logging device.. hmm ill take a look at it tomorrow thanx!


  • 10-20-2005 01:19 PM In reply to

    Re: Showing C# log info continiously in InfoPath

    OK, so in that case, you are using VS to create a new form. Drop a button on your form and a textbox (field1).
    Right-click and Properties / Go to Display Tab / Conditional Formating / Add:
    field1 is equal to "false" / Disable this control. Click Ok / Click Ok.
    Go back to the General Tab / Click "Edit Form Code..."
    In there, you need to set the value of field1 to false
    thisXDocument.DOM.selectSingleNode("/my:myFields/my:field1").text = "false";

    Run your form and click your button...Voila.

    Regards,

    Franck Dauché
  • 10-21-2005 12:32 AM In reply to

    Re: Showing C# log info continiously in InfoPath

    Hi

    disabling the button works like a charm!

    even re-enabling it when user cancels!

    excellent, thx! :-)

    about the task pane:
    i implemented that too, but it seems to work just like the "in-form" status window: window isnt updated until after the whole batch of listitems, documents and images has been uploaded to SPS -so no real improvement there im afraid :-(

    Does anyone have any other suggestions as how to instantly communicate status messages to a status window (taskpane textarea or textbox) as the managed code is iterated?

    thanx
    //AndersR

    ps:
    if anyone is interested here's how i write to the taskPane from managed code (C#):
    -add taskpane html to project under Form Options > Advanced
    -add Microsoft.mshtml.dll to project (its under .NET components tab)
    //define task pane as global field (i write to it using a method)
    private mshtml.IHTMLTextAreaElement statusWindow;

    private void WriteStatus( string msg )
    {
    statusWindow.value += msg + Environment.NewLine;
    }

    //initialize task pane
    HTMLTaskPaneObject taskPane = (HTMLTaskPaneObject)thisXDocument.View.Window.TaskPanes[0];
    //find the ID on the <textarea id="StatusWindow" />
    //and cast it as a textArea
    statusWindow = (mshtml.IHTMLTextAreaElement)taskPane.HTMLDocument.all.item("StatusWindow",0);
    statusWindow.value = String.Empty;

    WriteStatus("test");

  • 10-22-2005 01:37 PM In reply to

    Re: Showing C# log info continiously in InfoPath

    Hmm noone have any idea on how to, on the fly, pass on messages to a taskpane / textbox from managed code?

    The only way so far i have found is when i fire an alert / confirm or other UI event.

    I want to keep the user informed in the status window on the upload process of elements of a form to lists in sharepoint. We're talking +100 images so it will take some time and hence i dont want the user to be "in the dark" on whats going on.

    Maybe Mr Halstead himself have an idea on how to accomplish this? :-)
    thanx
    //Anders


  • 10-22-2005 05:17 PM In reply to

    Re: Showing C# log info continiously in InfoPath

    Hi Anders,

    You need to use the OnContextChange event to pass messages "on the fly" to the taskpane.

    Regards,

    Franck Dauché
  • 10-23-2005 11:56 PM In reply to

    Re: Showing C# log info continiously in InfoPath

    Thanx again franck, ill look into it!


  • 10-27-2005 01:27 AM In reply to

    Re: Showing C# log info continiously in InfoPath

    Hmm this actually didnt work!

    The problem is that im pressing a button and in the onclick event im doing alot of transferring lists and documents using web services to WSS, so no OnContextChange event is fired since no focus is shifted!

    Any other suggestions on how to force writing in either a textfield in the form or a textarea in a context menu?

    thx
    //AndersR


  • 10-28-2005 10:50 PM In reply to

    Re: Showing C# log info continiously in InfoPath

    When you press the button, you can call SelectNodes or something to change context. That should result in a firing of the OnContextChange. Kind of a side-effect I guess. Buttons are a special case since they don't bind to data source.

    Patrick Halstead [InfoPath MVP]
    InfoPathDev
    Patrick Halstead
    Project Manager at Qdabra
  • 10-31-2005 12:14 AM In reply to

    Re: Showing C# log info continiously in InfoPath

    Hmm im calling SelectSingleNode and SelectNodes on several occasions after pressing the button, but no OnContextChanged is triggered!

    Also setting the textarea / textbox that is my status window is not triggering events.

    The form itself is used as a tool to upload surveys to a WSS site comprised of 3 sharepoint custom lists, a picture gallery and a document library. There can be over a hundred pictures, so it would be real nice to be able to show some progress for the user...

    thanx for your input
    //AndersR


  • 10-31-2005 07:25 AM In reply to

    Re: Showing C# log info continiously in InfoPath

    Here's an idea for a workaround that might be helpful.

    After the user hits submit, "ping" the sharepoint server with a fixed-size image file that you have as a resource file in your form. Time how long it takes to upload this image to the server and then calculate the total amount of data (in KB, MB, etc.) that you will be uploading. Using the "ping" time that you got from the first image you could estimate rather accurately for a larger set of data and make a "psuedo-progress bar". Say a 100KB image takes 4.9 seconds to upload and the user wants to submit 100MB of images you would make a bar that goes from 0% to 100% in 81.6 minutes (1h 21.6m) (using 1MB = 1000KB).

    Not sure how this would work out, and it's not going to be completely accurate, but it's a start!

    ---------------
    Matt Faus
    Matt Faus / Microsoft InfoPath MVP
    Qdabra® Software / Streamline data gathering to turn process into knowledge
Page 1 of 1 (12 items)
Copyright © 2003-2019 Qdabra Software. All rights reserved.
View our Terms of Use.