2012年10月15日 星期一

C# Google Map Api V3 地址轉經緯度


public String [] TestLocation(String address)
        {
            String[] location = new String[2];
            var url = String.Format("http://maps.google.com/maps/api/geocode/json?sensor=false&address={0}", address);

            string result = String.Empty;
            HttpWebRequest request = (HttpWebRequest)HttpWebRequest.Create(url);
            using (var response = request.GetResponse())
            using (StreamReader sr = new StreamReader(response.GetResponseStream()))
            {
                //Json格式: 請參考http://code.google.com/intl/zh-TW/apis/maps/documentation/geocoding/
                result = sr.ReadToEnd();
                Dictionary back = (Dictionary)JsonConvert.DeserializeObject(result, typeof(Dictionary));

                result = "";
                foreach (var item in back)
                {
                    if (item.Key == "results")
                    {
                        String temp = item.Value.ToString();
                        temp = temp.Substring(0, temp.Length-1);
                        temp = temp.Substring(1, temp.Length-1);
                        temp.ToString();
                        Dictionary back2 = (Dictionary)JsonConvert.DeserializeObject(temp, typeof(Dictionary));
                        foreach (var item2 in back2)
                        {
                            if (item2.Key == "geometry")
                            {
                                temp = item2.Value.ToString();                              
                                Dictionary back3 = (Dictionary)JsonConvert.DeserializeObject(temp, typeof(Dictionary));
                                foreach (var item3 in back3)
                                {                                  
                                    if (item3.Key == "location")
                                    {
                                        temp = item3.Value.ToString();
                                        Dictionary back4 = (Dictionary)JsonConvert.DeserializeObject(temp, typeof(Dictionary));
                                        foreach (var item4 in back4)
                                        {
                                            if (item4.Key == "lat")
                                            {
                                                location[0] = item4.Value.ToString();
                                            }
                                            if (item4.Key == "lng")
                                            {
                                                location[1] = item4.Value.ToString();
                                            }

                                        }

                                    }
                                }

                            }
                           
                        }
                       
                    }
                }                              

            }
            return location;
        }

2012年10月6日 星期六

Kendo ui tree data by json


先照DEMO做的 整了出一個VIEW

           


           

           
       

產生 資料的後端


var dept =
                from ex in context.Dept
                       where (id.Length > 0 ? ex.UDEP_NO == int.Parse(id) : ex.UDEP_NO == null)
                       select new
                       {
                           dName = ex.DEP_NAME.Trim(),
                           did = ex.DEP_NO,
                           hasChildren = true
                       };

            Response.Write(JsonConvert.SerializeObject(dept));

結果的json字串
[{"dName":"公司名稱","did":1,"hasChildren":true}]

不過目前正在整理怎麼往下讀取...


2011年12月27日 星期二

新工作就職

職位:系統分析師
公司網址:http://www.sanfong.com.tw


開始過不太一樣的生活,但是一樣忙碌。

2011年4月22日 星期五

Sandy Bridge P67 B3主機板凍結解決方案

本人使用MSI P67C45 B3版之主機板,在經過多次測試後,確定可以避免凍結問題的方法是將DRAM的電壓加至1.6v,若不願意加壓記憶體,至少要將BISO升級至1.10版,經測試新版的BIOS是有減緩凍結之情況,不過測試之目前仍以加壓為較有效之手段。

2010年7月19日 星期一

2010年6月17日 星期四

Android第一支程式-Hello World

1.請先開啟Eclipse
選擇新增一個Android Project(我這邊是新增2.2的系統)
輸入相關資料如下











2.產生專案完畢產生檔案如下:











3.這時候已經可以選擇 Run As -> Android Application進行第一次試run了,記得先建立2.2的模擬器喔,由於樣版網專案已經先將Hellow Wolrd的簡單程式寫好了,現在看到左方的專案有紅色的X,這代表有個錯誤,錯誤的內容是,Build Path裡面有些要修正的,再專案上點選右鍵Build Path->Configure Build Path ,看到Android 2.2沒被選起來,請勾選起來,這時,專案的錯誤就消失了,可以第一次開始執行HelloWorld這支程式。

4.一樣在專案上點選右鍵,Run as -> Android Application就會開始執行程式,並可以看到結果。

小技巧,在專案開啟後,可以先執行2.2的虛擬機器,即時暫時不使用也可以開著,可以節省相當多等待的時間。