Пример #1
0
        public DomainModelMetadata()
        {
            MetadataEntityList     = new List <MetadataEntity>();
            metadataEntityForGuid_ = new Dictionary <string, MetadataEntity>();

            //No warnings
            if (metadataEntity_ == null)
            {
                metadataEntity_ = null;
            }
            if (neededMetadataEntity_ == null)
            {
                neededMetadataEntity_ = null;
            }
            if (needingMetadataEntity_ == null)
            {
                needingMetadataEntity_ = null;
            }
            if (metadataField_ == null)
            {
                metadataField_ = null;
            }
            if (metadataNavigationProperty_ == null)
            {
                metadataNavigationProperty_ = null;
            }

            //Pass1 : find entities

            //Pass2 : add entity usages
        }
Пример #2
0
        //Move Document
        public async Task MoveDocumentAsync(MetadataEntity meta, string newStorProvider)
        {
            try {
                var origStor = _config.Stors.FirstOrDefault(s => s.ShortName == meta.StorName).GetStorFromConfig();
                var newStor  = _config.Stors.FirstOrDefault(s => s.ShortName == newStorProvider).GetStorFromConfig();
                if (String.IsNullOrWhiteSpace(origStor.ShortName))
                {
                    throw new Exception("Unable to find old stor within config");
                }
                if (String.IsNullOrWhiteSpace(newStor.ShortName))
                {
                    throw new Exception("Unable to find new stor within config");
                }
                var    fileName = meta.GetServerFileName();
                string hash;
                using (var origStream = await origStor.GetFileAsync(fileName))
                {
                    await newStor.SetFileAsync(fileName, origStream);

                    hash = await newStor.GetFileHashAsync(fileName);

                    if (hash != meta.MD5Hash)
                    {
                        await newStor.RemoveFileAsync(fileName);

                        throw new Exception("File transfer failed MD5 hash is not equal");
                    }
                }
                await origStor.RemoveFileAsync(fileName);
            }
            catch (Exception ex) {
                throw new Exception("Unable to move document", ex);
            }
        }
Пример #3
0
        public IActionResult Unlock(int id)
        {
            string         currentUser = HttpContext.User.Identity.Name;
            MetadataEntity item        = _metadataRepository.GetById(id, false, false);

            if (item == null)
            {
                return(_securityRepository.GateNotFound(currentUser, AccessLogAction.DocumentUnlocked, "Metadata", id.ToString()));
            }

            if (!_securityRepository.UserIsAuthorisedByBuisnessAreas(HttpContext, AuthActions.Update, item.BuisnessArea))
            {
                return(_securityRepository.GateUnathorised(currentUser, AccessLogAction.DocumentUnlocked, "Metadata", id.ToString()));
            }

            bool success = _metadataRepository.TryUnlockDocument(ref item, HttpContext);

            if (!success)
            {
                return(_securityRepository.GateCannotUnlock(currentUser, "Metadata", id.ToString()));
            }

            _metadataRepository.Touch(ref item);

            _logger.Log(LogLevel.Debug, "DocumentMetadata {0} Locked By {1}", item.Id, currentUser);
            _securityRepository.LogUserAction(currentUser, AccessLogAction.DocumentUnlocked, item.Id.ToString(), "Metadata", true);

            _metadataRepository.SaveChanges();

            return(Ok(success));
        }
 private ShareFileClient()
 {
     Apps                 = new AppsEntity(this);
     Favorites            = new FavoritesEntity(this);
     WebhookClients       = new WebhookClientsEntity(this);
     WebhookSubscriptions = new WebhookSubscriptionsEntity(this);
     Workflows            = new WorkflowsEntity(this);
     Policies             = new PoliciesEntity(this);
     ConnectorGroups      = new ConnectorGroupsEntity(this);
     EncryptedEmails      = new EncryptedEmailsEntity(this);
     FileLock             = new FileLockEntity(this);
     RemoteUploads        = new RemoteUploadsEntity(this);
     Reports              = new ReportsEntity(this);
     FolderTemplates      = new FolderTemplatesEntity(this);
     AccessControls       = new AccessControlsEntity(this);
     Accounts             = new AccountsEntity(this);
     AsyncOperations      = new AsyncOperationsEntity(this);
     Capabilities         = new CapabilitiesEntity(this);
     Devices              = new DevicesEntity(this);
     FavoriteFolders      = new FavoriteFoldersEntity(this);
     Groups               = new GroupsEntity(this);
     Items                = new ItemsEntity(this);
     Metadata             = new MetadataEntity(this);
     Sessions             = new SessionsEntity(this);
     Shares               = new SharesEntity(this);
     StorageCenters       = new StorageCentersEntity(this);
     Users                = new UsersEntity(this);
     Zones                = new ZonesEntity(this);
     SamlMetadata         = new SamlMetadataEntity(this);
 }
Пример #5
0
        public IActionResult Put(int id, [FromBody] MetadataEntity value)
        {
            string         currentUser = HttpContext.User.Identity.Name;
            MetadataEntity origItem    = _metadataRepository.GetById(id, false, false);

            if (origItem == null)
            {
                return(_securityRepository.GateNotFound(currentUser, AccessLogAction.DocumentMetadataUpdate, "Metadata", id.ToString()));
            }

            //Check if user has access to both BuisnessAreas Will work even if both are the same
            if (!_securityRepository.UserIsAuthorisedByBuisnessAreas(HttpContext, AuthActions.Update, origItem.BuisnessArea, value.BuisnessArea))
            {
                return(_securityRepository.GateUnathorised(currentUser, AccessLogAction.DocumentMetadataUpdate, "Metadata", id.ToString()));
            }

            _metadataRepository.UserEdit(ref origItem, value, HttpContext);

            _logger.Log(LogLevel.Debug, "DocumentMetadata {0} Edited By {1}", origItem.Id, currentUser);
            _securityRepository.LogUserAction(currentUser, AccessLogAction.DocumentMetadataUpdate, origItem.Id.ToString(), "Metadata", true);

            _metadataRepository.SaveChanges();

            return(Ok(origItem));
        }
Пример #6
0
		public FromJoinClause(int aliasId, MetadataEntity entity, IList<MetadataEntityProperty> refs, IList<MetadataEntityProperty> dependentRefs)
		{
			_alias = "t" + aliasId.ToString();
			_entity = entity;
			_refs = refs;
			_dependentRefs = dependentRefs;
		}
Пример #7
0
        public IActionResult Archive(int id)
        {
            MetadataEntity origItem = _metadataRepository.GetById(id, false, false);

            string currentUser = HttpContext.User.Identity.Name;

            if (origItem == null)
            {
                return(_securityRepository.GateNotFound(currentUser, AccessLogAction.DocumentArchive, "Metadata", id.ToString()));
            }

            if (!_securityRepository.UserIsAuthorisedByBuisnessAreas(HttpContext, AuthActions.Archive, origItem.BuisnessArea))
            {
                return(_securityRepository.GateUnathorised(currentUser, AccessLogAction.DocumentArchive, "Metadata", id.ToString()));
            }

            origItem.Archive.Archive(currentUser);

            _logger.Log(LogLevel.Debug, "Document {0} Archived By {1}", origItem.Id, currentUser);
            _securityRepository.LogUserAction(currentUser, AccessLogAction.DocumentArchive, id, "Document", true);

            _metadataRepository.Edit(origItem);
            _metadataRepository.SaveChanges();

            return(Ok());
        }
Пример #8
0
		public FromJoinClause(string alias, MetadataEntity entity, IList<MetadataEntityProperty> refs, IList<MetadataEntityProperty> dependentRefs)
		{
			_alias = alias;
			_entity = entity;
			_refs = refs;
			_dependentRefs = dependentRefs;
		}
Пример #9
0
 //Rename
 public async Task RenameFileAsync(MetadataEntity oldFile, MetadataEntity newFile)
 {
     IStor stor        = _config.Stors.First(s => s.ShortName == oldFile.StorName).GetStorFromConfig();
     var   oldFileName = oldFile.GetServerFileName();
     var   newFileName = newFile.GetServerFileName();
     await stor.RenameFileAsync(oldFileName, newFileName);
 }
Пример #10
0
        protected virtual MetadataEntity EntityMetadata(
            object key,
            object entity,
            EntityState state,
            MetadataEntity existing)
        {
            if (state == EntityState.Added)
            {
                var result = new MetadataEntity
                {
                    Identity = key,
                    Entity   = entity,
                    Metadata = new Dictionary <string, string>()
                };

                return(result);
            }

            if (state == EntityState.Updated && existing != null)
            {
                existing.Entity   = entity;
                existing.Identity = key;
                // existing.Metadata setLastModified
            }

            throw new ArgumentException("Only god and me know how to use this function. Wrong parameter constellation.");
        }
Пример #11
0
        private async Task <UDSEntity> UpdateStorageAsync(UDSStorageFacade storage)
        {
            UDSEntity      entity    = null;
            MetadataEntity metadatas = new MetadataEntity(_logger);

            try
            {
                //verifica esistenza tabella
                using (SmoContext smo = new SmoContext(ConnectionString, DBSchema))
                {
                    if (!smo.TableExist(storage.Builder.UDSTableName))
                    {
                        _logger.WriteError(new LogMessage(string.Concat(storage.Builder.UDSTableName, " not exist")), LogCategories);
                        throw new Exception(string.Concat(storage.Builder.UDSTableName, " - UDS structures not found"));
                    }
                }

                await storage.UpdateStorageAsync(ConnectionString);

                _logger.WriteInfo(new LogMessage("update storage completed"), LogCategories);
                entity = metadatas.LoadMetadata(storage);
            }
            catch (Exception ex)
            {
                _logger.WriteError(ex, LogCategories);
                throw ex;
            }
            return(entity);
        }
Пример #12
0
        public bool TryLockDocument(ref MetadataEntity entity, HttpContext context, TimeSpan?duration = null)
        {
            var realDuration = duration ?? TimeSpan.FromHours(3);

            var success = entity.Locked.LockDocument(context.User.Identity.Name, realDuration);

            return(success);
        }
 public static V GetPropertyValue <V>(this MetadataEntity entity, string propertyName)
 {
     return(entity.Metadatas.OfType <IProperty>()
            .Where(t => t.Description.PropertyName == propertyName)
            .Where(s => s.Value is V)
            .Select(s => (V)s.Value)
            .FirstOrDefault());
 }
Пример #14
0
        //Gets
        public async Task <Stream> GetDocumentAsync(MetadataEntity meta)
        {
            var stor     = _config.Stors.First(s => s.ShortName == meta.StorName).GetStorFromConfig();
            var fileName = meta.GetServerFileName();
            var stream   = await stor.GetFileAsync(fileName);

            return(stream);
        }
        public static void SetPropertyValue <V>(this MetadataEntity entity, string propertyName, V value)
        {
            var propertyValue = entity.GetPropertyValue <V>(propertyName);

            if (propertyValue != null)
            {
                propertyValue = value;
            }
        }
Пример #16
0
        public ActionResult Edit(Guid id, MetadataEntityModel model, string button)
        {
            using (DBEntities context = Settings.CreateDataContext())
            {
                Validate(context, model);

                if (!ModelState.IsValid)
                {
                    return(View(model));
                }

                MetadataEntity target = null;
                if (model.Id != Guid.Empty)
                {
                    target = MetadataEntityHelper.Get(model.Id, context);
                    if (target == null)
                    {
                        ModelState.AddModelError("", Resources.Resource.RowNotFound);
                        return(View(model));
                    }
                }
                else
                {
                    target    = new MetadataEntity();
                    target.Id = Guid.NewGuid();
                    context.AddToMetadataEntity(target);
                }

                Mapper.CreateMap <MetadataEntityModel, MetadataEntity>().ForMember("Id", f => f.Ignore());
                Mapper.Map(model, target);

                try
                {
                    context.SaveChanges();
                }
                catch (Exception ex)
                {
                    var sb = new StringBuilder(Resources.Resource.SaveError + ": " + ex.Message);
                    if (ex.InnerException != null)
                    {
                        sb.AppendLine(ex.InnerException.Message);
                    }
                    ModelState.AddModelError("", sb.ToString());
                    return(View(model));
                }

                if (button == "SaveAndExit")
                {
                    return(RedirectToAction("Index"));
                }
                else
                {
                    return(RedirectToAction("Edit", new { target.Id }));
                }
            }
        }
Пример #17
0
        //Uploads all return MD5
        public async Task <string> SetDocumentAsync(MetadataEntity meta, Stream doc)
        {
            var stor     = _config.Stors.First(s => s.ShortName == meta.StorName).GetStorFromConfig();
            var fileName = meta.GetServerFileName();
            await stor.SetFileAsync(fileName, doc);

            var hash = await stor.GetFileHashAsync(fileName);

            return(hash);
        }
Пример #18
0
        public virtual void CascadeRemove(MetadataEntity item)
        {
            Requires <InvalidKeyException> .GreaterThan(item.Id, 0);

            Log.Verbose("CascadeRemove({0})", item.ToString());
            //1==>X
            //1<==>X
            CascadeRemoveRange(item.MetadataFieldList);              //1<==>N
            CascadeRemoveRange(item.MetadataNavigationPropertyList); //1<==>N
            base.CascadeRemove(item);
        }
Пример #19
0
        public static string TryGet <TTranslation>(this MetadataEntity <TTranslation> entity, string language)
            where TTranslation : class, ITranslationMetadataEntity
        {
            var translation = entity.Translations.FirstOrDefault(t => t.Language == language) ?? entity.Translations.FirstOrDefault(t => t.Language == "en");

            if (translation != null)
            {
                return(translation.Title);
            }
            return(String.Empty);
        }
Пример #20
0
        public async Task <ActionResult> GetCodelessEntity(JToken requestObject)
        {
            var metadataEntityName = requestObject["Entity"].ToString();
            var metadata           = new MetadataEntity(); //Find and get your type from json

            object response         = null;
            var    metadataQuerySet = (IQueryable <DynamicEntity>)_dynamicDbContext.GetType().GetMethod("Set").MakeGenericMethod(metadata.EntityType).Invoke(_dynamicDbContext, null);

            var filters = requestObject["Filters"].ToList();

            string selects = "*";

            if (requestObject["SelectList"] != null)
            {
                selects = string.Join(',', requestObject["SelectList"].ToList());
            }

            var i = 0;

            foreach (var filter in filters)
            {
                var filterValue = requestObject["FilterValues"].ElementAt(i).ToString();
                i++;
                metadataQuerySet = metadataQuerySet.Where(filter.ToString(), filterValue);
            }

            if (requestObject["SelectType"].ToString() == "List")
            {
                if (selects == "*")
                {
                    response = await metadataQuerySet.ToDynamicListAsync();
                }
                else
                {
                    response = await metadataQuerySet.Select($"new ({selects})").ToDynamicListAsync();
                }
            }

            if (requestObject["SelectType"].ToString() == "Single")
            {
                if (selects == "*")
                {
                    response = await metadataQuerySet.FirstOrDefaultAsync();
                }
                else
                {
                    response = await metadataQuerySet.Select($"new ({selects})").FirstOrDefault();
                }
            }


            return(Ok(response));
        }
Пример #21
0
        public ActionResult EditAttribute(Guid?id, Guid?EntityId, byte?TypeId)
        {
            MetadataEntityAttributeModel model = null;

            if (id.HasValue)
            {
                MetadataEntityAttribute att = MetadataEntityHelper.GetAttribute(id.Value);
                if (att == null)
                {
                    return(MessageHelper.FormedContentObjectNotFound());
                }

                MetadataEntityAttributeModel.CreateMap();
                model = Mapper.Map <MetadataEntityAttribute, MetadataEntityAttributeModel>(att);
                return(View(model));
            }
            else if (EntityId.HasValue)
            {
                MetadataEntity item = MetadataEntityHelper.Get(EntityId.Value);
                if (item != null)
                {
                    if (!TypeId.HasValue)
                    {
                        TypeId = 0;
                    }

                    MetadataEntityAttributeType type =
                        MetadataEntityHelper.CurrentTypeList.FirstOrDefault(c => c.Id == TypeId.Value) ??
                        new MetadataEntityAttributeType
                    {
                        Id   = 255,
                        Name = "Не определена"
                    };
                    return(View(new MetadataEntityAttributeModel
                    {
                        EntityId = item.Id,
                        EntityCaption = item.Caption,
                        TypeId = type.Id,
                        //AttributeTypeName = type.Name
                    }));
                }
                else
                {
                    return(MessageHelper.FormedContentObjectNotFound());
                }
            }
            else
            {
                return(MessageHelper.FormedContentObjectNotFound());
            }
        }
Пример #22
0
			public DataEntry(MetadataEntity conceptEntity)
			{
				if(conceptEntity == null)
					throw new ArgumentNullException("conceptEntity");

				if(conceptEntity.Kind != MetadataElementKind.Concept)
					throw new ArgumentException("The kind of entity is not Concept.");

				_conceptEntity = conceptEntity;
				_mapping = MetadataManager.Default.GetMapping(conceptEntity.QualifiedName) as MetadataMappingEntity;

				if(_mapping == null)
					throw new DataException("Missing mapping for concept entity.");
			}
Пример #23
0
        public IActionResult Post([FromBody] MetadataEntity value)
        {
            string currentUser = HttpContext.User.Identity.Name;

            if (!_securityRepository.UserIsAuthorisedByBuisnessAreas(HttpContext, AuthActions.Create, value.BuisnessArea))
            {
                return(_securityRepository.GateUnathorised(currentUser, AccessLogAction.DocumentMetadataCreate, "Metadata", "N/A"));
            }

            _metadataRepository.AddNew(ref value, currentUser);

            _logger.Log(LogLevel.Debug, "DocumentMetadata {0} Created By {1}", value.Id, currentUser);
            _securityRepository.LogUserAction(currentUser, AccessLogAction.DocumentMetadataCreate, value.Id, "Metadata", true);

            _metadataRepository.SaveChanges();

            return(Ok(value));
        }
 private ShareFileClient()
 {
     ConnectorGroups = new ConnectorGroupsEntity(this);
     FolderTemplates = new FolderTemplatesEntity(this);
     AccessControls  = new AccessControlsEntity(this);
     Accounts        = new AccountsEntity(this);
     AsyncOperations = new AsyncOperationsEntity(this);
     Capabilities    = new CapabilitiesEntity(this);
     FavoriteFolders = new FavoriteFoldersEntity(this);
     Groups          = new GroupsEntity(this);
     Items           = new ItemsEntity(this);
     Metadata        = new MetadataEntity(this);
     Sessions        = new SessionsEntity(this);
     Shares          = new SharesEntity(this);
     StorageCenters  = new StorageCentersEntity(this);
     Users           = new UsersEntity(this);
     Zones           = new ZonesEntity(this);
 }
        public bool CheckBeforeRender(MetadataEntity entity)
        {
            MetadataEntity origin = entity.Origin;

            if (origin.Name == "titleFormat")
            {
                return(false);
            }
            if (origin.Name == "script")
            {
                bool isRendered = RenderedScripts.Contains(origin);
                if (!isRendered)
                {
                    RenderedScripts.Add(origin);
                }
                return(!isRendered);
            }
            return(true);
        }
Пример #26
0
        MetadataEntity GetOrAddElement(string name, params string[] attributePairs)
        {
            var attributes = new List <KeyValuePair <string, string> >();

            for (int i = 0; i < attributePairs.Length; i += 2)
            {
                attributes.Add(new KeyValuePair <string, string>(attributePairs[i], attributePairs.ElementAtOrDefault(i + 1)));
            }

            MetadataEntity element = _entitiesToApply.FirstOrDefault(x =>
                                                                     x.Name == name &&
                                                                     attributes.All(a => x.Attributes.ContainsKey(a.Key) && (string.IsNullOrEmpty(a.Value) || x.Attributes[a.Key] == a.Value)));

            if (element == null)
            {
                element = new MetadataEntity(name, attributes);
                _entitiesToApply.Add(element);
            }
            return(element);
        }
Пример #27
0
        public ActionResult Edit(Guid?id)
        {
            if (id.HasValue)
            {
                MetadataEntity obj = MetadataEntityHelper.Get(id.Value);
                if (obj == null)
                {
                    return(MessageHelper.FormedContentObjectNotFound());
                }

                Mapper.CreateMap <MetadataEntity, MetadataEntityModel>();
                MetadataEntityModel model = Mapper.Map <MetadataEntity, MetadataEntityModel>(obj);
                return(View(model));
            }
            else
            {
                return(View(new MetadataEntityModel
                {
                    SchemaName = "dbo"
                }));
            }
        }
Пример #28
0
        public IActionResult Get(int id, [FromQuery] bool incVersions = false, [FromQuery] bool incArchive = false)
        {
            string         currentUser = HttpContext.User.Identity.Name;
            MetadataEntity item        = _metadataRepository.GetById(id, incVersions, incArchive);

            if (item == null)
            {
                return(_securityRepository.GateNotFound(currentUser, AccessLogAction.DocumentMetadataRead, "Metadata", id.ToString()));
            }

            if (!_securityRepository.UserIsAuthorisedByBuisnessAreas(HttpContext, AuthActions.Return, item.BuisnessArea))
            {
                return(_securityRepository.GateUnathorised(currentUser, AccessLogAction.DocumentMetadataRead, "Metadata", id.ToString()));
            }

            _logger.Log(LogLevel.Information, "DocumentMetadata {0} Returned For {1}", item.Id, currentUser);
            _securityRepository.LogUserAction(currentUser, AccessLogAction.DocumentMetadataRead, id, "Metadata", true);

            _metadataRepository.Touch(ref item);
            _metadataRepository.SaveChanges();

            return(Ok(item));
        }
Пример #29
0
        public async Task <IActionResult> Delete(int id)
        {
            string currentUser = HttpContext.User.Identity.Name;

            MetadataEntity origItem = _metadataRepository.GetById(id, true, true);

            if (origItem == null)
            {
                return(_securityRepository.GateNotFound(currentUser, AccessLogAction.DocumentDelete, "Metadata", id.ToString()));
            }

            if (!_securityRepository.UserIsAuthorisedByBuisnessAreas(HttpContext, AuthActions.Delete, origItem.BuisnessArea))
            {
                return(_securityRepository.GateUnathorised(currentUser, AccessLogAction.DocumentDelete, "Metadata", id.ToString()));
            }

            foreach (var oldVer in origItem.Versions)
            {
                await _documentRepository.DeleteDocumentVersionAsync(oldVer);

                _logger.Log(LogLevel.Debug, "Document File:'{0}' Deleted By {1}", oldVer.GetServerFileName(), currentUser);
                _securityRepository.LogUserAction(currentUser, AccessLogAction.DocumentVersionDelete, oldVer.Id, "DocumentVersion", true);
            }

            await _documentRepository.DeleteDocumentAsync(origItem);

            _logger.Log(LogLevel.Debug, "Document File:'{0}' Deleted By {1}", origItem.GetServerFileName(), currentUser);

            _metadataRepository.Delete(origItem);

            _logger.Log(LogLevel.Debug, "Document {0} Deleted By {1}", origItem.Id, currentUser);
            _securityRepository.LogUserAction(currentUser, AccessLogAction.DocumentDelete, id, "Document", true);

            _metadataRepository.SaveChanges();

            return(Ok());
        }
Пример #30
0
		private static void ResetProperties(HashSet<string> properties, MetadataEntity entity, bool containsAll)
		{
			foreach(var property in entity.Properties)
			{
				if(containsAll)
					properties.Add(property.Name.Trim());
				else
				{
					if(property is MetadataEntitySimplexProperty)
						properties.Add(property.Name.Trim());
				}
			}
		}
Пример #31
0
        public ActionResult Edit(Guid id, MetadataEntityModel model, string button)
        {
            using (DBEntities context = Settings.CreateDataContext())
            {
                Validate(context, model);

                if (!ModelState.IsValid)
                {
                    return View(model);
                }

                MetadataEntity target = null;
                if (model.Id != Guid.Empty)
                {
                    target = MetadataEntityHelper.Get(model.Id, context);
                    if (target == null)
                    {
                        ModelState.AddModelError("", Resources.Resource.RowNotFound);
                        return View(model);
                    }
                }
                else
                {
                    target = new MetadataEntity();
                    target.Id = Guid.NewGuid();
                    context.AddToMetadataEntity(target);
                }

                Mapper.CreateMap<MetadataEntityModel, MetadataEntity>().ForMember("Id", f => f.Ignore());
                Mapper.Map(model, target);

                try
                {
                    context.SaveChanges();
                }
                catch (Exception ex)
                {
                    var sb = new StringBuilder(Resources.Resource.SaveError + ": " + ex.Message);
                    if (ex.InnerException != null)
                        sb.AppendLine(ex.InnerException.Message);
                    ModelState.AddModelError("", sb.ToString());
                    return View(model);
                }

                if (button == "SaveAndExit")
                    return RedirectToAction("Index");
                else
                    return RedirectToAction("Edit", new {target.Id});
            }
        }
Пример #32
0
 //Deletes
 public async Task DeleteDocumentAsync(MetadataEntity meta)
 {
     IStor stor     = _config.Stors.First(s => s.ShortName == meta.StorName).GetStorFromConfig();
     var   fileName = meta.GetServerFileName();
     await stor.RemoveFileAsync(fileName);
 }
Пример #33
0
		public static ICollection<string> ResolveScope(MetadataEntity entity, string scope)
		{
			if(entity == null)
				return null;

			var members = scope.Split(',');
			var properties = new HashSet<string>(StringComparer.OrdinalIgnoreCase);

			var entities = GetInherits(entity);

			foreach(var item in entities)
			{
				//初始化所有单值属性到哈希集中
				ResetProperties(properties, item, false);
			}

			if(string.IsNullOrWhiteSpace(scope))
				return properties;

			for(int i = 0; i < members.Length; i++)
			{
				var member = members[i].Trim();

				if(member.Length == 0)
					continue;

				if(member == "*") //包含所有成员
				{
					foreach(var item in entities)
					{
						//初始化所有单值属性到哈希集中
						ResetProperties(properties, item, true);
					}
				}
				else if(member == "!" || member == "-") //排除所有成员
				{
					properties.Clear();
				}
				else if(member.Length > 1)
				{
					if(member[0] == '-') //排除指定成员
						properties.Remove(member.Substring(1));
					else //包含指定成员
					{
						if(!member.Contains(".") && entity.Properties.Contains(member))
							properties.Add(member);
					}
				}
			}

			return properties;
		}
Пример #34
0
			internal JoinClause(string principalAlias, MetadataEntity principalEntity,
			                    IEnumerable<MetadataEntityProperty> principalProperties,
			                    string dependentAlias, MetadataEntity dependentEntity,
			                    IEnumerable<MetadataEntityProperty> dependentProperties)
			{
				_principalAlias = principalAlias;
				_dependentAlias = dependentAlias;
				_principalEntity = principalEntity;
				_dependentEntity = dependentEntity;
				_principalProperties = principalProperties;
				_dependentProperties = dependentProperties;
			}
Пример #35
0
			public FromClause(MetadataEntity entity, int aliasId)
			{
				_entity = entity;
				_alias = "t" + aliasId.ToString();
			}
Пример #36
0
        public DomainModelMetadata()
        {
            MetadataEntityList     = new List <MetadataEntity>();
            metadataEntityForGuid_ = new Dictionary <string, MetadataEntity>();

            //No warnings
            if (metadataEntity_ == null)
            {
                metadataEntity_ = null;
            }
            if (neededMetadataEntity_ == null)
            {
                neededMetadataEntity_ = null;
            }
            if (needingMetadataEntity_ == null)
            {
                needingMetadataEntity_ = null;
            }
            if (metadataField_ == null)
            {
                metadataField_ = null;
            }
            if (metadataNavigationProperty_ == null)
            {
                metadataNavigationProperty_ = null;
            }

            //Pass1 : find entities
            metadataEntity_ = new MetadataEntity
            {
                Guid      = "25dd71dc-129b-45af-8075-555bea385132",
                Name      = "NewsItem",
                Dimension = false,
            };
            MetadataEntityList.Add(metadataEntity_);
            metadataEntityForGuid_.Add(metadataEntity_.Guid, metadataEntity_);

            metadataField_ = new MetadataField
            {
                Guid = "80f45e35-658b-4fa9-a841-30e5d22c9ba8",
                Name = "Comment",
                Type = "String",
            };
            metadataEntity_.MetadataFieldList.Add(metadataField_);
            metadataField_ = new MetadataField
            {
                Guid = "0963fdad-a793-4bd3-bbbd-45199a32c06b",
                Name = "Description",
                Type = "String",
            };
            metadataEntity_.MetadataFieldList.Add(metadataField_);
            metadataField_ = new MetadataField
            {
                Guid = "fbbf1185-4ab6-49b5-82c4-d525cd664e64",
                Name = "FileData",
                Type = "Binary",
            };
            metadataEntity_.MetadataFieldList.Add(metadataField_);
            metadataField_ = new MetadataField
            {
                Guid = "d65e132b-cac4-494c-8b6d-7e746bb01c0f",
                Name = "FileName",
                Type = "String",
            };
            metadataEntity_.MetadataFieldList.Add(metadataField_);
            metadataField_ = new MetadataField
            {
                Guid = "e1c04b79-c364-44b1-b92f-202306df7a69",
                Name = "FileType",
                Type = "String",
            };
            metadataEntity_.MetadataFieldList.Add(metadataField_);
            metadataField_ = new MetadataField
            {
                Guid = "544e6386-a648-47f7-bb67-8a14e8ab73ac",
                Name = "LinkUrl",
                Type = "String",
            };
            metadataEntity_.MetadataFieldList.Add(metadataField_);
            metadataField_ = new MetadataField
            {
                Guid = "92b2bf2d-9f43-4d62-9700-69aeabd81665",
                Name = "Title",
                Type = "String",
            };
            metadataEntity_.MetadataFieldList.Add(metadataField_);
            metadataField_ = new MetadataField
            {
                Guid = "5fcf3c0b-efc3-4f5d-8db4-c2dbafd6edbb",
                Name = "ValidityDateEnd",
                Type = "DateTime",
            };
            metadataEntity_.MetadataFieldList.Add(metadataField_);
            metadataField_ = new MetadataField
            {
                Guid = "073e0793-86ab-48bc-b459-8f4442d4a109",
                Name = "ValidityDateStart",
                Type = "DateTime",
            };
            metadataEntity_.MetadataFieldList.Add(metadataField_);

            //Pass2 : add entity usages
            metadataEntity_ = metadataEntityForGuid_["25dd71dc-129b-45af-8075-555bea385132"];      //NewsItem
            //Needed entities
            //Needing entities
        }
Пример #37
0
		internal static IList<DataEntry> GetOnetoOne(MetadataEntity entity, IEnumerable<string> members)
		{
			if(entity == null)
				throw new ArgumentNullException("entity");

			var entries = new List<DataEntry>();

			foreach(var member in members)
			{
				string propertyName;

				if(member.IndexOf('.') > 0)
					propertyName = member.Substring(0, member.IndexOf('.'));
				else
					propertyName = member;

				var property = entity.Properties[propertyName] as MetadataEntityComplexProperty;

				if(property != null)
				{
					var association = property.Relationship.Association;

					if(association != null && association.IsOneToOne(property.Relationship.From, property.Relationship.To))
					{
						var dependentEntity = association.Members[property.Relationship.To].Entity;

						entries.Add(new DataEntry(dependentEntity)
						{
							//ConceptProperties = ResolveScope(dependentEntity, scope)
						});
					}
				}
			}

			return entries;
		}
Пример #38
0
        public override async Task ExecuteAsync(ICommandCreateUDS command)
        {
            _logger.WriteInfo(new LogMessage(string.Concat(command.CommandName, " is arrived")), LogCategories);
            try
            {
                UDSStorageFacade udsStorageFacade = new UDSStorageFacade(_logger, command.ContentType.ContentTypeValue.XMLContent, CurrentUDSSchemaRepository.SchemaXML, _administrationClient, DBSchema);
                _logger.WriteInfo(new LogMessage("Starting create storage"), LogCategories);
                await udsStorageFacade.CreateStorageAsync(ConnectionString, async (smo) =>
                {
                    _logger.WriteInfo(new LogMessage("Create storage completed"), LogCategories);
                    bool res = true;
                    try
                    {
                        res &= smo.TableExist(udsStorageFacade.Builder.UDSTableName);
                        if (res)
                        {
                            _logger.WriteInfo(new LogMessage(string.Concat(udsStorageFacade.Builder.UDSTableName, " has been successfully created")), LogCategories);
                        }

                        res &= smo.TableExist(udsStorageFacade.Builder.UDSDocumentsTableName);
                        if (res)
                        {
                            _logger.WriteInfo(new LogMessage(string.Concat(udsStorageFacade.Builder.UDSDocumentsTableName, " has been successfully created")), LogCategories);
                        }

                        if (!res)
                        {
                            throw new InvalidOperationException("Error in creation table. Detect miss tables.");
                        }
                        MetadataEntity metadatas = new MetadataEntity(_logger);
                        UDSEntity udsEntity      = metadatas.LoadMetadata(udsStorageFacade);
                        bool codeGenerated       = await GenerateUDSCodeAsync(udsEntity);
                        if (codeGenerated)
                        {
                            _logger.WriteInfo(new LogMessage("UDS libraries has been successfully installed."), LogCategories);
                        }
                        else
                        {
                            _logger.WriteError(new LogMessage("Occour error in UDS libraries building. Process manual UDS Migrations"), LogCategories);
                        }
                        if (udsStorageFacade.UDS.Model.Documents != null)
                        {
                            if (udsStorageFacade.UDS.Model.Documents.Document != null && udsStorageFacade.UDS.Model.Documents.Document.CreateBiblosArchive)
                            {
                                await CreateBiblosDSArchiveAsync(udsEntity, udsStorageFacade, true);
                                udsStorageFacade.UDS.Model.Documents.Document.CreateBiblosArchive = false;
                                _logger.WriteInfo(new LogMessage("Archive created successfully"), LogCategories);
                            }

                            if ((udsStorageFacade.UDS.Model.Documents.DocumentAttachment != null && udsStorageFacade.UDS.Model.Documents.DocumentAttachment.CreateBiblosArchive) ||
                                (udsStorageFacade.UDS.Model.Documents.DocumentAnnexed != null && udsStorageFacade.UDS.Model.Documents.DocumentAnnexed.CreateBiblosArchive) ||
                                (udsStorageFacade.UDS.Model.Documents.Document != null && udsStorageFacade.UDS.Model.Documents.Document.DematerialisationEnabled) ||
                                (udsStorageFacade.UDS.Model.Documents.DocumentAttachment != null && udsStorageFacade.UDS.Model.Documents.DocumentAttachment.DematerialisationEnabled) ||
                                (udsStorageFacade.UDS.Model.Documents.DocumentAnnexed != null && udsStorageFacade.UDS.Model.Documents.DocumentAnnexed.DematerialisationEnabled))
                            {
                                await CreateBiblosDSArchiveAsync(udsEntity, udsStorageFacade);
                                if (udsStorageFacade.UDS.Model.Documents.DocumentAttachment != null)
                                {
                                    udsStorageFacade.UDS.Model.Documents.DocumentAttachment.CreateBiblosArchive = false;
                                }
                                if (udsStorageFacade.UDS.Model.Documents.DocumentAnnexed != null)
                                {
                                    udsStorageFacade.UDS.Model.Documents.DocumentAnnexed.CreateBiblosArchive = false;
                                }
                                _logger.WriteInfo(new LogMessage("Archive Miscellaneous created successfully"), LogCategories);
                            }
                            command.ContentType.ContentTypeValue.XMLContent = udsStorageFacade.UDS.SerializeToXml();
                        }

                        if (udsStorageFacade.UDS.Model.Container.CreateContainer)
                        {
                            _logger.WriteInfo(new LogMessage(string.Concat("Creating Container ", udsStorageFacade.UDS.Model.Title, " with admin SecurityUser ", command.Identity.User)), LogCategories);
                            DocSuiteWeb.Entity.Commons.Container container = CreateContainerFromArchive(udsStorageFacade.UDS.Model.Title, command.Identity.User);
                            container = await CreateConteainerAsync(container);
                            udsStorageFacade.UDS.Model.Container.IdContainer     = container.EntityShortId.ToString();
                            udsStorageFacade.UDS.Model.Container.CreateContainer = false;
                            command.ContentType.ContentTypeValue.XMLContent      = udsStorageFacade.UDS.SerializeToXml();
                            _logger.WriteInfo(new LogMessage("DocSuite Container created successfully"), LogCategories);
                        }

                        _logger.WriteInfo(new LogMessage("UDS storage configured successfully"), LogCategories);
                        await SaveUDSRepositoryAsync(command.ContentType.ContentTypeValue, udsStorageFacade.UDS.Model.Container.IdContainer);
                        _logger.WriteInfo(new LogMessage("UDS entity saved successfully"), LogCategories);
                        return(true);
                    }
                    catch (AggregateException aex)
                    {
                        foreach (Exception ex in aex.Flatten().InnerExceptions)
                        {
                            _logger.WriteError(ex, LogCategories);
                        }
                    }
                    catch (Exception ex)
                    {
                        _logger.WriteError(ex, LogCategories);
                    }
                    return(false);
                });
            }
            catch (Exception ex)
            {
                _logger.WriteError(ex, LogCategories);
                throw ex;
            }
        }
Пример #39
0
		public static Stack<MetadataEntity> GetInherits(MetadataEntity entity)
		{
			var stack = new Stack<MetadataEntity>();

			while(entity != null)
			{
				if(stack.Contains(entity))
					break;

				stack.Push(entity);
				entity = entity.BaseEntity;
			}

			return stack;
		}
Пример #40
0
        public DomainModelMetadata()
        {
            MetadataEntityList     = new List <MetadataEntity>();
            metadataEntityForGuid_ = new Dictionary <string, MetadataEntity>();

            //No warnings
            if (metadataEntity_ == null)
            {
                metadataEntity_ = null;
            }
            if (neededMetadataEntity_ == null)
            {
                neededMetadataEntity_ = null;
            }
            if (needingMetadataEntity_ == null)
            {
                needingMetadataEntity_ = null;
            }
            if (metadataField_ == null)
            {
                metadataField_ = null;
            }
            if (metadataNavigationProperty_ == null)
            {
                metadataNavigationProperty_ = null;
            }

            //Pass1 : find entities
            metadataEntity_ = new MetadataEntity
            {
                Guid      = "476b1ee2-94aa-454c-990a-f0a47a664e65",
                Name      = "CalendarEvent",
                Dimension = false,
            };
            MetadataEntityList.Add(metadataEntity_);
            metadataEntityForGuid_.Add(metadataEntity_.Guid, metadataEntity_);

            metadataField_ = new MetadataField
            {
                Guid = "7dd91293-3b6b-40b8-86ed-c43beb3bf2d0",
                Name = "AppliesTo",
                Type = "String",
            };
            metadataEntity_.MetadataFieldList.Add(metadataField_);
            metadataField_ = new MetadataField
            {
                Guid = "e3370f1e-eb31-434a-b0f0-4cde41895de0",
                Name = "Comment",
                Type = "String",
            };
            metadataEntity_.MetadataFieldList.Add(metadataField_);
            metadataField_ = new MetadataField
            {
                Guid = "f7a4aefb-fc2a-454f-b9b6-9e29e3b64943",
                Name = "Description",
                Type = "String",
            };
            metadataEntity_.MetadataFieldList.Add(metadataField_);
            metadataField_ = new MetadataField
            {
                Guid = "9becb296-458b-437a-8cda-7cb1afb453f3",
                Name = "EndDate",
                Type = "DateTime",
            };
            metadataEntity_.MetadataFieldList.Add(metadataField_);
            metadataField_ = new MetadataField
            {
                Guid = "dfb29f01-74aa-436d-a51a-9e7fd0bb1d36",
                Name = "FileData",
                Type = "Binary",
            };
            metadataEntity_.MetadataFieldList.Add(metadataField_);
            metadataField_ = new MetadataField
            {
                Guid = "d316fc2e-4de4-482f-91fc-c224310882ef",
                Name = "FileName",
                Type = "String",
            };
            metadataEntity_.MetadataFieldList.Add(metadataField_);
            metadataField_ = new MetadataField
            {
                Guid = "d4c2b107-a62d-4335-9dbf-aeddda69f571",
                Name = "FileType",
                Type = "String",
            };
            metadataEntity_.MetadataFieldList.Add(metadataField_);
            metadataField_ = new MetadataField
            {
                Guid = "c67653a0-75fb-4035-ba40-0a8af88136e4",
                Name = "Owner",
                Type = "String",
            };
            metadataEntity_.MetadataFieldList.Add(metadataField_);
            metadataField_ = new MetadataField
            {
                Guid = "b0b2bf9f-19f7-4aa0-9b76-86735e36d22a",
                Name = "StartDate",
                Type = "DateTime",
            };
            metadataEntity_.MetadataFieldList.Add(metadataField_);
            metadataField_ = new MetadataField
            {
                Guid = "f2574de4-bd49-4520-8d26-0376b612d5a2",
                Name = "Title",
                Type = "String",
            };
            metadataEntity_.MetadataFieldList.Add(metadataField_);
            metadataNavigationProperty_ = new MetadataNavigationProperty
            {
                Guid             = "4424a6e4-9e7b-4eb0-ae67-ff5655c83fbd",
                Name             = "Recurrence",
                Type             = "CalendarEventRecurrence",
                FromMultiplicity = MultiplicityTypes.ZeroOrMany,
                ToMultiplicity   = MultiplicityTypes.OneExactly,
            };
            metadataEntity_.MetadataNavigationPropertyList.Add(metadataNavigationProperty_);
            metadataNavigationProperty_ = new MetadataNavigationProperty
            {
                Guid             = "01a265a8-efb0-4095-9790-d042fe285fa4",
                Name             = "Status",
                Type             = "CalendarEventStatus",
                FromMultiplicity = MultiplicityTypes.ZeroOrMany,
                ToMultiplicity   = MultiplicityTypes.OneExactly,
            };
            metadataEntity_.MetadataNavigationPropertyList.Add(metadataNavigationProperty_);
            metadataEntity_ = new MetadataEntity
            {
                Guid      = "4a2d41a8-ce43-49d4-8577-0812b4e7cc0f",
                Name      = "CalendarEventRecurrence",
                Dimension = false,
            };
            MetadataEntityList.Add(metadataEntity_);
            metadataEntityForGuid_.Add(metadataEntity_.Guid, metadataEntity_);

            metadataField_ = new MetadataField
            {
                Guid = "21df7957-9b6e-4c8c-810a-43ce9eb99dd0",
                Name = "Code",
                Type = "Int32",
            };
            metadataEntity_.MetadataFieldList.Add(metadataField_);
            metadataField_ = new MetadataField
            {
                Guid = "876ecb5a-bb36-4ac5-b61f-1629ba436f63",
                Name = "Description",
                Type = "String",
            };
            metadataEntity_.MetadataFieldList.Add(metadataField_);
            metadataEntity_ = new MetadataEntity
            {
                Guid      = "251be393-8a31-42bb-9ed4-a58db1cae6db",
                Name      = "CalendarEventStatus",
                Dimension = false,
            };
            MetadataEntityList.Add(metadataEntity_);
            metadataEntityForGuid_.Add(metadataEntity_.Guid, metadataEntity_);

            metadataField_ = new MetadataField
            {
                Guid = "94b684ff-3e4b-449f-af82-24c6c052adfe",
                Name = "Code",
                Type = "Int32",
            };
            metadataEntity_.MetadataFieldList.Add(metadataField_);
            metadataField_ = new MetadataField
            {
                Guid = "b0d1316d-4a9e-4f85-a7c6-a993b84fba0c",
                Name = "Description",
                Type = "String",
            };
            metadataEntity_.MetadataFieldList.Add(metadataField_);

            //Pass2 : add entity usages
            metadataEntity_ = metadataEntityForGuid_["476b1ee2-94aa-454c-990a-f0a47a664e65"];       //CalendarEvent
            //Needed entities
            neededMetadataEntity_ = metadataEntityForGuid_["4a2d41a8-ce43-49d4-8577-0812b4e7cc0f"]; //CalendarEventRecurrence
            metadataEntity_.UsedEntityList.Add(neededMetadataEntity_);
            neededMetadataEntity_ = metadataEntityForGuid_["251be393-8a31-42bb-9ed4-a58db1cae6db"]; //CalendarEventStatus
            metadataEntity_.UsedEntityList.Add(neededMetadataEntity_);
            //Needing entities
            metadataEntity_ = metadataEntityForGuid_["4a2d41a8-ce43-49d4-8577-0812b4e7cc0f"];      //CalendarEventRecurrence
            //Needed entities
            //Needing entities
            needingMetadataEntity_ = metadataEntityForGuid_["476b1ee2-94aa-454c-990a-f0a47a664e65"]; //CalendarEvent
            metadataEntity_.UsingEntityList.Add(needingMetadataEntity_);
            metadataEntity_ = metadataEntityForGuid_["251be393-8a31-42bb-9ed4-a58db1cae6db"];        //CalendarEventStatus
            //Needed entities
            //Needing entities
            needingMetadataEntity_ = metadataEntityForGuid_["476b1ee2-94aa-454c-990a-f0a47a664e65"];         //CalendarEvent
            metadataEntity_.UsingEntityList.Add(needingMetadataEntity_);
        }