Jack @ ASP.NET

As a software engineer, I focus on .NET, especially asp.net, C#, WCF and so on, and I am also very interested in Search Engine Optimization.

Entries for April, 2011

Optional Parameters in C# 4.0

Just like other languages such as vb, and c/c++, C# can support the optional parameters from 4.0.

here is a code snippet

   1:  class Program
   2:  {
   3:      static void Main(string[] args)
   4:      {
   5:          MyTest("P1", "P2");
   6:          MyTest("P1");
   7:      }
   8:   
   9:      static void MyTest(string parameter1, string parameter2="Default Value 2")
  10:      {
  11:          Console.WriteLine("Para1={0}, Para2={1}", parameter1, parameter2);
  12:      }
  13:  }

And the returning result will be

Para1=P1, Para2=P2

Para1=P1, Para2=Default Value 2

and the parameter2 will use the default value in the definition if you do not give a value. Quite convenience, isn’t it?

Pipeline in PowerShell

PowerShell uses a pipeline for all command entries, which feeds the results of the preceding command directly into the subsequent command. The pipeline is active even when you enter only a single command because PowerShell always automatically adds the Out-Default cmdlet at the pipeline’s end so that it always results in a two-member instruction chain.

Single command results are passed as objects. The cmdlets can filter, sort, compare, measure, expand, and restrict pipeline elements. All cmdlets accomplish this on the basis
of object properties. In the process, the pipeline distinguishes between sequential and streaming modes. In streaming mode, command results are each collected, and then passed in mass onto the next command. Which mode you use depends solely on the pipeline commands used. Output cmdlets dispose of output. If you specify none, PowerShell automatically uses Out-Host to output the results in the console. However, you could just as well send results to a file or printer.

All output cmdlets convert objects into readable text while formatting cmdlets are responsible for conversion. Normally, formatting cmdlets convert only the most important, but if requested, all objects into text. The Extended Type System (ETS) helps convert objects into text. The ETS uses internal records that specify the best way of converting a particular object type into text. If an object type isn’t in an ETS internal record, the ETS resorts to a heuristic method, which is guided by, among other things, how many properties are contained in the unknown object.

In addition to traditional output cmdlets, export cmdlets store objects either as comma-separated lists that can be opened in Excel or serialized in an XML format. Serialized objects can be comfortably converted back into objects at a later time. Because when exporting, in contrast to outputting, only plain object properties, without cosmetic formatting, are stored so that no formatting cmdlets are used.

Call SQL Server Management Objects (SMO) in C#

Overview of SMO

SQL Server Management Objects (SMO) are objects designed for programmatic management of Microsoft SQL Server. You can use SMO to build customized SQL Server management applications. Although SQL Server Management Studio is a powerful and extensive application for managing SQL Server, there might be times when you would be better served by an SMO application.

SMO in SQL Server 2008 is compatible with SQL Server 2000, SQL Server 2005, SQL Server 2008 and SQL Server 2008 R2. SMO in SQL Server 2005 is compatible with SQL Server 2000, SQL Server 2005. So, you can easily manage a multi-version environment with a higher version of SMO.

Install SMO

Microsoft SQL Server 2008 Management Objects Collection (a component of Feature Pack for Microsoft SQL Server 2005/2008)

The Management Objects Collection package includes several key elements of the SQL Server 2008 management API, including Analysis Management Objects (AMO), Replication Management Objects (RMO), and SQL Server Management Objects (SMO). Developers and DBAs can use these components to programmatically manage SQL Server 2008.

By default, the SMO assemblies are installed in the C:\Program Files\Microsoft SQL Server\100\SDK\Assemblies, you can track this folder to see whether SMO installed successfully.

 

Call SMO in C#

These are the minimum files that are required to build an SMO application, and they are under the C:\Program Files\Microsoft SQL Server\100\SDK\Assemblies\ folder

Microsoft.SqlServer.ConnectionInfo.dll

Microsoft.SqlServer.Smo.dll

Microsoft.SqlServer.Management.Sdk.Sfc.dll

Microsoft.SqlServer.SqlEnum.dll

Here is a demo of script all jobs in sql server

   1:  Server server = new Server(ServerName);
   2:  JobServer server2 = server.JobServer;
   3:  foreach (Job job in server2.Jobs)
   4:  {
   5:      WriteToFile(job, PathToWriteScripts);
   6:  }

Globalization and Localization in ASP.NET

Internationalization involves Globalization and Localization. And the globalization is the process of designing applications that support different cultures. While localization is the process of customizing an application for a given culture.

The format for the culture name is "<languagecode2>-<country/regioncode2>", where <languagecode2> is the language code and <country/regioncode2> is the subculture code. Examples include es-CL for Spanish (Chile) and en-US for English (United States).

ASP.NET keeps track of two culture values, the Culture and UICulture. The culture value determines the results of culture-dependent functions, such as the date, number, and currency formatting. The UICulture determines which resources are to be loaded for the page by the ResourceManager. The ResourceManager simply looks up culture-specific resources that is determined by CurrentUICulture. Every thread in .NET has CurrentCulture and CurrentUICulture objects. So ASP.NET inspects these values when rendering culture-dependent functions. For example, if current thread’s culture (CurrentCulture) is set to "en-US" (English, United States), DateTime.Now.ToLongDateString() shows "Saturday, January 08, 2011", but if CurrentCulture is set to "es-CL" (Spanish, Chile) the result will be "sábado, 08 de enero de 2011".

Solid State Design Considerations

In this size range single-phase units, in contrast, a large three-phase units, relatively simple (4 PC board), easy to service English speaking technical personnel to give the scene. Solid-state design is not suitable for carrying large equipment components (silicon, transistors, IGBT, high capacity dimmers, welders, etc.), feed distortion back unless you take the line on it, or have taken isolated and filters the distortion. Rotary unit can be used to handle these goods (and, in fact, often used to isolate the same from others such as plant load) – be sure to specify the load, and our application engineers to discuss rotating or solid state frequency converter unit properties.

Three-phase units (5KVA and above) using our solid-state IGBT’s design should be considered as options in these applications, including:

Any person less than 25% of the load motor is at full capacity.
50% or more of the cost difference is acceptable (as opposed to rotating design) to achieve quieter operation and rotation of the three options, special circumstances can not be achieved. Instead, a rotating design unit should always be cheaper (more than 12KVA), particularly so if the motor and start the surge in (click rotation here)
An ability to speak English, use an oscilloscope or a unit with electrical and technical personnel can easily return to any repair facility (in other words, it is in the United States or nearby), and of course need to (or, if the case of non-warranty repairs You are willing to pay the travel, expenses, parts and labor of our staff visited the site.)
SCR, thyristor, and similar equipment, feed distortion into the supply line (our units in this case) do not constitute more than 20% back to the load or the input filter or isolation built-in.

For small motors and sub-scores involving motor, starter motor design capacity of the limited application of solid-state surge is usually needed on the determinants of the size of kVA. For comparison, we rotate the smallest unit of a single phase 6KVA will start and run a 2.5hp, design of the motor and generator oversizing F code can be designed to handle up to a 27kw pump: 4HP engine “across the line cycle.” We offer to start the motor up to 1500hp 2000KVA rotating units.

Formula Drift chooses Brakohiapa for Inaugural Abu Dhabi Invitational

San Francisco, California: Tony Brakohiapa Formula One driver to Formula Drift Drift was busy in Abu Dhabi, United Arab Emirates (UAE), the first Formula One event in Aspen stadium ready terminals. Brakohiapa honored to join Donald Foster, Chris Forsberg, Formula Drift and selected by the organization for the February 25 meeting of the International Activities of the other drivers.

The new Aspen terminal circuit characteristic equation, motorcycles, Abu Dhabi, Australia, trailer tires and wheels, etc. Super V8 is the world’s fastest growing tourist destination, the event should attract one of the world-class people.

“Clearly, Abu Dhabi has a professional rafting race management, which is committed to providing world-class racing venue concerns. I look forward to becoming a F1 drift as a member of the team, saying:” Brakohiapa. Brakohiapa by sharing in the Facebook and Twitter (@ brakohiapa) fans in real time to update their first visit to the UAE.

Brakohiapa, 2009 Formula Drift private, is fully prepared, after had a very busy 2010 schedule. Highlights include Las Vegas in Las Vegas completed the first 4 Formula D, Ken Block runs in the first professional Gymkhana activities to on-line TV shows SGNL special guest to review Sony’s new GT Electronics Turismo 5 video game.

Brakohiapa would like to thank all the support of his sponsors. Specifically, Mark Skorka activities in preparation for the special wild horse and Cooper Tire Brakohiapa Sinergy racing tires, Upland, Ca. Other sponsors include Glazier Iron Works, Sam’s town car, barn style performances, ToiBoy production, Exedy, Eibach, Enkei, Seibon, go pro, Sparco and Realperformancemustangs.com