/// <summary> /// 记录用户登录信息。 /// </summary> /// <param name="userKey">用户主键。</param> /// <param name="site">站点。</param> /// <param name="language">语言。</param> /// <param name="version">系统版本号。</param> public void LogUserLoginInfo(string userKey, string site, string language, string version) { string preLoginLogKey = PropertyService.Get(PROPERTY_FIELDS.LOGIN_LOG_KEY); DataTable loginLogDataTable = RBAC_LOGIN_LOG_FIELDS.CreateDataTable(); DataRow dataRow = loginLogDataTable.NewRow(); string loginLogKey = CommonUtils.GenerateNewKey(0); dataRow[RBAC_LOGIN_LOG_FIELDS.FIELD_LOGIN_LOG_KEY] = loginLogKey; dataRow[RBAC_LOGIN_LOG_FIELDS.FIELD_USER_KEY] = userKey; dataRow[RBAC_LOGIN_LOG_FIELDS.FIELD_SITE] = site; dataRow[RBAC_LOGIN_LOG_FIELDS.FIELD_LANGUAGE] = language; dataRow[RBAC_LOGIN_LOG_FIELDS.FIELD_COMPUTER_NAME] = Environment.MachineName.ToString(); dataRow[RBAC_LOGIN_LOG_FIELDS.FIELD_COMPUTER_IP] = FanHai.Hemera.Utils.Common.Utils.GetLocationIPAddress(); dataRow[RBAC_LOGIN_LOG_FIELDS.FIELD_VERSION] = version; loginLogDataTable.Rows.Add(dataRow); loginLogDataTable.AcceptChanges(); DataSet reqDS = new DataSet(); reqDS.Tables.Add(loginLogDataTable); try { IServerObjFactory serverFactory = CallRemotingService.GetRemoteObject(); IUserEngine userEngine = null; if (serverFactory != null) { userEngine = serverFactory.CreateIUserEngine(); } if (userEngine != null && !string.IsNullOrEmpty(preLoginLogKey)) { userEngine.LogUserLogoutInfo(preLoginLogKey); } if (userEngine != null && userEngine.LogUserLoginInfo(reqDS)) { PropertyService.Set(PROPERTY_FIELDS.LOGIN_LOG_KEY, loginLogKey); } } catch { //TODO: Ignore Generant Exception. } finally { CallRemotingService.UnregisterChannel(); } }