/// <summary> /// /// </summary> /// <param name="action"></param> /// <returns></returns> public String Handle(Func <String> action) { cfg.load(); String Msg = "执行成功"; String serverHost = cfg.get("ip"); Teamcenter.ClientX.Session session = null; Teamcenter.ClientX.Session2 session2 = null; try { session = new Teamcenter.ClientX.Session(serverHost); session2 = new Teamcenter.ClientX.Session2(serverHost); Teamcenter.Soa.Client.Model.Strong.User user = session.login(cfg.get("dbname"), cfg.get("dbpassword"), "", "", "", "SoaAppX"); Teamcenter.Soa.Client.Model.Strong.User user2 = session2.login(cfg.get("powerful_user_name"), cfg.get("powerful_user_password"), "", "", "", "SoaAppX"); var res = action.Invoke(); Msg = res.Equals("") ? Msg : res; } catch (Exception e) { Msg = e.ToString(); } finally { if (null != session) { session.logout(); } if (null != session2) { session2.logout(); } } return(Msg); }
public static User login() { return(session.login(userid, password, group, role)); //return session.login(); }