Exemple #1
0
        public static List<UpdateBuilder> AttachUpdateMetaData(this BsonDocument doc, List<UpdateBuilder> builders, IMongoIdentity user)
        {
            builders = builders ?? new List<UpdateBuilder>();
            builders.AddRange(from name in doc.Names where name != "Id" select Update.Set(name, doc.GetValue(name)));

            builders.Add(Update.Set("LastUpdatedBy", user.GetDisplayName()));
            builders.Add(Update.Set("LastModifiedOn", DateTime.Now));

            return builders;
        }
Exemple #2
0
        public static BsonDocument AttachCreationMetaData(this BsonDocument doc, IMongoIdentity user)
        {
            doc["OwnerId"] = user.GetOwnerId();
            doc["CreatedOn"] = DateTime.Now;
            doc["LastModifiedOn"] = DateTime.Now;
            doc["LastUpdatedBy"] = user.GetOwnerId();
            doc["UTCOffset"] = TimeZone.CurrentTimeZone.GetUtcOffset(DateTime.Now).ToString();

            return doc;
        }
Exemple #3
0
        public static List<UpdateBuilder> AttachUpdateMetaData(this object obj, IMongoIdentity user, double schema)
        {
            var builders = new List<UpdateBuilder>();

            obj.GetType().GetProperties(BindingFlags.Instance | BindingFlags.Public)
                .Where(x => x.GetValue(obj, null) != null)
                .ToList()
                .ForEach(p =>
                {
                    var val = BsonValue.Create(p.GetValue(obj, null));
                    builders.Add(Update.Set(p.Name, val));
                });

            builders.Add(Update.Set("__schemaVersion", schema));
            builders.Add(Update.Set("LastUpdatedBy", user.GetDisplayName()));
            builders.Add(Update.Set("LastModifiedOn", DateTime.Now));

            return builders;
        }
Exemple #4
0
 public NoSqlReportAggregator(INoSqlConnect connector, IMongoIdentity user)
     : base(connector)
 {
     User = user;
     Connector = connector;
 }
 public static bool IsOwner(this BsonDocument doc, IMongoIdentity user)
 {
     return doc.Contains("OwnerId") && (doc["OwnerId"].AsInt64 == user.GetOwnerId());
 }