BIM工程信息管理新系统- 系统管理模块
程序员文章站
2022-06-04 11:34:18
系统管理模块 1、实体类 public partial class T_Role { public string RoleId { get; set; } public string RoleName { get; set; } public string CommentAry { get; set ......
系统管理模块
1、实体类
public partial class t_role { public string roleid { get; set; } public string rolename { get; set; } public string commentary { get; set; } public string codeno { get; set; } public string customno { get; set; } public string spellno { get; set; } public string strokeno { get; set; } }
public partial class t_role_privilege { public string roleid { get; set; } public string privid { get; set; } public string barcaption { get; set; } public nullable<int> barorder { get; set; } public string isendnode { get; set; } public nullable<int> istoolbar { get; set; } public string nodeid { get; set; } public string parentnode { get; set; } public int id { get; set; } }
public partial class t_operator { public string operatorid { get; set; } public string depid { get; set; } public string operatorname { get; set; } public string passwrod { get; set; } public string roleid { get; set; } public string userid { get; set; } public string cellphone { get; set; } public string emial { get; set; } public nullable<int> logincount { get; set; } public string lastlogintime { get; set; } public nullable<int> state { get; set; } public string buildman { get; set; } public nullable<system.datetime> builddate { get; set; } public string editman { get; set; } public nullable<system.datetime> editdate { get; set; } }
public partial class t_operator_privilege { public string barcaption { get; set; } public nullable<int> barorder { get; set; } public string isendnode { get; set; } public nullable<int> istoolbar { get; set; } public string nodeid { get; set; } public string operatorid { get; set; } public string parentnode { get; set; } public string privid { get; set; } public int id { get; set; } }
public partial class t_organization { public string f_orgid { get; set; } public string f_orgname { get; set; } public string f_orgmanager { get; set; } public nullable<system.datetime> f_builddate { get; set; } public string f_buildman { get; set; } public string f_tellphonenum { get; set; } public string f_address { get; set; } public nullable<bool> f_state { get; set; } public string f_parentid { get; set; } }
public partial class t_wholemenu { public string nodeid { get; set; } public string nodename { get; set; } public string parentnode { get; set; } public string isendnode { get; set; } public string pluginid { get; set; } public string commentary { get; set; } public string disporder { get; set; } public nullable<int> type { get; set; } public string groupbyname { get; set; } public string imageico { get; set; } public nullable<int> typeshow { get; set; } public nullable<bool> isstartup { get; set; } }
public partial class sys_buttons { public int keyid { get; set; } public string buttoncaption { get; set; } public int sortnum { get; set; } public string iconcls { get; set; } public string iconurl { get; set; } public string buttontag { get; set; } public string remark { get; set; } public string buttonhtml { get; set; } public string buggongroup { get; set; } public int state { get; set; } public string tooltip { get; set; } }
public partial class sys_button_privilege { public int sysid { get; set; } public nullable<int> buttonid { get; set; } public string operatorid { get; set; } public string roleid { get; set; } public string nodeid { get; set; } }
public partial class sys_wholemenubuttons { public int keyid { get; set; } public string menuid { get; set; } public nullable<int> buttonid { get; set; } public nullable<int> sortnum { get; set; } public string buttonname { get; set; } }
2、服务器契约
服务契约代码
[servicecontract(namespace = "www.kubim.com/operatorserivce")] public interface ioperationpurviewservice {
#region 操作人员管理 //添加人员 [operationcontract(isinitiating = true)] bool insertoperatorinfo(t_operator operatorentity); ///<summary> ///修改操作t_operator /// </summary> [operationcontract(isinitiating = true)] bool updatet_operator(t_operator model); ///<summary> ///修改操作t_operator /// </summary> [operationcontract(isinitiating = true)] t_operator t_operatorbyid(string operatorid); ///<summary> ///删除操作t_operator /// </summary> [operationcontract(isinitiating = true)] bool deletet_operator(string id); //获取最大人员编号 [operationcontract(isinitiating = true)] int getmaxoperatorid(); //获取所有人员 [operationcontract(isinitiating = true)] iqueryable<t_operator> getoperatoralllist(); //根据用户登录的id查询 [operationcontract(isinitiating = true)] list<findmenurigthbyoperator> getrightoperatorbyoperatorid(string operatorid); //根据用户登录的id查询 [operationcontract(isinitiating = true)] list<findmenurigthbyoperator> getrightoperatorbyroleid(string roleid); /// <summary> /// 用户登录 /// </summary> /// <param name="loginusername">登录名称</param> /// <param name="loginpassword">登录密码</param> /// <returns></returns> [operationcontract(isinitiating = true)] bool loginuser(string loginusername, string loginpassword); /// <summary> /// 用户登录 /// </summary> /// <param name="loginusername">登录名称</param> /// <param name="loginpassword">登录密码</param> /// <param name="log">登录其它信息</param> /// <returns>返回字符串信息</returns> [operationcontract(isinitiating = true)] string login(string loginusername, string loginpassword, params string[] log); /// <summary> /// 用户登陆 /// </summary> /// <param name="loginusername">name of the login user.</param> /// <param name="loginpassword">the login password.</param> /// <param name="log">the log.</param> /// <returns>用户信息.</returns> [operationcontract(isinitiating = true)] t_operator loginoperator(string loginusername, string loginpassword, params string[] log); /// <summary> /// 用户登录次数添加 /// </summary> /// <param name="operatorid">操作员id</param> [operationcontract(isinitiating = true)] bool operatoraddlogincount(t_operator operatorid); /// <summary> /// 获取人员信息 /// </summary> /// <param name="departid">以部门编号</param> [operationcontract(isinitiating = true)] list<t_operator> getoperatorlistbydepartid(string departid); /// <summary> /// 判斷用戶登陸名稱是否存在 /// determines whether [is existe login user name] [the specified login user name]. /// </summary> /// <param name="loginusername">name of the login user.</param> /// <returns><c>true</c> if [is existe login user name] [the specified login user name]; otherwise, <c>false</c>.</returns> [operationcontract(isinitiating = true)] bool isexisteloginusername(string loginusername); #endregion
#region 用户角色管理 //新增用户角色 [operationcontract(isinitiating = true)] bool insertroleinfo(t_role roleentity); /// <summary> /// 获取用户角色 /// </summary> /// <param name="roleid">获取用户信息</param> /// <returns></returns> [operationcontract(isinitiating = true)] t_role t_rolebyid(string roleid); ///<summary> ///修改操作t_role /// </summary> [operationcontract(isinitiating = true)] bool updatet_role(t_role model); ///<summary> ///删除操作t_role /// </summary> [operationcontract(isinitiating = true)] bool deletet_role(string id); //获取用户角色人员信息 [operationcontract(isinitiating = true)] list<findrolerigthbyrole> getrolerigthbyrolecode(string rolecode); //获取所有角色 [operationcontract(isinitiating = true)] list<t_role> getrolealllist(); //获取最大角色编号 [operationcontract(isinitiating = true)] int getmaxroleid(); /// <summary> /// 修改用户密码 /// </summary> /// <param name="oldpwd">旧的用户密码</param> /// <param name="newpwd">新的用户密码</param> /// <param name="userid">用户人员编号</param> /// <returns></returns> [operationcontract(isinitiating = true)] string changeuserpwd(string oldpwd, string newpwd, string userid); #endregion
#region 用户授权管理 //新增用户权限信息 [operationcontract(isinitiating = true)] void insertoperatorprivilegeinfo(t_operator_privilege operatorentity); //删除用户权限信息 [operationcontract(isinitiating = true)] void deleteoperatorprivilegeinfobyoperatorid(string operatorid); #endregion
#region 角色授权管理 //新增角色权限 [operationcontract(isinitiating = true)] void inserttroleprivilege(t_role_privilege roleentity); //删除角色权限 [operationcontract(isinitiating = true)] void deleteroleprivilegebyroleid(string roleid); /// <summary> /// 添加项目权限 /// </summary> /// <param name="projectlimitses">项目权限信息</param> /// <param name="typeinfo">操作员/角色 operator/role</param> /// <param name="typeid">角色编号/用户编号</param> /// <returns>bool</returns> [operationcontract(isinitiating = true)] bool addprojectlimits(list<t_projectlimits> projectlimitses, string typeinfo, string typeid); /// <summary> /// 添加机构数据权限 /// </summary> /// <param name="organizationprivileges">项目权限信息</param> /// <param name="typeinfo">操作员/角色 operator/role</param> /// <param name="typeid">角色编号/用户编号</param> /// <returns>bool</returns> [operationcontract(isinitiating = true)] bool addorgizationlimits(list<t_organization_privilege> organizationprivileges, string typeinfo, string typeid); /// <summary> /// 添加项目权限 /// </summary> /// <param name="organizationprivileges">项目权限信息</param> /// <param name="typeinfo">操作员/角色 operator/role</param> /// <param name="typeid">角色编号/用户编号</param> /// <returns>bool</returns> [operationcontract(isinitiating = true)] bool addlinemileagelimits(list<linemileage_privilege> organizationprivileges, string typeinfo, string typeid); #endregion
#region 菜单管理 //添加菜单 [operationcontract(isinitiating = true)] void inserttwholemenu(t_wholemenu menuentity); //修改菜单 [operationcontract(isinitiating = true)] bool updatetwholemenu(t_wholemenu menuentity); //获取所有菜单 [operationcontract(isinitiating = true)] list<t_wholemenu> getallwholemenulist(); //获取父菜单的id [operationcontract(isinitiating = true)] int gettwholemenunodeid(); //获取子菜单的id [operationcontract(isinitiating = true)] int gettwholemenunodechildrenid(); //获取最大的菜单 [operationcontract(isinitiating = true)] int getmaxwholemenuid(string parentnode); //删除父节点下所有菜单 [operationcontract(isinitiating = true)] void deletewholemenu(string parentid); //根据菜单编号删除下面所有信息 [operationcontract(isinitiating = true)] void deletewholemenunode(string nodeid); //保存用户权限 [operationcontract(isinitiating = true)] bool adduserright(datatable dt, string type, string typeid); #endregion
#region 系统字典管理 //添加字典信息 [operationcontract(isinitiating = true)] bool insertdectionary(t_dictionaryinfo tinfo); //修改字典信息 [operationcontract(isinitiating = true)] bool updatedectionary(t_dictionaryinfo tinfo); //获取所有字典信息 [operationcontract(isinitiating = true)] list<t_dictionaryinfo> getalldictonarylist(); //根据字典类型 [operationcontract(isinitiating = true)] list<t_dictionaryinfo> searchdictionaryoftype(string fdictonarytype); //根据字典类型 [operationcontract()] list<t_dictionaryinfo> searchdictionaryoftypecode(string typecode); //获取父菜单的编号 [operationcontract(isinitiating = true)] int getmaxdictionaryparentcode(); //获取子菜单的编号 [operationcontract(isinitiating = true)] int getdictionarynodechildrencode(); //获取最大的菜单 [operationcontract(isinitiating = true)] int getmaxdictionarycode(string parentcode); //删除子菜单 [operationcontract(isinitiating = true)] bool deletedictionarychildrencode(string dictonarycode); //删除父菜和下面的所有的子菜单 bool deletedictonarycode(string parnentdictonarycode); //数据库名称 [operationcontract(isinitiating = true)] datatable getalltablenamebydb(string databasename); //获取父节点下的子节点的count [operationcontract(isinitiating = true)] int getdictionarycountbyparentcode(string parentcode); //根据字典编号获取明细信息 [operationcontract(isinitiating = true)] t_dictionaryinfo gettdictonaryinfo(string dictonarycode); #endregion
#region 组织机构 /// <summary> /// 新增操作t_organization /// </summary> /// <param name="model">the model.</param> /// <param name="operatorid">the operatorid.</param> /// <returns><c>true</c> if xxxx, <c>false</c> otherwise.</returns> [operationcontract(isinitiating = true)] bool insertt_organization(t_organization model,string operatorid); ///<summary> ///修改操作t_organization /// </summary> [operationcontract(isinitiating = true)] bool updatet_organization(t_organization model); ///<summary> ///删除操作t_organization /// </summary> [operationcontract(isinitiating = true)] bool deletet_organization(string id); ///<summary> ///获取所有数据t_organization /// </summary> [operationcontract(isinitiating = true)] list<t_organization> gett_organizationlistdata(); /// <summary> /// 根据用户判断当前组织机构信息 </summary> /// <param name="operatorid"></param> /// <returns></returns> [operationcontract(isinitiating = true)] iqueryable<t_organization> gett_organizationby(string operatorid); #endregion
#region 机构权限 /// <summary> ///根据sql语句查询返回iqueryablet_organization_privilege /// <param name="sql">t_organization_privilegesql语句</param> /// </summary> [operationcontract] iqueryable<t_organization_privilege> gett_organization_privilegebysql(string sql, params object[] obj); /// <summary> ///获取实体t_organization_privilege /// <param name="id">主键编号</param> /// </summary> [operationcontract] list<t_organization_privilege> gett_organization_privilegebyid(string id); /// <summary> ///修改实体t_organization_privilege /// <param name="entity">t_organization_privilege实体</param> /// </summary> [operationcontract] bool updatet_organization_privilege(list<t_organization_privilege> entity); /// <summary> ///新增实体t_organization_privilege /// <param name="entity">t_organization_privilege实体</param> /// </summary> [operationcontract] bool createt_organization_privilege(list<t_organization_privilege> entity, string operatorid); /// <summary> ///新增实体t_organization_privilege /// <param name="entity">t_organization_privilege实体</param> /// </summary> [operationcontract] bool createt_organization_privilegeentity(t_organization_privilege entity); /// <summary> ///删除t_organization_privilege /// <param name="id">主键编号</param> /// </summary> [operationcontract] bool deletet_organization_privilege(list<int> id); /// <summary> ///获取实体linemileage_privilege /// <param name="id">主键编号</param> /// </summary> [operationcontract] linemileage_privilege getlinemileage_privilegebyid(string id); /// <summary> ///修改实体linemileage_privilege /// <param name="entity">linemileage_privilege实体</param> /// </summary> [operationcontract] bool updatelinemileage_privilege(linemileage_privilege entity); /// <summary> ///新增实体linemileage_privilege /// <param name="entity">linemileage_privilege实体</param> /// </summary> [operationcontract] bool createlinemileage_privilege(list<linemileage_privilege> entity, string operatorid); /// <summary> ///删除linemileage_privilege /// <param name="id">主键编号</param> /// </summary> [operationcontract] bool deletelinemileage_privilege(string id); /// <summary> /// 获取线路里程权限信息 /// </summary> /// <param name="strsql">sql</param> /// <param name="obj">参数</param> /// <returns>iqueryable</returns> [operationcontract] iqueryable<t_projectlimits> gett_projectlimitsbysql(string strsql, params object[] obj); /// <summary> ///根据sql语句查询返回iqueryablelinemileage_privilege /// <param name="sql">linemileage_privilegesql语句</param> /// </summary> [operationcontract] iqueryable<linemileage_privilege> getlinemileage_privilegebysql(string sql, params cmdparameter[] obj); /// <summary> ///新增实体t_projectlimits /// <param name="entity">t_projectlimits实体</param> /// </summary> [operationcontract] bool createt_projectlimits_privilege(list<t_projectlimits> entity, string operatorid); /// <summary> /// 获取当前用户的信息 /// </summary> /// <param name="operatorid"></param> /// <returns></returns> [operationcontract] iqueryable<t_projectlimits> gett_projectlimitsbyoperator(string operatorid); #endregion
#region 系统菜单按钮 /// <summary> ///获取实体sys_buttons /// <param name="id">主键编号</param> /// </summary> [operationcontract] sys_buttons getsys_buttonsbyid(int id); /// <summary> ///修改实体sys_buttons /// <param name="entity">sys_buttons实体</param> /// </summary> [operationcontract] bool updatesys_buttons(sys_buttons entity); /// <summary> ///新增实体sys_buttons /// <param name="entity">sys_buttons实体</param> /// </summary> [operationcontract] bool createsys_buttons(sys_buttons entity); /// <summary> ///删除sys_buttons /// <param name="id">主键编号</param> /// </summary> [operationcontract] bool deletesys_buttons(int id); [operationcontract] iqueryable<sys_wholemenubuttons> getsys_wholemenubuttonsbysql(string sql, params cmdparameter[] obj); /// <summary> ///根据sql语句查询返回iqueryablesys_buttons /// <param name="sql">sys_buttonssql语句</param> /// </summary> [operationcontract] iqueryable<sys_buttons> getsys_buttonsbysql(string sql, params cmdparameter[] obj); /// <summary> /// 返回菜单的按钮 /// </summary> /// <param name="menuid">菜单编号</param> /// <returns></returns> [operationcontract] list<twholemenubutton> gettwholemenubuttons(string menuid); /// <summary> /// 返回所有的菜单信息 /// </summary> /// <returns></returns> [operationcontract] list<twholemenubutton> gettwholemenubuttonsalllist(); /// <summary> /// 获取对应的权限 /// </summary> /// <param name="operatorid">操作员id</param> /// <returns></returns> [operationcontract] list<twholemenubutton> getbuttonlimitsallist(string operatorid); /// <summary> /// 获取对应的权限 /// </summary> /// <param name="roleid">角色id</param> /// <returns></returns> [operationcontract] list<twholemenubutton> getbuttonlimitstrolealllist(string roleid); /// <summary> ///新增实体sys_wholemenubuttons /// <param name="entity">sys_wholemenubuttons实体</param> /// </summary> [operationcontract] bool createsys_wholemenubuttons(list<sys_wholemenubuttons> entity); /// <summary> ///删除sys_wholemenubuttons /// <param name="nodeid">主键编号</param> /// </summary> [operationcontract] bool deletesys_wholemenubuttons(string nodeid); /// <summary> /// 根据用户获取项目权限 /// </summary> /// <param name="operatorid">操作员编号</param> /// <returns></returns> [operationcontract] iqueryable<projectslimits> getprojectslimitsesbyoperator(string operatorid); /// <summary> /// 根据用户编号获取对应的线程里程信息 /// </summary> /// <param name="operatorid">操作员编号</param> /// <param name="projectkey">项目编号</param> /// <returns></returns> [operationcontract] ienumerable<linemileagelimits> getlinemileagelimitsesbyoperator(string operatorid, string projectkey); #endregion
}
3、服务契约实现
服务类代码
//服务 /// <summary> /// class operationservice. /// </summary> [servicebehavior(instancecontextmode = instancecontextmode.percall)] public class operationservice : ioperationpurviewservice, idisposable { private readonly rbim5d_projectcontext _dbcontext; public operationservice() { _dbcontext = new rbim5d_projectentities(); }
#region 操作人员管理 public bool insertoperatorinfo(t_operator operatorentity) { try { _dbcontext.set<t_operator>().attach(operatorentity); _dbcontext.set<t_operator>().add(operatorentity); _dbcontext.savechanges(); } catch (dbentityvalidationexception ex) { throw ex.innerexception; } catch (dbexception ee) { throw ee.innerexception; } return true; } /// <summary> /// 修改操作t_operator /// </summary> /// <param name="model">the model.</param> /// <returns><c>true</c> if xxxx, <c>false</c> otherwise.</returns> public bool updatet_operator(t_operator model) { try { var category = _dbcontext.t_operator.firstordefault(o => o.operatorid == model.operatorid); if (category != null) { category.operatorid = model.operatorid; category.depid = model.depid; category.operatorname = model.operatorname; category.passwrod = model.passwrod; category.roleid = model.roleid; category.userid = model.userid; category.cellphone = model.cellphone; category.emial = model.emial; category.state = model.state; category.editman = model.editman; category.editdate = model.editdate; } _dbcontext.savechanges(); } catch (entityexception) { return false; } catch (exception) { return false; } return true; } /// <summary> /// 修改操作t_operator /// </summary> /// <param name="operatorid">the operatorid.</param> /// <returns>t_operator.</returns> public t_operator t_operatorbyid(string operatorid) { try { return _dbcontext.set<t_operator>().firstordefault(o => o.operatorid == operatorid && o.state == 0); } catch (entityexception ex) { loghelper.error(ex.message); throw ex.innerexception; } catch (dbexception ex) { loghelper.error(ex.message); throw ex.innerexception; } } /// <summary> /// 删除操作t_operator /// </summary> /// <param name="id">the identifier.</param> /// <returns><c>true</c> if xxxx, <c>false</c> otherwise.</returns> public bool deletet_operator(string id) { try { t_operator category = _dbcontext.t_operator.first(o => o.operatorid == id); return lu.dal.basedal<t_operator>.managercontent(_dbcontext).del(category); } catch (entityexception) { return false; } catch (exception) { return false; } } /// <summary> /// gets the maximum operator identifier. /// </summary> /// <returns>system.int32.</returns> public int getmaxoperatorid() { try { const string strsql = "select max(convert(int,operatorid)) from t_operator"; return _dbcontext.database.sqlquery<int>(strsql).first(); } catch (exception ee) { throw ee.innerexception; } } public iqueryable<t_operator> getoperatoralllist() { try { return _dbcontext.t_operator.where(o => o.state == 0); } catch (entityexception ex) { loghelper.error(ex.message); throw ex.innerexception; } } /// <summary> /// gets the right operator by operator identifier. /// </summary> /// <param name="operatorid">the operatorid.</param> /// <returns>list<findmenurigthbyoperator>.</returns> public list<findmenurigthbyoperator> getrightoperatorbyoperatorid(string operatorid) { try { var list = new list<findmenurigthbyoperator>(); { var query = from a in _dbcontext.t_operator_privilege join b in _dbcontext.t_wholemenu on a.nodeid equals b.nodeid where a.operatorid == operatorid select new { a.operatorid, parentnode1 = a.parentnode, a.nodeid, a.isendnode, a.privid, a.istoolbar, a.barorder, a.barcaption, b.nodename, b.parentnode, b.pluginid, b.commentary, b.disporder, b.type, b.groupbyname, b.imageico, b.typeshow, b.isstartup }; if (query.any()) { list.addrange(query.tolist().select(item => new findmenurigthbyoperator { barcaption = item.barcaption, barorder = item.barorder, commentary = item.commentary, isendnode = item.isendnode, istoolbar = item.istoolbar, nodeid = item.nodeid, nodename = item.nodename, parentnode1 = item.parentnode1, parentnode = item.parentnode, pluginid = item.pluginid, privid = item.privid, groupbyname = item.groupbyname, imageico = item.imageico, typeshow = item.typeshow, isstartup = item.isstartup, })); } } return list; } catch (entityexception e) { throw e.innerexception; } } /// <summary> /// gets the right operator by role identifier. /// </summary> /// <param name="roleid">the roleid.</param> /// <returns>list<findmenurigthbyoperator>.</returns> public list<findmenurigthbyoperator> getrightoperatorbyroleid(string roleid) { try { var list = new list<findmenurigthbyoperator>(); { var query = from a in _dbcontext.t_role_privilege join b in _dbcontext.t_wholemenu on a.nodeid equals b.nodeid where a.roleid == roleid select new { a.roleid, parentnode1 = a.parentnode, a.nodeid, a.isendnode, a.privid, a.istoolbar, a.barorder, a.barcaption, b.nodename, b.parentnode, b.pluginid, b.commentary, b.disporder, b.type, b.groupbyname, b.imageico, b.typeshow, b.isstartup }; if (query.any()) { list.addrange(query.tolist().select(item => new findmenurigthbyoperator { barcaption = item.barcaption, barorder = item.barorder, commentary = item.commentary, isendnode = item.isendnode, istoolbar = item.istoolbar, nodeid = item.nodeid, nodename = item.nodename, parentnode1 = item.parentnode1, parentnode = item.parentnode, pluginid = item.pluginid, privid = item.privid, groupbyname = item.groupbyname, imageico = item.imageico, typeshow = item.typeshow, isstartup = item.isstartup })); } } return list; } catch (entityexception e) { throw e.innerexception; } } /// <summary> /// 用户登录 /// </summary> /// <param name="loginusername">登录名称</param> /// <param name="loginpassword">登录密码</param> /// <returns><c>true</c> if xxxx, <c>false</c> otherwise.</returns> public bool loginuser(string loginusername, string loginpassword) { if (string.isnullorempty(loginusername) || string.isnullorempty(loginpassword)) return false; try { // resharper disable implicitlycapturedclosure var queryexits = _dbcontext.t_operator.where(o => o.operatorid == loginusername); // resharper restore implicitlycapturedclosure if (queryexits.any()) { string password = encodehelper.desencrypt(loginpassword); var querylogin = _dbcontext.t_operator.where(o => o.operatorid == loginusername && o.passwrod == password); if (querylogin.any()) { var firstordefault = querylogin.firstordefault(); if (firstordefault != null) operatoraddlogincount(firstordefault); return true; } return false; } } catch (entityexception) { return false; } return false; } /// <summary> /// 用户登录 /// </summary> /// <param name="loginusername">登录名称</param> /// <param name="loginpassword">登录密码</param> /// <param name="log">登录其它信息</param> /// <returns>返回字符串信息</returns> public string login(string loginusername, string loginpassword, params string[] log) { if (string.isnullorempty(loginusername) || string.isnullorempty(loginpassword)) return "用户或密码不能为空!谢谢"; try { t_operator queryexits = _dbcontext.t_operator.firstordefault(o => o.operatorid == loginusername); if (queryexits != null) { if (queryexits.state == 0) { string password = encodehelper.desencrypt(loginpassword); var querylogin = _dbcontext.t_operator.firstordefault(o => o.operatorid == loginusername && o.passwrod == password); if (querylogin != null) { operatoraddlogincount(querylogin); return "success"; } return "密码与当前用户不匹配!请从新尝试!"; } return "尊敬的用户您好!您的账户已经锁定或无效!请联系系统管理员!谢谢"; } return "系统中没有查找到该用户!请查看用户名称是否正确!谢谢"; } catch (entityexception ex) { loghelper.info("用户登录", ex); return "服务端数据库打开无法连接!请联系系统管理!谢谢"; } catch (exception ex) { loghelper.info("用户登录", ex); return "登录失败!"; } } /// <summary> /// 用户登陆 /// </summary> /// <param name="loginusername">name of the login user.</param> /// <param name="loginpassword">the login password.</param> /// <param name="log">the log.</param> /// <returns>用户信息.</returns> public t_operator loginoperator(string loginusername, string loginpassword, params string[] log) { if (string.isnullorempty(loginusername) || string.isnullorempty(loginpassword)) return null; try { string loginuser = loginusername.tolower(); t_operator queryexits = _dbcontext.t_operator.firstordefault(o => o.operatorid.tolower() == loginuser || o.userid.tolower() == loginuser); if (queryexits != null) { if (queryexits.state == 0) { string password = encodehelper.desencrypt(loginpassword); if (queryexits.passwrod == password) { operatoraddlogincount(queryexits); return queryexits; } } } return null; } catch (entityexception ex) { loghelper.info("用户登录", ex); throw ex; } catch (exception ex) { loghelper.info("用户登录", ex); throw ex; } } /// <summary> /// 用户登录次数添加 /// </summary> /// <param name="operatorid">操作员id</param> /// <returns><c>true</c> if xxxx, <c>false</c> otherwise.</returns> public bool operatoraddlogincount(t_operator operatorid) { if (operatorid != null) { _dbcontext.sys_logs.add(new sys_logs { businessname = "用户登录", operationip = operatorid.operatorid, operationtime = datetime.now }); operatorid.logincount = operatorid.logincount == null ? 0 : operatorid.logincount + 1; operatorid.lastlogintime = datetime.now.tostring("yyyy-mm-dd hh:mm:ss"); } _dbcontext.savechanges(); return false; } /// <summary> /// 获取人员信息 /// </summary> /// <param name="departid">以部门编号</param> /// <returns>list<t_operator>.</returns> public list<t_operator> getoperatorlistbydepartid(string departid) { try { return _dbcontext.set<t_operator>().where(@operator => @operator.depid == departid).tolist(); } catch (entityexception e) { throw e.innerexception; } } /// <summary> /// 判斷用戶登陸名稱是否存在 /// determines whether [is existe login user name] [the specified login user name]. /// </summary> /// <param name="loginusername">name of the login user.</param> /// <returns><c>true</c> if [is existe login user name] [the specified login user name]; otherwise, <c>false</c>.</returns> public bool isexisteloginusername(string loginusername) { t_operator toperator = _dbcontext.t_operator.firstordefault(o => o.userid == loginusername); if (toperator != null) return true; return false; } /// <summary> /// gets the toperators by role identifier. /// </summary> /// <param name="roleid">the roleid.</param> /// <returns>list<t_operator>.</returns> list<t_operator> gettoperatorsbyroleid(string roleid) { try { return _dbcontext.set<t_operator>().where(o => o.roleid == roleid).tolist(); } catch (sqlexception ex) { loghelper.error(ex.message); throw ex.innerexception; } catch (entityexception ex) { loghelper.error(ex.message); throw ex.innerexception; } } /// <summary> /// 修改用户密码 /// </summary> /// <param name="oldpwd">旧的用户密码</param> /// <param name="newpwd">新的用户密码</param> /// <param name="userid">用户人员编号</param> /// <returns>system.string.</returns> public string changeuserpwd(string oldpwd, string newpwd, string userid) { string password = encodehelper.desencrypt(oldpwd); var istrue = _dbcontext.t_operator.firstordefault(o => o.operatorid == userid && o.passwrod == password); if (istrue != null) { istrue.passwrod = encodehelper.desencrypt(newpwd); _dbcontext.savechanges(); } else { return "当前的用户密码不正确!"; } return "成功"; } #endregion
#region 用户权限管理 public void insertoperatorprivilegeinfo(t_operator_privilege operatorentity) { try { // _enity.attach(operatorentity); _dbcontext.set<t_operator_privilege>().add(operatorentity); // _enity.objectstatemanager.changeobjectstate(operatorentity, entitystate.added); _dbcontext.savechanges(); } catch (exception ee) { throw ee.innerexception; } } public void deleteoperatorprivilegeinfobyoperatorid(string operatorid) { try { // _enity.executestorecommand("delete from t_operator_privilege where operatorid=@operatorids", new sqlparameter("@operatorids", operatorid)); var rsult = from fx in _dbcontext.t_operator_privilege where fx.operatorid == operatorid select fx; if (rsult.any()) { foreach (var privilege in rsult) { _dbcontext.t_operator_privilege.remove(privilege); } _dbcontext.savechanges(); } } catch (exception ee) { throw ee.innerexception; } } #endregion
#region 用户角色 //新增角色 public bool insertroleinfo(t_role roleentity) { try { _dbcontext.t_role.add(roleentity); _dbcontext.savechanges(); return true; } catch (dbexception ex) { loghelper.error(ex.message); throw ex.innerexception; } } public t_role t_rolebyid(string roleid) { try { return _dbcontext.set<t_role>().firstordefault(o => o.roleid == roleid && o.codeno == "有效"); } catch (dbexception ex) { loghelper.error(ex.message); throw ex.innerexception; } } ///<summary> ///修改操作t_role /// </summary> public bool updatet_role(t_role model) { try { var category = _dbcontext.t_role.firstordefault(o => o.roleid == model.roleid); if (category != null) { category.roleid = model.roleid; category.rolename = model.rolename; category.commentary = model.commentary; category.codeno = model.codeno; category.customno = model.customno; category.spellno = model.spellno; category.strokeno = model.strokeno; } _dbcontext.savechanges(); } catch (entityexception) { return false; } catch (exception) { return false; } return true; } ///<summary> ///删除操作t_role /// </summary> public bool deletet_role(string model) { try { var category = _dbcontext.t_role.where(o => o.roleid == model); if (category.any()) { foreach (var item in category) { _dbcontext.set<t_role>().attach(item); _dbcontext.set<t_role>().remove(item); } _dbcontext.savechanges(); } } catch (entityexception) { return false; } catch (exception) { return false; } return true; } //返回角色权限信息 public list<findrolerigthbyrole> getrolerigthbyrolecode(string rolecode) { var list = new list<findrolerigthbyrole>(); var query = from a in _dbcontext.t_role_privilege join b in _dbcontext.t_wholemenu on a.nodeid equals b.nodeid where a.roleid == rolecode select new { a.roleid, parentnode1 = a.parentnode, a.nodeid, a.isendnode, a.privid, a.istoolbar, a.barorder, a.barcaption, b.nodename, b.parentnode, b.pluginid, b.commentary, b.disporder, b.type, b.groupbyname, b.imageico, b.typeshow }; if (query.any()) { list.addrange(query.tolist().select(item => new findrolerigthbyrole { barcaption = item.barcaption, barorder = item.barorder, commentary = item.commentary, isendnode = item.isendnode, istoolbar = item.istoolbar, nodeid = item.nodeid, nodename = item.nodename, parentnode1 = item.parentnode1, parentnode = item.parentnode, pluginid = item.pluginid, privid = item.privid, groupbyname = item.groupbyname, imageico = item.imageico, typeshow = item.typeshow, disporder = item.disporder })); } return list; } public list<t_role> getrolealllist() { try { return (from fx in _dbcontext.t_role select fx).tolist(); } catch (entityexception ex) { loghelper.error(ex.message); throw ex.innerexception; } } public int getmaxroleid() { try { const string strsql = "select max(convert(int,roleid)) from t_role"; return _dbcontext.database.sqlquery<int>(strsql).firstordefault(); } catch (exception ee) { throw ee.innerexception; } } #endregion
#region 用户角色权限管理 public void inserttroleprivilege(t_role_privilege roleentity) { // _enity.attach(roleentity); try { _dbcontext.t_role_privilege.add(roleentity); // _enity.objectstatemanager.changeobjectstate(roleentity, entitystate.added); _dbcontext.savechanges(); } catch (exception ee) { throw ee.innerexception; } } public void deleteroleprivilegebyroleid(string roleid) { try { _dbcontext.database.executesqlcommand("delete from t_role_privilege where roleid=@roleid", new sqlparameter("@roleid", roleid)); } catch (exception ee) { throw ee.innerexception; } } public bool addprojectlimits(list<t_projectlimits> projectlimitses, string typeinfo, string typeid) { try { switch (typeinfo) { case "operator": string strsql = "delete from t_projectlimits where f_operatorid=@opid"; sqlparameter[] parms = new sqlparameter[] { new sqlparameter("@opid", typeid) }; _dbcontext.database.executesqlcommand(strsql, parms); _dbcontext.set<t_projectlimits>().addrange(projectlimitses); break; case "role": string sqlrole = "delete from t_projectlimits where f_roleid=@opid"; sqlparameter[] parmsrole = new sqlparameter[] { new sqlparameter("@opid", typeid) }; _dbcontext.database.executesqlcommand(sqlrole, parmsrole); //获取该角色的操作员 datatable opdt = untity.listtodatatable(gettoperatorsbyroleid(typeid)); if (opdt.rows.count > 0) { foreach (datarow rows in opdt.rows) { string strsqloperator = "delete from t_projectlimits where f_operatorid=@optuser"; sqlparameter[] parmsoperator = new sqlparameter[] { new sqlparameter("@optuser", rows["operatorid"]) }; _dbcontext.database.executesqlcommand(strsqloperator, parmsoperator); } } foreach (var item in projectlimitses) { //添加角色信息 item.f_roleid = typeid; item.f_operatorid = ""; _dbcontext.set<t_projectlimits>().add(item); foreach (datarow rows in opdt.rows) { t_projectlimits tp=new t_projectlimits() { f_itemkey = item.f_itemkey, f_itemtext = item.f_itemtext, f_operatorid = rows["operatorid"].tostring(), f_roleid = typeid, f_sortid = item.f_sortid }; _dbcontext.set<t_projectlimits>().add(tp); } } break; } _dbcontext.savechanges(); return true; } catch (entityexception ex) { loghelper.error(ex.message); throw ex.innerexception; } catch (dbexception exception) { throw exception.innerexception; } } public bool addorgizationlimits(list<t_organization_privilege> organizationprivileges, string typeinfo, string typeid) { try { switch (typeinfo) { case "operator": string strsql = "delete from t_organization_privilege where f_operatorid=@opid"; sqlparameter[] parms = new sqlparameter[] { new sqlparameter("@opid", typeid) }; _dbcontext.database.executesqlcommand(strsql, parms); _dbcontext.set<t_organization_privilege>().addrange(organizationprivileges); break; case "role": string sqlrole = "delete from t_organization_privilege where f_roleid=@opid"; sqlparameter[] parmsrole = new sqlparameter[] { new sqlparameter("@opid", typeid) }; _dbcontext.database.executesqlcommand(sqlrole, parmsrole); //获取该角色的操作员 datatable opdt = untity.listtodatatable(gettoperatorsbyroleid(typeid)); if (opdt.rows.count > 0) { foreach (datarow rows in opdt.rows) { string strsqloperator = "delete from t_organization_privilege where f_operatorid=@optuser"; sqlparameter[] parmsoperator = new sqlparameter[] { new sqlparameter("@optuser", rows["operatorid"]) }; _dbcontext.database.executesqlcommand(strsqloperator, parmsoperator); } } foreach (var item in organizationprivileges) { //添加角色信息 item.f_operatorid = ""; item.f_roleid = typeid; _dbcontext.set<t_organization_privilege>().add(item); foreach (datarow rows in opdt.rows) { t_organization_privilege torg=new t_organization_privilege() { f_keyid = item.f_keyid, f_operatorid = rows["operatorid"].tostring(), f_orgid = item.f_orgid, f_orgname = item.f_orgname, f_roleid = typeid, f_parentid = item.f_parentid }; _dbcontext.set<t_organization_privilege>().add(torg); } } break; } _dbcontext.savechanges(); return true; } catch (entityexception ex) { loghelper.error(ex.message); throw ex.innerexception; } catch (dbexception exception) { throw exception.innerexception; } } public bool addlinemileagelimits(list<linemileage_privilege> organizationprivileges, string typeinfo, string typeid) { try { switch (typeinfo) { case "operator": string strsql = "delete from linemileage_privilege where operatorid=@opid"; sqlparameter[] parms = new sqlparameter[] { new sqlparameter("@opid", typeid) }; _dbcontext.database.executesqlcommand(strsql, parms); _dbcontext.set<linemileage_privilege>().addrange(organizationprivileges); _dbcontext.savechanges(); break; case "role": string sqlrole = "delete from linemileage_privilege where roleid=@opid"; sqlparameter[] parmsrole = new sqlparameter[] { new sqlparameter("@opid", typeid) }; _dbcontext.database.executesqlcommand(sqlrole, parmsrole); //获取该角色的操作员 datatable opdt = untity.listtodatatable(gettoperatorsbyroleid(typeid)); if (opdt.rows.count > 0) { foreach (datarow rows in opdt.rows) { string strsqloperator = "delete from linemileage_privilege where operatorid=@optuser"; sqlparameter[] parmsoperator = new sqlparameter[] { new sqlparameter("@optuser", rows["operatorid"]) }; _dbcontext.database.executesqlcommand(strsqloperator, parmsoperator); } } foreach (var item in organizationprivileges) { //添加角色信息 item.roleid = typeid; item.operatorid = ""; _dbcontext.set<linemileage_privilege>().add(item); foreach (datarow rows in opdt.rows) { linemileage_privilege line = new linemileage_privilege() { mileageid = item.mileageid, mileagename = item.mileagename, nodeid = item.nodeid, operatorid = rows["operatorid"].tostring(), roleid = typeid }; _dbcontext.set<linemileage_privilege>().add(line); } } _dbcontext.savechanges(); break; } return true; } catch (dbentityvalidationexception ex) { loghelper.error(ex.message); throw ex.innerexception; } catch (entityexception ex) { loghelper.error(ex.message); throw ex.innerexception; } catch (dbexception exception) { throw exception.innerexception; } } #endregion
#region 菜单管理 public void inserttwholemenu(t_wholemenu menuentity) { try { _dbcontext.set<t_wholemenu>().add(menuentity); _dbcontext.savechanges(); } catch (exception ee) { throw ee.innerexception; } } public bool updatetwholemenu(t_wholemenu menuentity) { try { var category = _dbcontext.t_wholemenu.firstordefault(o => o.nodeid == menuentity.nodeid); if (category != null) { category.nodeid = menuentity.nodeid; category.nodename = menuentity.nodename; category.parentnode = menuentity.parentnode; category.isendnode = menuentity.isendnode; category.pluginid = menuentity.pluginid; category.commentary = menuentity.commentary; category.disporder = menuentity.disporder; category.type = menuentity.type; category.groupbyname = menuentity.groupbyname; category.imageico = menuentity.imageico; category.typeshow = menuentity.typeshow; category.isstartup = menuentity.isstartup; } _dbcontext.savechanges(); } catch (exception ee) { throw ee.innerexception; } return true; } public list<t_wholemenu> getallwholemenulist() { try { var query = from fx in _dbcontext.t_wholemenu select fx; return query.tolist(); } catch (entityexception ex) { loghelper.error("getallwholemenulist",ex); throw ex.innerexception; } } public int gettwholemenunodeid() { try { var category = _dbcontext.t_wholemenu.where(o => o.nodeid.length == 2).max(o => o.nodeid); return convert.toint32(category); } catch (entityexception ex) { loghelper.error("gettwholemenunodeid", ex); throw ex.innerexception; } } public int gettwholemenunodechildrenid() { try { var category = _dbcontext.t_wholemenu.where(o => o.nodeid.length > 3).max(o => o.nodeid); return convert.toint32(category); } catch (entityexception ex) { loghelper.error("gettwholemenunodechildrenid", ex); throw ex.innerexception; } } public int getmaxwholemenuid(string parentnode) { try { var category = _dbcontext.t_wholemenu.where (o => o.parentnode == parentnode).max(o => o.nodeid); return convert.toint32(category); } catch (entityexception ex) { loghelper.error("getmaxwholemenuid", ex); throw ex.innerexception; } } //多级菜单删除 public void deletewholemenu(string parentid) { try { var catetory = _dbcontext.t_wholemenu.where(o => o.parentnode == parentid); if (catetory.any()) { foreach (var item in catetory) { t_wholemenu itemtwhole = item; var queryreslut = _dbcontext.t_wholemenu.where(o => o.parentnode == itemtwhole.nodeid);//查询该菜单下面是否有子菜单 if (queryreslut.any()) { foreach (var wholemenu in queryreslut) { t_wholemenu menu = wholemenu; var queryrm = _dbcontext.t_wholemenu.where(o => o.parentnode == menu.nodeid); if (queryrm.any()) { foreach (var itemmenu in queryrm) { _dbcontext.t_wholemenu.remove(itemmenu); } } _dbcontext.t_wholemenu.remove(wholemenu); } } _dbcontext.t_wholemenu.remove(item); } _dbcontext.savechanges(); } } catch (invalidoperationexception e) { console.writeline(e); } catch (exception ee) { throw ee.innerexception; } } public void deletewholemenunode(string nodeid) { try { var catetory = _dbcontext.t_wholemenu.where(o => o.nodeid == nodeid); if (catetory.any()) { foreach (var item in catetory) { _dbcontext.set<t_wholemenu>().attach(item); _dbcontext.set<t_wholemenu>().remove(item); } _dbcontext.savechanges(); } } catch (invalidoperationexception e) { console.writeline(e); } catch (exception ee) { throw ee.innerexception; } } /// <summary> /// 保存用户权限 /// </summary> /// <param name="dt">datatable 数据源</param> /// <param name="type">类型</param> /// <param name="typeid">roleid或operatorid</param> /// <returns></returns> public bool adduserright(datatable dt, string type, string typeid) { try { switch (type) { #region role case "role": //删除该角色所有的权限 deleteroleprivilegebyroleid(typeid); _dbcontext.sys_button_privilege.removerange(_dbcontext.sys_button_privilege.where(o => o.roleid == typeid)); _dbcontext.savechanges(); //获取该角色的操作员 datatable opdt = untity.listtodatatable(gettoperatorsbyroleid(typeid)); if (opdt.rows.count > 0) { foreach (datarow row in opdt.rows) { //删除该角色对应操作员权限信息 deleteoperatorprivilegeinfobyoperatorid(row["operatorid"].tostring()); removesysbuttonsprivilege(row); } } foreach (datarow rolerow in dt.select(" isendnode='menu'")) { if (rolerow.rowstate == datarowstate.deleted) continue; //创建对象 var roledata = new t_role_privilege { barcaption = rolerow["nodename"].tostring(), barorder = 0, isendnode = rolerow["isendnode"].tostring(), nodeid = rolerow["nodeid"].tostring(), parentnode = rolerow["parentnode"].tostring(), privid = rolerow["nodeid"].tostring(), roleid = typeid, istoolbar = 0 }; //插入新的角色权限信息 // roleprivilege.inserttroleprivilege(roledata); inserttroleprivilege(roledata); foreach (datarow oprow in opdt.rows) { var operdata = new t_operator_privilege { barcaption = rolerow["nodename"].tostring(), barorder = 0, isendnode = rolerow["isendnode"].tostring(), nodeid = rolerow["nodeid"].tostring(), parentnode = rolerow["parentnode"].tostring(), privid = rolerow["nodeid"].tostring(), operatorid = oprow["operatorid"].tostring(), istoolbar = 0 }; //插入新的该角色操作员权限信息 insertoperatorprivilegeinfo(operdata); } } foreach (datarow rows in dt.select(" isendnode='button'")) { if (rows.rowstate == datarowstate.deleted) continue; //newrow["nodeid"] = rowbutton.keyid; //newrow["parentnode"] = rowbutton.menuid; //newrow["nodename"] = rowbutton.buttoncaption; //newrow["isendnode"] = "button"; //newrow["disporder"] = rowbutton.buttonid; var opdata = new sys_button_privilege(); if (rows["disporder"] != null) { opdata.buttonid = convert.toint32(rows["disporder"]); } opdata.roleid = typeid; string nodeid = rows["nodeid"].tostring(); if (nodeid.length == 1) { nodeid = nodeid.padleft(2, '0'); } opdata.nodeid = nodeid; _dbcontext.set<sys_button_privilege>().add(opdata); foreach (datarow oprow in opdt.rows) { var opdata2 = new sys_button_privilege(); if (rows["disporder"] != null) { opdata2.buttonid = convert.toint32(rows["disporder"]); } opdata2.roleid = typeid; opdata2.operatorid = oprow["operatorid"].tostring(); opdata2.nodeid = nodeid; _dbcontext.set<sys_button_privilege>().add(opdata2); } } _dbcontext.savechanges(); break; #endregion #region operator case "operator": //删除该操作员权限信息 try { deleteoperatorprivilegeinfobyoperatorid(typeid); _dbcontext.sys_button_privilege.removerange( _dbcontext.sys_button_privilege.where(o => o.operatorid == typeid)); _dbcontext.savechanges(); } catch (exception) { return false; } foreach (datarow rows in dt.select(" isendnode='menu'")) { if (rows.rowstate == datarowstate.deleted) continue; var opdata = new t_operator_privilege { barcaption = rows["nodename"].tostring(), barorder = 0, isendnode = rows["isendnode"].tostring(), istoolbar = 0, nodeid = rows["nodeid"].tostring(), parentnode = rows["parentnode"].tostring(), privid = rows["nodeid"].tostring(), operatorid = typeid }; //插入该操作员权限信息 insertoperatorprivilegeinfo(opdata); } foreach (datarow rows in dt.select(" isendnode='button'")) { if (rows.rowstate == datarowstate.deleted) continue; //newrow["nodeid"] = rowbutton.keyid; //newrow["parentnode"] = rowbutton.menuid; //newrow["nodename"] = rowbutton.buttoncaption; //newrow["isendnode"] = "button"; //newrow["disporder"] = rowbutton.buttonid; var opdata = new sys_button_privilege(); if (rows["disporder"] != null) { opdata.buttonid = convert.toint32(rows["disporder"]); } opdata.operatorid = typeid; string nodeid = rows["nodeid"].tostring(); if (nodeid.length == 1) { nodeid = nodeid.padleft(2, '0'); } opdata.nodeid = nodeid; _dbcontext.set<sys_button_privilege>().add(opdata); } _dbcontext.savechanges(); break; #endregion } } catch (entitysqlexception) { return false; } catch (invalidoperationexception) { return false; } catch (entityexception) { return false; } catch (exception ee) { throw ee.innerexception; } return true; } private void removesysbuttonsprivilege(datarow row) { try { string operatorid = row["operatorid"].tostring(); var query = _dbcontext.sys_button_privilege.where(o => o.operatorid == operatorid); if (query.any()) { _dbcontext.sys_button_privilege.removerange(query); _dbcontext.savechanges(); } } catch (entityexception ex) { loghelper.error("removesysbuttonsprivilege", ex); throw ex.innerexception; } } #endregion
#region 系统字典 public bool insertdectionary(t_dictionaryinfo tinfo) { try { if (!_dbcontext.set<t_dictionaryinfo>().any(o => o.f_dictonarycode == tinfo.f_dictonarycode)) { _dbcontext.set<t_dictionaryinfo>().add(tinfo); _dbcontext.savechanges(); return true; } } catch (updateexception e) { throw e.innerexception; } catch (exception ee) { throw ee.innerexception; } return false; } public bool updatedectionary(t_dictionaryinfo tinfo) { try { var catetory = _dbcontext.t_dictionaryinfo.first(o => o.f_dictonarycode == tinfo.f_dictonarycode); catetory.f_dictonarycode = tinfo.f_dictonarycode; catetory.f_dictonarycoding = tinfo.f_dictonarycoding; catetory.f_dictonaryname = tinfo.f_dictonaryname; catetory.f_dictonarytype = tinfo.f_dictonarytype; catetory.f_parentdictonarycode = tinfo.f_parentdictonarycode; catetory.f_remark = tinfo.f_remark; _dbcontext.savechanges(); } catch (updateexception exception) { throw exception.innerexception; } catch (entityexception exception) { throw exception.innerexception; } catch (exception exception) { throw exception.innerexception; } return true; } public list<t_dictionaryinfo> getalldictonarylist() { try { list<t_dictionaryinfo> list = (from dictionaryinfo in _dbcontext.t_dictionaryinfo select dictionaryinfo).tolist(); return list; } catch (exception ee) { throw ee.innerexception; } } public list<t_dictionaryinfo> searchdictionaryoftype(string fdictonarycode) { var list = new list<t_dictionaryinfo>(); try { if (!string.isnullorempty(fdictonarycode)) { list = (from dictionaryinfo in _dbcontext.t_dictionaryinfo where dictionaryinfo.f_parentdictonarycode == fdictonarycode select dictionaryinfo).tolist(); return list; } } catch (updateexception e) { throw e.innerexception; } catch (exception ee) { throw ee.innerexception; } return list; } public list<t_dictionaryinfo> searchdictionaryoftypecode(string typecode) { list<t_dictionaryinfo> list=new list<t_dictionaryinfo>(); try { if (!string.isnullorempty(typecode)) { t_dictionaryinfo tdictionaryinfo= _dbcontext.t_dictionaryinfo.firstordefault(o=>o.f_dictonarytype==typecode); if (tdictionaryinfo != null) { list = searchdictionaryoftype(tdictionaryinfo.f_dictonarycode); } } } catch (updateexception e) { throw e.innerexception; } catch (exception ee) { throw ee.innerexception; } return list; } public int getmaxdictionaryparentcode() { try { var category = _dbcontext.t_dictionaryinfo.where(o => o.f_dictonarycode.length == 2).max(o => o.f_dictonarycode); return convert.toint32(category); } catch (updateexception e) { throw e.innerexception; } catch (exception ee) { throw ee.innerexception; } } public int getdictionarynodechildrencode() { try { var category = _dbcontext.t_dictionaryinfo.where(o => o.f_dictonarycode.length > 3).max(o => o.f_dictonarycode); return convert.toint32(category); } catch (updateexception e) { throw e.innerexception; } catch (exception ee) { throw ee.innerexception; } } public int getmaxdictionarycode(string parentcode) { try { var category = _dbcontext.t_dictionaryinfo.where (o => o.f_parentdictonarycode == parentcode).max(o => o.f_dictonarycode); return convert.toint32(category); } catch (updateexception e) { throw e.innerexception; } catch (exception ee) { throw ee.innerexception; } } public bool deletedictionarychildrencode(string dictonarycode) { try { var catetory = _dbcontext.t_dictionaryinfo.where(o => o.f_dictonarycode == dictonarycode); if (catetory.any()) { foreach (var item in catetory) { _dbcontext.set<t_dictionaryinfo>().attach(item); _dbcontext.set<t_dictionaryinfo>().remove(item); } _dbcontext.savechanges(); } } catch (updateexception e) { throw e.innerexception; } catch (exception ee) { throw ee.innerexception; } return true; } public bool deletedictonarycode(string parnentdictonarycode) { try { var catetory = _dbcontext.t_dictionaryinfo.where(o => o.f_parentdictonarycode == parnentdictonarycode); if (catetory.any()) { foreach (var item in catetory) { _dbcontext.set<t_dictionaryinfo>().attach(item); _dbcontext.set<t_dictionaryinfo>().remove(item); } _dbcontext.savechanges(); } } catch (updateexception) { return false; } catch (entityexception) { return false; } catch (exception) { return false; } return true; } public datatable getalltablenamebydb(string databasename) { try { var retval = new datatable(); var sqlconn = (sqlconnection)_dbcontext.database.connection; var cmdreport = new sqlcommand(string.format("select name from {0}..sysobjects where xtype='u' order by name", databasename), sqlconn); var dareport = new sqldataadapter(cmdreport); using (cmdreport) { dareport.fill(retval); } retval.tablename = "systemtablename"; return retval; } catch (updateexception e) { throw e.innerexception; } catch (exception ee) { throw ee.innerexception; } } public int getdictionarycountbyparentcode(string parentcode) { try { var category = _dbcontext.t_dictionaryinfo.count(o => o.f_parentdictonarycode == parentcode); return convert.toint32(category); } catch (updateexception e) { throw e.innerexception; } catch (exception ee) { throw ee.innerexception; } } public t_dictionaryinfo gettdictonaryinfo(string dictonarycode) { var query = (from fx in _dbcontext.t_dictionaryinfo where fx.f_dictonarycode.equals(dictonarycode) select fx).firstordefault(); return query; } #endregion
#region 机构 ///<summary> ///新增操作t_organization /// </summary> public bool insertt_organization(t_organization model,string operatorid) { try { _dbcontext.set<t_organization>().add(model); //插入权限 _dbcontext.set<t_organization_privilege>().add(new t_organization_privilege() { f_operatorid =operatorid, f_orgid = model.f_orgid, f_orgname = model.f_orgname, f_parentid = model.f_parentid }); if (operatorid != "10000") { //插入超级管理员的权限 _dbcontext.set<t_organization_privilege>().add(new t_organization_privilege() { f_operatorid = "10000", f_orgid = model.f_orgid, f_orgname = model.f_orgname, f_parentid = model.f_parentid }); } _dbcontext.savechanges(); } catch (entityexception) { return false; } catch (exception) { return false; } return true; } ///<summary> ///修改操作t_organization /// </summary> public bool updatet_organization(t_organization model) { try { var category = _dbcontext.t_organization.firstordefault(o => o.f_orgid == model.f_orgid); if (category != null) { category.f_orgid = model.f_orgid; category.f_orgname = model.f_orgname; category.f_orgmanager = model.f_orgmanager; category.f_builddate = model.f_builddate; category.f_buildman = model.f_buildman; category.f_tellphonenum = model.f_tellphonenum; category.f_address = model.f_address; category.f_parentid = model.f_parentid; category.f_state = model.f_state; } // _enity.entry(.state = entitystate.modified; _dbcontext.entry(category).state = entitystate.modified; //修改权限表 var privialeages = _dbcontext.t_organization_privilege.where(o => o.f_orgid == model.f_orgid); if (privialeages.any()) { foreach (t_organization_privilege privialeage in privialeages) { privialeage.f_orgname = model.f_orgname; } } _dbcontext.savechanges(); } catch (entityexception) { return false; } catch (exception) { return false; } return true; } ///<summary> ///删除操作t_organization /// </summary> public bool deletet_organization(string modelcode) { try { var category = _dbcontext.t_organization.where(o => o.f_orgid == modelcode); if (category.any()) { foreach (t_organization item in category) { _dbcontext.set<t_organization>().attach(item); _dbcontext.set<t_organization>().remove(item); } _dbcontext.savechanges(); } //删除权限表里面的信息 var privleages = _dbcontext.t_organization_privilege.where(o => o.f_orgid == modelcode); if (privleages.any()) { foreach (t_organization_privilege organization in privleages) { _dbcontext.set<t_organization_privilege>().attach(organization); _dbcontext.set<t_organization_privilege>().remove(organization); } _dbcontext.savechanges(); } } catch (entityexception) { return false; } catch (exception) { return false; } return true; } ///<summary> ///获取所有数据t_organization /// </summary> public list<t_organization> gett_organizationlistdata() { try { return _dbcontext.t_organization.tolist(); } catch (entityexception exception) { throw exception.innerexception; } catch (exception exception) { throw exception.innerexception; } } public iqueryable<t_organization> gett_organizationby(string operatorid) { try { var query = _dbcontext.t_organization.where(o => o.f_orgid == operatorid); return query; } catch (entityexception ex) { loghelper.error(ex.message); throw ex.innerexception; } catch (dbexception ex) { loghelper.error(ex.message); throw ex.innerexception; } } #endregion
#region 机构数据权限 /// <summary> ///根据sql语句查询返回iqueryablet_organization_privilege /// <param name="strsql">t_organization_privilegesql语句</param> /// </summary> public iqueryable<t_organization_privilege> gett_organization_privilegebysql(string strsql, params object[] obj) { try { iqueryable<t_organization_privilege> iqueryable = _dbcontext.database.sqlquery<t_organization_privilege>(strsql, obj).asqueryable(); return iqueryable; } catch (entityexception ex) { loghelper.error(ex.message); throw ex.innerexception; } catch (dbexception ex) { loghelper.error(ex.message); throw ex.innerexception; } } public list<t_organization_privilege> gett_organization_privilegebyid(string id) { try { return _dbcontext.set<t_organization_privilege>().where(o => o.f_operatorid == id).tolist(); } catch (entityexception ex) { loghelper.error(ex.message); throw ex.innerexception; } catch (dbexception exception) { loghelper.error(exception.message); throw exception.innerexception; } } public bool updatet_organization_privilege(list<t_organization_privilege> entity) { try { foreach (var operatororgprivilege in entity) { new basedal<t_organization_privilege>(_dbcontext).modify(operatororgprivilege); } return true; } catch (entityexception ex) { loghelper.error(ex.message); throw ex.innerexception; } catch (dbexception exception) { throw exception.innerexception; } } public bool createt_organization_privilege(list<t_organization_privilege> entity, string operatorid) { try { string strsql = "delete from t_organization_privilege where f_operatorid=@opid"; sqlparameter[] parms = new sqlparameter[]{ new sqlparameter("@opid",operatorid) }; _dbcontext.database.executesqlcommand(strsql, parms); foreach (var operatororgprivilege in entity) { _dbcontext.set<t_organization_privilege>().add(operatororgprivilege); } _dbcontext.savechanges(); return true; } catch (entityexception ex) { loghelper.error(ex.message); throw ex.innerexception; } catch (dbexception exception) { throw exception.innerexception; } } public bool createt_organization_privilegeentity(t_organization_privilege entity) { try { _dbcontext.set<t_organization_privilege>().add(entity); _dbcontext.savechanges(); return true; } catch (entityexception ex) { loghelper.error(ex.message); throw ex.innerexception; } catch (dbexception exception) { throw exception.innerexception; } } public bool deletet_organization_privilege(list<int> id) { try { foreach (var i in id) { new basedal<t_organization_privilege>(_dbcontext).delby(o => o.f_keyid == i); } return true; } catch (entityexception ex) { loghelper.error(ex.message); throw ex.innerexception; } catch (dbexception exception) { throw exception.innerexception; } } /// <summary> ///获取实体linemileage_privilege /// <param name="id">主键编号</param> /// </summary> public linemileage_privilege getlinemileage_privilegebyid(string id) { try { return _dbcontext.linemileage_privilege.firstordefault(o => o.sysid == int.parse(id)); } catch (entityexception ex) { loghelper.error(ex.message); throw ex.innerexception; } catch (dbexception ex) { loghelper.error(ex.message); throw ex.innerexception; } } /// <summary> ///修改实体linemileage_privilege /// <param name="entity">linemileage_privilege实体</param> /// </summary> public bool updatelinemileage_privilege(linemileage_privilege entity) { try { var category = _dbcontext.linemileage_privilege.firstordefault(o => o.sysid == entity.sysid); if (category != null) { category.sysid = entity.sysid; category.nodeid = entity.nodeid; category.operatorid = entity.operatorid; category.mileageid = entity.mileageid; _dbcontext.savechanges(); } } catch (entityexception ex) { loghelper.error(ex.message); throw ex.innerexception; } catch (dbexception ex) { loghelper.error(ex.message); throw ex.innerexception; } return true; } /// <summary> ///新增实体linemileage_privilege /// <param name="entity">linemileage_privilege实体</param> /// </summary> public bool createlinemileage_privilege(list<linemileage_privilege> entity, string operatorid) { try { string strsql = "delete from linemileage_privilege where operatorid=@opid"; sqlparameter[] parms = new sqlparameter[]{ new sqlparameter("@opid",operatorid) }; _dbcontext.database.executesqlcommand(strsql, parms); foreach (var item in entity) { _dbcontext.set<linemileage_privilege>().add(item); _dbcontext.savechanges(); } return true; } catch (entityexception ex) { loghelper.error(ex.message); throw ex.innerexception; } catch (dbexception ex) { loghelper.error(ex.message); throw ex.innerexception; } } /// <summary> ///删除linemileage_privilege /// <param name="id">主键编号sysid</param> /// </summary> public bool deletelinemileage_privilege(string id) { try { var category = _dbcontext.linemileage_privilege.firstordefault(o => o.sysid == int.parse(id)); if (category != null) { _dbcontext.set<linemileage_privilege>().attach(category); _dbcontext.set<linemileage_privilege>().remove(category); _dbcontext.savechanges(); } } catch (entityexception ex) { loghelper.error(ex.message); throw ex.innerexception; } catch (dbexception ex) { loghelper.error(ex.message); throw ex.innerexception; } return true; } public iqueryable<t_projectlimits> gett_projectlimitsbysql(string strsql, params object[] obj) { try { iqueryable<t_projectlimits> iqueryable = _dbcontext.database.sqlquery<t_projectlimits>(strsql, obj).asqueryable(); return iqueryable; } catch (entityexception ex) { loghelper.error(ex.message); throw ex.innerexception; } catch (dbexception ex) { loghelper.error(ex.message); throw ex.innerexception; } } /// <summary> ///根据sql语句查询返回iqueryablelinemileage_privilege /// <param name="strsql">linemileage_privilegesql语句</param> /// </summary> public iqueryable<linemileage_privilege> getlinemileage_privilegebysql(string strsql, params cmdparameter[] obj) { try { dbparameter[] parameters = new dbparameter[obj.length]; for (int i = 0; i < obj.length; i++) { dbparameter sqlpram = new sqlparameter(obj[i].parametername, obj[i].value); parameters[i] = sqlpram; } iqueryable<linemileage_privilege> iqueryable = _dbcontext.database.sqlquery<linemileage_privilege>(strsql, parameters).asqueryable(); return iqueryable; } catch (entityexception ex) { loghelper.error(ex.message); throw ex.innerexception; } catch (dbexception ex) { loghelper.error(ex.message); throw ex.innerexception; } } public bool createt_projectlimits_privilege(list<t_projectlimits> entity, string operatorid) { try { string strsql = "delete from t_projectlimits where f_operatorid=@opid"; sqlparameter[] parms = new sqlparameter[]{ new sqlparameter("@opid",operatorid) }; _dbcontext.database.executesqlcommand(strsql, parms); foreach (var item in entity) { _dbcontext.set<t_projectlimits>().add(item); } _dbcontext.savechanges(); return true; } catch (entityexception ex) { loghelper.error(ex.message); throw ex.innerexception; } catch (dbexception ex) { loghelper.error(ex.message); throw ex.innerexception; } } public iqueryable<t_projectlimits> gett_projectlimitsbyoperator(string operatorid) { try { var query=_dbcontext.t_projectlimits.where(o => o.f_operatorid == operatorid); return query; } catch (entityexception ex) { loghelper.error(ex.message); throw ex.innerexception; } catch (dbexception ex) { loghelper.error(ex.message); throw ex.innerexception; } } #endregion bn
#region 按钮服务 /// <summary> ///获取实体sys_buttons /// <param name="id">主键编号</param> /// </summary> public sys_buttons getsys_buttonsbyid(int id) { try { return _dbcontext.sys_buttons.firstordefault(o => o.keyid == id); } catch (dbexception ex) { loghelper.error(ex.message); throw ex.innerexception; } } /// <summary> ///修改实体sys_buttons /// <param name="entity">sys_buttons实体</param> /// </summary> public bool updatesys_buttons(sys_buttons entity) { try { var category = _dbcontext.sys_buttons.firstordefault(o => o.keyid == entity.keyid); if (category != null) { category.keyid = entity.keyid; category.buttoncaption = entity.buttoncaption; category.sortnum = entity.sortnum; category.iconcls = entity.iconcls; category.iconurl = entity.iconurl; category.buttontag = entity.buttontag; category.remark = entity.remark; category.buttonhtml = entity.buttonhtml; category.buggongroup = entity.buggongroup; category.state = entity.state; category.tooltip = entity.tooltip; _dbcontext.savechanges(); } } catch (dbexception ex) { loghelper.error(ex.message); throw ex.innerexception; } return true; } /// <summary> ///新增实体sys_buttons /// <param name="entity">sys_buttons实体</param> /// </summary> public bool createsys_buttons(sys_buttons entity) { try { _dbcontext.set<sys_buttons>().add(entity); _dbcontext.savechanges(); return true; } catch (dbexception ex) { loghelper.error(ex.message); throw ex.innerexception; } } /// <summary> ///删除sys_buttons /// <param name="id">主键编号keyid</param> /// </summary> public bool deletesys_buttons(int id) { try { var category = _dbcontext.sys_buttons.firstordefault(o => o.keyid == id); if (category != null) { _dbcontext.set<sys_buttons>().attach(category); _dbcontext.set<sys_buttons>().remove(category); _dbcontext.savechanges(); } } catch (dbexception ex) { loghelper.error(ex.message); throw ex.innerexception; } return true; } public iqueryable<sys_wholemenubuttons> getsys_wholemenubuttonsbysql(string sql, params cmdparameter[] obj) { try { dbparameter[] parameters = new dbparameter[obj.length]; for (int i = 0; i < obj.length; i++) { dbparameter sqlpram = new sqlparameter(obj[i].parametername, obj[i].value); parameters[i] = sqlpram; } iqueryable<sys_wholemenubuttons> iqueryable = _dbcontext.database.sqlquery<sys_wholemenubuttons>(sql, parameters).asqueryable(); return iqueryable; } catch (dbexception ex) { loghelper.error(ex.message); throw ex.innerexception; } } /// <summary> ///根据sql语句查询返回iqueryablesys_buttons /// <param name="sql">sys_buttonssql语句</param> /// </summary> public iqueryable<sys_buttons> getsys_buttonsbysql(string strsql, params cmdparameter[] obj) { try { dbparameter[] parameters = new dbparameter[obj.length]; for (int i = 0; i < obj.length; i++) { dbparameter sqlpram = new sqlparameter(obj[i].parametername, obj[i].value); parameters[i] = sqlpram; } iqueryable<sys_buttons> iqueryable = _dbcontext.database.sqlquery<sys_buttons>(strsql, parameters).asqueryable(); return iqueryable; } catch (dbexception ex) { loghelper.error(ex.message); throw ex.innerexception; } } public list<twholemenubutton> gettwholemenubuttons(string menuid) { try { var query = (from fx in _dbcontext.sys_wholemenubuttons join fb in _dbcontext.sys_buttons on fx.buttonid equals fb.keyid where fx.menuid == menuid select new twholemenubutton { keyid = fx.keyid, menuid = fx.menuid, sortnum = fx.sortnum, buttoncaption = fb.buttoncaption, iconcls = fb.iconcls }).tolist(); return query; } catch (formatexception ex) { loghelper.error(ex.message); throw ex.innerexception; } catch (dbexception ex) { loghelper.error(ex.message); throw ex.innerexception; } } public list<twholemenubutton> gettwholemenubuttonsalllist() { try { var queryresult = (from fx in _dbcontext.sys_buttons join dx in _dbcontext.sys_wholemenubuttons on fx.keyid equals dx.buttonid select new twholemenubutton() { keyid = dx.keyid, buttoncaption = fx.buttoncaption, buttonid = fx.keyid, iconcls = fx.iconcls, menuid = dx.menuid, sortnum = dx.sortnum }).tolist(); return queryresult; } catch (entityexception ex) { loghelper.error(ex.message); throw ex.innerexception; } catch (dbexception ex) { loghelper.error(ex.message); throw ex.innerexception; } } public list<twholemenubutton> getbuttonlimitsallist(string operatorid) { try { var queryresult = (from db in _dbcontext.sys_buttons join fx in _dbcontext.sys_button_privilege on db.keyid equals fx.buttonid where fx.operatorid == operatorid select new twholemenubutton() { keyid = db.keyid, buttonid = db.keyid, menuid = fx.nodeid, buttoncaption = db.buttoncaption, operatorid = operatorid }).tolist(); return queryresult; } catch (entityexception ex) { loghelper.error(ex.message); throw ex.innerexception; } catch (dbexception ex) { loghelper.error(ex.message); throw ex.innerexception; } } public list<twholemenubutton> getbuttonlimitstrolealllist(string roleid) { try { var queryresult = (from db in _dbcontext.sys_buttons join fx in _dbcontext.sys_button_privilege on db.keyid equals fx.buttonid where fx.roleid == roleid && fx.operatorid == null || fx.operatorid == "" select new twholemenubutton() { keyid = db.keyid, buttonid = db.keyid, menuid = fx.nodeid, buttoncaption = db.buttoncaption, roleid = roleid }).tolist(); return queryresult; } catch (entityexception ex) { loghelper.error(ex.message); throw ex.innerexception; } catch (dbexception ex) { loghelper.error(ex.message); throw ex.innerexception; } } /// <summary> ///新增实体sys_wholemenubuttons /// <param name="entity">sys_wholemenubuttons实体</param> /// </summary> public bool createsys_wholemenubuttons(list<sys_wholemenubuttons> entity) { try { foreach (var item in entity) { _dbcontext.set<sys_wholemenubuttons>().add(item); } _dbcontext.savechanges(); return true; } catch (dbexception ex) { loghelper.error(ex.message); throw ex.innerexception; } } /// <summary> ///删除sys_wholemenubuttons /// <param name="nodeid">主键编号keyid</param> /// </summary> public bool deletesys_wholemenubuttons(string nodeid) { try { var category = _dbcontext.sys_wholemenubuttons.where(o => o.menuid == nodeid); if (category.any()) { foreach (var item in category) { _dbcontext.set<sys_wholemenubuttons>().attach(item); _dbcontext.set<sys_wholemenubuttons>().remove(item); } } _dbcontext.savechanges(); } catch (dbexception ex) { loghelper.error(ex.message); throw ex.innerexception; } return true; } public iqueryable<projectslimits> getprojectslimitsesbyoperator(string operatorid) { try { var category = (from fx in _dbcontext.t_projectlimits join db in _dbcontext.rbimproject on fx.f_itemkey equals db.itemkey where fx.f_operatorid == operatorid select new projectslimits() { projectcode = db.projectcode, itemkey = db.itemkey, itemtext = fx.f_itemtext, operatorid = operatorid, projectlocation = db.projectlocation, projectremark = db.projectremark, projecturl = db.projecturl, roleid = fx.f_roleid, sortid = fx.f_sortid }).asqueryable(); return category; } catch (entityexception ex) { loghelper.error(ex.message); throw ex.innerexception; } catch (dbexception ex) { loghelper.error(ex.message); throw ex.innerexception; } } public ienumerable<linemileagelimits> getlinemileagelimitsesbyoperator(string operatorid, string projectkey) { try { var category = (from fx in _dbcontext.linemileage_privilege join db in _dbcontext.linemileages on fx.mileageid equals db.mileageid.tostring() where fx.nodeid == projectkey && fx.operatorid==operatorid select new linemileagelimits() { sysid = fx.sysid, mileageid = fx.mileageid, mileagename = fx.mileagename, projectkey = fx.nodeid, modelsizes = db.modelsizes, modeltype = db.modeltype, nodetype = db.nodetype, operatorid = fx.operatorid, parentmileageid = db.parentmileageid, planpath = db.planpath, sortid = db.sortid, relationmodel = db.relationmodel, soidmodelfile = db.soidmodelfile }).asenumerable(); return category; } catch (entityexception ex) { loghelper.error(ex.message); throw ex.innerexception; } catch (dbexception ex) { loghelper.error(ex.message); throw ex.innerexception; } } #endregion
public void dispose() { var dispose = _dbcontext as idisposable; if (dispose != null) { _dbcontext.dispose(); } } }
4、wcf服务启动
public void servicestart() { try { string serviceport = configurationmanager.appsettings["port"];// "8007"; string serviceip = configurationmanager.appsettings["serviceip"];// "127.0.0.1"; string serviceaddress = string.format("net.tcp://{0}:{1}", serviceip, serviceport); var sevtypes = new dictionary<type, type> { {typeof (ioperationpurviewservice), typeof (operationservice)} }; foreach (var item in sevtypes) { string tname = item.key.name.substring(1); string endpointaddress = serviceaddress + tname; if (!serviceaddress.endswith("/")) endpointaddress = string.format("{0}/{1}", serviceaddress, tname); var servicehost = new servicehost(item.value, new uri(endpointaddress)); //加载元数据结点 var smb = new servicemetadatabehavior(); servicehost.description.behaviors.add(smb); // servicehost.description.behaviors.add(new servicedebugbehavior(){includeexceptiondetailinfaults = true}); servicehost.addserviceendpoint(typeof(imetadataexchange), metadataexchangebindings.createmextcpbinding(), "mex"); //加载nettcpbinding结点 var nettcpbinding = new nettcpbinding { security = { mode = securitymode.none }, receivetimeout = timespan.parse("10:59:00"), closetimeout = timespan.parse("10:59:00"), opentimeout = timespan.parse("10:59:00"), sendtimeout = timespan.parse("10:59:00"), maxbufferpoolsize = long.maxvalue - 1, maxbuffersize = int.maxvalue - 1, maxreceivedmessagesize = int.maxvalue - 1, //maxconnections = 1000, readerquotas = { maxdepth = int.maxvalue - 1, maxstringcontentlength = int.maxvalue - 1, maxarraylength = int.maxvalue - 1, maxbytesperread = int.maxvalue - 1, maxnametablecharcount = int.maxvalue - 1 } // ,portsharingenabled = true //端口共享 }; servicehost.addserviceendpoint(item.key, nettcpbinding, endpointaddress); string address = endpointaddress; servicehost.opened += delegate { loadpluginnamespace.add(new serviceinfo() { address = address + "/mex", id = 0, state = "启动" }); }; servicehost.open(); servicehosts.add(servicehost); } } catch (configurationexception e) { console.writeline(e); } catch (exception ex) { throw ex; } }
下一篇: 终于做出了目录认证!_PHP教程