6. October 2010
ASP.NET , VB.NET
Maybe you find the need to; or you think of the possibilities of controlling a Windows Service from a Web App might be useful. For me I like the idea of writing a Windows Service that does some server function but can be controlled or called by a user. This is a more detailed post on code examples from the previous post with some other considerations.
- Maybe a Administrator needs to start and stop services but doesn’t have access to the server by normal methods.
- A user that calls a Windows Service that performs some type of Emailing functionality such as a notifying users when they have a new Task. Maybe this table is populated by many means. Win service would check the database every 30min and send off emails. In your web app, your users are special, so every time they assign a task, you fire off the windows service right there and then. Or maybe sometimes you have the need to fire off a manual send and have written redundant code to do it.
- Windows service control center for developers? Or Support users?
Anyway, the process is quite easy.
Windows Service code, somewhere have a method like this…
- Protected Overrides Sub OnCustomCommand(ByVal command As Integer)
- Select Case command
- Case 130
- 'Call one of your other methods from here
- Case 150
- 'Call some other method or command
- Case Else
- 'Do Nothing
- End Select
- End Sub
You can only call one CustomCommand, so you send in Command Integers and from there decided what you want to do.
In your ASP.Net app on a button click event..
- Using sc As System.ServiceProcess.ServiceController = New System.ServiceProcess.ServiceController()
- sc.MachineName = "Mastro-PC"
- sc.ServiceName = "ComplyTrackMainTimer"
- End Using
This will work on a web.app on a button click event. You have to set the MachineName and the ServiceName. You can also Stop() and Start() the Service or look up the Status.
You can get the MachineName of the server by opening a command prompt from the server and typing in “HostName”
You can get the ServiceName by opening up the server and looking at the name in Services. Don’t use the Display Name use the Service Name.
I have a previous post on this with more detailed information on valid Command Integers and Security.
I’ve been using DevExpress’s Visual Studio Tool, CodeRush, for awhile now and I love it.
There’s been a feature though I was never familiar with, and that’s the little digits next to my methods. Choices of Cyclomatic Complexity, Maintenance Complexity and Line Count. Granted I figured out what Line Count was.
So I did some research and found that Mike Miller from DevExpress has a Blog over there and goes over some CodeRush features that I found helpful. I don’t know where his post on the Complexity count went but he did mention to another user on a forum post that there was this PDF which he describes the Complexity numbers.
This has been helpful in alerting to me when I need to refractor my code and make changes, and break it out.
Here’s the charts from the PDF, which is the meat of it.
Probably the simplest measure of complexity. CC is the number of decision points for a method plus one. It also happens to represent the minimum number of test cases needed to travel through all branches of a method.
The purpose of Maintenance Complexity is to give you a picture of how much code you have in a given member.
Maintenance Complexity Points
Breakdown of how the Maintenance is counted
My friend sent me this link it’s so funny. I copied it here just in case the original disappears.
Hat tip to Hyperbole and a Half for the artwork on this one.
If you get the error, “Sending email is not enabled”, its because you haven't configured this yet.
You can configure email settings using following command.
Or just do it via the TFS Administrator Tool which you can also Enable Email Alerts.
India is about to put out a computer that’s only $35!! Crazy! Then drop the price to $10 a unit as it sells. Don’t know what the stats are other then it’s a Linux based machine but I’d buy 10 of them.
From the picture it kind of looks like a wallet and flexible. Who’s been smudging up my screen!
“India has unveiled a $35 computer prototype as part of its program to provide connectivity to its students and teachers at affordable prices.”
“The ministry said the price would gradually fall to $10 a piece.”
“The Linux-based computer is equipped with an Internet browser, a PDF reader and several other facilities…”
Looks like it’s still in progress and more legit then the original post. http://news.cnet.com/8301-17938_105-20013370-1.html
- OS: It was changed from Linux to Android.
- Virtual Keyboard
- Full Video Capability
- 2GB Ram
- Scheduled for Mid-2011
14. July 2010
About Me , Personal
This interesting study, I wanted to post. As when I talk to someone about politics or religion, it’s interesting how when faced with factual information, someone’s views will not change.
"In a series of studies in 2005 and 2006, researchers at the University of Michigan found that misinformed people, particularly political partisans, rarely changed their minds when exposed to corrected facts in news stories. In fact, they often became even more strongly set in their beliefs. Facts, they found, were not curing misinformation. Like an underpowered antibiotic, facts could actually make misinformation even stronger."
“…we base our opinions on beliefs and when presented with contradictory facts, we adhere to our original belief even more strongly. “
Does anyone have an nCore.cc invite they can send me? I don’t speak Hungarian, but I love BitTorrent sites. Seems this one is invite only, and of course you have to know someone in the circle to get an invite, so no access for me. Reminds me of Oink.cd in the old days before they were taken down, was invite only and a great site. Demonoid is as well, but at least I was able to get in eventually. Though lately I find myself using Kickasstorrents.com for everything. I do like RLSLog, I’m glad they are back online.
So you’re getting error message…
The HTTP request to <URL To WCF Service> has exceeded the allotted timeout. The time allotted to this operation may have been a portion of a longer timeout.
Three places to set time values to fix this issue…
<httpRuntime executionTimeout="600" />
(this is seconds, so here it’s 10min). More info on httpRuntime here.
2) On your Web.Config Binding Elements
3) On your ServerReferences.ClientConfig binding elements within the system.serviceModel
Yes, I can speak english. That statement was a play off a famous game that was poorly localized to english and that was the phrase they used, “All your base are belong to us”
I had so many spam/flood comments in my blog that I’ve wipe them ALL!! So I’m sorry for those of you that had valid comments. I’ve added captcha so hopefully that will slow that process down a whole lot.
So again, sorry for those of you that had your real comments wiped. Clean slate time.