Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public int EditFile(File file, FileValidationParameters validationParameters = null)
- {
- var isContentRelocationRequired = false;
- try
- {
- string errorMessage;
- if (!ValidateFile(file, out errorMessage))
- {
- throw new Exception(errorMessage);
- }
- DocumentFile documentFile = null;
- int newRevisionNumber;
- // TODO [IP] : Вернуть или удалить в зависимости от результата исследования проблемы с боя
- //using (var redisLock = new StrictRedisLockCreator(RedisCacheHelper.GenerateFullKey(RedisCacheKeyName.FileAccessLockObjectForVirusScannerKeyName, file.Guid.ToString()), TimeSpan.FromSeconds(15))
- // .Create(RedisLockConstants.DefaultLockWaitTime, RedisLockConstants.DefaultLockRetryTime))
- //{
- //if (redisLock.IsAcquired)
- // {
- documentFile = DataAccessEf.SelectDocumentFile(file.Guid);
- //}
- if (documentFile == null)
- {
- throw new Exception(String.Format("Файл (Guid = {0}) не найден.", file.Guid.ToString()));
- }
- isContentRelocationRequired = IsContentRelocationRequired(file, documentFile);
- if (isContentRelocationRequired)
- {
- _redisCacheClient.Set(RedisCacheRegionName.FileFileServiceModifing, documentFile.Guid,
- Public.RedisCache.Client.NullObject.Value, TimeSpan.MaxValue);
- }
- newRevisionNumber = documentFile.RevisionNumber + 1;
- // Если контент документа был экспортирован во внешнее хранилище,
- // то сбрасываем этот признак, чтобы отдавать новый контент (из БД) и экспорт прошёл ещё раз (во внешнее хранилище).
- if (documentFile.IsMovedToStorage)
- {
- DocumentFileStoragePropertyService.ResetDocumentFileStorageProperties(documentFile);
- }
- UpdateDocumentFile(documentFile, file);
- documentFile.VirusState = (int) VirusCheckState.NotChecked;
- documentFile.RevisionNumber = newRevisionNumber;
- IUserSecurityToken token = ContextContainer.CurrentContext.GetUserSecurityToken();
- if (token != null)
- {
- documentFile.LastChangeUserId = token.UserInfo.UserId;
- }
- documentFile.LastChangeDate = DateTime.UtcNow;
- DataAccessEf.UpdateDocumentFile(documentFile);
- if (isContentRelocationRequired)
- {
- _redisCacheClient.Set(RedisCacheRegionName.FileFileServiceModified, documentFile.Guid,
- Public.RedisCache.Client.NullObject.Value, TimeSpan.MaxValue);
- }
- UpdateCertificateThumbprint(documentFile, file);
- var dalFileSignatures = DataAccess.SelectDocumentFileSignatures(documentFile.ID);
- UpdateFileSignatures(documentFile.ID, file.Signatures, dalFileSignatures);
- //}
- return newRevisionNumber;
- }
- catch (Exception e)
- {
- throw LogAndWrapException(e);
- }
- finally
- {
- if (isContentRelocationRequired)
- {
- _redisCacheClient.Remove(RedisCacheRegionName.FileFileServiceModifing, file.Guid.ToString());
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement