Talks on Thoughts, Work Experience, Issues and Problems Encountered,Learning of BizTalk Server as Integration Layer
Saturday, November 20, 2010
configuration management database (CMDB)
Before sometime writing to this post i was also among you people about what is CMDB, but after doing some research i came to know that it is very helpful for Enterprise Level Applications and Infrastructure projects.
Here i am sharing some basics with you to familiar with CMDB
DEFINITION -
A configuration management database (CMDB) is a database that contains all relevant information about the components of the information system used in an organization's IT services and the relationships between those components. A CMDB provides an organized view of data and a means of examining that data from any desired perspective. Within this context, components of an information system are referred to as configuration items (CI). A CI can be any conceivable IT component, including software, hardware, documentation, and personnel, as well as any combination of them. The processes of configuration management seek to specify, control, and track configuration items and any changes made to them in a comprehensive and systematic fashion.
The IT Infrastructure Library (ITIL) best practices standards include specifications for configuration management. According to ITIL specifications, the four major tasks of configuration management are:
(1)Identification of configuration items to be included in the CMDB
(2)Control of data to ensure that it can only be changed by authorized individuals
(3)Status maintenance, which involves ensuring that current status of any CI is consistently recorded and kept updated
(4)Verification, through audits and reviews of the data to ensure that it is accurate.
Guys i am sharing only basics of what CMDB is and duties it performs. i am sure you will go far than me and explore more...!!!
Happy Coding
C# program that interfaces with MS Access: Store data (text, image) in an Access database file
2. Design a form. Add three Textboxes and two Buttons
3. Set Name property of Textboxes to “txtDatabase”, “txtStudentName” and “txtStudentPicture”.
4. Set Name property of Buttons to “btnCreateTable” with text property “Create Table” and “btnSave” with text property “Save”.
5. In the code file add namespace:
using System.Text;
using System.Data.OleDb;
6. Double click on the Button “Create Table” and pest the following code into the “btnCreateTable_Click” event.
OleDbCommand Cmd;
string SQL = "";
OleDbCommand objCmd = new OleDbCommand();
OleDbConnection Con = new OleDbConnection("Provider=Microsoft.Jet.OleDb.4.0;data
source=" + txtDatabase.Text + "");
SQL = "CREATE
TABLE tblStudentInfo ([StudentID] COUNTER, [StudentName] TEXT(50), [Picture]
OLEObject)";
Cmd = new
OleDbCommand(SQL, Con);
Con.Open();
objCmd = new OleDbCommand(SQL,
Con);
objCmd.ExecuteNonQuery();
Con.Close();
7. Double click on the Button “btnSave” and pest the following code into the “btnSave_Click” event.
StoreData(ImageToStream(txtStudentPicture.Text));
8. Add the following modules to the code file.
private byte[] ImageToStream(string fileName)
{
Bitmap image = new Bitmap(fileName);
MemoryStream stream = new
MemoryStream();
image.Save(stream, System.Drawing.Imaging.ImageFormat.Bmp);
return stream.ToArray();
}
private void
StoreData(byte[] content)
{
OleDbConnection
conn = new OleDbConnection("Provider=Microsoft.Jet.OleDb.4.0;data source="
+ txtDatabase.Text + "");
conn.Open();
if (conn.State.Equals(ConnectionState.Closed))
conn.Open();
try
{
OleDbCommand insert = new OleDbCommand("Insert into tblStudentInfo (StudentName,Picture)
values(@StudentName,@image)", conn);
OleDbParameter
picParameter = insert.Parameters.Add("@StudentName",
OleDbType.VarChar );
picParameter.Value = txtStudentName.Text;
picParameter.Size = 50;
OleDbParameter
imageParameter = insert.Parameters.Add("@image", SqlDbType.Binary);
imageParameter.Value = content;
imageParameter.Size = content.Length;
insert.ExecuteNonQuery();
MessageBox.Show("Data
Stored successfully");
}
catch (Exception ex)
{
MessageBox.Show(ex.Message.ToString());
MessageBox.Show(ex.StackTrace.ToString());
}
finally
{
conn.Close();
}
}
9. Press F5 to build and run the project.
Put your database name with location like c:\MyAccessDB in the text box “txtDatabase”, put student name in the text box “txtStudentName” and put student picture path in the text box “txtStudentPicture” then press the “Create Table” Button and after that press “Save” button to save the student information to the database table.
Saturday, March 20, 2010
Solution to search suggestions with permutition
In one of requirement i need to show the all possible combinitation of text provided in input to show possible search suggestions, i started thinking like school student of permutition and i found the solution, here is my code i have solved with Javascript
permute = function(v, m){ //v1.0
for(var p = -1, j, k, f, r, l = v.length, q = 1, i = l + 1; --i; q *= i);
for(x = [new Array(l), new Array(l), new Array(l), new Array(l)], j = q, k = l + 1, i = -1;
++i < l; x[2][i] = i, x[1][i] = x[0][i] = j /= --k);
for(r = new Array(q); ++p < q;)
for(r[p] = new Array(l), i = -1; ++i < l; !--x[1][i] && (x[1][i] = x[0][i],
x[2][i] = (x[2][i] + 1) % l), r[p][i] = m ? x[3][i] : v[x[3][i]])
for(x[3][i] = x[2][i], f = 0; !f; f = !f)
for(j = i; j; x[3][--j] == x[2][i] && (x[3][i] = x[2][i] = (x[2][i] + 1) % l, f = 1));
return r;
};
function callPermute()
{
var a = ["A","B","C"], j = permute(a);
document.write("< h2 >", a.join(" "), " = ", j.length, "< /h2 >",j.join("< br / >"));
}
you can call the method callPermute() to show the require result
Happy Coding :)
Sunday, January 31, 2010
AssociatedControlID of Asp.Label control in Asp.net
Today i have found one interesting part of Asp.Net Label control. Label server control have one property AssociatedControlID.
Problem : without asssigning the AssociatedControlID property a Asp.net Label server control rendered as "span" which is not satisfied the client requirement of 'it should render as label for accessibility'
Here is the output before and after,
Before,
span id="form_103_lblFirst_Name">First Name /span
Assigned "AssociatedControlID" property and Result after,
123 lblTitle.AssociatedControlID = txtName.ID;
label id="form_103_lblFirst_Name" for="form_103_First_Name">First Name /label
Solution : I have assigned the AssociatedControlID to the Asp.net Label server control to the textbox.ID to which it refering to. and found that it is rendered to "label" html tag which i required it also includes 'for' property which references the ID of Associated Control.
Happy Coding :)
Wednesday, January 27, 2010
New keyword 'dynamic' in framework 4.0,Difference between var and dynamic/ object and dynamic.
C# 4.0 introduces a new keyword called 'Dynamic'. It can consume any object anything. Let's see some examples for that.
dynamic intExample = 1;
Console.Write(intExample);
dynamic floatExample = 3.6;
Console.Write(floatExample);
dynamic stringExample = "SharpFour";
Console.Write(stringExample);
will print 13.6SharpFour
I know you will all have one question in mind that,It could be also done with var keyword . Yes, you can do same thing with var but dynamic keyword is slightly different then var keyword.
Main Diffrence between var and dynamic :
var keyword will know the value assigned to it at compile time while dynamic keyword will resolve value assigned to it at run time. I know you guys don't believe me without example. So let's take example of string.
string s = "this is test string";
var varstring=s;
Console.Write(varstring.MyMethodCall());
while compiling above code it will not compile and it gives a error that 'string' does not contain a definition for 'MethodDoesnotExist' and no extension method 'MethodDoesnotExist' accepting a first argument of type 'string' could be found (are you missing a using directive or an assembly reference?'. So var keyword knows that what value or object or anything assigned to it. Now lets try to compile same code with dynamic example like following.
string s = "this is test string";
dynamic varstring=s;
Console.Write(varstring.MyMethodCall());
Above line of code get compile. So it is the difference between dynamic and var keyword. With dynamic keyword anything assigned to it like property,objects operators anything that will be determined at compile time. It can be useful while we are doing programming with com,JavaScript which can have runtime properties.
similar thing is applied to the keyword type 'object'. we will discuss more on 'dynamic' keyword and 'object' keyword in my next post.
Happy Coding :-)
Sunday, January 24, 2010
Variable Methods and use of "params" in C#.
Recently in one of my requirements i require do make some method which will accepts n numbers of parameters, here i am not sure howmany parameters as argument will required.
I come up with solution with "params" keyword. below is a sample example of how i am able to solve it,i have used the console application to show how the "params" keyword will be used.
6 public static void Main()
7 {
8 Console.Clear();
9 Console.WriteLine("Hello World");
10 Console.ReadLine();
11 paramsExample(" vikas", 10, 11, " Aks");
12 }
13 public static void paramsExample(params object[] arglist)
14 {
15 foreach (object obj in arglist)
16 {
17 Console.Write("Hi{0}", obj);
18 }
19 }
The output of the above code will simply shows the,
"Hi vikas", "Hi 10","Hi 11","Hi Aks".
Hope you could be easily understand the code and use of "params" keyword.
Happy Coding :)
Sunday, January 17, 2010
Handling Exceptions in Using Expression Tree in C#
In my previous post i have explained how we can work with Expression Tree to access the Properties easily. The major consideration which we have to take here using Lambda Expressions is Expressions are failed if inputs are given wrong.
So here with this post i come up with the solution of Manage possible Exceptions, I have made some corrections in my previous post method named "GetName".
8 public static string GetName<T>(Expression<Func<T>> e)
9 {
10 var member = e.Body as MemberExpression;
11
12 // If the method gets a lambda expression
13 // that is not a member access,
14 // for example, () => FirstName + LastName, an exception is thrown.
15 if (member != null)
16 return member.Member.Name;
17 else
18 throw new ArgumentException(
19 "'" + e +
20 "': is not a valid expression for this method");
21 }
Now code looks safer to show proper exception whenever wrong inputs are given to it.
Happy Coding :)