Implementation of Atomicity and Durability using Shadow Copy

The recovery-management component of a database system can support atomicity and durability by a variety of schemes.

Here we are going to learn about one of the simplest scheme called Shadow copy.

Shadow copy:

Continue reading “Implementation of Atomicity and Durability using Shadow Copy”

Convert local path to UNC (Universal) File Path using Java Script ActiveXObject


function getUNCPath() {
var filePath = document.getElementById("uploadedFile").value;

var WshNetwork = new ActiveXObject("WScript.Network");
var Drives = WshNetwork.EnumNetworkDrives();
for (i = 0; i < Drives.length; i += 2) {
if(Drives.Item(i) != "")
filePath = filePath.replace(Drives.Item(i), Drives.Item(i + 1));


<form onsubmit="getUNCPath()">
<input type="file" id="uploadedFile"/>
<input type="submit" value="Get the UNC Path!" />

in razor view engine add the following line to support ActiveXObject:

@using System.Web.Script.Serialization

DBMS Notes for GATE 2020

Types of Functional Dependencies in Normalization


Functional Dependency:

In Relational database, Functional dependency is denoted as X -> Y where X:Determinant and Y: Dependent. So, as per the concept the value of Y gets determined by the value of X.

If value of X gets duplicated, then in those rows value of Y shall also gets duplicated correspondingly.

If the determinant X value is unique (different) then the dependent Y could have any value meaning:

  • For same X , value of Y should be same.
  • For different X, value of Y could be same or different.

Continue reading……..

Difference between DBMS and RDBMS


How To Redirect HTTP to HTTPS using C#


Hello Readers,

While developing web application many of us must have observed that after deploying to web server, web page url starts with http but not the secured one https.

So if we want to redirect url from HTTP to HTTPS there is a very simple solution in C#.

Just copy and paste the below code in your “Global.asax.cs” file and you are all done.

Continue reading “How To Redirect HTTP to HTTPS using C#”

What’s new in .NET Framework 4.7.1 (Part 3)

New Release .NET Framework 4.7.1

Hello Readers,

This post is in continuation with “What’s new in .NET Framework 4.7.1 Part 2“.

[Whats new in .Net Framework 4.7.1 Part 1,Whats new in .Net Framework 4.7.1 Part 2]

New Features includes:

WPF – Changing implicit data templates 

  • This feature enables the automatic update of elements that use implicit DataTemplates after changing a resource.
  • When an application adds, removes, or replaces a value declared in a ResourceDictionary, WPF automatically updates all elements that use the value in most cases, including the implicit style case:<Style TargetType=”Button”.
Continue reading “What’s new in .NET Framework 4.7.1 (Part 3)”

What’s new in .NET Framework 4.7.1 (Part 2)

New Release .NET Framework 4.7.1

Hello Readers,

This post is in continuation with “What’s new in .NET Framework 4.7.1 Part 1“.

New Features includes:

Accessibility improvements

.NET Framework 4.7.1 brings in a lot of accessibility improvements across different libraries to align with the broad Microsoft product accessibility goals. 

Windows Forms Accessibility improvements

Windows Forms accessibility changes are in the following areas:

  • Improved display during High Contrast mode
  • Enhanced UI accessibility patterns
  • Improved UI Accessibility properties with the outcome of improved experiences in accessibility tools like Narrator

High Contrast Improvements

Various controls in WinForms are now improved in the way they render under the various HighContrast modes available in the Operating System (OS).

Continue reading “What’s new in .NET Framework 4.7.1 (Part 2)”

What’s new in .NET Framework 4.7.1 (Part 1)

New Release .NET Framework 4.7.1
New Release .NET Framework 4.7.1

Hello Readers,

Today I am writing about new features implemented on the recently released .NET Framework 4.7.1. On October 17, 2017 Microsoft has announced the release of .NET Framework 4.7.1.  It’s included in the Windows 10 Fall Creators Update. .NET Framework 4.7.1 is also available on Windows 7+ and Windows Server 2008 R2+.  Microsoft has added support for targeting the .NET Framework 4.7.1 in Visual Studio 2017 15.5.

The .NET Framework 4.7.1 includes improvements in several areas:

  • Accessibility improvements in narration, high contrast and focus control areas
  • .NET Framework support for .NET Standard 2.0 and compiler features
  • More secure SHA-2 support in ASP.NET and System.Messaging
Continue reading “What’s new in .NET Framework 4.7.1 (Part 1)”

Download a PDF file stored in a network location

In View page (.cshtml) Create a Link using anchor tag and define href field as:

href = ‘@Url.Action(“Download”, “YourControllerName”,new{filePath = “”})’

public FileResult Download(string filePath)
MemoryStream ms = new MemoryStream();

byte[] fileBytes = System.IO.File.ReadAllBytes(filePath);
string fileNAme = Path.GetFileName(filePath);

string tmpPath = Path.GetTempPath();
tmpPath = tmpPath + fileNAme;

PdfReader pdfReader = new PdfReader(fileBytes);

PdfReader.unethicalreading = true;
FileStream sourceFileStream = new FileStream(tmpPath, FileMode.Create, FileAccess.Write);
PdfStamper pdfStream = new PdfStamper(pdfReader, sourceFileStream);
string waterMark= "Confidential"
for (int page = 1; page <= pdfReader.NumberOfPages; page++)
Rectangle pageRectangle = pdfReader.GetPageSizeWithRotation(page);
PdfContentByte pdfData = pdfStream.GetUnderContent(page);
pdfData.SetFontAndSize(BaseFont.CreateFont(BaseFont.HELVETICA_BOLD, BaseFont.CP1252, BaseFont.NOT_EMBEDDED), 50);
PdfGState graphicsState = new PdfGState();
graphicsState.FillOpacity = 0.6F;
pdfData.ShowTextAligned(Element.ALIGN_CENTER, waterMark, pageRectangle.Width / 2, pageRectangle.Height / 2, 45);
pdfStream.FormFlattening = true;

byte[] byteArray = System.IO.File.ReadAllBytes(tmpPath);
ms.Write(byteArray, 0, byteArray.Length);
ms.Position = 0;

return new FileStreamResult(ms, "application/pdf");

To use above code you need iTextSharp dll. you can install it using Nuget as: Install-Package iTextSharp

References :

How to convert local path to UNC (Universal) File Path in C#

In your controller initialize class obj:

LocalPathToUNCPathConversion obj = new LocalPathToUNCPathConversion();
string localPath = "filename"; //give locally mapped network drive file path
string UNCFilePath = obj.GetUniversalName(localPath);

write logic in a separate class file named as LocalPathToUNCPathConversion.cs

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Text;
using System.IO;
using System.Runtime.InteropServices;
using System.ComponentModel;

namespace YourProjectName
public class LocalPathToUNCPathConversion
[DllImport("mpr.dll", CharSet = CharSet.Unicode)]
[return: MarshalAs(UnmanagedType.U4)]
static extern int WNetGetUniversalName(
string lpLocalPath,
[MarshalAs(UnmanagedType.U4)] int dwInfoLevel,
IntPtr lpBuffer,
[MarshalAs(UnmanagedType.U4)] ref int lpBufferSize);

const int UNIVERSAL_NAME_INFO_LEVEL = 0x00000001;
const int REMOTE_NAME_INFO_LEVEL = 0x00000002;

const int ERROR_MORE_DATA = 234;
const int NOERROR = 0;

public string GetUniversalName(string localPath)
// The return value.
string retVal = null;

// The pointer in memory to the structure.
IntPtr buffer = IntPtr.Zero;

// Wrap in a try/catch block for cleanup.
// First, call WNetGetUniversalName to get the size.
int size = 0;

// Make the call.
// Pass IntPtr.Size because the API doesn't like null, even though
// size is zero. We know that IntPtr.Size will be
// aligned correctly.
int apiRetVal = WNetGetUniversalName(localPath, UNIVERSAL_NAME_INFO_LEVEL, (IntPtr)IntPtr.Size, ref size);

// If the return value is not ERROR_MORE_DATA, then
// raise an exception.
if (apiRetVal != ERROR_MORE_DATA)
// Throw an exception.
throw new Win32Exception(apiRetVal);

// Allocate the memory.
buffer = Marshal.AllocCoTaskMem(size);

// Now make the call.
apiRetVal = WNetGetUniversalName(localPath, UNIVERSAL_NAME_INFO_LEVEL, buffer, ref size);

// If it didn't succeed, then throw.
if (apiRetVal != NOERROR)
// Throw an exception.
throw new Win32Exception(apiRetVal);

// Now get the string. It's all in the same buffer, but
// the pointer is first, so offset the pointer by IntPtr.Size
// and pass to PtrToStringAnsi.
retVal = Marshal.PtrToStringAuto(new IntPtr(buffer.ToInt64() + IntPtr.Size), size);
retVal = retVal.Substring(0, retVal.IndexOf('\0'));
// Release the buffer.

// First, allocate the memory for the structure.

// That's all folks.
return retVal;

Convert local path to UNC (Universal) File Path using Java Script ActiveXObject



In Your View

Create a Link: using anchor tag href = "'@Url.Action("ExportToExcel", "YourControllerName")'";

<strong><span style="text-decoration: underline;">Create a Model class to store the data:</span></strong>

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using OpenXmlPackaging;

namespace ExportToExcel
public class ExcelModel
public string Column1{ get; set; }
public string Column2{ get; set; }
public string Column3{ get; set; }
public string Column4{ get; set; }}


<span style="text-decoration: underline;"><strong>In Your Controller</strong></span>

<strong>public FileResult ExportToExcel()</strong>
<strong> {</strong>
List ListExcelModelObj = new List();

var data = (from row1 in DBEntity.Table1
join row2 in DBEntity.Table2 on row1.Id equals
select new {

ExcelModel ExcelModelObj = null;

foreach(var item in data)
ExcelModelObj = new ExcelModel ();
ExcelModelObj.Column1 = item.Col1;
ExcelModelObj.Column2 = item.Col2;
ExcelModelObj.Column3 = item.Col3;
ExcelModelObj.Column4 = item.Col4;

<strong>DataTable table = ConvertToDataTable(ListExcelModelObj);</strong>

string tmpPath = Path.GetTempPath();
tmpPath = tmpPath + "ExcelName.xlsx";
<strong>ExportToExcelUsingOpenXMLPkg(table, tmpPath);</strong>

byte[] fileBytes = System.IO.File.ReadAllBytes(tmpPath);
string fileName = Path.GetFileName(tmpPath);
return File(fileBytes, System.Net.Mime.MediaTypeNames.Application.Octet, fileName);


<strong>public DataTable ConvertToDataTable(IList data)</strong>
<strong> {</strong>
PropertyDescriptorCollection properties =
DataTable table = new DataTable();
foreach (PropertyDescriptor prop in properties)
table.Columns.Add(prop.Name, Nullable.GetUnderlyingType(prop.PropertyType) ?? prop.PropertyType);
foreach (T item in data)
DataRow row = table.NewRow();
foreach (PropertyDescriptor prop in properties)
row[prop.Name] = prop.GetValue(item) ?? DBNull.Value;
return table;

<strong>public void ExportToExcelUsingOpenXMLPkg(DataTable tbl, string excelFilePath = null)</strong>
<strong> {</strong>
using (var doc = new SpreadsheetDocument(excelFilePath))
Worksheet sheet1 = doc.Worksheets.Add("My Sheet");
//sheet1.Cells[1, 1].Value = "Test";
//sheet1.Cells["A1"].Value = 1;
sheet1.ImportDataTable(tbl, "A1", true);

To use above code you need Open XML Package dll. you can install it using Nuget as: Install-Package DocumentFormat.OpenXml

References :
	<li><a href="">Nuget Install OPEN XML PACKAGE</a></li>
	<li><a href=""></a></li>
	<li><a href="">MSDN - Create Excel Document</a></li>
%d bloggers like this: