Wednesday 20 April 2011

How to Enqueue Submits While Offline



How to Enqueue Submits While Offline


Scenario:


User fills out forms for a particular form template while the laptop is disconnected from the network.  Upon reconnection, seamlessly syncrhonize the offline forms to a Windows SharePoint Services form library.



Solution:


Using OnSubmitRequest, you can have the code save to the offline folder depending on if we're offline or not, as in the following code, which is written in C# using our Visual Studio .NET Toolkit.  You will also need to add a project reference to System.Xml.dll and the using System.XML; directive to your form code.


public void OnSubmitRequest(DocReturnEvent e)



{


if (thisApplication.MachineOnlineState == XdMachineOnlineState.Online)

{

// submit to Sharepoint using DAVAdapter

(thisXDocument.DataAdapters["Submit to Sharepoint"] as DAVAdapter).Submit();

}

else

{

// We are offline or working offline.

XmlDocument oDOM = new XmlDocument();

Microsoft.Office.Interop.InfoPath.SemiTrust.IXMLDOMDocument oWrappedDOM = thisXDocument.DOM;


oDOM.PreserveWhitespace = true;

oDOM.LoadXml(oWrappedDOM.xml);

oDOM.Save("C:SubmitForm_"

+ DateTime.Now.ToString("yyyy.MM.dd_HH.mm.ss.ff") + ".xml");

}


e.ReturnStatus = true;

}


Then, if you've been offline for a while and a number of files have built up, you can run the following jscript to invoke InfoPath externally and force a submit looping through the files, as below:




var oFileSys = new ActiveXObject("Scripting.FileSystemObject");

var oSubmitDir = oFileSys.GetFolder("C:Submit");

var oFilesInSubmitDir = new Enumerator(oSubmitDir.Files);


var oApp = new ActiveXObject("InfoPath.Application");


var fso = new ActiveXObject("Scripting.FileSystemObject");


for (; !oFilesInSubmitDir.atEnd(); oFilesInSubmitDir.moveNext())

{

var strFileName = oFilesInSubmitDir.item().Name.toLowerCase();


if (strFileName.length >= 4

&& strFileName.lastIndexOf(".xml") == (strFileName.length - 4))

{

try

{

var oDoc = oApp.XDocuments.Open(oFilesInSubmitDir.item().Path);

oDoc.Submit();

oDoc.View.Window.Close();


var f = fso.GetFile(oFilesInSubmitDir.item().Path);

f.Delete();


}

catch (e)

{

WScript.echo("ERROR: " + e.description);

}

}

}

oApp.Quit();




The InfoPath 2003 SP1 Preview



Do you know about the InfoPath 2003 SP1 Preview release? There are actually two free downloads available:




  1. The InfoPath 2003 SP1 client: new features and improvements added to the InfoPath client.

  2. The InfoPath 2003 Visual Studio toolkit: this provides the ability to write .NET managed code business logic in your InfoPath form.


Anyone can download and install this version of InfoPath and use it until it expires.


When the Office System 2003 SP1 is released (mid-2004), InfoPath will be updated to have many new features, in addition to performance improvements and bug fixes (and if you just want the performance improvements and bug fixes, the new features can be turned off).  The SP1 is completely backwards compatible with InfoPath 2003.


This preview gives you a chance to try out an initial version of the SP1 bits now so that you can learn the new features and plan for the SP1 deployment within your company.


The SP1 release is very important in that we were able to address customer wishes.  Give it a try!  We're certainly excited about it and will be posting about InfoPath SP1 here often (and we'll make it clear when a post is SP1 specific).




Welcome to the InfoPath

The InfoPath Team is looking forward to posting a variety of topics for our InfoPath users, including:

  • Feature highlights.

  • Code snippets.

  • Our best practices.

  • Tips 'n Tricks.

  • Common work-arounds.

  • Show how to leverage other Microsoft technology with InfoPath.


We're super-excited about InfoPath and look forward to helping our customers realize the most they can out of our new Office System 2003 application.

Please leave some feedback if there are areas you'd like to see us cover

Change of Apache port in xamp http.config file

Change apache port in xamp http.config file
C://xamp/apache/config/--> change localhost 80 to 8080

Sample example of error message infomation for site

Sorry, an error has occurred...

Unfortunately an error has occurred during the processing of your page request. Please be assured we log and review all errors, even if you do not report this error we will endeavor to correct it.

Google:
500. That’s an error.

The server encountered an error and could not complete your request.

If the problem persists, please report your problem and mention this error message and the query that caused it. That’s all we know.

URL Redirection on HTML Head meta code

<html>
<head>
<title></title>
<meta HTTP-EQUIV="REFRESH" content="0; url=http://domain.com/">
</head>
<body>
</body>
</html>

Display Logo & banner from SQL Server Database

<%
string sql = "select * from header";
string href = "";
string src = "";
string title = "";

foreach (DataRow dr in DbConnection.GetData(sql).Tables["ResultTable"].Rows)
{

href = dr["header_href"].ToString();
src = dr["header_src"].ToString();
title = dr["header_title"].ToString();

}
}

%>
<span><a href="Default.aspx"><img src="images/logo.png" alt="logo" border="0px"/></a></span>

<span><a href="<%=href %>" title='<%=title %>' target="_blank"><img src="<%=src %>" alt="<%=title %>" border="0px"/></a></span>

<%--<span><a href="banner.aspx" title=' banner title' target="_blank"><img src="images/banner.jpg" alt="banner" border="0px"/></a></span>--%>

Email contact form in php

<html>
<head>
<script src="calendar.js"></script>
<style>
input {border:1px solid #ABABAB}
</style>
</head>
<body>

<?php

$t=$_GET['to'];
if ($t=="m")
//if "email" is filled out, send email
{
$t="to@mail.com";
}
else
//if "email" is not filled out, display the form
{
$t="your@mail.com";
}

?>

<form method='post' action='mailform.php'>

<input name='to' type='hidden' value='<?php echo $t; ?>' />

Email: &nbsp;&nbsp;
<input name='email' type='text' /><br />
Subject: <input name='subject' type='text' /><br />
Date &nbsp;&nbsp; :
<input name='todate' onclick="event.cancelBubble=true;this.select();lcs(this)" onfocus="this.select();lcs(this)" type="text" value="dd/mm/yy" /><br />
Message:<br />
<textarea name='message' rows='15' cols='40'>
</textarea><br />
<input type='submit' />
</form>

</body>
</html>

mailform.php

<?php

$to = $_REQUEST['to'];
$subject = "New Appointment on ".$_REQUEST['todate'];
$message = $_REQUEST['message'];
$from = $_REQUEST['email'];
$headers = "From: $from";
mail($to,$subject,$message,$headers);
echo "Mail Sent to the concerned doctor.";

?>

Stored Procedures Questions and Answers

Why do stored procedures reduce network traffic?

When a stored procedure is called, only the procedure call is sent to the server and not the statements that...
What are stored-procedures? And what are the advantages of using them.

Stored procedures are database objects that perform a user defined operation. A stored procedure can have a set of compound...
What is stored procedure?

Stored procedure is a group of SQL statements that forms a logical unit and performs a particular task. Stored Procedures...
What is the advantage of using stored procedure over the SQL queries ?

Writing the SQL statements inside our code is usually not a good idea. In this way you expose your database...
Can you have a nested transaction ?

Yes, very much. Check out BEGIN TRAN, COMMIT, ROLLBACK, SAVE TRAN and @@TRANCOUNT

What is an extended stored procedure?

Can...
How can I return from within a T-SQL the list of all available character sets and code pages ?

You can use the xp_enumcodepages undocumented extended stored procedure to return the list of all available character sets and code...
How do I report information about the active locks ?

To report information about the active locks, you can use the sp_lock system stored procedure. Read about the sp_lock stored procedure...
What is normalization ?

Well a relational database is basically composed of tables that contain related data. So the Process of organizing this data...
What is a DATABASE trigger ?

What is a DATABASE Procedure ?

A DATABASE TRIGGER is a stored procedure associated with a table that ORACLE7 automatically executes on one or more specified...
How can I return from within a T-SQL the list of server’s hard drives ?

You can use the xp_fixeddrives undocumented extended stored procedure to return the list of all hard drives and the amount...