1) Service account must be added to the IIS_WPG group
2) Add a new application domain and set the identify to the service account
3) Update the web.config to use trusted connections
October 5, 2009
IIS – Service account in application pool
June 25, 2009
RegEx: Match word boundaries
// matches “forfeiture” or “52″
System.Text.RegularExpressions.Regex rg = new Regex(@”\bforfeiture\b|\b52\b”, RegexOptions.IgnoreCase);
Match m = rg.Match(“forfeiture 52 dkjf 520 foooj”);
while (m.Success)
{
string s = m.ToString();
m = m.NextMatch();
}
March 19, 2009
March 9, 2009
RegEx: Replace string within a file
Sample Call
ReplaceInFile(@”x:\setup\P8574.T857402.R45.T107801.CSV”, @”\s{65,}”, System.Environment.NewLine);
/// <summary>
/// Replaces text in a file.
/// </summary>
/// <param name=”filePath”>Path of the text file.</param>
/// <param name=”searchText”>Text to search for.</param>
/// <param name=”replaceText”>Text to replace the search text.</param>
static public void ReplaceInFile( string filePath, string searchText, string replaceText )
{
StreamReader reader = new StreamReader( filePath );
string content = reader.ReadToEnd();
reader.Close();
content = Regex.Replace( content, searchText, replaceText, RegexOptions.Singleline);
StreamWriter writer = new StreamWriter( filePath );
writer.Write( content );
writer.Close();
}
December 1, 2008
November 18, 2008
Enterprise Library Data – Retrieving XML from SQL Server
SqlDatabase db = (SqlDatabase)DatabaseFactory.CreateDatabase();
SqlCommand cmd = (SqlCommand)db.GetStoredProcCommand(“usp_GetProjects_XML”);
db.AddInParameter(cmd, “AirID”, SqlDbType.Int, airID);
XmlReader xmlRdr = null;
StringBuilder sbData = new StringBuilder();
try
{
xmlRdr = db.ExecuteXmlReader(cmd);
while (!xmlRdr.EOF)
{
if (xmlRdr.IsStartElement())
{
sbData.Append(xmlRdr.ReadOuterXml());
sbData.Append(Environment.NewLine);
}
}
}
finally
{
if (xmlRdr != null)
{
xmlRdr.Close();
}
// Explicitly close the connection. The connection is not closed
// when the XmlReader is closed.
if (cmd.Connection != null)
{
cmd.Connection.Close();
}
}
return = sbData.ToString();
October 6, 2008
XML – sp_xml_preparedocument replacement
*** Get TABLE *** DECLARE @xml xml SET @xml = ... SELECT T.c.value('Text[1]','varchar(35)') AS MyText , T.c.value('Selected[1]','varchar(5)') AS Selected FROM @xml.nodes('/AIRInfo/Platform/ArrayOfListItem/ListItem') T(c) -- ???? *** Get value directly *** @ProjectInfo.value('(/ProjectInfo/project_type_id)[1]', 'int') *** SELECT *** vm.AfterTaxYrOfFirstContrib As "AfterTaxYrOfFirstContrib" , m.ex_user_id As "PersonalInfo/MemberID" *** Check to see if a value exists within the XML *** @XML.exist('//Selected/../Text[. = "SQL"]')
September 13, 2008
ASPX – CheckBoxList RequiredFieldValidator
function ValidateCheckBoxList(source, args)
{
var chkList = document.getElementById(‘<%= lbChangeType.ClientID %>’);
var chkLista= chkList.getElementsByTagName(“input”);
for(var i=0;i<chkLista.length;i++)
{
if(chkLista[i].checked)
{
args.IsValid = true;
return;
}
}
args.IsValid = false;
}
</script>
July 6, 2008
CSS: Backgrounds sample
background: url(/approvalrunner/images/MenuRepeat.png) repeat-x 100% -2px;
image > no-repeat; repeat-x;repeat-y > x (100% of x, 15px of x) > y (same as x)
x or y – negative is x number of pixels into image; positive x number of space then start of image