Ejemplo n.º 1
0
        public void SetMetaData(Guid userId, TakeDocModel.Document document, TakeDocModel.Entity entity, bool startWorkflow, Newtonsoft.Json.Linq.JArray jsonMetaData)
        {
            ICollection <TakeDocModel.MetaData> metadatas = daoMetaData.GetBy(x => x.MetaDataVersionId == document.DocumentCurrentVersionId && x.EtatDeleteData == false && x.EntityId == document.EntityId);

            foreach (Newtonsoft.Json.Linq.JObject obj in jsonMetaData)
            {
                string name = obj.Value <string>("name");

                TakeDocModel.MetaData meta = metadatas.First(x => x.MetaDataName == name);
                meta.MetaDataValue = obj.Value <string>("value");
                meta.MetaDataText  = obj.Value <string>("text");

                if (obj.Value <string>("type") != null && IsBlob(obj.Value <string>("type")))
                {
                    meta.MetaDataBlob  = obj.Value <string>("value");
                    meta.MetaDataText  = null;
                    meta.MetaDataValue = null;
                }
            }

            try
            {
                daoMetaData.SetMetaData(userId, document.EntityId, document.DocumentTypeId, metadatas);
            }
            catch (System.Data.Entity.Validation.DbEntityValidationException ex1)
            {
                base.Logger.Error(ex1);
                throw ex1;
            }
        }
Ejemplo n.º 2
0
        public void CreateMetaData(Guid userId, Guid entityId, Guid versionId, Guid typeDocumentId)
        {
            ICollection <TakeDocModel.View_TypeDocumentDataField> fields = servDataField.GetDataField(typeDocumentId, entityId);

            foreach (TakeDocModel.View_TypeDocumentDataField field in fields)
            {
                bool isSection             = field.InputType.ToUpper().Equals("SECTION");
                TakeDocModel.MetaData meta = new TakeDocModel.MetaData();
                meta.DataFieldId          = field.FieldId;
                meta.DateCreateData       = System.DateTime.UtcNow;
                meta.EntityId             = entityId;
                meta.EtatDeleteData       = false;
                meta.MetaDataDisplayIndex = field.DisplayIndex;
                meta.MetaDataMandatory    = field.Mandatory;
                meta.MetaDataVersionId    = versionId;
                meta.MetaDataId           = System.Guid.NewGuid();
                meta.MetaDataName         = field.Reference;
                meta.UserCreateData       = userId;
                if (isSection)
                {
                    meta.MetaDataText = field.Label;
                }
                daoMetaData.Add(meta);
            }
        }
Ejemplo n.º 3
0
        public void GetMetadDataTest()
        {
            ICollection <TakeDocModel.MetaData> metas = servMeta.GetByVersion(MyDocument.DocumentCurrentVersionId.Value, MyDocument.EntityId);

            Assert.IsTrue(metas.Count() > 0);
            TakeDocModel.MetaData mois = metas.Where(x => x.MetaDataName == "MONTH").First();
            Assert.IsTrue(mois.DataFieldValues.ToList().Count() == 12);
        }
Ejemplo n.º 4
0
        private TakeDocModel.Dto.Document.ReadOnlyMetadata ToReadOnlyMetaData(TakeDocModel.MetaData metadata)
        {
            TakeDocModel.Dto.Document.ReadOnlyMetadata ro = new TakeDocModel.Dto.Document.ReadOnlyMetadata();
            ro.Name         = metadata.MetaDataName;
            ro.EntityId     = metadata.EntityId;
            ro.DisplayIndex = metadata.MetaDataDisplayIndex;
            ro.Label        = metadata.DataField.DataFieldLabel;
            ro.Value        = metadata.MetaDataValue;
            ro.Text         = metadata.MetaDataText;
            ro.Type         = (this.IsBlob(metadata.DataField.DataFieldTypeId))? "IMAGE" : metadata.DataField.DataFieldType.DataFieldInputType;

            if (ro.Type.ToUpper().Equals("IMAGE"))
            {
                ro.Value = (string.IsNullOrEmpty(metadata.MetaDataBlob) ? string.Empty : metadata.MetaDataBlob);
                ro.Text  = string.Empty;
            }
            return(ro);
        }