Пример #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 tree = context.GetState <TreePtr>();

            var result = new TreeNodeInfo();

            result.Forest      = tree.IdForest;
            result.Tree        = tree.IdTree;
            result.Gdid        = reader.AsGdidField("GDID");
            result.G_Parent    = reader.AsGdidField("G_PARENT");
            result.PathSegment = reader.AsStringField("PATH_SEGMENT");
            result.FullPath    = null;//calculated by logic
            result.StartUtc    = reader.AsDateTimeField("START_UTC").Value;
            result.Properties  = Constraints.MapToConfigRoot(reader.AsStringField("PROPERTIES"));
            result.LevelConfig = Constraints.MapToConfigRoot(reader.AsStringField("CONFIG"));
            result.DataVersion = new VersionInfo
            {
                G_Version = reader.AsGdidField("G_VERSION"),
                State     = verState,
                Actor     = reader.AsEntityIdField("VERSION_ACTOR").Value,
                Origin    = reader.AsAtomField("VERSION_ORIGIN").Value,
                Utc       = reader.AsDateTimeField("VERSION_UTC").Value
            };

            return(result);
        }
Пример #2
0
        protected override Doc DoPopulateDoc(MySqlCrudQueryExecutionContext context, Type tDoc, Schema schema, Schema.FieldDef[] toLoad, MySqlDataReader reader)
        {
            var verState = VersionInfo.MapCanonicalState(reader.AsStringField("VERSION_STATE"));
            var gop      = context.GetState <GdidOrPath>();

            var result = new TreeNodeInfo();

            result.Forest      = gop.Id.System;
            result.Tree        = gop.Id.Type;
            result.Gdid        = reader.AsGdidField("GDID");
            result.G_Parent    = reader.AsGdidField("G_PARENT");
            result.PathSegment = reader.AsStringField("PATH_SEGMENT");
            result.FullPath    = "[n/a for version specific node]";
            result.StartUtc    = reader.AsDateTimeField("START_UTC").Value;
            result.Properties  = Constraints.MapToConfigRoot(reader.AsStringField("PROPERTIES"));
            result.LevelConfig = Constraints.MapToConfigRoot(reader.AsStringField("CONFIG"));
            result.DataVersion = new VersionInfo
            {
                G_Version = reader.AsGdidField("G_VERSION"),
                State     = verState,
                Actor     = reader.AsEntityIdField("VERSION_ACTOR").Value,
                Origin    = reader.AsAtomField("VERSION_ORIGIN").Value,
                Utc       = reader.AsDateTimeField("VERSION_UTC").Value
            };

            return(result);
        }
Пример #3
0
 protected override Doc DoPopulateDoc(MySqlCrudQueryExecutionContext context, Type tDoc, Schema schema, Schema.FieldDef[] toLoad, MySqlDataReader reader)
 {
     return(new VersionInfo()
     {
         G_Version = reader.AsGdidField("GDID"),
         State = VersionInfo.MapCanonicalState(reader.AsStringField("VERSION_STATE")),
         Actor = reader.AsEntityIdField("VERSION_ACTOR").Value,
         Origin = reader.AsAtomField("VERSION_ORIGIN").Value,
         Utc = reader.AsDateTimeField("VERSION_UTC").Value
     });
 }
Пример #4
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);
        }
Пример #5
0
        protected override Doc DoPopulateDoc(MySqlCrudQueryExecutionContext context, Type tDoc, Schema schema, Schema.FieldDef[] toLoad, MySqlDataReader reader)
        {
            var json      = (reader.AsStringField("DATA").JsonToDataObject() as JsonDataMap).NonNull("DATA!null");
            var isDeleted = VersionInfo.MapCanonicalState(json["version_state"].AsString()) == VersionInfo.DataState.Deleted;

            if (isDeleted)
            {
                return(null);
            }

            var gdid = json["gdid"].AsGDID();
            var tree = context.GetState <TreePtr>();
            var eid  = new EntityId(tree.IdForest, tree.IdTree, Constraints.SCH_GNODE, gdid.ToString());

            return(new TreeNodeHeader
            {
                Id = eid,
                G_Version = json["g_ver"].AsGDID(),
                PathSegment = json["psegment"].AsString(),
                StartUtc = json["start_utc"].AsDateTime(CoreConsts.UTC_TIMESTAMP_STYLES)
            });
        }