Beispiel #1
0
        public virtual IQueryable <Sungero.Docflow.IStoragePolicyBase> StoragePolicyDataQuery(IQueryable <Sungero.Docflow.IStoragePolicyBase> query)
        {
            if (_filter == null)
            {
                return(query);
            }

            if (_filter.Active || _filter.Closed)
            {
                query = query.Where(r => _filter.Active && r.Status == Status.Active ||
                                    _filter.Closed && r.Status == Status.Closed);
            }

            if (_filter.DocumentKind != null)
            {
                query = query.Where(r => !r.DocumentKinds.Any() || r.DocumentKinds.Any(u => Equals(u.DocumentKind, _filter.DocumentKind)));
            }

            if (_filter.StoragePolicy || _filter.RetentionPolicy)
            {
                query = query.Where(r => StoragePolicies.Is(r) && _filter.StoragePolicy ||
                                    RetentionPolicies.Is(r) && _filter.RetentionPolicy);
            }

            return(query);
        }
Beispiel #2
0
        /// <summary>
        /// Подобрать для документа подходящее хранилище.
        /// </summary>
        /// <param name="document">Документ.</param>
        /// <returns>Наиболее подходящее хранилище для документа.</returns>
        public virtual IStorage GetStorageByPolicies(IOfficialDocument document)
        {
            var policies = StoragePolicies.GetAllCached().Where(r => r.Status == Docflow.StoragePolicyBase.Status.Active &&
                                                                (document.DocumentKind == null ||
                                                                 !r.DocumentKinds.Any() ||
                                                                 r.DocumentKinds.Any(k => Equals(k.DocumentKind, document.DocumentKind))));

            var policy = policies.OrderByDescending(p => p.Priority).FirstOrDefault();

            if (policy != null)
            {
                return(policy.Storage);
            }

            return(null);
        }
 /// <summary>
 /// Проверить наличие политик с таким же приоритетом.
 /// </summary>
 /// <returns>Признак наличия политик с таким же приоритетом.</returns>
 public override bool HasSamePriorityPolicies()
 {
     return(StoragePolicies.GetAll().Any(x => x.Status == Docflow.StoragePolicyBase.Status.Active && x.Priority == _obj.Priority && x.Id != _obj.Id));
 }