routing-table basics

Every router use a routing table to control the data-flow. Sometimes you have to set up the table. With this steps you can easy define the data-flow:

  1. Describe the local networks
  2. Describe the rest of all networks opposed to the standard-route
  3. Describe the standard-route (0.0.0.0)

The standard route is the way through the network to the internet. If there is no internet connection you have to define the standard-route but probably you have an internet connection.

Lets do this with an example:

unbenannt

We want to set up the routing table for the router “West”.

  • 10.0.1.0 (local) – by step 1
  • 10.0.2.0 (next network opposed to the standard route) – by step 2
  • 0.0.0.0 (standard route) – by step 3

Thats all to checkout the entries for the routing table.

One further thing: metric.

Metric are the units of the “hops”. If we are router “West” and we want to have the metric for the networks 10.0.1.0 and 10.0.2.0:

10.0.1.0 = local = 0 hops => metric = 0
10.0.2.0 = 1 hop => metric = 1

Thats all …

Advertisements

set up windows 10 newly

Today I set up my laptop new. The last times I had to organize a disc or a stick with the windows installation. For this I had to download the iso-file, install a programm to create a useble disc/stick and had to check out the windows key. This time I found something that handles everything for my automaticly. You can find it here:

settings -> update and security -> recovery

You can start it and even can choose if you want to keep your folder “my documents”. After this it will clear everything and reinstall windows 10.

With this I could use my day without spending time into the basic-preperations # Thanks ūüėÄ

dynamic read on JSON response in c#

If you want to work with a JSON-formatted response, there are many ways to handle this. In the following I could figure out a dynamic read that will give you the opportunity to use the different types.

The first code-example shows how to download some data with a given URL. For this you will need the assembly “System.Net”:

string url = "address?$format=json";
var webClient = new WebClient();
String jsonResponse = webClient.DownloadString(url);

The second code-example shows how to read out the single attributes. For this you have to include the assembly “Newtonsoft.Json”:

dynamic results = JsonConvert.DeserializeObject(jsonResponse);

string myName = results.Name;
string myFirstName = results.FirstName;
int myAge = results.Age;
//...

After using the JsonConvert.DeserializeObject-function you can use every single attribute.

JSON response via NAV

#This article will work with NAV 2016!

To get a JSON Response via NAV¬†we can create¬†a webservice-codeunit and publish it. Following this we¬†probably use SOAP to publish the functions and will get a XML-response. In some projects it is easier to handle a JSON response. As well there are opportunities to read out a NAV response with the JSON format. The easiest way to do this is by publishing a page. To do this just go to the table “Web Service” (2000000076) and create an entry for a page. If you run this via the normal user-client (search for “web service”) you will see a Odata-link. This link is generated automatic. If you set¬†on the Odata on the service tier and use this link you will get a response with the data of the page.

Probably it is xml-format but you can add the following at the end of you Odata-url:

?$format=json

Now your response should use the JSON-format.

If you want to do the same with a codeunit you will get no odata-link. ¬†This is because we use a REST-service. A REST-service is done to have the basic-handler GET, POST, PUT, … . So if you would try to write some codeunit that should provide a json-response, the codeunit had to handle all of this basic-statements.¬†A codeunit in NAV is not made to provide data like a real REST-service. But if you want to use data that way -> publish the data with a page and you can work with this.

rotate an image in c#

There are different ways to rotate an image in C#. The first is probably the easiest one but provides just the basic 90, 180, 240 and 360 degree. Here is the way to do this:

mainPicBox.Image.RotateFlip(RotateFlipType.Rotate90FlipXY);
mainPicPox.Refresh();

For this example you need the library “System.Drawing” and an image.

The next example shows how to turn an image with an given angle:

private Bitmap rotateImage(Image thisImage, float angle)
{
 var newBitmap = new Bitmap(thisImage.Width, thisImage.Height);

 using (Graphics g = Graphics.FromImage(newBitmap))
 {
  g.TranslateTransform(thisImage.Width / 2, thisImage.Height / 2);
  g.RotateTransform(angle);
  g.TranslateTransform(-thisImage.Width / 2, -thisImage.Height / 2);
  g.DrawImage(thisImage, new Point(0, 0));
 }

 return newBitmap;
}

At the end of the function the grafic draw a new image. Here I used a new point (0/0). This is the orientation of the new draw and left-top of the new picture.

And this is the result:
rotation