using System;
using BP.Web;
using BP.En;
using BP.Port;
using BP.Sys;
namespace BP.CCOA.WorkLog
{
///
/// 日志共享 属性
///
public class WorkShareAttr : EntityMyPKAttr
{
///
/// 共享人
///
public const string EmpNo = "EmpNo";
///
/// 共享人名称
///
public const string EmpName = "EmpName";
///
/// 共享给
///
public const string ShareToEmpNo = "ShareToEmpNo";
///
/// 共享给人员名称
///
public const string ShareToEmpName = "ShareToEmpName";
///
/// 状态
///
public const string ShareState = "ShareState";
///
/// 组织编号
///
public const string OrgNo = "OrgNo";
}
///
/// 日志共享
///
public class WorkShare : EntityMyPK
{
#region 基本属性
///
/// 组织编号
///
public string OrgNo
{
get { return this.GetValStrByKey(WorkShareAttr.OrgNo); }
set { this.SetValByKey(WorkShareAttr.OrgNo, value); }
}
public string EmpNo
{
get { return this.GetValStrByKey(WorkShareAttr.EmpNo); }
set { this.SetValByKey(WorkShareAttr.EmpNo, value); }
}
public string EmpName
{
get { return this.GetValStrByKey(WorkShareAttr.EmpName); }
set { this.SetValByKey(WorkShareAttr.EmpName, value); }
}
public string ShareToEmpNo
{
get { return this.GetValStrByKey(WorkShareAttr.ShareToEmpNo); }
set { this.SetValByKey(WorkShareAttr.ShareToEmpNo, value); }
}
public string ShareToEmpName
{
get { return this.GetValStrByKey(WorkShareAttr.ShareToEmpName); }
set { this.SetValByKey(WorkShareAttr.ShareToEmpName, value); }
}
public int ShareState
{
get { return this.GetValIntByKey(WorkShareAttr.ShareState); }
set { this.SetValByKey(WorkShareAttr.ShareState, value); }
}
#endregion
#region 构造方法
///
/// 权限控制
///
public override UAC HisUAC
{
get
{
UAC uac = new UAC();
if (WebUser.IsAdmin)
{
uac.IsUpdate = true;
return uac;
}
return base.HisUAC;
}
}
///
/// 日志共享
///
public WorkShare()
{
}
public WorkShare(string mypk)
{
this.setMyPK(mypk);
this.Retrieve();
}
///
/// 重写基类方法
///
public override Map EnMap
{
get
{
if (this._enMap != null)
return this._enMap;
Map map = new Map("OA_WorkShare", "日志共享");
map.AddMyPK();
map.AddTBString(WorkShareAttr.EmpNo, null, "记录人", false, false, 0, 100, 10, true);
map.AddTBString(WorkShareAttr.EmpName, null, "记录人名称", false, false, 0, 100, 10, true);
map.AddTBString(WorkShareAttr.ShareToEmpNo, null, "记录人名称", false, false, 0, 100, 10, true);
map.AddTBString(WorkShareAttr.ShareToEmpName, null, "记录人名称", false, false, 0, 100, 10, true);
map.AddTBInt(WorkShareAttr.ShareState, 0, "状态0=关闭,1=分享", false, false);
map.AddTBString(WorkShareAttr.OrgNo, null, "组织编号", false, false, 0, 50, 10);
this._enMap = map;
return this._enMap;
}
}
#endregion
#region 执行方法.
protected override bool beforeInsert()
{
this.OrgNo = BP.Web.WebUser.OrgNo;
if (BP.Difference.SystemConfig.CCBPMRunModel == CCBPMRunModel.Single)
this.setMyPK(this.EmpNo + "_" + this.ShareToEmpNo);
else
this.setMyPK(this.OrgNo + "_" + this.EmpNo + "_" + this.ShareToEmpNo);
this.EmpNo = WebUser.No;
this.EmpName = WebUser.Name;
BP.Port.Emp emp = new Emp();
emp.No = this.ShareToEmpNo;
if (emp.RetrieveFromDBSources() == 0)
throw new Exception("err@错误:人员编号不正确." + emp.No);
this.ShareToEmpName = emp.Name;
this.ShareState = 1;
return base.beforeInsert();
}
protected override bool beforeUpdate()
{
return base.beforeUpdate();
}
#endregion 执行方法.
}
///
/// 日志共享 s
///
public class WorkShares : EntitiesMyPK
{
public string DoAddEmp(string empNo)
{
return "err@执行失败.";
}
public string ShareTo_Init()
{
this.Retrieve(WorkShareAttr.EmpNo, WebUser.No);
if (this.Count == 0)
{
Emps emps = new Emps();
emps.Retrieve(EmpAttr.FK_Dept, WebUser.FK_Dept);
foreach (Emp emp in emps)
{
WorkShare en = new WorkShare();
en.ShareToEmpNo = emp.No;
en.ShareToEmpName = emp.Name;
en.ShareState = 1;
en.Insert();
}
this.Retrieve(WorkShareAttr.EmpNo, WebUser.No);
}
return this.ToJson();
}
///
/// 日志共享
///
public WorkShares() { }
///
/// 得到它的 Entity
///
public override Entity GetNewEntity
{
get
{
return new WorkShare();
}
}
#region 为了适应自动翻译成java的需要,把实体转换成List.
///
/// 转化成 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((WorkShare)this[i]);
}
return list;
}
#endregion 为了适应自动翻译成java的需要,把实体转换成List.
}
}