Alvin’s Blog

October 5, 2009

IIS – Service account in application pool

Filed under: .NET, IIS — amcbride @ 6:20 pm

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

June 25, 2009

RegEx: Match word boundaries

Filed under: RegEx — amcbride @ 6:11 pm

// 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

CSS: Prevent extra line with

Filed under: CSS — amcbride @ 1:02 am

<pre style=”display: inline”>

March 9, 2009

RegEx: Replace string within a file

Filed under: .NET, RegEx — amcbride @ 11:43 pm

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

VS – Reset skipped packages

Filed under: .NET — amcbride @ 10:54 pm

devenv /resetskippkgs

November 18, 2008

Enterprise Library Data – Retrieving XML from SQL Server

Filed under: .NET — amcbride @ 9:48 pm
Tags: ,

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();

XBAP – Clear cache

Filed under: WPF — amcbride @ 1:55 am
Tags:

mage -cc

October 6, 2008

XML – sp_xml_preparedocument replacement

Filed under: SQL Server — amcbride @ 11:54 pm
*** 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

Filed under: .NET — amcbride @ 5:14 pm
Tags: ,
<script type=”text/javascript”>
        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

Filed under: CSS — amcbride @ 6:30 pm

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

Next Page »

Blog at WordPress.com.