If you are getting this error than restore database using script
Use Master
RESTORE DATABASE ihkdb01
FROM DISK = 'C:\Program Files\Microsoft SQL Server\MSSQL.1\MSSQL\Backup\ihkdb01.bak'
WITH MOVE 'ihkdb01' TO 'D:\SQLServerRepository\ihkdb01.mdf',
MOVE 'ihkdb01_Log' TO 'D:\SQLServerRepository\ihkdb01_log.ldf',
REPLACE
Wednesday, June 1, 2011
Thursday, May 26, 2011
Method to create Share folder in web server C#
public void CreateSharedFolder(string PhysicalPath, bool bFolderCreated)
{
try
{
int index = PhysicalPath.LastIndexOf("\\");
string AliasFolder = PhysicalPath.Substring(index + 1);
ManagementClass managementClass = new ManagementClass("Win32_Share");
// Create ManagementBaseObjects for in and out parameters
ManagementBaseObject inParams = managementClass.GetMethodParameters("Create");
ManagementBaseObject outParams;
// Set the input parameters
inParams["Name"] = AliasFolder;
inParams["Path"] = PhysicalPath;
inParams["Type"] = 0x0; // Disk Drive
// Invoke the method on the ManagementClass object
outParams = managementClass.InvokeMethod("Create", inParams, null);
// Check to see if the method invocation was successful
if ((uint)(outParams.Properties["ReturnValue"].Value) != 0)
{
if (bFolderCreated)
{
Directory.Delete(PhysicalPath, true);
}
throw new Exception("Unable to share directory as it is already in use.");
}
}
catch (Exception ex)
{
throw new Exception("Error :", ex);
}
}
{
try
{
int index = PhysicalPath.LastIndexOf("\\");
string AliasFolder = PhysicalPath.Substring(index + 1);
ManagementClass managementClass = new ManagementClass("Win32_Share");
// Create ManagementBaseObjects for in and out parameters
ManagementBaseObject inParams = managementClass.GetMethodParameters("Create");
ManagementBaseObject outParams;
// Set the input parameters
inParams["Name"] = AliasFolder;
inParams["Path"] = PhysicalPath;
inParams["Type"] = 0x0; // Disk Drive
// Invoke the method on the ManagementClass object
outParams = managementClass.InvokeMethod("Create", inParams, null);
// Check to see if the method invocation was successful
if ((uint)(outParams.Properties["ReturnValue"].Value) != 0)
{
if (bFolderCreated)
{
Directory.Delete(PhysicalPath, true);
}
throw new Exception("Unable to share directory as it is already in use.");
}
}
catch (Exception ex)
{
throw new Exception("Error :", ex);
}
}
Method to create Create IIS Virtual Directory in C#
private void CreateIISVirtualDirectory(string PhysicalPath)
{
try
{
string strVDPath = ConfigurationManager.AppSettings["VDPath"];
//Get the folder Name and assign it to alias for creating Virtual Directory
DirectoryInfo di = System.IO.Directory.GetParent(PhysicalPath);
PhysicalPath = di.Parent.FullName;
int index = PhysicalPath.LastIndexOf("\\");
string AliasFolder = PhysicalPath.Substring(index + 1);
DirectoryEntry de = new DirectoryEntry(GetWebSitePath() + "/ROOT/" + strVDPath);
DirectoryEntry newVDir = de.Children.Add(AliasFolder, "IIsWebVirtualDir");
newVDir.Properties["Path"][0] = PhysicalPath;
newVDir.Properties["AccessScript"][0] = true;
// These properties are necessary for an application to be created.
newVDir.Properties["AppFriendlyName"][0] = AliasFolder;
newVDir.CommitChanges();
}
catch (Exception ex)
{
Error.LogError(ex);
throw new Exception("Error :", ex);
}
}
private string GetWebSitePath()
{
string strPath = "";
string strWebSiteName = ConfigurationManager.AppSettings["HostedWebSite"];
DirectoryEntry w3svc = new DirectoryEntry("IIS://" + Environment.MachineName + "/w3svc");
foreach (DirectoryEntry de in w3svc.Children)
{
if (de.SchemaClassName == "IIsWebServer")
{
if (de.Properties["ServerComment"][0].ToString().ToUpper() == strWebSiteName.ToUpper())
{
strPath = de.Path;
break;
}
}
}
return strPath;
}
{
try
{
string strVDPath = ConfigurationManager.AppSettings["VDPath"];
//Get the folder Name and assign it to alias for creating Virtual Directory
DirectoryInfo di = System.IO.Directory.GetParent(PhysicalPath);
PhysicalPath = di.Parent.FullName;
int index = PhysicalPath.LastIndexOf("\\");
string AliasFolder = PhysicalPath.Substring(index + 1);
DirectoryEntry de = new DirectoryEntry(GetWebSitePath() + "/ROOT/" + strVDPath);
DirectoryEntry newVDir = de.Children.Add(AliasFolder, "IIsWebVirtualDir");
newVDir.Properties["Path"][0] = PhysicalPath;
newVDir.Properties["AccessScript"][0] = true;
// These properties are necessary for an application to be created.
newVDir.Properties["AppFriendlyName"][0] = AliasFolder;
newVDir.CommitChanges();
}
catch (Exception ex)
{
Error.LogError(ex);
throw new Exception("Error :", ex);
}
}
private string GetWebSitePath()
{
string strPath = "";
string strWebSiteName = ConfigurationManager.AppSettings["HostedWebSite"];
DirectoryEntry w3svc = new DirectoryEntry("IIS://" + Environment.MachineName + "/w3svc");
foreach (DirectoryEntry de in w3svc.Children)
{
if (de.SchemaClassName == "IIsWebServer")
{
if (de.Properties["ServerComment"][0].ToString().ToUpper() == strWebSiteName.ToUpper())
{
strPath = de.Path;
break;
}
}
}
return strPath;
}
Thursday, February 17, 2011
ABC and Endpoint of WCF
Address: WCF services must have an address. The address specifies the location of the service which will be exposed for clients that will use it to communicate with the service. The address's protocol that WCF can provided: HTTP , TCP ,NamedPipe , Peer2Peer ,MSMQ.
Binding: Specifies how a service is accessible. In other words: how the two parties will communicate in terms of transport (HTTP , TCP ,NamedPipe , Peer2Peer ,MSMQ) ,encoding (text, binary etc.) and protocols (like transactional support or reliable messaging).
Contract: Used to specify what your service can do. For example: give you the square when providing 2 numbers.
Endpoints:
All communications with the WCF service will happen via the endpoints. The endpoints specify a Contract that defines which methods of the Service class will be accessible via the endpoint; each endpoint may expose a different set of methods. The endpoints also define a binding that specifies how a client will communicate with the service and the address where the endpoint is hosted. WCF provides Windows Activation Services which can be used to host the WCF service. Otherwise the WCF service can also be hosted in IIS or in any process by using the Service Host class, which is provided by WCF. Services can also be self-hosted.
Binding: Specifies how a service is accessible. In other words: how the two parties will communicate in terms of transport (HTTP , TCP ,NamedPipe , Peer2Peer ,MSMQ) ,encoding (text, binary etc.) and protocols (like transactional support or reliable messaging).
Contract: Used to specify what your service can do. For example: give you the square when providing 2 numbers.
Endpoints:
All communications with the WCF service will happen via the endpoints. The endpoints specify a Contract that defines which methods of the Service class will be accessible via the endpoint; each endpoint may expose a different set of methods. The endpoints also define a binding that specifies how a client will communicate with the service and the address where the endpoint is hosted. WCF provides Windows Activation Services which can be used to host the WCF service. Otherwise the WCF service can also be hosted in IIS or in any process by using the Service Host class, which is provided by WCF. Services can also be self-hosted.
Wednesday, January 12, 2011
Encapsulation and Abstraction
Two concepts that go together in the object oriented approach are Encapsulation & Abstraction. Abstraction is the representation of only the essential features of an object, while Encapsulation is the hiding of the non-essential features.
Think of a person driving a car. He does not need to know the internal working of the engine or the way gear changes work, to be able to drive the car (Encapsulation). Instead, he needs to know things such as how much turning the steering wheel needs, etc (Abstraction).
Consider the example from the programmer’s perspective who wants to allow the user to add items to a list. The user only needs to click a button to add an item (Abstraction). The mechanism of how the item is added to the list is not essential for him (Encapsulation).
By using encapsulation & abstraction, we reduce complexity by ignoring unimportant details and we maintain effectiveness by representing important ones.
Think of a person driving a car. He does not need to know the internal working of the engine or the way gear changes work, to be able to drive the car (Encapsulation). Instead, he needs to know things such as how much turning the steering wheel needs, etc (Abstraction).
Consider the example from the programmer’s perspective who wants to allow the user to add items to a list. The user only needs to click a button to add an item (Abstraction). The mechanism of how the item is added to the list is not essential for him (Encapsulation).
By using encapsulation & abstraction, we reduce complexity by ignoring unimportant details and we maintain effectiveness by representing important ones.
Subscribe to:
Posts (Atom)