Ejemplo n.º 1
0
        /// <summary>
        /// 记录用户登出信息。
        /// </summary>
        /// <param name="loginLogKey">用户登录日志主键。</param>
        /// <returns>true:记录成功。false:记录失败。</returns>
        public bool LogUserLogoutInfo(string loginLogKey)
        {
            try
            {
                RBAC_LOGIN_LOG_FIELDS loginLogFields = new RBAC_LOGIN_LOG_FIELDS();

                Hashtable updatedFields = new Hashtable();

                updatedFields.Add(RBAC_LOGIN_LOG_FIELDS.FIELD_LOGOUT_TIME, string.Empty);

                Conditions conditions = new Conditions();

                Condition condition = new Condition(DatabaseLogicOperator.And, RBAC_LOGIN_LOG_FIELDS.FIELD_LOGIN_LOG_KEY, DatabaseCompareOperator.Equal,
                                                    loginLogKey);

                conditions.Add(condition);

                string sqlString = DatabaseTable.BuildUpdateSqlStatement(loginLogFields, updatedFields, conditions);

                if (!string.IsNullOrEmpty(sqlString))
                {
                    if (db.ExecuteNonQuery(CommandType.Text, sqlString) > 0)
                    {
                        return(true);
                    }
                }
                return(false);
            }
            catch (Exception ex)
            {
                LogService.LogError("LogUserLogoutInfo Error: " + ex.Message);
                return(false);
            }
        }
Ejemplo n.º 2
0
        /// <summary>
        /// 记录用户登入信息。
        /// </summary>
        /// <param name="dsParams">包含用户登录信息的数据集对象。</param>
        /// <returns>true:记录成功。false:记录失败。</returns>
        public bool LogUserLoginInfo(DataSet dsParams)
        {
            try
            {
                if (dsParams != null && dsParams.Tables.Contains(RBAC_LOGIN_LOG_FIELDS.DATABASE_TABLE_NAME))
                {
                    DataTable loginLogDataTable = dsParams.Tables[RBAC_LOGIN_LOG_FIELDS.DATABASE_TABLE_NAME];
                    loginLogDataTable.Rows[0][RBAC_LOGIN_LOG_FIELDS.FIELD_SERVER_IP] = System.Environment.MachineName;
                    RBAC_LOGIN_LOG_FIELDS loginLogFields = new RBAC_LOGIN_LOG_FIELDS();

                    List <string> sqlStringList = DatabaseTable.BuildInsertSqlStatements(loginLogFields, loginLogDataTable);

                    if (sqlStringList.Count > 0)
                    {
                        if (db.ExecuteNonQuery(CommandType.Text, sqlStringList[0]) > 0)
                        {
                            return(true);
                        }
                    }
                }

                return(false);
            }
            catch (Exception ex)
            {
                LogService.LogError("LogUserLoginInfo Error: " + ex.Message);
                return(false);
            }
        }
Ejemplo n.º 3
0
        /// <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();
            }
        }