using System;
using System.Collections;
using System.Collections.Generic;
using BP.DA;
using BP.En;
using BP;
using BP.Web;
namespace BP.Sys
{
///
/// 用户注册表
///
public class UserRegeditAttr
{
///
/// 是否显示图片
///
public const string IsPic = "IsPic";
///
/// 名称
///
public const string FK_Emp = "FK_Emp";
///
/// 实体名称
///
public const string CfgKey = "CfgKey";
///
/// 属性
///
public const string Vals = "Vals";
///
/// 查询
///
public const string SearchKey = "SearchKey";
///
/// MyPK
///
public const string MyPK = "MyPK";
///
/// OrderBy
///
public const string OrderBy = "OrderBy";
///
/// OrderWay
///
public const string OrderWay = "OrderWay";
///
/// 产生的sql
///
public const string GenerSQL = "GenerSQL";
///
/// 参数
///
public const string Paras = "Paras";
///
/// 数值
///
public const string NumKey = "NumKey";
///
/// 查询
///
public const string MVals = "MVals";
///
/// 查询时间从
///
public const string DTFrom = "DTFrom";
///
/// 查询时间到
///
public const string DTTo = "DTTo";
}
///
/// 用户注册表
///
public class UserRegedit : EntityMyPK
{
#region 用户注册表信息键值列表
#endregion
///
/// 是否使用自动的MyPK,即FK_Emp + CfgKey
///
public bool AutoMyPK { get; set; }
#region 基本属性
///
/// 是否显示图片
///
public bool IsPic
{
get
{
return this.GetValBooleanByKey(UserRegeditAttr.IsPic);
}
set
{
this.SetValByKey(UserRegeditAttr.IsPic, value);
}
}
///
/// 数值键
///
public string NumKey
{
get
{
return this.GetValStringByKey(UserRegeditAttr.NumKey);
}
set
{
this.SetValByKey(UserRegeditAttr.NumKey, value);
}
}
///
/// 参数
///
public string Paras
{
get
{
return this.GetValStringByKey(UserRegeditAttr.Paras);
}
set
{
this.SetValByKey(UserRegeditAttr.Paras, value);
}
}
///
/// 产生的sql
///
public string GenerSQL
{
get
{
string GenerSQL = this.GetValStringByKey(UserRegeditAttr.GenerSQL);
GenerSQL = GenerSQL.Replace("~", "'");
return GenerSQL;
}
set
{
this.SetValByKey(UserRegeditAttr.GenerSQL, value);
}
}
///
/// 排序方式
///
public string OrderWay
{
get
{
return this.GetValStringByKey(UserRegeditAttr.OrderWay);
}
}
public string OrderBy
{
get
{
return this.GetValStringByKey(UserRegeditAttr.OrderBy);
}
}
///
/// FK_Emp
///
public string FK_Emp
{
get
{
return this.GetValStringByKey(UserRegeditAttr.FK_Emp);
}
}
///
/// 查询时间从
///
public string DTFrom_Data
{
get
{
string s = this.GetValStringByKey(UserRegeditAttr.DTFrom);
if (DataType.IsNullOrEmpty(s) || 1 == 1)
{
DateTime dt = DateTime.Now.AddDays(-14);
return dt.ToString(DataType.SysDataFormat);
}
return s.Substring(0, 10);
}
}
///
/// 到
///
public string DTTo_Data
{
get
{
string s = this.GetValStringByKey(UserRegeditAttr.DTTo);
if (DataType.IsNullOrEmpty(s) || 1 == 1)
{
DateTime dt = DateTime.Now;
return dt.ToString(DataType.SysDataFormat);
}
return s.Substring(0, 10);
}
}
///
/// 查询时间从
///
public string DTFrom
{
get
{
return this.GetValStringByKey(UserRegeditAttr.DTFrom);
//string s = this.GetValStringByKey(UserRegeditAttr.DTFrom);
//if (DataType.IsNullOrEmpty(s) || 1==1)
//{
// DateTime dt = DateTime.Now.AddDays(-14);
// return dt.ToString(DataType.SysDataFormat);
//}
//return s.Substring(0, 10);
}
}
///
/// 到
///
public string DTTo
{
get
{
return this.GetValStringByKey(UserRegeditAttr.DTTo);
//string s = this.GetValStringByKey(UserRegeditAttr.DTTo);
//if (DataType.IsNullOrEmpty(s) || 1 == 1 )
//{
// DateTime dt = DateTime.Now;
// return dt.ToString(DataType.SysDataFormat);
//}
//return s.Substring(0, 10);
}
set
{
this.SetValByKey(UserRegeditAttr.DTTo, value);
}
}
public string DTFrom_Datatime
{
get
{
string s = this.GetValStringByKey(UserRegeditAttr.DTFrom);
if (DataType.IsNullOrEmpty(s))
{
DateTime dt = DateTime.Now.AddDays(-14);
return dt.ToString(DataType.SysDateTimeFormat);
}
return s;
}
set
{
this.SetValByKey(UserRegeditAttr.DTFrom, value);
}
}
///
/// 到
///
public string DTTo_Datatime
{
get
{
string s = this.GetValStringByKey(UserRegeditAttr.DTTo);
if (DataType.IsNullOrEmpty(s))
{
DateTime dt = DateTime.Now;
return dt.ToString(DataType.SysDateTimeFormat);
}
return s;
}
set
{
this.SetValByKey(UserRegeditAttr.DTTo, value);
}
}
///
/// CfgKey
///
public string CfgKey
{
get
{
return this.GetValStringByKey(UserRegeditAttr.CfgKey);
}
}
public string SearchKey
{
get
{
return this.GetValStringByKey(UserRegeditAttr.SearchKey);
}
set
{
this.SetValByKey(UserRegeditAttr.SearchKey, value);
}
}
///
/// Vals
///
public string Vals
{
get
{
return this.GetValStringByKey(UserRegeditAttr.Vals);
}
}
public string MVals
{
get
{
return this.GetValStringByKey(UserRegeditAttr.MVals);
}
}
public string MyPK
{
get
{
return this.GetValStringByKey(UserRegeditAttr.MyPK);
}
}
#endregion
#region 构造方法
///
/// 用户注册表
///
public UserRegedit()
{
AutoMyPK = true;
}
public void setMyPK(string val)
{
this.SetValByKey("MyPK", val);
}
public void setFK_Emp(string val)
{
this.SetValByKey("FK_Emp", val);
}
public void setCfgKey(string val)
{
this.SetValByKey("CfgKey", val);
}
///
/// 用户注册表
///
/// 人员
/// 配置
public UserRegedit(string fk_emp, string cfgkey)
: this()
{
this.SetValByKey("MyPK", fk_emp + cfgkey);
this.SetValByKey("CfgKey", cfgkey);
this.SetValByKey("FK_Emp", fk_emp);
int i = this.RetrieveFromDBSources();
if (i == 0)
{
this.SetValByKey("CfgKey", cfgkey);
this.SetValByKey("FK_Emp", fk_emp);
//this.CfgKey = cfgkey;
//this.FK_Emp = fk_emp;
this.DirectInsert();
// this.DirectInsert();
}
}
///
/// EnMap
///
public override Map EnMap
{
get
{
if (this._enMap != null)
return this._enMap;
Map map = new Map("Sys_UserRegedit", "用户注册表");
map.setEnType(EnType.Sys);
map.AddMyPK();
map.AddTBString(UserRegeditAttr.FK_Emp, null, "用户", false, false, 0, 100, 20);
map.AddTBString(UserRegeditAttr.CfgKey, null, "键", true, false, 0, 200, 20);
map.AddTBString(UserRegeditAttr.Vals, null, "值", true, false, 0, 2000, 20);
map.AddTBString(UserRegeditAttr.GenerSQL, null, "GenerSQL", true, false, 0, 2000, 20);
map.AddTBString(UserRegeditAttr.Paras, null, "Paras", true, false, 0, 2000, 20);
map.AddTBString(UserRegeditAttr.NumKey, null, "分析的Key", true, false, 0, 300, 20);
map.AddTBString(UserRegeditAttr.OrderBy, null, "OrderBy", true, false, 0, 300, 20);
map.AddTBString(UserRegeditAttr.OrderWay, null, "OrderWay", true, false, 0, 300, 20);
map.AddTBString(UserRegeditAttr.SearchKey, null, "SearchKey", true, false, 0, 300, 20);
map.AddTBString(UserRegeditAttr.MVals, null, "MVals", true, false, 0, 2000, 20);
map.AddBoolean(UserRegeditAttr.IsPic, false, "是否图片", true, false);
map.AddTBString(UserRegeditAttr.DTFrom, null, "查询时间从", true, false, 0, 20, 20);
map.AddTBString(UserRegeditAttr.DTTo, null, "到", true, false, 0, 20, 20);
map.AddTBString("OrgNo", null, "OrgNo", true, false, 0, 100, 32);
//增加属性.
map.AddTBAtParas(4000);
this._enMap = map;
return this._enMap;
}
}
#endregion
#region 重写
public override Entities GetNewEntities
{
get { return new UserRegedits(); }
}
protected override bool beforeUpdateInsertAction()
{
this.SetValByKey("OrgNo", BP.Web.WebUser.OrgNo);
return base.beforeUpdateInsertAction();
}
#endregion 重写
///
/// 获取键/值对集合
///
///
public Dictionary GetVals()
{
if (string.IsNullOrWhiteSpace(this.Vals))
return new Dictionary();
string[] arr = null;
string[] strs = this.Vals.Split("@".ToCharArray(), StringSplitOptions.RemoveEmptyEntries);
int idx = -1;
Dictionary kvs = new Dictionary();
foreach (string str in strs)
{
idx = str.IndexOf('=');
if (idx == -1)
continue;
kvs.Add(str.Substring(0, idx), idx == str.Length - 1 ? "" : str.Substring(idx + 1));
}
return kvs;
}
///
/// 获取当前用户是否具有导入数据的权限
/// added by liuxc,2017-04-30
/// 注意:此权限数据保存于Sys_Regedit.Paras字段中,为@ImpEmpNos=liyan,liping,ligen格式
///
/// 集合类全名,如BP.Port.Emps
///
public static bool HaveRoleForImp(string ensName)
{
//获取可导入权限
UserRegedit ur = new UserRegedit("admin", ensName + "_SearchAttrs");
string impEmps = new AtPara(ur.Paras).GetValStrByKey("ImpEmpNos");
if (string.IsNullOrWhiteSpace(impEmps))
{
return true;
}
else
{
return WebUser.No.Equals("admin")==true || ("," + impEmps + ",").IndexOf("," + WebUser.No + ",") != -1;
}
}
///
/// 获取当前用户是否具有导出数据的权限
/// added by liuxc,2017-04-30
/// 注意:此权限数据保存于Sys_Regedit.Paras字段中,为@ExpEmpNos=liyan,liping,ligen格式
///
/// 集合类全名,如BP.Port.Emps
///
public static bool HaveRoleForExp(string ensName)
{
//获取可导入权限
UserRegedit ur = new UserRegedit("admin", ensName + "_SearchAttrs");
string impEmps = new AtPara(ur.Paras).GetValStrByKey("ExpEmpNos");
if (string.IsNullOrWhiteSpace(impEmps))
{
return true;
}
else
{
return WebUser.No.Equals("admin")==true || ("," + impEmps + ",").IndexOf("," + WebUser.No + ",") != -1;
}
}
}
///
/// 用户注册表s
///
public class UserRegedits : EntitiesMyPK
{
#region 构造
public UserRegedits()
{
}
///
///
///
///
public UserRegedits(string emp)
{
QueryObject qo = new QueryObject(this);
qo.AddWhere(UserRegeditAttr.FK_Emp, emp);
qo.DoQuery();
}
#endregion
#region 重写
///
/// 得到它的 Entity
///
public override Entity GetNewEntity
{
get
{
return new UserRegedit();
}
}
#endregion
#region 为了适应自动翻译成java的需要,把实体转换成IList, c#代码调用会出错误。
///
/// 转化成 java list,C#不能调用.
///
/// List
public System.Collections.Generic.IList ToJavaList()
{
return (System.Collections.Generic.IList)this;
}
///
/// 转化成list
///
/// List
public System.Collections.Generic.List Tolist()
{
System.Collections.Generic.List list = new System.Collections.Generic.List();
for (int i = 0; i < this.Count; i++)
{
list.Add((UserRegedit)this[i]);
}
return list;
}
#endregion 为了适应自动翻译成java的需要,把实体转换成List.
}
}