發表文章

目前顯示的是有「專案」標籤的文章

關於DbUpdateConcurrencyException

Building an MVC 4 App with Database First and Entity Framework 最近遇到的專案,是已經有大量的資料在資料庫裡。對於這種情況,就不適合使用 比較熟悉的code first的方式來開發,所以將採用DB First的方式來進行。當我們用 ADO.NET Entity Data Model,visual studio 將會為我們先建立好相關的類別、模 型。 在這個時候問題來了,採用這種方式的話,我們在code first中,我們會直接把 表單驗證的條件寫在model中,但是db first的方式,我們取得的model是經由範本 產生的,所以當我們資料庫有做了異動,或是我們的model有做更新的話,我們把 驗證的條件寫在自動產生的model中,將會全被清掉。 在自動產生的類別可以看到這幾行的註解。 //------------------------------------------------------------------------------ // <auto-generated> //    This code was generated from a template. // //    Manual changes to this file may cause unexpected behavior in your application. //    Manual changes to this file will be overwritten if the code is regenerated. // </auto-generated> //---------------------------- 所以這時候我們將要用到Buddy Class的幫忙。 例如一開始我們建立的model如下 :  namespace MvcLeaning . Models {     using System ;     usin...

FlashDevelop 復習(3)

如何下指令關閉AIR程式。 package com.lovecocoa { import flash.display.Sprite; import flash.display.MovieClip; import flash.media.StageWebView; import flash.geom.Rectangle; import flash.events.Event; import flash.display.Graphics; import flash.events.MouseEvent; import flash.desktop.NativeApplication; import flash.display.NativeWindow; import flash.display.NativeWindowInitOptions; import flash.display.NativeWindowSystemChrome; import flash.display.NativeWindowType; public class Main extends Sprite { public function Main():void { //新增一個按鈕 this.testButton(); } protected function testButton():void { var button:Sprite; //Create a new instance of a Sprite to act as the button graphic. button = new Sprite(); //Set the color of the button graphic button.graphics.beginFill(0xFFCC00); //Set the X,Y, Width, and Height of the button graphic button.graphics.drawRect(0, 0, 200, 200); //Apply the fill butto...

FlashDevelop 復習筆記(2)

圖片
package com.loveococa { import flash.display.Bitmap; import flash.display.Sprite; import flash.events.Event; import flash.ui.Mouse; /** * ... * @author Alex */ public class Enemy extends Sprite {                 //載外外部圖片,要注意圖片資料夾的階層,如上圖所示。 [Embed(source = "./img/gardengnome.png")]                 //定義圖片的類別,要用圖片名稱再接class為命名 private var gardengnomeClass:Class;                 //這邊要特別注意,圖片的檔案是什麼,名字就要定義一樣。                 //如果不採這種方式將會一直出錯。 private var gardengnome:Bitmap = new gardengnomeClass (); public function Test():void { Mouse.hide();                         //以下就如同呼叫物件的方式使用。 gardengnome.height = 30; gardengnome.width = 30; addChild(gardengnome); this.addEventListener(Event.ENTER_FRAME, mouseMove); ...

FlashDevelop 復習筆記(1)

package  { //載入其他的類別庫需要在這撰寫 import flash.display.Sprite; import com.loveococa.Enemy;//載入自建的類別 /** * Hello World * @author benny! */ // This overwrites the Project specific settings                 //定義顯示的視窗大小,以及背景 [SWF(width = "640", height = "480", backgroundColor = "#000000")] public class HelloWorld extends Sprite { public function HelloWorld() { trace( "Hello World" );         this.initGame();//呼叫初始化的方法 } public function initGame():void { var enemy:Enemy = new Enemy(); addChild(enemy)     } } }

把我們的iPhone變成網頁伺服器!

圖片
來到新公司已經兩個月了,終於可以感覺到對工作有點上手,終於可以來分享最近的技術心得了:)這兩個月真的把我操成一個ruby人了,看了好多好多ruby的gem,rack, sinatra, redis-objects, 寄iOS notifications的gem, 等等好多,也寫了好多ruby code。 雖然這些都很值得一說,但是對我來說更有趣的是我最近的專案"your iPhone as a web server"。原始碼在 https://github.com/fumin/rubymotion-zeromq 與 https://github.com/fumin/world 。 這個軟體簡單來說就是讓使用者可以“只透過瀏覽器”就可以與自己的iPhone交流。舉凡瀏覽iPhone裡的照片,閱讀iPhone裡的筆記,下載檔案等等,以後不再需要經由拖曳到dropbox,上傳到免空,或是寄給自己沒有標題的郵件來完成了! 整個系統的架構大致為使用者經由瀏覽器連接到web server,web server代理連到broker server,broker server再與與之有socket連接的iPhone做request,回來的response再循原路回到瀏覽器。 有趣的是整個系統都是用ruby寫的喔,連iPhone程式本身!因為有了rubymotion:)其他使用的核心技術還包含了zeromq,web server則是使用sinatra搭配unicorn,並且host在hiroku上。 http://www.rubymotion.com/ http://www.zeromq.org/ http://www.sinatrarb.com/

在iphone中如何讓某個uiview順著某個圓心轉

首先定義,把角度轉換成弧度 #define RADIANS( degrees ) ( degrees * M_PI / 180 )  [NSTimer scheduledTimerWithTimeInterval:0.01f                                     target:self                                   selector:@selector(testeeee)                                   userInfo:nil                                    repeats:YES] ; -(void)  testeeee{  if (angle > 360) {         angle = 0;     }              angle++;     //    NSLog(@"%f",angle);     int r = 100;     //    testView.f...