This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// check the current session connections | |
SELECT login_name, [program_name], COUNT(session_id) AS [session_count] | |
FROM sys.dm_exec_sessions WITH (NOLOCK) | |
GROUP BY login_name,[program_name] | |
ORDER BY COUNT(session_id) desc; | |
// session connection based on the individual database | |
SELECT DB_NAME(dbid) AS DBName, COUNT(dbid) AS NumberOfConnections, loginame AS LoginName | |
FROM sys.sysprocesses WHERE dbid > 0 GROUP BY dbid,loginame |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
///summary | |
///DateTime extension is also commonly used | |
///summary | |
public static class DateTimeExtensions | |
{ | |
private const string _auNormalTimeFormat = "hh:mm tt"; | |
private const string _auNormalDateFormat = "dd/MM/yyyy"; | |
private const string _auNormalDateTimeFormat = "dd/MM/yyyy hh:mm tt"; | |
private const string _normalDateFormat = "yyyy-MM-dd"; | |
private const string _normalDateTimeFormat = "yyyy-MM-dd h:mm tt"; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
///summary | |
/// the most common way will be used in string conversion | |
///summary | |
public static class StringExtensions | |
{ | |
public static bool IsNullOrWhiteSpace(this string str) | |
{ | |
return string.IsNullOrWhiteSpace(str); | |
} | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
///Summary | |
///IEnumableExtension is another common used in c# MVC. In the dropdown List | |
///Summary | |
public static class IEnumerableExtensions | |
{ | |
public static string JoinString(this IEnumerable<string> values) | |
{ | |
return JoinString(values, ","); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
///Summary | |
///enum extension are used commonly in C# | |
///Summary | |
public static class EnumExtensions | |
{ | |
public static string GetDisplayText(this Enum e) | |
{ | |
object value = e; | |
FieldInfo fieldInfo = value.GetType().GetField(value.ToString()); | |
if (fieldInfo == null) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Under many situations the web server needs to call the application server which sits in the server server. It will be fine if the server address is used in ip address format. But if the application is also used for external application. So have to use the domain name of the server. so for windows server we need to map the hosts file (system32/dirves/etc/hosts) to the domain name for example: 127.0.0.1 to the xx.com.au domain. Otherwise it will throw a connection time out exception. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/// using system.net.mail API | |
///enable the api using port number. SMTP using 587 | |
public void sendGmail(host, port){ | |
var form="fromEmail"; | |
var to ="toEmail"; | |
var mail = new MailMessage(from, to){ | |
BodyEncoding = Encoding.GetEncoding( | |
Thread.CurrentThread.CurrentCulture.TextInfo.ANSICodePage), | |
Subject ="subject", | |
Body = "", |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
.NET MVC project to speed up the start/load: | |
1: under IIS chose the site and advance setting, set the automatically to true | |
2: application pool advanced setting, set the automatically to true | |
3: CPU interval to 0 | |
4: Rapid-Fail protection to 0 | |
5: Recycling time interval depending on the period when there are more requests | |
6: under web.config system.webServer section add the following (for IIS 7.5 ABOVE) | |
<applicationInitialization skipManagedModules="true"> <add initializationPage="/" /></applicationInitialization> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
.NET MVC4 technology introduction | |
//if have time, I will write the detail information.... | |
front-end(Js library) | |
moment.js --used for date time | |
underscore.js-used for template,ROM | |
jquery/bootstrap | |
datatable.js--used for table | |
stickem.js--used for absulate position | |
date-picker.js--for date time display |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//get the x.509 certificate from the ldaps server and convert to pemstring | |
public String ContextSearchLDAPs() throws NamingException { | |
//create the hashtable to store the parameters to retrieve the data | |
Hashtable env = new Hashtable(); | |
env.put(Context.INITIAL_CONTEXT_FACTORY, "com.sun.jndi.ldap.LdapCtxFactory"); | |
//set the provider URL | |
env.put(Context.PROVIDER_URL, providerURL); | |
//important, this is used to let the server return the binary data | |
env.put("java.naming.ldap.attributes.binary", searchAttribute); | |
// Principal and credentials will be obtained from the connection, // cn,ou,o |
NewerOlder