Tuesday, November 10, 2009

Umbraco Hosting

Almost every other day I get asked where should I host my Umbraco Site? Or I've just joined XXX hosting company and Umbraco doesn't work.

There are loads of guides and tutorials on the net about how to get Umbraco working on your host, normally these guides have common traits such as make sure you have the correct permissions set and check the hosting runs their websites in Full Trust.

If you want to skip all that hassle then I highly recommend softsyshosting I currently host over 10 Umbraco sites with them and their support system has always been awesome (along with their prices).

In New Zealand (where I am from) I highly recommend Net24 (for speed and reliability), I also run a few Umbraco sites here and again there service and systems are pretty good (as long as you don't need weekend support). Net24 runs Plesk so you'll need to search Google for "Plesk and Umbraco installation" and you shouldn't have any issues.

Friday, October 23, 2009

skiltz.nzPost

Attached is example of what is to come when the nzpost api is realeased for calculating freight costs.

This is a c# .NET solution so you will need to have visual studio 2008 to run it.

Download from http://agentx.info/skiltz.nzpost.zip

Any questions let me know.

c# Example using the nzpost api



skiltz.nzpost.Package Package = new skiltz.nzpost.Package();
Package.height = 3;
Package.length = 3;
Package.thickness = 3;
Package.weight = 3;
Package.Qty = 1;

//Crete new request to NZPOST RateFinder url
skiltz.nzpost.Request Request = new skiltz.nzpost.Request("Wellington", "Auckland");

//Add our shipment package to the request.
//Can add as many as you like.
Request.PackageCollection.Add(Package);

//Get the response from NZPost
skiltz.nzpost.Response Response = new skiltz.nzpost.Response();
Response = Request.GetRate();

//TO:DO Error Handling.

//we could loop through each package and spit out whatever we want
foreach (skiltz.nzpost.Product p in Response.PackageCollection)
{
decimal cost = default(decimal);
cost = p.Cost;
}

gv1.DataSource = Response.PackageCollection;
gv1.DataBind();



Result:





vb.net Example



'Create new package for shipment
Dim Package As New skiltz.nzpost.Package()
Package.height = txtHeight.Text
Package.length = txtLength.Text
Package.thickness = txtThickness.Text
Package.weight = txtWeight.Text
Package.Qty = 1



'Crete new request to NZPOST RateFinder url
Dim Request As New skiltz.nzpost.Request(txtSrc.Text, txtDestination.Text)



'Add our shipment package to the request.
'Can add as many as you like.
Request.PackageCollection.Add(Package)



'Get the response from NZPost
Dim Response As New skiltz.nzpost.Response()
Response = Request.GetRate()



'TO:DO Error Handling.



'we could loop through each package and spit out whatever we want
For Each p As skiltz.nzpost.Product In Response.PackageCollection
Dim cost As Decimal
cost = p.Cost
Next


If you're looking to implement the nzpost api into your application today and need a developer to make it work please send me an email.

skiltz.DateTimePicker

This projects wraps Martin Milesich's (http://milesich.com/timepicker/) date time picker an extention to jquery ui components into an Umbraco Datatype.

Both of these controls are licensed under the MIT and GPL licenses.

Installing this package will Install the following items:

- Files insalled/umbraco_client/skiltz.DateTimePicker directory
- .dll file installed to your bin directory called skiltz.DateTimePicker.
- Two datatypes called skiltz.DatePicker and skiltz.DateTimePicker

The datatype has 6 properties which can be set.

showTime | true/false
constrainInput | true/false allow user to input text into textbox
stepMinutes | int 1 to 60
stepHours | int 1 to 24
time24h | true/false
dateFormat | dd/mm/yy (javascript format)

Furthur information about these properties should be looked up at Martin's blog as mentioed above.

-Known bugs:
Having two of these datatypes on one page with showTime property set to true caused the time dialog box not to show. This is because the script tags are being rendered to the Master page multiple times.

Any questions feel free to ask.

Download from: http://our.umbraco.org/projects/skiltzdatetimepicker

Wednesday, September 9, 2009

Import data into nopCommerce

skiltz.nopImport
Current Version - Alpha 0.1 *****NOT for Production Systems******

What does skiltz.nopImport do?

skiltz.nopImport will import data from a data source into the nopCommerce database.

What assumptions are made?- Each product has 1 product variant and zero attributes.
- Only products with SKU's that don't exist in nopCommerce will be imported.
- That you have a ProductTypeID that = 1
- That you have a TemplateID that = 4
- That your product images are stored in the database(nop Default) not on the file system.
- That you can remotely connect to your nopCommerce database.
- That your product images are on the file system.
- .net 3.5 framework is installed on PC

What data sources can I Import from?
Currently you can import from Excel or Microsoft Sql Server.

Where can I get help?
Please post all bugs on the nopCommerce forums or email mskilton@gmail.com

Install guide.

Where can I download the installation from?
It can be downloaded from http://skiltzonnet.blogspot.com


Double click on the install file and follow the prompts.


To open the program go to "Program Files"/skiltz/skiltz.nopimport

Steps to complete a import.
Step 1:
Right Mouse Click on NopSqlConnection and click "Update Connection String"
• Type in your server name i.e /home/sqlexpress
• Choose if using Windows Authentication or username and password
• Type in your database name
• Click test connection
• If successful then click ok

Step 2:
Right Mouse Click on Database (under External Data Sources) and click "Add Connection"
• Click "change" on right and choose your data source type (Excel or Sql Server)
• Type in your server name i.e /home/sqlexpress
• Choose if using Windows Authentication or username and password
• Type in your database name
• Click test connection
• If successful then click ok
• Type name of connection
• Click Save

Step 3:
Right mouse click on the connection you made and click "Database Mapping"
• Choose the table you want to import from
• Choose the column that contains your SKU code.
• Match your columns with the columns in nop using the dropdown boxes.
• click save to save you database mapping.

Step 4:
Right mouse click on the connection you made and click "Analyze data" this should some details about the file you are importing and information about nopCommerce.

Step 5:
Right mouse click on the connection you made and click "Import New Products". This should import products. Go to your website and see if it worked.


File can be downloaded from
http://www.agentx.info/setup.msi

Sunday, July 5, 2009

Change ValidationGroup on Wizard Buttons

To change the validation group programatically on the Wizard Control button you can loop through find all buttons and assign the validation group property. See below.



public void AssignValidationGroup(Control ctrl)
{
foreach (Control c in ctrl.Controls)
{
string i = c.GetType().ToString();
if (c.GetType().ToString() == "System.Web.UI.WebControls.Button")
{
((Button)c).ValidationGroup = "osMemberControlsValidate";
}
if (c.Controls.Count > 0)
{
foreach (Control cc in c.Controls)
{
AssignValidationGroup(cc);
}
}
}
}

Tuesday, June 30, 2009

Umbraco Member CanEdit == False?

How do you deal with this situation? In the members section of Umbraco there is a property called MemberCanEdit which then allows in theory a member to edit or not edit the property.

Each property renders a System.Web.UI.Control from the IDataEdtior interface. With System.Web.UI.Control there is no property which can disable the control as opposed to the System.Web.UI.WebControls.WebControl which you are normally use to which has the enabled property.

For controls which are infact webcontrols you can cast the control to a System.Web.UI.WebControl.WebControl control and you will then get the benefit of an enabled property. Not sure what do to do if this fails...Show a label instead?



if (mt.MemberCanEdit(pt))
{
_dataFields.Add(dt);
}
else
{
try
{
((System.Web.UI.WebControls.WebControl)dt.DataEditor.Editor).Enabled = false;
}
catch
{

}
}

Monday, June 29, 2009

Member Action Handlers

Sometimes you need do stuff with members once you've created, delete, changed something. The code below adds two new action handlers 1 when a member is created and one when a members is saved. In version 4 of Umbraco create a new class project and do something like so:




   1:   public class MemberAction : ApplicationBase

   2:      {

   3:   

   4:          public MemberAction() {

   5:          Member.New += new Member.NewEventHandler(Member_BeforeSave);

   6:          Member.AfterSave += new Member.SaveEventHandler(Member_Save);

   7:          }

   8:   

   9:          void Member_BeforeSave(Member sender, NewEventArgs e)

  10:          {

  11:              //do something here

  12:          }

  13:          

  14:          void Member_Save(Member sender, SaveEventArgs e)

  15:           {

  16:              //do something here

  17:             

  18:              //get new member details

  19:               Member m = Member.GetMemberFromEmail(sender.Email);

  20:           }

  21:          

  22:      }

Tuesday, June 23, 2009

Gravatar Package for Umbraco

To learn more about Gravatar please visit http://en.gravatar.com/.

This is a very simple asp.net C# user control which will spit out a gravatar image. All gravatar options are included in this package.

You can choose to use a default image if no email is fond (silhouette, blank image etc) or use a generated one from Gravatar (identicon, monsterid, wavatar)

Happy to fix any issues you encounter or download the source and alter.

Thanks,
Matthew

DOWNLOAD SOURCE DOWNLOAD PACKAGE

Monday, June 22, 2009

Umbraco Tip #3

Save time by using post build events

Whenever I am building Umbraco user controls there is a of development time and one way to save some time is to use Visual Studio post build events, this saves time by not having to manually copy over the .dll and ascx files from from user control solution to your umbraco solution.

To Add post build events right mouse click on your project > properties > build events. Click on the Edit- Post-build event button.

Here are what my post build events look like. Remeber if your path inludes spaces you will need to surround you copy statments with ""

copy "$(TargetPath)" "E:\Projects\Test Projects\ApplicationForm\bin"
copy "$(SolutionDir)\ApplicationFormUserControls\*.ascx" "$(SolutionDir)\UserControls\ApplicationFormControls\"

Umbraco Tip #2

How to redirect to a nodeid.

Response.Redirect(umbraco.library.NiceUrl());

Example: - Redirect to the same page currently on.

Response.Redirect(umbraco.library.NiceUrl( umbraco.presentation.nodeFactory.Node.GetCurrent().Id));

Umbraco Tip #1

Over the next few weeks I'll be posting a daily tips about the Umbraco library and how to use them in your code behind when building Umbraco user controls. This tips are targeted towards beginners of Umbraco user controls.

Tip #1

How to get the current nodeid from code behind?

umbraco.presentation.nodeFactory.Node.GetCurrent().Id

Sunday, June 14, 2009

nopCommerce vs dashCommerce?

Anyone have any thoughts? I have been a big fan of dashCommerce in the past and I have many websites still running dashCommerce with a lot of success, however recently I've become less favourable towards dashCommerce and I'm not exactly sure why. When dashCommerce use to be the CommerceStarterKit there use to be a huge community/help each other out feel to the software and to the community. However dashComemrce now doesn't seem quite this way and with the introduction of having to pay for certain provider I would suggest this has gone a long to making the software seem less from open source. I've just started a new e-commerce store (still in development) and I had a search around for other open source asp.net shopping carts. I stumbled upon nopCommerce (how did I not know about this before!) and all I can say is WOW so far, the architecture seems very similar to dashCommerce there are plenty of free providers and most importantly there seems to be a great feel to the nopCommerce community. I look forward to working with this software and will let you know how it goes. If you have some thoughts on dashCommerce or nopCommerce then I would love to hear them.

Sunday, May 3, 2009

Agentx.co.nz

Finding your next real estate agent in New Zealand just got a whole lot easier with a website I've been working on. Its built using an early version of MVC. To view the website please vist www.agentx.co.nz.

Wednesday, March 25, 2009

MVC Live Application Take 2

I've just released my second asp.net mvc application based on mvc 1.0!

Feel free to check it out at http://www.soccer.co.nz, feel free to check it out and let me know your thoughts.

UPDATE: SOCCER.CO.NZ has been sold.

If you want to see the website please visit http://soccer.co.nz.serv6.temphostspace.com

Thursday, March 12, 2009

Create a MVC Helper to Display a Microsoft Chart Control




1. Add a reference to C:\Program Files\Microsoft Chart Controls\Assemblies\System.Web.DataVisualization.dll and C:\Program Files\Microsoft Chart Controls\Assemblies\System.Web.DataVisualization.Design.dll

---Helper Class --

2. using System.Web.UI.DataVisualization.Charting;

3. Add static method.


public static void Chart(this HtmlHelper helper, string polltitle, List<int> values, List<string> labels, int width, int height, SeriesChartType ChartType, System.Web.UI.Page page)
{
System.Web.UI.DataVisualization.Charting.Chart Chart1 = new System.Web.UI.DataVisualization.Charting.Chart();
Chart1 = new System.Web.UI.DataVisualization.Charting.Chart();
Chart1.Width = width;
Chart1.Height = height;
Chart1.RenderType = RenderType.ImageTag;
// Populate series data
Chart1.Series.Add("Default");
Chart1.ChartAreas.Add("ChartArea1");
Chart1.Series["Default"].Points.DataBindXY(labels, values);

// Set Doughnut chart type
Chart1.Series["Default"].ChartType = ChartType;

// Set labels style
Chart1.Series["Default"]["PieLabelStyle"] = "outside";

Chart1.Titles.Add(polltitle);
// Enable 3D
Chart1.ChartAreas["ChartArea1"].Area3DStyle.Enable3D = true;

// Disable the Legend
//Chart1.Legends[0].Enabled = false;


// Render chart control
Chart1.Page = page;
HtmlTextWriter writer = new HtmlTextWriter(page.Response.Output);
Chart1.RenderControl(writer);


}


4. In your view page.



<%Html.Chart(ViewData["charttitle"].ToString(), (List<int>)ViewData["chartvalues"], (List<string>)ViewData["chartlabels"], 400, 400, SeriesChartType.Pie, this); %>


Obvisouly you could go nuts in your helper method and have all kind of different options like enable 3d, show title, color etc etc.

Enjoy.

Tuesday, March 10, 2009

It's Official I'm addicted to MVC Html Helpers

If you've been using MVC recently and haven't been using your own HTML helpers then I suggest you do!

I started off using HTML helpers very sparingly probably because I didn't understand them enough, however onced I'd started just "doing it" the more and more HTML Helpers I seem to create, they are easy to develop and makes your HTML view pages so much nicer and cleaner.

On my latest project I've gone absolutely nuts I have so many helpers its not funny (you can never have enough can you?). I've cut some of my HTML pages from a few hundred lines down to about 50 and because my website is so "modula" in design it makes it easy to plug in modules to different pages.

For example we have crap loads of google adsense on the site, we need to have different adsense for different pages so they fit within the allocated space etc. So at the moment we are storing all the adsense code in the database and then just using helpers to pull out the one we need.



And our MVC helper is:

public static string GoogleAdsense(this HtmlHelper helper, int AdsenseID)
{
SoccerDataContext s = new SoccerDataContext();
return s.tbl_settings_adsenses.Single(t => t.tbl_settings_adsense_id == AdsenseID).Description;
}

Probably my favourite helper at the moment is the "header" helper, basically every item on out website sites in a box with a colour header see below of example page with 4 headers.



My helpers then look like this, which I can change the colour with ease, saves have to copy and paste html code form one page to another.




<%=Html.StartHeader("Sponsored Links", "green", "") %>
<%=Html.GoogleAdsense(0) %>
<%=Html.EndHeader() %>


What are some of your favourite html helpers you have produced?

Sunday, February 22, 2009

My First Live Production MVC Application

I've finally completed (not that a website is ever completed) my first MVC web application using the recently released RC1 ASP.NET MVC project from Microsoft.

If you want to check it out please visit www.erealestate.co.nz.

I absolutely enjoyed the experience, if you look at some of the search URLs you'll notice every page is now is search engine friendly, while this is nothing new it was extremely easy to setup with little fuss.

Having full control over the markup of the html pages was also a nice change, I got learn a lot more about javascript and jquery which previously was very lacking my skills.

I hope there will be a lot more MVC project down the track for me.

Web Service Generator for Databases

Want to generate web services quickly without having to write code?

Download at the following address.

http://agentx.info/webservicegeneratorsetup.msi

Generating web services can sometimes be sometiems be tedious. I built this little program so I could build web services quickly and easily.

I use the web service to produce graphs using Xcelsius.

Any comments suggestions bugs relating to this software please flick me an email.

Thanks,
Matthew