Beispiel #1
0
        private TodoFrame toFrame(TodoQueue queue, BSONDocument doc)
        {
            try
            {
                var result = new TodoFrame();

                result.ID   = DataDocConverter.GDID_BSONtoCLR(doc[Query._ID] as BSONBinaryElement);
                result.Type = Guid.Parse(((BSONStringElement)doc[FLD_TODO_TYPE]).Value);
                result.CreateTimestampUTC = ((BSONDateTimeElement)doc[FLD_TODO_CREATETIMESTAMP]).Value;

                result.ShardingKey = elmStr(doc[FLD_TODO_SHARDINGKEY]);
                result.ParallelKey = elmStr(doc[FLD_TODO_PARALLELKEY]);

                result.Priority  = ((BSONInt32Element)doc[FLD_TODO_PRIORITY]).Value;
                result.StartDate = ((BSONDateTimeElement)doc[FLD_TODO_STARTDATE]).Value;

                result.CorrelationKey = elmStr(doc[FLD_TODO_CORRELATIONKEY]);

                result.State = ((BSONInt32Element)doc[FLD_TODO_STATE]).Value;
                result.Tries = ((BSONInt32Element)doc[FLD_TODO_TRIES]).Value;

                result.Serializer = ((BSONInt32Element)doc[FLD_TODO_SERIALIZER]).Value;
                result.Content    = elmBin(doc[FLD_TODO_CONTENT]);

                return(result);
            }
            catch (Exception error)
            {
                throw new MongoWorkersException(StringConsts.TODO_QUEUE_BSON_READ_ERROR.Args(queue, error.ToMessageWithType()), error);
            }
        }
Beispiel #2
0
        public static Event FromBson(BSONDocument bson)
        {
            var gdid = bson[FLD_GDID] is BSONBinaryElement binGdid?DataDocConverter.GDID_BSONtoCLR(binGdid) : GDID.ZERO;

            var createUtc     = bson[FLD_CREATEUTC] is BSONInt64Element cutc       ? (ulong)cutc.Value : 0ul;
            var origin        = bson[FLD_ORIGIN] is BSONInt64Element orig          ? new Atom((ulong)orig.Value) : Atom.ZERO;
            var checkpointUtc = bson[FLD_CHECKPOINTUTC] is BSONInt64Element chkutc ? (ulong)chkutc.Value : 0ul;

            var headers = bson[FLD_HEADERS] is BSONStringElement hdrs   ? hdrs.Value : null;

            var contentType = bson[FLD_CONTENTTYPE] is BSONInt64Element ctp ? new Atom((ulong)ctp.Value) : Atom.ZERO;
            var content     = bson[FLD_CONTENT] is BSONBinaryElement bin    ? bin.Value.Data : null;

            return(Event.__AsDeserialized(gdid, createUtc, origin, checkpointUtc, headers, contentType, content));
        }
Beispiel #3
0
        public static Message FromBson(BSONDocument bson)
        {
            var msg = new Message();

            if (bson[FLD_GDID] is BSONBinaryElement binGdid)
            {
                msg.Gdid = DataDocConverter.GDID_BSONtoCLR(binGdid);
            }
            if (bson[FLD_GUID] is BSONBinaryElement binGuid)
            {
                msg.Guid = DataDocConverter.GUID_BSONtoCLR(binGuid);
            }
            if (bson[FLD_RELATED_TO] is BSONBinaryElement binRel)
            {
                msg.RelatedTo = DataDocConverter.GUID_BSONtoCLR(binRel);
            }

            if (bson[FLD_CHANNEL] is BSONInt64Element chn)
            {
                msg.Channel = new Atom((ulong)chn.Value);
            }
            if (bson[FLD_APP] is BSONInt64Element app)
            {
                msg.App = new Atom((ulong)app.Value);
            }
            if (bson[FLD_TYPE] is BSONInt32Element tp)
            {
                msg.Type = (MessageType)tp.Value;
            }
            if (bson[FLD_SOURCE] is BSONInt32Element src)
            {
                msg.Source = src.Value;
            }
            if (bson[FLD_TIMESTAMP] is BSONDateTimeElement utc)
            {
                msg.UTCTimeStamp = utc.Value;
            }

            if (bson[FLD_HOST] is BSONStringElement host)
            {
                msg.Host = host.Value;
            }
            if (bson[FLD_FROM] is BSONStringElement from)
            {
                msg.From = from.Value;
            }
            if (bson[FLD_TOPIC] is BSONStringElement topic)
            {
                msg.Topic = topic.Value;
            }

            if (bson[FLD_TEXT] is BSONStringElement text)
            {
                msg.Text = text.Value;
            }
            if (bson[FLD_PARAMETERS] is BSONStringElement pars)
            {
                msg.Parameters = pars.Value;
            }
            if (bson[FLD_EXCEPTION] is BSONStringElement except)
            {
                msg.ExceptionData = JsonReader.ToDoc <WrappedExceptionData>(except.Value);
            }
            if (bson[FLD_AD] is BSONDocumentElement ad)
            {
                msg.ArchiveDimensions = ArchiveConventions.EncodeArchiveDimensions(ad.Value);
            }

            return(msg);
        }