Exemplo n.º 1
0
        /// <summary>
        /// Check if the specified user with user name and password exists.
        /// </summary>
        /// <param name="user">
        /// The <see cref="IUser"/> object that holds the user credentials
        /// </param>
        /// <returns>
        /// True if the specified user with user name and password exists. Else false
        /// </returns>
        private bool Exists(IUser user)
        {
            object o = this._database.ExecuteScalar(this._query, new[] { this._database.CreateInParameter(DbConstants.UserParamName, DbType.String, user.UserName) });

            if (o != null)
            {
                return(user.CheckPasswordEnc(AuthUtils.ConvertDBValue <string>(o)));
            }

            return(false);
        }
Exemplo n.º 2
0
        /// <summary>
        /// Retrieve allowed dataflows for user from the database
        /// </summary>
        /// <param name="user">
        /// The user
        /// </param>
        protected void RetrieveAllowedDataFlows(IUser user)
        {
            this._dataflowSet.Clear();
            this._dataflowIdSet.Clear();
            string userParam = this._database.BuildParameterName(DbConstants.UserParamName);

            string sql =
                this._selectQuery.Replace(DbConstants.UserMacro, userParam).Replace(
                    DbConstants.DataflowIdMacro, DbConstants.DataflowIdField).Replace(
                    DbConstants.DataflowVersionMacro, DbConstants.DataflowVersionField).Replace(
                    DbConstants.DataflowAgencyIdMacro, DbConstants.DataflowAgencyIdField);

            using (DbCommand command = this._database.GetSqlStringCommand(sql))
            {
                this._database.AddInParameter(command, DbConstants.UserParamName, DbType.String, user.UserName);
                using (IDataReader reader = this._database.ExecuteReader(command))
                {
                    int idIdx      = reader.GetOrdinal(DbConstants.DataflowIdField);
                    int versionIdx = reader.GetOrdinal(DbConstants.DataflowVersionField);
                    int agencyIdx  = reader.GetOrdinal(DbConstants.DataflowAgencyIdField);
                    while (reader.Read())
                    {
                        IMaintainableRefObject dataflowRefBean = new MaintainableRefObjectImpl
                        {
                            MaintainableId = AuthUtils.ConvertDBValue <string>(reader.GetValue(idIdx)),
                            AgencyId       = AuthUtils.ConvertDBValue <string>(reader.GetValue(agencyIdx)),
                            Version        = AuthUtils.ConvertDBValue <string>(reader.GetValue(versionIdx))
                        };
                        if (!this._dataflowSet.ContainsKey(dataflowRefBean))
                        {
                            this._dataflowSet.Add(dataflowRefBean, dataflowRefBean.MaintainableId);
                            List <IMaintainableRefObject> dataflowRefBeans;
                            if (!this._dataflowIdSet.TryGetValue(dataflowRefBean.MaintainableId, out dataflowRefBeans))
                            {
                                dataflowRefBeans = new List <IMaintainableRefObject>();
                                this._dataflowIdSet.Add(dataflowRefBean.MaintainableId, dataflowRefBeans);
                            }

                            dataflowRefBeans.Add(dataflowRefBean);
                        }
                    }
                }
            }
        }