using System;
using System.Collections;
using System.Collections.Generic;
using Zhaizj.Framework.Data;
using Zhaizj.Framework.SOA.Controls;
namespace Zhaizj.Framework.SOA {
///
/// 服务的状态
///
public class ServiceStatus {
///
/// 禁止在服务列表中查看
///
public static readonly int ListForbidden = 1;
}
///
/// 系统中各类服务
///
public class Service : CacheObject {
///
/// 服务的全名,比如 Zhaizj.Framework.Apps.Forum.Service.ForumTopicService
///
public String Type { get; set; }
///
/// 服务公开的方法名称,比如 GetRecentTopic
///
public String Method { get; set; }
///
/// 参数类型,包括在web页面中显示的名称和控件类型(比如:显示数量=IntTextbox;性别=StringDroplist(男/女/保密);名称=StringTextBox;)
///
public String Params { get; set; }
///
/// 参数的默认值(可选)
///
public String ParamsDefault { get; set; }
///
/// 获取参数的默认值
///
///
public Dictionary GetParamDefault() {
Dictionary result = new Dictionary();
if (strUtil.IsNullOrEmpty( this.ParamsDefault )) return result;
String[] arrPair = this.ParamsDefault.Split( ';' );
foreach (String pair in arrPair) {
if (strUtil.IsNullOrEmpty( pair )) continue;
String[] arrItem = pair.Split( '=' );
if (arrItem.Length != 2) continue;
result.Add( arrItem[0].Trim(), arrItem[1].Trim() );
}
return result;
}
///
/// 分类:可以通过 GetBy(String tag) 获得某类别的所有服务
///
public String Tags { get; set; }
///
/// 预留的自定义的筛选条件(通常指出对应的模板名称)
///
public String Note { get; set; }
///
/// 预留的服务状态:启用、停用、禁止等
///
public int Status { get; set; }
///
/// 只有允许的 owner 才可以使用本服务。留空表示不限制。多个owner可以用英文分号隔开
///
public String Owner { get; set; }
///
/// 服务简介。用于可视化界面中
///
public String Description { get; set; }
///
/// 此服务对应的链接
///
public String Link { get; set; }
private ArrayList _controls;
///
/// 获得所有参数所对应的控件
///
///
public ArrayList GetParams() {
if (_controls == null) {
_controls = getParamsList( Params );
}
return _controls;
}
private ArrayList getParamsList( String paramString ) {
ArrayList list = new ArrayList();
if (strUtil.IsNullOrEmpty( paramString )) return list;
String[] arrItem = paramString.Split( ';' );
for (int i = 0; i < arrItem.Length; i++) {
String item = arrItem[i];
if (strUtil.HasText( item )) {
list.Add( ParamControl.GetControl( item, i ) );
}
}
return list;
}
///
/// 获得所有允许的 Owner 数组
///
///
public String[] GetOwnerTypes() {
return this.Owner.Split( ';' );
}
}
}