The big nerd. Like you have no idea.
engineering, coding, government, design, construction, development and some RTV gaskets (google it)

another vbscript "cheat"

June 23, 2008 13:08 by Jesse

I hate putting text boxes and labels on an aspx page.  It's stupid boring and that trigger in my brain says "There's GOT to be a faster way to do this" ...and now there is, I got sick of it so I made a vb script as such...

DIM fso, outputFile

const ForAppending = 8
dim LabelStart, TextBoxStart
LabelStart = "<asp:Label runat=" & chr(34) & "server" & chr(34) & " ID=" & chr(34) & "lbl"
TextBoxStart = "<asp:TextBox runat=" & chr(34) & "server" & chr(34) & " ID=" & chr(34) & "txt"

'variables we will need
dim controlName, labelText
dim keepAdding, intVal
keepAdding = True
Set fso = CreateObject("Scripting.FileSystemObject")
Set outputFile = fso.OpenTextFile("ControlGenerator.txt", ForAppending, True)
do while keepAdding

 controlName = InputBox("ControlName?")
 labelText = InputBox("Label Text?")

 outputFile.WriteLine(LabelStart & controlName & chr(34 & " Text=" & chr(34) & labelText & chr(34) & "/>")
 outputFile.WriteLine(TextBoxStart & controlName & chr(34) & "/><br />" )
 intVal = MsgBox("Add Another?", 4)
 if (intval = 7) then keepAdding = false
loop
outputFile.Close
wscript.echo("Complete")
 

Save that as a vbs file.  What will this do?

<asp:Label runat="server" ID="lblStreetName" Text="Street : "/>
<asp:TextBox runat="server" ID="txtStreetName"/><br />

Now to go pound out 40 or so controls like this....no, not joking.


Be the first to rate this post

  • Currently 0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5
Tags:
Categories:
Actions: E-mail | Permalink | Comments (0) | Comment RSSRSS comment feed

Graduation

June 22, 2008 17:43 by Jesse

Today I went to a graduation.  This wasn't any graduation but someone that use to work for me for a couple years.  He's older than me, has a family (two kids in high school) and never went to college before, although his wife has a masters so this was new to him.  He was going for all the right reasons.  He didn't like where he was nor where he was going so it was time to change it -- off to college he went.  The first couple classes in electronics, he brought in some questions from his homework (which I encouraged, I have a similar degree) so we used the whiteboard to draw out the whole thing and break it up so it's easy.  Each time we did so, at the end he'd shake his head "That's it?! Are you serious?" -- this was great, it let me know he was understanding how to make it simple.  To make it stick, I made a point to bridge what he was doing at the office with what he was learning so it was practical and useful in other places.  I also began to teach him how to ask exact questions to get the answer he wanted.  This went on almost daily as I was his manager/mentor.

Interestingly, he graduated exactly 5 years after I obtained my bachelors.  Same place, same time, just 5 years later.  It caused a moment of reflection of what I'd done in those 5 years and more importantly, I had a direct hand in someone's continuation of bettering himself.  It was a somewhat strange feeling watching him walk across the stage.  I'd guess it's the same feeling my parents had when I walked across that very stage -- I wasn't expecting that since I have no kids.  Strange as it was, it made me proud.

After his commencement, he told me he wants to talk -- thinking of the next step, "what's next".  I'm sure it'll be a great conversation because by now, he's fully outgrown his position where I use to manage.


Be the first to rate this post

  • Currently 0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5
Tags: ,
Categories: Misc
Actions: E-mail | Permalink | Comments (0) | Comment RSSRSS comment feed

DotNetPanel, how I love thee

June 17, 2008 09:35 by Jesse

Recently we've been playing hot and loose with a couple webhosting companies.  I have my own here for rileytech, BUT its an uber account (resellers) so I host a number of other sites for people I know and trust.  As of late, I've been having to deal with some truly terrible interfaces for webhosting and no one is safe.  GoDaddy, NetworkSolutions, WebHosts4Life, I hate their interfaces but I must digress, I've been spoiled by DotNetPanel.

If you've never used DNP, you need to something fierce.  Since I came from the net admin side, I want everything even if I don't need it (because hey, I might ...someday).  I'd encourage you to check out their demo and insist whatever host you pick has DNP.  Yes, it's that good and better.  Just a quick search, I found that Integral Hosting has individual plans and runs DNP.

No, I don't own any type of share of DNP, nor do I know anyone that works there, nor getting anything for free from them (unless they'd like to!) -- I just happen to like stuff that works the way it should.


Be the first to rate this post

  • Currently 0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5
Tags: ,
Categories:
Actions: E-mail | Permalink | Comments (0) | Comment RSSRSS comment feed

Sitefinity modules, the easier way!

June 16, 2008 15:07 by Jesse

From my previous posts, I talked about creating a custom module that complies into a dll.  I've discovered that is THE hardest way possible to create a custom control.  The experience was good, but not exactly fun.

Luck would have it, they have a much stupid simpler way.  It's not as shareable, you have to add the files to each and evey site instead of just changing up the web.config.  So what?  There's a download they provide in their documentation that's kind of burried, but no sweat, you can get it here.  It's a full project and it takes a minute to unzip.

Before we get started, let me explain what this custom module does and what we're going to do to it.  The JobsModule consists of 4 user controls, your tried and true ascx files, that do various things, a couple classes, nothing intimidating.  One neat thing they did in this example was use an interface, "IJobsControlPanel", (app_code/jobsmodule.cs:142) to switch between two modes, "Category" and "Type", but in my examples I removed this for simplicity and the real module I was creating does not call for it.  Other files you need to note are all within the /Jobs folder.  Control panel and Toolbox are for the admin side, where the "JobList" and "JobListSummary" are for the user side. 

If you haven't went though the pain and agony of unzipping that file, do so now and let's take a look at the "JobsModule.cs" under the app code directory.  Line 28 begins the Nolics database init which later on, we won't need, but note where it is.  Under the properties region, lies the name/title/descript that will show up on the admin side.  On line 93/94, these are the files that will show up for the user side which will get more into later, just note that is where they are.  Next, take a look at line 112 and 121 as these are you admin controls.  Very easy to do.  Finally, there's the enum and interface for the other items they use for this module.  This is 95% of what it takes to make a module.

For this example, I am going to completely ignore the code behind for the user controls on the public facing side as they are unimportant.  Why?  Because user controls are user controls are user controls.  Make one, make 'em all, which is a very good thing!  Now, let's make a custom module, shall we?  Let's say we have a customer that wants a very very basic control that displays how many orders recieved today with the option to look at yesterday.  Our database table will look something like this...

TableName : Orders
Id  uniqueidentifier, not null, primary key
OrderDate datetime, not null
Quantity int, not null
DollarAmount money, not null
ItemOrdered nvarchar(1000), not null

Very simple, nothing fancy.  For the next step, I went away from the example just a bit and created a "CustomModules" folder under the App_Code directory along with a "DAL" folder with two folders within named "Generated" and "Extended".  See the image below for a bit of clarity. Now move "JobsModule.cs" into the CustomModule folder. Create yourself a folder in the root named "CustomControls" and a folder within it called "Orders" -- this is where the user controls will live.

At this point, if you've never touched subsonic, I would highly suggest jumping over there to brain up on how it works as I will not be covering that aspect.  Also, if you are unfamiliar with subsonic generating only certain tables, add the tag includeTableList="Orders" to your subsonic service.  For reference, this is a comma seperated list and will restrict subsonic to generating only those tables defined there.  Very handy since sitefinity has around 100 tables out of the box.  Generate this table and dump the files into App_Code/DAL/Generated.

Next, make a new class in App_Code/CustomModules and name it "OrdersModule.cs".  On the class declaration, inherit the WebModule from the Telerik namespace, implement the abstract class and change out the constructor from public to static as seen below.

Hop over to the JobsModule and copy the Methods region (override CreateControlPanel and Override CreateToolBoxControls), paste those into your OrdersModule -- don't worry about the string values yet, we'll get to those.  Also copy over the get in JobsModule:83-99 and paste that into the "Controls" override.  Finally, create a private variable of IList<Telerik.Web.IToolboxItems> (look to JobsModule:40 for example).

Now that's prepped, hop over to the CustomControl folder and create 3 user controls - "ControlPanel.ascx", "ToolboxPanel.ascx" and "OrderList.ascx".

ControlPanel needs to inherit the Telerik.IControlPanel and go ahead and give some string values, similar to this...

#region IControlPanel Members private readonly string status = "Orders";
private readonly string title = "Orders";

string IControlPanel.Status
{
     get { return status; }
}

string IControlPanel.Title
{
    
get { return title; }
}

#endregion

In the ToolboxPanel, inherit the Telerik.IControlPanelCommand and give values where necessary (Title for one).

Finally, for OrderList, we don't have to do anything yet.  If you feel like it, drop some text on the page just for rendering reasons.  Guess what? Most of the "behind the scenes" work is already done.  No really!

At this point, it should build and give you a custom module within your sitefinify project.  For the next post, I'll talk about how to wire up the subsonic stuff and even get at some data within sitefinity!


Be the first to rate this post

  • Currently 0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5

SQL Domain Error Occurred? Hu?

June 6, 2008 15:57 by Jesse

Working with some good ole Sql today, get slapped in the face with this

Msg 3623, Level 16, State 1, Procedure FindLocations, Line 9
A domain error occurred.

Gah! Considering I copied this from an in-line sql statement, I figured I was golden, wrong.  So what's going on?  The procedure that did this is doing a little calculation to determine miles away based on a lat/long value lookup.  Where's the problem?  Lat/Long values can be negative and if you know anything about math, the square root of a negative number is (!) imaginary, something sql has NO CLUE how to handle (but matlab does!). 

So, to fix this problem, and since no results will ever be negative miles away (relativity?), I pulled the calculation result into the magical "ABS" (absolute) function to give me a positive number, no matter what.

 


Be the first to rate this post

  • Currently 0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5
Tags: ,
Categories: Tech | Weird | Sql
Actions: E-mail | Permalink | Comments (0) | Comment RSSRSS comment feed

Teaching or lack of

May 30, 2008 09:49 by Jesse

A friend of mine has been in school for programming now for nearly 2 years and getting his associates really soon.  Good for him!  On and off he's come and asked me some questions about how to approach certain problems, most of which have been fairly easy to me so I was happy to help and walk him though some of the confusing aspects.  No sweat.

About 2 days ago he approached me about his senior project and that they were doing a website and needed some help with editing, updating employee info.  He also noted that just getting data was a huge pain and took hours for them to get it to work.  No problem, that's easy stuff.  I busted out my favorite ORM tool (subsonic!!!) and showed him how to make his data access life easy.  None of this inline sql crap.  Then I discovered something downright offensive.

We all know architechure is important.  Someone forgot to tell them that.  Further, they didn't seek out any assistance and went crazy.  What they ended up with was a horrific db structure and data access the hardest way known to man (by hand using the object data source).  I kid you not there's a page, an aspx page that has over 1000 lines and its just displaying simple address info, nothing more.  Adding more pain, instead of using 1 page as a one stop shop, every CRUD operation is broken up into individual pages.  View the data over here, edit it over there and save it somewhere else.  I'm not joking.  Just to step it up a notch, the naming conventions are "NewUser" (new employee), "Employee Management" (editing employee data) and "ManagePhoneNumbers" (just to edit phone numbers).  In their defense, the graphics and layout aren't bad, B+.  The links and useability, F.

What are they teaching these students?!  Are the professors this far removed from the real world?  This isn't the first time I've heard of teachers being way way off base and furthers my desire to teach.  It's terrible, sad and pathetic.


Be the first to rate this post

  • Currently 0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5

Encryption, Development and AES

May 16, 2008 12:55 by Jesse

If the custom module wasn't enough, I'm now wondering off into encryption land.  A quick scouting of the System.Security.Cryptography namespace shows me a ton of stuff to play with.

Ooo, AES.  I like AES.  It runs on my router(s) @ home and is viciously annoying to crack (TKIP f0r t3h w1n!!!11).  Cool, let's use that, its good enough for top secret docs for the gov so it should be good enough for me.  But, as with anything else, there's a catch or ...20.  Here's some basic considerations.

Will this data be searched? 

Searching encrypted data is a royal PITA and a huge overhead.  Example : saving data to a db with encryption happening in the business layer.  A perfectly viable user says to the application "hey, find this" -- you cannot directly ask the database to find it, it is impossible, so every search that happens comes across, ALL OF IT (say 2 million records), decrypts, the search happens, find the records necessary and passes that on.  Not very reasonable nor scalable.  2nd option for this is do it on the sql server itself.  Fundamentally I have a problem with this for 2 reasons.  1, a purely architecture standpoint, this should never be passed off to the data source.  In the real world, it's probably ok to offload some of that overhead, but still, using the OSI model alone says "no no" -- encryption happens in the presentation level and offloading it means you pass though all 7 layers ONCE before you encrypt -- bad bad bad.  2nd, unless the data connection between app/server is encrypted to hell and back itself, your encryption is trumped and effectively worthless.

How much protection is necessary?

The question of the ages.  Understanding the CISSP-ism of protection and risk management: the amount of protection spent on it should be equal to the amount of total loss of one breach by the inverse of the possibility of recurrence.  So say the data is worth 10 million dollars for ONE loss.  The probability of loss is once every 5 years.  10m/5y = 2 million a year should be spent to protect it.  No really.  Now, if there's no REAL value to the data, ie, its personal junk you keep at home for giggles, then whatever the server can handle works fine.  Otherwise, use reasonable + 1.

I'll stop there.  Other questions can range from "Who needs access to it?" to "Where will the server be physically housed" -- but thats somewhat outside of the scope of this post.  Not saying they're unimportant, just "too much" for this post.  I think my first task will be working on getting something simple to encrypt, like a file or a string and work up from there to see how much overhead this thing creates.


Be the first to rate this post

  • Currently 0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5

SiteFinity and Custom Modules - Final

May 15, 2008 11:49 by Jesse

It works, I see data, it comes, it goes.  It all works.  This'll be my last posting about this for a while but ...Marathon post, GO!

From part 2 of the sitefinity adventure, we left off with controlpanel.cs, I'll continue from there.

webcontrols/admin/<controlName>Editor.cs - where you edit/change/modify your content for your control.  This is another complicated class on the surface yet very similiar in operation to controlPanel.cs.  This also contains a Methods section with CreateChildControls which is important (don't forget to wire events in this method too).  Additionally, update/save/delete methods will be added in here as private methods.   Templates is also important section yet again because you have to line up your event commands to match what your handler understands.

I<controlName>.cs I eliminated completely.  No need for it since subsonic handles the class generation.

<controlName>.cs I also elimated -- again, subsonic handles this.

<controlName>Manager.cs - module name is defined in here, along with some other minor lightweight labeling.  I removed all get/update/delete/etc calls from here, subsonic's controller class handles this.

<controlName>Module.cs - simliar to manager, lightweight and mostly a labeler.

<controlName>Provider.cs - this pulls the info you define in the web.config for your custom control.  Pay close attention to the names (string values) that grab this info, otherwise expect some nasty "I can't find this!" errors.

A quick recap on the classes.  Well, the important/involved ones.  Admin/<controlName>Editor.cs and Admin/ControlPanel.cs require a lot of focus.  The override method "CreateChildControls()" needs to have all things necessary for that on-the-fly usercontrol to operate including events for button clicks and the like.  The Template section defines what shows up where via the container region with what names of what controls when childControls does its magic.  The rest on a really high level view is labeling and correct text pointing to the new control.

So onto the fun stuff, how do you make subsonic work with sitefinity?  It's not nearly as hard as you'd think, thanks to the <Table>Controller.  This ties right up to an ObjectDataSource real easy like.  First you find your objectdatasource that looks something like this from the contacts example...

ObjectDataSource dataSource = new ObjectDataSource();
dataSource.ID =
"ContactsDataSource";
dataSource.TypeName =
"Sample.Contacts.ContactsManager";
dataSource.SelectMethod = "GetContacts";
dataSource.DeleteMethod =
"DeleteContact";
dataSource.DeleteParameters.Add(
"id", Guid.Empty.ToString());
this.container.Controls.Add(dataSource);

and switch it out to something like this...

ObjectDataSource datasource = new ObjectDataSource();
datasource.ID =
"SubsonicDataSource";
datasource.TypeName =
"MyNamespace.Data.MyTableObjectController";
datasource.SelectMethod =
"FetchAll";
datasource.DeleteMethod =
"Delete";
datasource.DeleteParameters.Add(
"id", Guid.Empty.ToString());
this.Controls.Add(datasource);

And thats it, it's good to go.  You can find these methods within the controller object and if you've used subsonic at all, you know these already without looking.  From there, some wiring needs done for the save events and things of that nature...here's an update example pulled from the <controlName>Editor.cs, in this case, my example is a "SalesStat" ....

private void Button_Command(object sender, CommandEventArgs e)
{
switch (e.CommandName)
{

case "Cancel":

this.OnCanceled(EventArgs.Empty);
base.ChildControlsCreated = false;
break;

case "Save":

if (this.salesStatId == Guid.Empty)
{

CreateNewSalesStat();
this.OnSaved(EventArgs.Empty);
base.ChildControlsCreated = false;

}
else
{

this.UpdateSalesStat();
this.OnSaved(EventArgs.Empty);
base.ChildControlsCreated = false;

}
break;

}

private void CreateNewSalesStat()
{

salesStatData = new QSalesStat();
salesStatData.SalesStat =
this.container.SaleDollarAmount.Text;
salesStatData.Save();

}

Very easy to do.  I'm becoming a huge fan of subsonic :-)


Be the first to rate this post

  • Currently 0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5
Tags: ,
Categories:
Actions: E-mail | Permalink | Comments (2) | Comment RSSRSS comment feed

60 Second Science

May 14, 2008 10:15 by Jesse

Ever since I got my zune, I've subscribed to all kinds of podcasts, one I particularlly enjoy is the 60 second science from Scientific American.  It's good stuff and REALLY lasts 60 seconds (with intro and junk, 1:15).  One that really caught my attention was one regarding Training Scientists to Run for Office.  It's an awesome idea and here's the transcript...

[The following is an exact transcript of this podcast.]

Would America be a better place if more people with science training held elective office?  One organization that thinks so is Scientists and Engineers for America, or SEA.  On May 10th, they’re holding a daylong workshop in Washington, D.C., to teach researchers the nuts and bolts of running for office.  More than 70 attendees have signed up.
 
SEA points out that understanding a lot of today’s most pressing challenges requires a science background. Energy, health care, climate, even general competitiveness are all deeply connected to scientific research and progress.  Even more important may be the general intellectual approach that scientists could bring. The group’s director, Lesley Stone, says, “Scientists and engineers have an appreciation for the kind of evidence-based decision making necessary for tackling our nation’s most pressing problems.”
 
For more information, go to
www.Elections.SEforA.org.

--Steve Mirsky 


Be the first to rate this post

  • Currently 0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5
Tags:
Categories: Government
Actions: E-mail | Permalink | Comments (0) | Comment RSSRSS comment feed

Sitefinity and Custom Modules - Part 2.5

May 14, 2008 09:44 by Jesse

in the past couple posts, I've been covering custom modules in sitefinity with subsonic.  This morning, I hit a snag and I'm not sure how I'm going to go about fixing it.  Immediately after one of the overloads, the SalesStatManager constructor is called where it gathers the provider info and promptly bombs out as such...

Configuration Error

Description: An error occurred during the processing of a configuration file required to service this request. Please review the specific error details below and modify your configuration file appropriately.

Parser Error Message: Could not find a type for a name.  The type name was 'SalesStats.DefaultProvider'.

Source Error:
Line 215: <providers>
Line 216: <clear/>
Line 217: <add name="Sales" securityProviderName="" type="SalesStats.DefaultProvider" conectionStringName="DefaultConnection" visible="true"/>
Line 218: </providers>
Line 219:</salesStats>

I've submitted a question to one of their devs in hopes they can tell me its something stupid (it has to be) and I can move forward with my uber cool research.  I love these projects.


Be the first to rate this post

  • Currently 0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5
Tags: , ,
Categories: .Net | Misc
Actions: E-mail | Permalink | Comments (0) | Comment RSSRSS comment feed