Code Behind Page Page /ResultsMapping.aspx.cs (C#)
Used by Page /ResultsMapping.aspx (C#)
1: using System;  
2: using System.Data;  
3: using System.Configuration;  
4: using System.Web.Caching;  
5: using Microsoft.ApplicationBlocks.Data;  
6: using QuizNetOnline.Logic;  
7:   
8: namespace QuiznetOnline.Web.UI  
9: {  
10:     public partial class ResultsMapping : QuiznetOnline.Web.UI.BusinessClasses.BasePage  
11:     {  
12:   
13:         protected override void Page_Load(object sender, EventArgs e)  
14:         {  
15:             if (!Page.IsPostBack)  
16:             {  
17:                 base.Page_Load(sender, e);  
18:                 //var log = new Log("", "Visiting ResultMapping");  
19:                 //log.Save();  
20:                 LoadMap();  
21:             }  
22:         }  
23:   
24:         protected void LoadMap()  
25:         {  
26:             var period=string.Empty;  
27:             int country_count = 0;  
28:   
29:             if (Request.QueryString["Period"] != null)  
30:                 period = Request.QueryString["Period"];  
31:   
32:             string cacheGoogleKey = "GoogleMap" + period;  
33:             GoogleObject mapCache = Cache[cacheGoogleKey] as GoogleObject;  
34:   
35:             lblMap.Text = "Quiz results by country";  
36:             if (period == "month")  
37:                 lblMap.Text = lblMap.Text + " for the current month";  
38:             if (period == "year")  
39:                 lblMap.Text = lblMap.Text + " for the current year";  
40:   
41:             if (mapCache == null)  
42:             {  
43:                 //You must specify Google Map API Key for this component. You can obtain this key from http://code.google.com/apis/maps/signup.html  
44:                 //For samples to run properly, set GoogleAPIKey in Web.Config file.  
45:                 GoogleMapForASPNet1.GoogleMapObject.APIKey = ConfigurationManager.AppSettings["GoogleAPIKey"];  
46:   
47:                 //Specify width and height for map. You can specify either in pixels or in percentage relative to it's container.  
48:                 GoogleMapForASPNet1.GoogleMapObject.Width = "800px"; // You can also specify percentage(e.g. 80%) here  
49:                 GoogleMapForASPNet1.GoogleMapObject.Height = "600px";  
50:   
51:                 Result results = new Result();  
52:                 DataTable tbl;  
53:                 ISqlWrapper iSqlWrapper=new SqlWrapper();  
54:                 tbl = results.GetResultCordinates(period, iSqlWrapper);  
55:   
56:                 GooglePoint gp;  
57:                 foreach (DataRow row in tbl.Rows)  
58:                 {  
59:                     gp = new GooglePoint();  
60:                     gp.Address = row["countrydesc"].ToString();  
61:   
62:                     if (gp.GeocodeAddress(ConfigurationManager.AppSettings["GoogleAPIKey"]))  
63:                     {  
64:                         int countrycount = Convert.ToInt32(row["countrycount"].ToString());  
65:   
66:                         //GP.ToolTip = row["countrycode"].ToString() + " - " + countrycount + " tests completed" + Environment.NewLine + "Percentage correct- " + Convert.ToInt32(row["AvgCorrect"].ToString()) + "%";  
67:                         gp.InfoHTML = "<img src='Images/Countries/" + row["countrycode"] + ".gif' /> " + row["countrycode"] + "<br/>" + countrycount + " tests completed<br/>";  
68:                         gp.InfoHTML = gp.InfoHTML + "Last test completed on " + row["LastTestTaken"];  
69:                         //GoogleMapForASPNet1.GoogleMapObject.CenterPoint = GP;  
70:                         //GoogleMapForASPNet1.GoogleMapObject.Points.Clear();  
71:                         country_count++;  
72:                         GoogleMapForASPNet1.GoogleMapObject.Points.Add(gp);  
73:                         //GoogleMapForASPNet1.GoogleMapObject.RecenterMap = true;  
74:                     }  
75:                 }  
76:   
77:                 mapCache = GoogleMapForASPNet1.GoogleMapObject;  
78:                 Cache.Insert(cacheGoogleKey, mapCache, null, Cache.NoAbsoluteExpiration, TimeSpan.FromDays(7), CacheItemPriority.Default, null);  
79:             }  
80:   
81:             GoogleMapForASPNet1.GoogleMapObject.ZoomLevel = 2;  
82:             GoogleMapForASPNet1.GoogleMapObject = mapCache;  
83:         }  
84:   
85:     }  
86: }  

.NET Documentation Tool is © 2002 - 2009 Winnersh Triangle Web Solutions Limited.