Ejemplo n.º 1
0
        public void CreateDataEntity(Guid userId, DataEntity dataEntity)
        {
            LoadMetadata();

            EntityMetadata em;
            List<EntityMetadata> ems = this.metadata.Entities.Where(e => e.Id == dataEntity.Id).ToList();
            if (ems.Count == 1)
            {
                em = ems[0];
            }
            else
            {
                em = new EntityMetadata();
                this.metadata.Entities.Add(em);
            }

            TranslateToMetadata(userId, em, dataEntity);

            SaveMetadata();

            File.WriteAllBytes(Path.Combine(this.entityDirPath, dataEntity.Id.ToString()), dataEntity.Payload.Content);
        }
Ejemplo n.º 2
0
 private static void TranslateToMetadata(Guid authorId, EntityMetadata rm, DataEntity e)
 {
     rm.AesIV = ConvertBinary(e.AesInfo.IV);
     rm.AesKey = ConvertBinary(e.AesInfo.Key);
     rm.Attributes = new Collection<EntityAttribute>(e.Attributes.Select(a => new EntityAttribute(a.Id, ConvertBinary(a.Keyword))).ToList());
     rm.AuthorId = authorId;
     rm.Id = e.Id;
     rm.Name = ConvertBinary(e.Payload.Name);
     rm.Signature = ConvertBinary(e.Signature.Value);
     rm.Size = e.Payload.Size;
 }
Ejemplo n.º 3
0
 private static DataEntity TranslateFromMetadata(EntityMetadata em)
 {
     DataEntity e = new DataEntity();
     e.AesInfo = new AesEncryptionInfo(ConvertBinary(em.AesKey), ConvertBinary(em.AesIV));
     e.Attributes = new List<Attribute>(em.Attributes.Select(a => new Attribute(a.Id, ConvertBinary(a.Keyword))));
     e.Id = em.Id;
     e.Payload = new FilePayload(ConvertBinary(em.Name), em.Size);
     e.Signature = new Signature(ConvertBinary(em.Signature));
     return e;
 }