Sunday, November 16, 2014

check corrupted .tif tiff file using vb.net OpenTiff Library

-install package related .tif using nuget
PM> Install-Package BitMiracle.LibTiff.NET

Imports BitMiracle.LibTiff.Classic

 Public Shared Function CheckCorruptedTiff(ByVal path As String) As Boolean
        Dim result As Boolean = False
        Using image As Tiff = Tiff.Open(path, "r")
            If image Is Nothing Then
                result = True
            End If

            Dim numberOfDirectories As Integer = image.NumberOfDirectories()
            For i As Integer = 0 To numberOfDirectories - 1
                image.SetDirectory(CShort(i))

                Dim width As Integer = image.GetField(TiffTag.IMAGEWIDTH)(0).ToInt()
                Dim height As Integer = image.GetField(TiffTag.IMAGELENGTH)(0).ToInt()

                Dim imageSize As Integer = height * width
                Dim raster As Integer() = New Integer(imageSize) {}

                If Not image.ReadRGBAImage(width, height, raster, True) Then
                    result = False
                End If
            Next
        End Using
        Return result
    End Function

Saturday, November 15, 2014

Prevent Duplicate Event when inserting or Updating when refresh Page Using C# asp.net

To Prevent Duplicate Event on page after insert or update if user press F5 to refresh page you can handle it using this code sample
1- in page_load when !postback create session and save datetime to that session

  if (!IsPostBack)
        {
            Session["update"] = Server.UrlEncode(System.DateTime.Now.ToString());
}

2- save the session value to view State on Page_PreRender Event like this
   protected void Page_PreRender(object sender, EventArgs e)
    {
        ViewState["update"] = Session["update"];
    }

3- on Button_Click Event You will Check That viewstate value equal to session value if true do action and then update session value with the new datetime .
on the second time the condition will not executed because of change in value between session value and viewstate value.
 protected void BTN_SEND_Click(object sender, EventArgs e)
    {
if (Session["update"].ToString() == ViewState["update"].ToString())
                {
//write your action code here
  Session["update"] = Server.UrlEncode(DateTime.Now.ToString());
                  }
else
{
     //write exception that no duplicate allowed or do any thing else.
}
}

Thursday, November 13, 2014

sql server can't connect using remote computer

the soultion is to add port in connection string , shit
http://stackoverflow.com/questions/18462821/cannot-connect-remotely-to-sql-server-instance

Saturday, November 8, 2014

An unexpected error occurred in the Oracle Data Provider for .NET. Please contact the provider vendor to resolve this problem

Error Message : An unexpected error occurred in the Oracle Data Provider for .NET. Please contact the provider vendor to resolve this problem

Solving : 
Delete any registry keys where you find {D601BB95-E404-4A8E-9F24-5C1A462426CE} (Oracle Developer Tools for .NET)

An unexpected error occurred in the Oracle Data Provider for .NET. Please contact the provider vendor to resolve this problem

Error Message : An unexpected error occurred in the Oracle Data Provider for .NET. Please contact the provider vendor to resolve this problem

Solving :