Bootstrap tools

I’m working with boostrap and before doing my work I usually create mockups about what I would realyze.
In the past I used pencil and paper, after that I bought a laptop with touchscreen, so now I use one note do draw and share my mockups.
When everything is ok I create a mockup for customers, and if have to work with bootstrap I found a great tool to achieve that:
Pingendo

It’s free and it works very well! It permits to create sample sites wasting little time.
The only drawback is that I can’t extend the tool by adding custom components. As workaround you can use some txt files with the html code of your custom components.
Currently they are working on the version compatible with bootstrap 4.

In addition, I suggest having a look to this site:
bootsnipp.com

There are a lot of code snippets to use in a fast way.
I don’t like the site search beacuse founds too many results, but using google search you can find great example.
To do this you have to write this in google:
WhatYouNeed site:http://bootsnipp.com/

Pubblicato in Bootstrap | Contrassegnato , , , , , | Lascia un commento

Exam Simulator VCE dumps free

I’m currently studying to pass exam certifications and I’ve already read 2 books.
Now the question is: how can I do same exercises to check my level?
In order to do that I have found some sites where you can download .vce file.
A .vce file is a file that contains questions and answers and could be opened from VCE Exam Simulator, a program that to be installed on your local pc.
Here some sites where you can download that file:

After downloading the vce files, how can you use them?
You can buy VCE Exam Simulator or you can use A+ VCE Player for Android.

But if you would like to use vce files on your PC (without buying VCE Exam Simulator) below you can find the right steps:

  1. Download and install Bluestacks (Android emulator free)
  2. Download and install A+ VCE (after you have installed Bluestacks double click .apk file)
  3. Copy yours .vce files to folder “C:\Users\YOUR_ACCOUNT\Pictures\Saved Pictures”
  4. Open Bluestacks
  5. Open A+ VCE
    1. Click Add File
    2. Go to path “/storage/sdcard/windows/Pictures/Saved Pictures”
    3. Select the file you want to import

Here are some videos I used to write this guide (same videos have more steps like connect with your google account and download other apps from the play store)
https://www.youtube.com/watch?v=zLMLfly3xi8
https://www.youtube.com/watch?v=DG41krt1Fok

Now the only thing i need is to do a lot of tests, hoping to get the exam certification😉

Pubblicato in Uncategorized | Contrassegnato , , , , , , | Lascia un commento

Multiple content type

Today I’ve worked on a generic handler that recovers file from else where, than it sends the file to client browser.

When you write a generic handler it is important to specify the contentType before complete the response.
There are many mime type availables:
image/png, text/plain etc.

But if you don’t know which mime type use I suggest you to use this one:

context.Response.ContentType = "application/octet-stream"
Pubblicato in .Net, HTML5 | Lascia un commento

HTTP Error 404.3-Not Found

Some times ago I got this error using IIS:

HTTP Error 404.3-Not Found

The page you are requesting cannot be served because of the extension configuration. If the page is script, add a handler. If the file should be downloaded, add a MIME map.

I looked for a solution on Internet and I found this:
You should install IIS sub components from
Control Panel -> Programs and Features -> Turn Windows features on or off
Internet Information Services has subsection World Wide Web Services / Application Development Features
There you must check ASP.NET (.NET Extensibility, ISAPI Extensions, ISAPI Filters will be selected automatically). Double check that specific versions are checked. Under Windows Server 2012 R2, these options are split into 4 & 4.5.
Run from cmd:

%windir%\Microsoft.NET\Framework64\v4.0.30319\aspnet_regiis.exe -ir

Finally check in IIS manager, that your application uses application pool with .NET framework version v4.0.
Also, look at this answer.

This happen when you install Visual Studio before IIS; in this case you need only to run the command regiis

Pubblicato in Uncategorized | Contrassegnato , , | Lascia un commento

Serializing Entity Framework classes with JSON (Web API) without relationship

How many times have you ever tried to serialize an object of a type generated by EntityFramework.
As you know with Entity Framework the relationship between to tables are made using virtual IEnumerable.

As just you try to access to these properties, Entity Framework will load it. This is the default behavior called LazyLoading.

This behavior is a problem when you try to serialize it with Json (Web Api or other) because it will loop and load all the related entities.
Looking for a solution I found many people suggest to create a DTO class or create an anonymous type like this:

[RoutePrefix("api/Inventario")]
public class InventarioController : ApiController
{
    // GET: api/Inventario
    [Route("Modelli/{idCategoria}")]
    public IEnumerable<TAB_MODELLI_INVENTARIO> GetModelli(decimal idCategoria)
    {
        using (var db = new EFContext())
        {
            var models = db.SelectModelli(idCategoria);
            // Creating anonymous type
            return models.Select(a => new { id = a.id, prop1 = a.prop1, prop2 = a.prop2 });
        }
    }
}

I don’t like this solution because I hate write dummy code.

My preferred solution is disable lazy loading before serialize it.
This doesn’t allow Entity Framework to load the relationship while JSON.Net serialize the object

[RoutePrefix("api/Inventario")]
public class InventarioController : ApiController
{
    // GET: api/Inventario
    [Route("Modelli/{idCategoria}")]
    public IEnumerable<TAB_MODELLI_INVENTARIO> GetModelli(decimal idCategoria)
    {
        using (var db = new EFContext())
        {
            var models = db.SelectModelli(idCategoria);

            db.Configuration.LazyLoadingEnabled = false;

            return models;
        }
    }
}
Pubblicato in .Net, Asp.Net, c#, Entity Framework, MVC | Contrassegnato , | Lascia un commento

Missing compiler required member ‘Microsoft.CSharp.RuntimeBinder.CSharpArgumentInfo.Create’

If you are working with MS unit test that use dynamics object, you’ll get this error.

Missing compiler required member ‘Microsoft.CSharp.RuntimeBinder.CSharpArgumentInfo.Create’

to solve it add the reference to Microsoft.CSharp

Pubblicato in .Net, c# | Contrassegnato , , | Lascia un commento

The entity or complex type cannnot be constructed in a LINQ to Entities query

In some cases it is necessary read form a table and return a different type. A typical cases is if you read from a base table but you wanna return the view class and not the table class mapped by Entity Framework.

If you try to it, you’ll get this error:
The entity or complex type cannnot be constructed in a LINQ to Entities query

// Error because we try to re-use a class mapped by EF
public IList<V_TAB_ANAGRAFICA> SelectResp() 
{
    var q = from a in this.TAB_ANAGRAFICA
        where a.ID_AUTORIZZATORE.HasValue
        select new V_TAB_ANAGRAFICA
        {
            ID_ANAGRAFICA = a.ID_AUTORIZZATORE.Value,
            NOME = a.NOMEAUTORIZZATORE,
            COGNOME = a.COGNOMEAUTORIZZATORE,
            COGNOMENOME = a.COGNOMENOMEAUTORIZZATORE,
            COD_GECOSE = a.COD_GECOSE,
            GECOSE = a.GECOSE
        };
 
    return q.ToList();
}

Solution 1

Create a DTO Class like this:

class V_TAB_ANAGRAFICA_DTO : TAB_ANAGRAFICA {}

public IList<V_TAB_ANAGRAFICA> SelectResp() 
{
    var q = from a in this.TAB_ANAGRAFICA
        where a.ID_AUTORIZZATORE.HasValue
        select new V_TAB_ANAGRAFICA_DTO
        {
            ID_ANAGRAFICA = a.ID_AUTORIZZATORE.Value,
            NOME = a.NOMEAUTORIZZATORE,
            COGNOME = a.COGNOMEAUTORIZZATORE,
            COGNOMENOME = a.COGNOMENOMEAUTORIZZATORE,
            COD_GECOSE = a.COD_GECOSE,
            GECOSE = a.GECOSE
        };
 
    return q.ToList();
}

This solution works and it is fast, but it will introduce an additional class, and sincerely I don’t like it.

Solution 2

Recover the entities from DB and load them into memory using .AsEnumerable() than use linq to Enty (not Entity Framework) to select what we want.
This solution doesn’t need another class BUT it is slower than the first solution because we do a select in memory to re-map the item in another class.
Probably this is not a problem but It could be with a great amount of data.

public IList<V_TAB_ANAGRAFICA> SelectResp() 
{
    var q = from a in this.TAB_ANAGRAFICA
        where a.ID_AUTORIZZATORE.HasValue
        select a;
    var q1 = q.AsEnumerable().Select( a =>
        new V_TAB_ANAGRAFICA
        {
            ID_ANAGRAFICA = a.ID_AUTORIZZATORE.Value,
            NOME = a.NOMEAUTORIZZATORE,
            COGNOME = a.COGNOMEAUTORIZZATORE,
            COGNOMENOME = a.COGNOMENOMEAUTORIZZATORE,
            COD_GECOSE = a.COD_GECOSE,
            GECOSE = a.GECOSE
        });
 
    return q1.ToList();
}
Pubblicato in .Net, c#, Entity Framework | Contrassegnato | Lascia un commento