forked from tshi0912/baguajie
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
62 changed files
with
3,207 additions
and
53 deletions.
There are no files selected for viewing
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<s:Application xmlns:fx="http://ns.adobe.com/mxml/2009" | ||
xmlns:s="library://ns.adobe.com/flex/spark" | ||
xmlns:mx="library://ns.adobe.com/flex/mx" | ||
xmlns:service="net.baguajie.admin.service.*" | ||
xmlns:controller="net.baguajie.admin.controller.*" | ||
xmlns:view="net.baguajie.admin.view.*" | ||
xmlns:viewhelper="net.baguajie.admin.viewhelper.*" | ||
minWidth="400" | ||
minHeight="300" | ||
currentState="login"> | ||
<fx:Declarations> | ||
<service:Services id="services"/> | ||
<controller:AppController id="controller"/> | ||
<viewhelper:AdminHelper id="adminHelper"/> | ||
</fx:Declarations> | ||
<fx:Style source="styles.css" /> | ||
<s:states> | ||
<s:State name="default"/> | ||
<s:State name="login"/> | ||
</s:states> | ||
<s:layout> | ||
<s:VerticalLayout paddingLeft="0" | ||
paddingTop="0" | ||
paddingBottom="0" | ||
paddingRight="0"/> | ||
</s:layout> | ||
<s:Group width="100%" | ||
height="100%" | ||
visible="false" | ||
includeInLayout="false" | ||
visible.login="true" | ||
includeInLayout.login="true"> | ||
<s:layout> | ||
<s:VerticalLayout horizontalAlign="center" | ||
verticalAlign="middle"/> | ||
</s:layout> | ||
<view:LoginPanel/> | ||
</s:Group> | ||
<s:Group width="100%" | ||
height="100%" | ||
visible.login="false" | ||
includeInLayout.login="false"> | ||
<s:layout> | ||
<s:VerticalLayout gap="0" /> | ||
</s:layout> | ||
<view:Header/> | ||
<view:Menu /> | ||
<view:Body /> | ||
</s:Group> | ||
</s:Application> |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
97 changes: 97 additions & 0 deletions
97
baguajie-admin/src/net/baguajie/admin/command/BaseCommand.as
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,97 @@ | ||
package net.baguajie.admin.command | ||
{ | ||
import com.adobe.cairngorm.business.ServiceLocator; | ||
import com.adobe.cairngorm.commands.ICommand; | ||
import com.adobe.cairngorm.control.CairngormEvent; | ||
import mx.rpc.AsyncToken; | ||
import mx.rpc.IResponder; | ||
import mx.rpc.events.FaultEvent; | ||
import net.baguajie.admin.util.ErrorHandleUtil; | ||
|
||
public class BaseCommand implements ICommand, IResponder | ||
{ | ||
private static const TRACE_EXCUTING_TIME:Boolean=true; | ||
|
||
public function BaseCommand() | ||
{ | ||
|
||
} | ||
|
||
protected var serviceId:String="adminRO"; | ||
|
||
private var executingStartTime:Number; | ||
private var methodName:String; | ||
|
||
public function execute(event:CairngormEvent):void | ||
{ | ||
// to be overridden by subclasses | ||
// prepare necessary arguments for the remote call | ||
// and then use the method "sendRemoteCall" to do the actual remote calling | ||
} | ||
|
||
public function fault(event:Object):void | ||
{ | ||
// to be overridden by subclasses | ||
} | ||
|
||
public function finallyExecute(event:Object):void | ||
{ | ||
// to be overridden by subclasses | ||
} | ||
|
||
public function result(event:Object):void | ||
{ | ||
// to be overridden by subclasses | ||
} | ||
|
||
protected function faultHandler(event:Object):void | ||
{ | ||
if (!event || !event.fault) | ||
return; | ||
|
||
trace("Command \"" + methodName + "\" failed."); | ||
trace(FaultEvent(event).message); | ||
trace(FaultEvent(event).fault); | ||
|
||
fault(event); | ||
|
||
finallyExecute(event); | ||
} | ||
|
||
protected function resultHandler(event:Object):void | ||
{ | ||
if (TRACE_EXCUTING_TIME) | ||
trace("Method \"" + methodName + "\" cost", ((new Date()).getTime() - executingStartTime) / 1000, "seconds."); | ||
|
||
var containError:Boolean=false; | ||
|
||
if (!event || !event.result || !ErrorHandleUtil.checkErrorForRemoteObject(event.result)) | ||
{ | ||
containError=true; | ||
} | ||
|
||
if (!containError) | ||
{ | ||
result(event); | ||
} | ||
|
||
finallyExecute(event); | ||
} | ||
|
||
/* | ||
* This method is to call a remote function on service | ||
*/ | ||
protected function sendRemoteCall(methodName:String, ... args):void | ||
{ | ||
if (TRACE_EXCUTING_TIME) | ||
this.executingStartTime=(new Date()).getTime(); | ||
|
||
this.methodName=methodName; | ||
|
||
var service:Object=ServiceLocator.getInstance().getRemoteObject(serviceId); | ||
var token:AsyncToken=service.getOperation(methodName).send.apply(null, args); | ||
token.resultHandler=resultHandler; | ||
token.faultHandler=faultHandler; | ||
} | ||
} | ||
} |
32 changes: 32 additions & 0 deletions
32
baguajie-admin/src/net/baguajie/admin/command/MultipleROCommand.as
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
package net.baguajie.admin.command | ||
{ | ||
import com.adobe.cairngorm.control.CairngormEvent; | ||
import net.baguajie.admin.controller.MultipleROToken; | ||
import net.baguajie.admin.event.MultipleROEvent; | ||
|
||
public class MultipleROCommand extends SimpleROCommand | ||
{ | ||
|
||
public function MultipleROCommand() | ||
{ | ||
super(); | ||
} | ||
|
||
private var multipleROToken:MultipleROToken; | ||
|
||
override public function execute(event:CairngormEvent):void | ||
{ | ||
super.execute(event); | ||
|
||
multipleROToken=MultipleROToken(MultipleROEvent(event).token); | ||
} | ||
|
||
override public function result(event:Object):void | ||
{ | ||
super.result(event); | ||
|
||
if (multipleROToken.defaultResultHandler != null) | ||
multipleROToken.defaultResultHandler(); | ||
} | ||
} | ||
} |
57 changes: 57 additions & 0 deletions
57
baguajie-admin/src/net/baguajie/admin/command/SimpleROCommand.as
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
package net.baguajie.admin.command | ||
{ | ||
import com.adobe.cairngorm.control.CairngormEvent; | ||
import mx.rpc.events.ResultEvent; | ||
import net.baguajie.admin.controller.ROResult; | ||
import net.baguajie.admin.controller.SimpleROToken; | ||
import net.baguajie.admin.event.SimpleROEvent; | ||
|
||
public class SimpleROCommand extends BaseCommand | ||
{ | ||
|
||
public function SimpleROCommand() | ||
{ | ||
super(); | ||
} | ||
|
||
private var simpleROToken:SimpleROToken; | ||
|
||
override public function execute(event:CairngormEvent):void | ||
{ | ||
var simpleROEvent:SimpleROEvent=SimpleROEvent(event); | ||
var newArgs:Array=[simpleROEvent.methodName]; | ||
if (simpleROEvent.args && simpleROEvent.args.length > 0) | ||
{ | ||
newArgs=newArgs.concat(simpleROEvent.args); | ||
} | ||
|
||
sendRemoteCall.apply(null, newArgs); | ||
|
||
simpleROToken=simpleROEvent.token; | ||
} | ||
|
||
override public function fault(event:Object):void | ||
{ | ||
if (simpleROToken.faultHandler != null) | ||
{ | ||
simpleROToken.faultHandler(); | ||
} | ||
} | ||
|
||
override public function finallyExecute(event:Object):void | ||
{ | ||
if (simpleROToken.finalHandler != null) | ||
{ | ||
simpleROToken.finalHandler(); | ||
} | ||
} | ||
|
||
override public function result(event:Object):void | ||
{ | ||
if (simpleROToken.resultHandler != null) | ||
{ | ||
simpleROToken.resultHandler(ROResult(ResultEvent(event).result).result); | ||
} | ||
} | ||
} | ||
} |
18 changes: 18 additions & 0 deletions
18
baguajie-admin/src/net/baguajie/admin/controller/AppController.as
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
package net.baguajie.admin.controller | ||
{ | ||
import com.adobe.cairngorm.control.FrontController; | ||
import net.baguajie.admin.command.MultipleROCommand; | ||
import net.baguajie.admin.command.SimpleROCommand; | ||
import net.baguajie.admin.event.MultipleROEvent; | ||
import net.baguajie.admin.event.SimpleROEvent; | ||
|
||
public class AppController extends FrontController | ||
{ | ||
public function AppController() | ||
{ | ||
super(); | ||
addCommand(SimpleROEvent.SIMPLE_RO_EVENT, SimpleROCommand); | ||
addCommand(MultipleROEvent.MULTIPLE_RO_EVENT, MultipleROCommand); | ||
} | ||
} | ||
} |
26 changes: 26 additions & 0 deletions
26
baguajie-admin/src/net/baguajie/admin/controller/MultipleROInvoker.as
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
package net.baguajie.admin.controller | ||
{ | ||
import mx.collections.ArrayCollection; | ||
|
||
public class MultipleROInvoker extends MultipleROInvokerBase | ||
{ | ||
|
||
private static const SAVE_OR_UPDATE_PROXY_LIMITS:String = "saveOrUpdateProxyLimits"; | ||
private static const DELETE_PORXY_LIMITS:String="deleteProxyLimits"; | ||
|
||
public function MultipleROInvoker() | ||
{ | ||
super(); | ||
} | ||
|
||
public function saveOrUpdateProxyLimits(proxyLimits:ArrayCollection):SimpleROToken | ||
{ | ||
return newInitialRO(SAVE_OR_UPDATE_PROXY_LIMITS, arguments); | ||
} | ||
|
||
public function deleteProxyLimits(proxyLimits:ArrayCollection):SimpleROToken | ||
{ | ||
return newInitialRO(DELETE_PORXY_LIMITS, arguments); | ||
} | ||
} | ||
} |
34 changes: 34 additions & 0 deletions
34
baguajie-admin/src/net/baguajie/admin/controller/MultipleROInvokerBase.as
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
package net.baguajie.admin.controller | ||
{ | ||
import com.adobe.cairngorm.control.CairngormEventDispatcher; | ||
|
||
import flash.events.EventDispatcher; | ||
|
||
import net.baguajie.admin.controller.MultipleROToken; | ||
import net.baguajie.admin.event.MultipleROEvent; | ||
|
||
[Event(name="multipleROComplete", type="com.statestr.gmrm.event.MultipleROEvent")] | ||
|
||
public class MultipleROInvokerBase extends EventDispatcher | ||
{ | ||
protected var counter:int = 0; | ||
|
||
protected function newInitialRO(methodName:String, arguments:Array):SimpleROToken | ||
{ | ||
counter--; | ||
var token:MultipleROToken = new MultipleROToken(); | ||
token._defaultResultHandler = multipleRODefaultResultHandler; | ||
var event:MultipleROToken = MultipleROEvent.newInitialROEvent(methodName, arguments, token); | ||
CairngormEventDispatcher.getInstance().dispatchEvent(event); | ||
return token; | ||
} | ||
|
||
protected function multipleRODefaultResultHandler():void | ||
{ | ||
counter++; | ||
if (counter == 0){ | ||
dispatchEvent(new MultipleROEvent(MultipleROEvent.MULTIPLE_RO_COMPLETE)); | ||
} | ||
} | ||
} | ||
} |
12 changes: 12 additions & 0 deletions
12
baguajie-admin/src/net/baguajie/admin/controller/MultipleROToken.as
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
package net.baguajie.admin.controller | ||
{ | ||
public class MultipleROToken extends SimpleROToken | ||
{ | ||
internal var _defaultResultHandler:Function; | ||
|
||
public function get defaultResultHandler():Function | ||
{ | ||
return _defaultResultHandler; | ||
} | ||
} | ||
} |
16 changes: 16 additions & 0 deletions
16
baguajie-admin/src/net/baguajie/admin/controller/ROResult.as
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
package net.baguajie.admin.controller | ||
{ | ||
import mx.collections.ArrayCollection; | ||
|
||
import net.baguajie.admin.vo.ErrorCodeVo; | ||
|
||
[RemoteClass(alias="net.baguajie.web.ros.ROResult")] | ||
public class ROResult | ||
{ | ||
public var errors:ArrayCollection; | ||
|
||
public var result:Object; | ||
|
||
public var errorCode:ErrorCodeVo; | ||
} | ||
} |
Oops, something went wrong.