How to do Dependency Injection With Azure Web Job using Ninject

So here I going to write up how to do Dependency Injection using Ninject with a Azure Queue Trigger web job.

So Firstly we have to create our Azure WebJob so right click on the solution

  • Add new web job project
  • Capture
  • After you have added we are going to NuGet and install the Ninject Package
    • Install-Package Ninject -Version 3.3.4
    • Next Create a new folder called JobActivator
    • Once the folder is created ,Then create the JobActivator.cs
using Microsoft.Azure.WebJobs.Host;

using Ninject;

namespace WebJob.JobActivator

{

publicclass JobActivator : IJobActivator

{

privatereadonly IKernel _container;

public JobActivator(IKernel container)

{

_container = container;

}

public T CreateInstance<T>()

{

return _container.Get<T>();

}

}

}
  • Once you created this go your Program.cs . Now we will set up the Dependency Injection .
  • So next create another folder called Bindings
  • You Next need to create a BindingModule to Ninject Module
  • I am using a mock Test Class which does nothing
using Ninject.Modules;

namespace WebJob.Bindings

{

publicclass BindingModule : NinjectModule

{

publicoverridevoid Load()

{

Bind<ITestClass>().To<TestClass>();

}

}

}
using System.Configuration;
using Microsoft.Azure.WebJobs;
using Ninject;

namespace WebJob
{
class Program
{

// Please set the following connection strings in app.config
// for this WebJob to run:

// AzureWebJobsDashboard and AzureWebJobsStorage

static void Main()
{

//Set up DI

var kernel = new StandardKernel(module);

//This the Storage Credentials for your Azure Storage Account 
var storageConnectionString = 
      ConfigurationManager.ConnectionStrings["AzureWebJobsDashboard"].ConnectionString;

var config = new JobHostConfiguration(storageConnectionString) 
{
//This is where we passed the Job Activator 
JobActivator = new JobActivator.JobActivator(kernel)
};
if (config.IsDevelopment)
{
config.UseDevelopmentSettings();
}

//Pass configuration to JobJost

var host = new JobHost(config);

// The following code ensures that the WebJob will be running continuously

host.RunAndBlock();

}

 

Now you can go your Functions class use your injected classes as see below

using System.IO;
using Microsoft.Azure.WebJobs;

namespace WebJob
{

publicclass Functions
{

private readonly ITestclass _testClass;

public Functions(ITestclass testClass)
{

_testClass= testClass;

}

// This function will get triggered/executed when a new message is written

// on an Azure Queue called queue.

public void ProcessQueueMessage([QueueTrigger("QueueMessage")] 
  string message, TextWriter log)
{

testClass.SomeGenericMessageHandler(message);

}
}
}

  • As you can see above now can use your injected classes without it throwing errors.
Advertisements

When to use iFrames from Parent to Child Communctions?

So currenly I am looking into iFrames and how to pass information to and from parent to child , but through all my searching I dont really find where and when you should do this . Maybe someone alot smarter than me can point me towards the right path.

But interestly enough I have seen one example of it and why it should be used . So the real life example is a company that deals with securing credit card payments that doesnt not want to share out an api endpoint to its service to the outside world or their client and wants to do the validation on the card on their internal system and return a response from that .

How it validates the card and secures the card information is not too relevant for this conversation .

But this iFrame after submit on the form returns back a  jsonObject if it failed or succeeded it goes back to the parent and you as the client can deal with the response as you see fit .

So the reason I mention it is , I’d like to know more other ways of using it but also want to help anyone else who had the same question on why and when should it be used and the credit card secure example is only one I have so far .

An nice example of Two way iframe communication can be seen here by Petar Bojinov :

I really recommend people have a look at its a nice solution and easy to understand.

 

 

React notes For myself – Setting it up

To set up REACT you need to follow these steps:

  1. You need to use install Node Js so you can use the NPM(Node Package Manager)  https://nodejs.org/en/ . Make suire to type node -v . This should print a version number if installed correctly.
  2. You next need to get the React packages from NPM or CDN and create your app
    1. You can get the cdn  links directly https://reactjs.org/docs/cdn-links.html and just import them directly over however I would not recommend this myself but each their own
    2. Or you can go to your command line type in
      npm install -g create-react-app 
      create-react-app my-app 
      cd my-app npm start

       (Much easier 🙂 )

  3. This blog post by : Nipuni Bhagya   https://blog.cloudboost.io/how-to-setup-your-first-react-app-7faf81db8bce is worth checking as it goes through the entire process of creating your set up and first project . She also mentions Babel which is important as this is what will interpret your JSX code . This will save so much time on creating react elements and classes . From the examples below:

Not Using JSX :

http://jamesknelson.com/learn-raw-react-no-jsx-flux-es6-webpack/

by James K Nelson

var rootElement =

React.createElement('div', {},

React.createElement('h1', {}, "Contacts"),

React.createElement('ul', {},

React.createElement('li', {},

React.createElement('h2', {}, "James Nelson"),

React.createElement('a', {href: 'mailto:james@jamesknelson.com'}, 'james@jamesknelson.com') ),

React.createElement('li', {},

React.createElement('h2', {}, "Joe Citizen"),

React.createElement('a', {href: 'mailto:joe@example.com'}, 'joe@example.com') ) ) )

ReactDOM.render(rootElement, document.getElementById('react-app'))

There may be a scenario where you might have to do this but I haven’t come across one myself yet

Using JSX Example :

https://www.sitepoint.com/getting-started-react/

By Eric Greene

"use strict";

var HelloWorld = React.createClass({

  render: function() {
    return (
      <h1>Hello World!!!</h1>
    );
  },

});

var mainElement = document.querySelector("main");

ReactDOM.render(<HelloWorld></HelloWorld>, mainElement);

 

Soon Ill be talking about slowly converting over an MVC project to use REACT.

I think I can sum it up in one quote when talking about REACT in MVC:

“The right man in the wrong place makes all the difference in the world”- GMAN

LampTree Applications : Gobias Coffee

This was the name we choose for our business start up. The company was called LampTree Applications and our initial product was named Gobias Coffee, this was a reference to an old episode of “Arrested Development“,.

The application is a concept for coffee shops to use android tablets for menus, that customers would have access to. The customer would be able to order straight from the tablet and the coffee shop would have the ability to customise the app to display their own logos and special offers/promotions being able to advertise different promotions or change the menus at the click of a button. This was partially inspired from the following video

The unique selling point was the ability to introduce social games that the customers could challenge each other offering discounts or promotions to who ever becomes the champion of a game, Chessmaster, Scrabble King or Lord of Catan for example. The idea being that this would instill a sense of community into the shops customer base as well as giving them reason to spend more time in the shop. The ability to also include subscriptions to digital papers and other publications also allows the coffee shop to offer their customers reading material while they enjoy a lunch or coffee.

The Presentation is available here :

and the document can be viewed here :

I was tasked with gather data on possible clientele and how cost efficiency of how this product could be. I researched into current technologies out there and decided which one would be appropriated over others such as Android over iPad s and research other decisions such as that.This means that I had to find out which products where cheaper and more effective . This was process of basically taken the pros and the cons of each systems this had to be done as certain options wouldn’t not make viable sense if everything is not taken in to account.

The other Members of the group were:

  • Max whose focus was on finding out possible competitors and similar products already in the market.
  • Ray would we thought should be the leader as he had great drive for this product and why really pushed the rest of us into gear
  • and William who did a lot of work on the financial projections for the project.

Time at iTrac Global

 

 

ITrac Global was created by global trade compliance & technology experts,using 21th technologies to develop a network centric solution that allows their clients to move goods in an extremely efficient and compliant manner. It is where international trade regulation and compliance is combined with operational know how to build or improve a global trade compliance program that supports the supply chain.
iTRAC Global, Inc.,is  where international trade regulation and compliance is combined with operational know-how to build or improve a global trade compliance program that supports the supply-chain in a compliant and efficient manner.

I met up with Serge who worked for ITrac Global Inc in the lobby when we were being introduced to the Start up companies within the Nexus Building. When I came into ITrac Global I was introduce to all the members of staff by Serge. After I had met up and talked with the other members of staff. I was brought into a meeting to explain how the software worked and then we discussed about creating a potential app that would be similar to their website and transfer over the same functionality from the website. We tried to decide on how it would be designed and how the user/client would use this app. After this meeting I then signed a Nondisclosure Agreement(NDA).

Once this meeting was concluded I decide to divide up my work into separate tasks. I was tasked with creating a User Interface design which is the design of software applications and focusing on the user’s experience and interaction. So initially I began researching into iTrac Global site and how it worked then I began researching into other apps such as Yelp and Hipmunk which were recommended to me by Andrei to try learn from these apps’ functionally and try and take similar concept to bring them towards the app’s design. After doing some research on other apps I began dividing the functionality  again the reason for this was so that I could concentrate on each part separately and be focused on each objective/goal.

So I began working on the Design by firstly drawing up some rough sketches on what the app would possibly look like and how it would function from scene to scene.I created a  high level example for myself so I knew where I was going with the app.I then began working Axure which is program which draws wire frames and has images such as buttons of the Iphone UI(User Interface)which allowed me to create a mock up UI of the app.I concentrated on this part trying to design each section within my timeframe. I showed Andrei the design and we decided on what was more feasible and intuitive.This was a rinse repeat cycle for the project each time refining the process.I try to design it in a way that anyone coming onto this design will be able to modify and add to the project.

What conditions that makes up the successful cluster account of Art?

In a previous lecturer we had a discussion about art and what makes up successful art. Bery Gaut believes that there are ten rules that art must follow that make up the successfully cluster account of art.

  1. Possessing positive aesthetic properties, such as being beautiful, graceful, or elegant (properties which ground a capacity to give sensuous pleasure).
  2. Being expressive of emotion.
  3. Being intellectually challenging(i.e questioning received views and modes of thought ).
  4. Being formally complex and coherent.
  5. Having a capacity to convey complex meanings.
  6. Exhibiting an individual point of view.
  7. Being an exercise of creative imagination (being original ).
  8. Being an artifact or performance which is the product of a high degree of skill.
  9. Belonging to an established artistic form (music, painting, film, etc.)
  10. being the product of an intention to make a work of art. (Gaut, 2000: 28).

These are Bery Gaut’s own opinion on what makes up successful art . I am going to go through each point with my own take either agreeing or disagreeing with Bery.

  1. For the first point I would have to agree with that art needs to have positive aesthetic properties.Why ?Well I believe that art can be quite graphic showing some disturbing scenes as you can see with the painting done below by Francisco de Goya. Successful art can be show the aesthetic values in the expressions of the soldiers about to be shot show grim aesthetic properties.However even though this scene is grim there is greaete aesthetic beauty behind with the expressions of the faces of the men about to die showing great detail which is highlighted as a point of interest.

    El Tres de Mayo, by Francisco de Goya
  2. I would agree with Gaut on this point as art needs to stir a response of emotion from the observers.Art in its self is primal made through emotion however big or small the emotional response.
  3. Again I would have to agree with Gaut , good art always makes us question ourselves on our own thoughts.Breathing new life to an artist’s painting with a new interpretation from all different people.
  4. Art doesn’t need to be complex to be good as art can be anything to anybody one may find the aesthetic shape of a rock noteworthy of art however another may see it  as another rock.
  5. Art does need to the capacity to convey complex meanings arts needs to able to allow all people to understand the art on many different levels from the structure of the painting and aesthetic beauty to the subliminal and underlining details.
  6. No successful art does not need exhibited a individual point of view to as we can look at abstract art and see that most artists within this medium tend to avoid naming their own painting and the meanings behind because they want to engage the opinions of others.
  7. Again I don’t believe that art needs to be original to a work of art as we can look at films which we’re remade taken a different outlook of the same story but with many differences with feel and the look for an example Tim Burton’s Batman 1989 against the recently made Christopher Nolan Batman series or first Casino Royale with Sean Connery compared to the new remake of Casino Royale with Daniel Craig each working off the same material although completely different on out take. Showing that something does not need to be original to be a work of art.
  8. I would agree with this as most of famous art work showed the great skill involved to make it as we can see with Michelangelo‘s Pieta showing the ability he had crafting from marble or the engravinf work of Knight, Death and the Devil by Albrecht Dürer. Showing the the talent within the artist.
  9. Well I completely disagree with this as if that where the case we would only have two art forms music and painting no I believe art creates it’s own artistic form no matter the medium.
  10. No I disagree as the beauty in the world would refute this point with the leaves blooming from trees to the budding of flowers which all have a design purpose to attract insects and the art being a side product of this as it was made for more of functional use.

They are my opinions on these although I agree with some and disagree with others I find that art can be define in many different ways.