Ejemplo n.º 1
0
        protected override Doc DoPopulateDoc(MySqlCrudQueryExecutionContext context, Type tDoc, Schema schema, Schema.FieldDef[] toLoad, MySqlDataReader reader)
        {
            var verState = VersionInfo.MapCanonicalState(reader.AsStringField("VERSION_STATE"));

            if (!VersionInfo.IsExistingStateOf(verState))
            {
                return(null);                                    //deleted, skip this doc
            }
            var id = context.GetState <EntityId>();

            var realm    = reader.AsAtomField("REALM").Value;
            var gUser    = reader.AsGdidField("GDID");
            var sysToken = m_Logic.MakeSystemTokenData(realm, gUser);
            var name     = reader.AsStringField("NAME");

            var level     = Constraints.MapUserStatus(reader.AsString("LEVEL")) ?? Security.UserStatus.Invalid;
            var levelDown = Constraints.MapUserStatus(reader.AsString("LEVEL_DOWN"));

            if (levelDown.HasValue && levelDown.Value < level)
            {
                level = levelDown.Value;
            }

            var result = new MinIdpUserData
            {
                SysId        = gUser.ToHexString(),
                Realm        = realm,
                SysTokenData = sysToken,
                Status       = level,

                CreateUtc     = reader.AsDateTimeField("CREATE_UTC", DateTime.MinValue).Value,
                StartUtc      = reader.AsDateTimeField("START_UTC", DateTime.MinValue).Value,
                EndUtc        = reader.AsDateTimeField("END_UTC", DateTime.MaxValue).Value,
                LoginId       = id,
                LoginPassword = reader.AsStringField("PWD"),
                LoginStartUtc = reader.AsDateTimeField("LOGIN_START_UTC"),
                LoginEndUtc   = reader.AsDateTimeField("LOGIN_START_UTC"),
                ScreenName    = name,
                Name          = name,
                Description   = reader.AsStringField("DESCRIPTION"),
                Note          = reader.AsStringField("NOTE"),

                Role   = null, // TODO: extract role from PROPS column data
                Rights = reader.AsStringField("RIGHTS"),
                Props  = null
            };


            return(result);
        }