onsdag den 6. februar 2013

Hello Windows 8

At last I installed Windows 8 on my work computer. It's a Lenovo W520 with 32 Gb ram and overall it runs fine.

But what is this new beast? I'll try to figure out what can be done smarter than windows 7.

Start

The first thing you'll find out is the start screen.. This is smarter on a touchscreen where you can use gestures. On a normal screen its just indifferent, and sometimes a little annoying.

When you go to the desktop you'll see that the startbutton is gone. But then again, why use it, when you have the windows-button. But what happens when you press the windows-buton.. You'll go to the start-page and without a touchscreen, its just a screen with buttons.

Apps vs. Applications

In windows 8 Microsoft has followed the wave of apps as you see them on mobiles and tablets, but what is the smart thing about apps on windows?? 

In my opinion: On a normal laptop or desktop computer.. absolutely nothing or at least so close to nothing as it can be. 

We are now split up in to environments
  1. The App/Modern UI style/Windows Store App environment
  2. The desktop environment. 

Security

In the app model you need to allow the app to use your system. That sounds appealing.. But on the other hand.. How often does a user read a dialog.. and if they want to play a game, do they really wonder if it requires access to the local network or webcamera?
Of course it's easier to send the responsibility to Microsoft as they have to approve the app, and then the IT-pro can use the UAC again, and disallow the users to install desktop applications. 

The desktop application has the same security level as usual, and you cannot actually trust them as a ground rule. Of course that will be a paranoid world and who wouldn't take a chance. 

App/Modern UI environment

Or Windows Store App/Desktop app. What's the user experience on these? Well, the easiest way is taking a look at the Internet Explorer. It's in a app and a application version out of the box. If you take a normal website as http://msn.com it's ok. Its in full screen but otherwise it's working as expected. But then try to go to a web chat or something that requires some kind of update.. It actually uses the F5 update, which causes it to crash..
So you cannot use it on all sites. 
But in apps you can use the contracts. That means, that you can use the different buttons when you open the right side bar.. 

Share

The sharebutton is, well for sharing.. So if you have a page in the internet explorer - you can share the link to what ever can receive it.. Fx. Facebook - through "Persons". 

Search

With the search button you search the current app as the search contract is implementet. In internet explorer it's through Bing but it can be anything. 

Multitasking

Windows 8 can multitask, BUT the app environment takes the human part of it away.. You cannot run 2 apps beside each other if you work with one screen. Furthermore, the mediaplayer app stops playing when you cannot see it.. so you'll still need a desktop version. Which is the case for many apps.
A Little edit: the Windows+. actually makes it possible to have 2 app Windows available at the same time

Shortcuts

I like to use the keyboard.. A lot of these shortcuts also work in previous versions of windows
  • Alt+Tab: Switch between apps.. Both windows store and desktop
  • Ctrl+Tab: Switch between tabs/dialogs in an application. Application dependend. 
  • Ctrl+Shift+Esc: Opens the taskbar
  • Windows+Tab: Switch between windows store apps. 
  • Windows + : Switch to desktop app no. if there are more than one window in that app, switch between those
  • Windows+q: search installed apps or the search for the current app. This is smart when you have to open an app fast.. Try to press windows+q and then write "note".. but, it can also be a bit confusing
  • Windows+w: starts settings.. again start typing and you'll find the right setting
  • Windows+e: starts the windows desktop explorer
  • Windows+r: starts the "Run" dialog
  • Windows+t: opens the preview of applications in the task line
  • Windows+u: starts the "Ease of access" 
  • Windows+i: opens the settings sidebar.. 
  • Windows+p: opens the "Project to a connected screen" sidebar
  • Windows+s: Sends screenshot to OneNote (if installed)
  • Windows+d: Shows the desktop environment - if in app environment - and the desktop otherwise.. 
  • Windows+f: Starts the filesearch bar
  • Windows+h: Starts the Share contract - only for windows store apps
  • Windows+k: Sends to devices
  • Windows+l: Locks the workstation
  • Windows+x: Opens a quickstart for controlpanel
  • Windows+c: Opens the start sidebar.. The same as if you take the mouse to the right corner
  • Windows+n: Starts new onenotenote
  • Windows+m: Minimizes all windows
  • Windows+,: Quickshows the desktop, as long as you hold down windows key
  • Windows+.: I don't get this

Conclusion

It's faster than Windows 7 I think.. But the user experience on a normal laptop requires a lot of shortcuts to be really good, and the apps.. Well they are fun for the enduser, but not applicable for heavy use. 

Hello blogger app

Just installed blogger for android

tirsdag den 13. november 2012

Hello layered programming

Groft sagt gør alle applikationer det samme

  • Modtager bruger data
  • Behandler data/Gemmer data
  • Returnerer behandlede data
Så endnu simplere har vi en brugergrænseflade og en behandlingsflade. 
Brugergænsefladen kan være forskellige flader:
  • Windows form applikation
  • Web applikation
  • Mobil applikation
  • Powershell script
  • Kommando prompt
Behandlingsfladen kan ligeledes deles op i forskellige flader:
  • Funktionsflade
  • Filflade
  • Databaseflade
  • Webserviceflade 
og for at man kan genbruge fladerne bedst muligt, deler man det op i mindre dele/byggeklodser, som kan bruges i de forskellige sammenhænge. Det svarer til at man har stikkontakter i huset, som kan bruges til forskellige elektriske enheder. 

I udvikling (i windows) kan man gøre det med klassebiblioteker. 

Lav et klassebibliotek

Lad os starte med at lave et simpelt beregningsbibliotek. (Nyt projekt, Windows C#, Class Library)
Det generer et projekt med en Class.cs fil. Start med at ændre filnavnet til Calculator.cs, hvilket også ændrer navnet på klassen. 

Vi vil gerne have de 4 grundlæggende regneformer. 
  • Addition +
  • Subtraktion -
  • Division /
  • Multiplikation *

så vi starter med at tilføje en funktion, der kan addere 2 decimaltal
        public decimal Add(decimal value1, decimal value2)
        {
            return value1 + value2;
        }

Vi kan jo ikke se hvordan det virker, så vi starter med at lave et ekstra projekt - en Console Application. (Højreklik på solution og vælg Add > New Project)
Her skal vi have tilføjet en reference til Calculator projektet, så højreklik på References og vælg Add Reference... og under fanen Projects vælges Calculator projektet. 
Derefter højreklikkes på ConsoleCalc projektet og Select as Startup Project, da man ikke kan køre et klasse bibliotek. 

I program.cs skal vi lægge kode ind til at kalde vores calculator funktioner, en meget simpel udgave er her. 

            Calculator.Calculator calc = new Calculator.Calculator();

            decimal value1 = decimal.Parse(Console.ReadLine());

            decimal value2 = decimal.Parse(Console.ReadLine());

            Console.WriteLine(calc.Add(value1, value2));

            Console.ReadKey();

Bemærk: Der er INGEN fejlhåndtering i koden. 
Tryk F5 for at køre programmet og prøv at indtaste nogle værdier. 
Nu kan du tilføje de resterende funktioner til koden for at kunne bruge regneformerne. 

tirsdag den 21. februar 2012

Hello Powershell xml

I remember when I started looking at xml and I thought that I had to write a parser myself. Then I started looking at mssql which made it a lot easier. But it still had some bugs. Then I tried powershell and xml. This is quite smart.

Lets see. To read a text file, we need to call the Get-Content. This returns an object and by putting the [XML] in front of the returned object, we can use it as a structure of objects. Lets see, first we'll make an xmlfile with a couple of services in them:



wininit explorer



Let's just read the information on the process, so we read the xml file and gets the process info for each service in the xml-file


[xml]$xmlFile=Get-Content "D:\temp\test.xml"
$xmlFile.Services.Service | ForEach-Object {     Get-Process $_ | Format-List }


Voila, we now have read an xmlfile and tested the processes. But what if we want to write the Ids back to an xmlfile.. 

Lets see - first we make an xml template of what we want. 







and lets use the xml in another way.. just for fun, you can still use [XML]


cls
[xml]$xmlFile=Get-Content "D:\temp\test.xml"
$processFile=New-Object xml
$processFile.Load("D:\temp\processes.xml")
$newProcess=(@($processFile.processes.process)[0]).Clone()
Write-Host $newProcess.pId
$xmlFile.Services.Service | ForEach-Object {
    Get-Process $_ | ForEach-Object {
        $newProcess = $newProcess.Clone()
        $newProcess.Id = $_.Id.ToString()
        write-host $newProcess.Id
        $processFile.processes.AppendChild($newProcess)
    }
}
$processFile.processes.RemoveChild($processFile.processes.process[0])
$processFile.Save("D:\temp\proc.xml")

This reads from the first xmlfile, opens the next as a template. Makes a cloneable object, clones it and inserts values. It appends the new object to the xml and at last it removes the first child as it was the template and voila, we have ourselves a written xml



 
    844   
    4056 

lørdag den 21. januar 2012

Hello Powershell

For a long time I have thought about writing a hello world  on Powershell.. I have done a lot of scripting in my career and Powershell is a great step in the right direction.

So lets get it fired up.
But.. it just looks like a command prompt.. whats so special about that.. Well wait and see. First of all lets do the general Hello world.  In the prompt write:

Write-host "Hello world"

And it returns Hello world as you might imagine.. WOW?? not yet.. Lets try another little thing. Try to write get-pr and press the Tab key. It now fills out the rest and writes Get-Process. Thats great, it has autocompletion .. Press enter, and see the running processes.. Impressed??

Now for something even better. The pipelining. (|) when you write a command it returns an object. This object can be further processed by another command after the pipecharacter through the variable $_. So when you write Get-Process you'll receive a collection of processes, and if you see at the top of the list, the propertynames are shown.
This'll lead us to the first wow.. Try to write :

Get_Process |  Where-Object {$_.ProcessName -like "wi*" }

Now you should see only the processes where the processname starts with wi. So to make a final Hello world in this blog. Try to write


Get-Process | Where-Object {$_.ProcessName -like "wi*" } | ForEach-Object {Write-Host "Hello" $_.ProcessName }

Now you should have a hello for the processes.


onsdag den 9. november 2011

Hello WiRunSQL

I am working with MSI at the time being. It started with the Visual Studio setup project which is easy, but not allways that good in larger projects. Then I found Orca which is good at the developing point. I needed to put some parameters into the package. I knew this could be done by a transformation file (mst) or directly as properties. But eventhough how well I tried to document it there would still be problems. Sometimes the IT-professionals forgot to apply the transformation or the properties, or the rollout method didn't support it.

Then I thought, what if we batched it? On the Google quest I found out that WiRunSQL that also could be found in Windows SDK Components for Windows Installer Developers could to nice things.

It actually connects to the WindowsInstaller.Installer-component which makes it possible to call the content of the MSI package with SQL sentences.

It's a VB-script, so the sourcecode is easily read. Which makes it easy to convert to C# or VB.NET to include in other projects.

Why is this smart?
If you have any customer related information in the installationpackage you can script the updates of the package.

The version of the package is not represented in the property of the file. I don't know why. But with this you can make a script to test the version before the installation.

cscript wirunsql.vbs %1 "select * from Property where Property='ProductVersion'"

So .. Hello WiRunSQL!

onsdag den 14. september 2011

Hello SQL-server

Ever wondered how to find text in stored procedures, functions and triggers?


SELECT OBJECT_NAME(id)
FROM syscomments
WHERE [text] LIKE '%your_search_here%' AND OBJECTPROPERTY(id, 'IsTrigger') = 1
GROUP BY OBJECT_NAME(id)
SELECT ROUTINE_NAME, ROUTINE_DEFINITION 
    FROM INFORMATION_SCHEMA.ROUTINES 
    WHERE ROUTINE_DEFINITION LIKE '%foobar%' 
    AND ROUTINE_TYPE='PROCEDURE'


http://databases.aspfaq.com/database/how-do-i-find-a-stored-procedure-containing-text.html

http://www.sharpdeveloper.net/content/archive/2007/06/26/search-trigger-text-sql-server-2005.aspx