Tuesday, June 7, 2016

Flexi urls

For personal reference

 if any one move to versatile flexi, you should use 5906 flexi only

For Pondy Office : 192.168.1.116:5906
For Chennai Office : 114.69.235.39:5906

Move back to 5904 / 5905 once you move back to client flexi, please co operate.

Monday, May 9, 2016

WCF Service Trace log

https://coab.wordpress.com/2010/03/08/quickly-finding-wcf-serializationdeserialization-issues/

Quickly finding WCF Serialization/Deserialization Issues

Once control leaves your code, and heads into the land of WCF serialization, or before it hits your code, when it is in the land of WCF deserialization, you usually don’t have much insight into what’s going on. Yes, you can write your own handlers and step into the process but in most cases, there is no need for that. All you need is a little bit of logging and some error messages to help you catch issues.
Fortunately, Visual Studio comes with a handy little tool called SvcTraceViewer.exe that can help you quickly find issues with serialization or deserialization of your DataContracts.
You need to do the following two steps to quickly find the issue:

Step 1

Tell WCF to start logging out into a file. You can do this by adding the following diagnostic section as a child of the <configuration> tag. But be careful, it has to be after the end of the<congifSections> tag. There are a lot of options and flexibility WCF provides around this tracing, and you can read all about it here. The section below will cause WCF to log out its activity to the file c:\wcf.svclog
<system.diagnostics>
    <sources>
        <source     name="System.ServiceModel"
                    switchValue="Information, ActivityTracing"
                    propagateActivity="true">
            <listeners>
                <add    name="traceListener"
                        type="System.Diagnostics.XmlWriterTraceListener"
                        initializeData= "c:\wcf.svclog" />
            </listeners>
        </source>
    </sources>
</system.diagnostics>
Source: http://msdn.microsoft.com/en-us/library/ms733025.aspx

Step 2

Now that you have set WCF to log out all its activity into c:\wcf.svclog, all you need to do it open that file using the utility SvcTraceViewer.exe. It ships along with Visual Studio (atleast VS 2008 Professional Edition that I have), and it lives in the following folder on my machine.
C:\Program Files\Microsoft SDKs\Windows\v6.0A\bin
Once you open the trace file in SvcTraceViewer.exe, you will see the log entries (activities). Something like this:
image
Here you can see that a number of activities are logged and also a couple of errors are pointed out in red.
When I click on one of those error entries, this is what I see on the right side of my SvcTraceViewer window:
image
As you can see, all the steps for processing that particular request are listed, and the step that failed is logged out in red. When I click on the step that failed, this is what I see in the bottom pane of my SvcTraceViewer window:
image
As you can tell from the “Message” field under the “Exception Information” section, the error is pretty clear. While attempting to fulfill a request, WCF ran into an interface that was actually implemented by a type it did not recognize (WLogicTree). I need to tell it about the type. I can do this by adding it to the ServiceKnownTypes list.
In short, once you know how to use tools like SvcTraceViewer, and understand some of WCF rules for serialization and deserialization, it is not very painful to catch most errors.
Happy debugging!

Wednesday, April 20, 2016



Custom Route Handler Sample

 public class CustomRouteHandler : MvcRouteHandler
    {
        protected override IHttpHandler GetHttpHandler(RequestContext requestContext)
        {
            var acceptValue = requestContext.HttpContext.Request.Headers["Accept"];

            if (true /* do something with the accept value */)
            {
                // Set the new route value in the
                // requestContext.RouteData.Values dictionary
                // e.g. requestContext.RouteData.Values["action"] = "Customer";
                SetPermission(requestContext, requestContext.RouteData.Values["controller"].ToString(), requestContext.RouteData.Values["action"].ToString());

            }
           // return new CustomHttpHandler();
            return base.GetHttpHandler(requestContext);
        }


        private void SetPermission(RequestContext requestContext, string controller, string action)
        {

            VIPEREntities db = new VIPEREntities();
            var permission = db.sp_GetAccessPermission(controller, action, "fbe5b60f-dfff-4384-808d-d212e4791c00");
          
        }
    }


    public class CustomHttpHandler : MvcHttpHandler  // IHttpHandler
    {
        public bool IsReusable
        {
            get
            {                return false;
            }
        }

        public void ProcessRequest(HttpContext context)
        {
            context.Session["SessionPermission"] = "2";
            base.ProcessRequest(context);
            //context.Response.Redirect("http://www.itfunda.com", true);
        }
    }

Tuesday, February 2, 2016

To create a deployment package using Octopus

Install OctoPack nugget to the project

Add the following section in the project
 
< propertygroup >
< runoctopack >true< / runoctopack > < octopackpublishpackagetofileshare >C:\MyPackages < / octopackpublishpackagetofileshare >
< / propertygroup >
 

   

on build of solution the package will created to the destined folder.
C:\MyPackages

We can upload the package to Octopus Server and create a release to deploy it in targetted environments

Wednesday, January 13, 2016

Fix Issue : Microsoft.Practices.EnterpriseLibrary.Data.Database, is an abstract class and cannot be constructed.



Server Error in '/' Application.


The current type, Microsoft.Practices.EnterpriseLibrary.Data.Database, is an abstract class and cannot be constructed. Are you missing a type mapping?


While deploying a web application which use Microsoft enterprise library for data access. If you get the above error. 
Please make sure all the dll is in bin folder and make sure to add the following section in web.config file 

   
       
       
     

 
   
     
     
   
 

Thursday, January 7, 2016

SQL_NO_CACHE MySQl no cache


The mysql workbench return the cached value of data.

To get the latest data from db use the keyword SQL_NO_CACHE
 Select SQL_NO_CACHE * from UserDetail

Thursday, November 12, 2015

Reference for extension method in C#

https://msdn.microsoft.com/en-IN/library/bb383977.aspx

Extension methods are defined as static methods but are called by using instance method syntax. Their first parameter specifies which type the method operates on, and the parameter is preceded by the this modifier. Extension methods are only in scope when you explicitly import the namespace into your source code with a using directive.

The following example shows an extension method defined for the System.String class. Note that it is defined inside a non-nested, non-generic static class:
namespace ExtensionMethods
{
    public static class MyExtensions
    {
        public static int WordCount(this String str)
        {
            return str.Split(new char[] { ' ', '.', '?' }, 
                             StringSplitOptions.RemoveEmptyEntries).Length;
        }
    }   
}
The WordCount extension method can be brought into scope with this using directive:
using ExtensionMethods;
And it can be called from an application by using this syntax:
string s = "Hello Extension Methods";
int i = s.WordCount();