/// <summary> /// Копировать файл /// </summary> public IResultValue <string> CopyFile(string fileSource, string fileDestination) => fileSource.WhereContinue(_ => !String.IsNullOrEmpty(fileSource) && !String.IsNullOrEmpty(fileDestination), okFunc: _ => ExecuteResultHandler.ExecuteBindResultValue(() => { File.Copy(fileSource, fileDestination, true); return(fileDestination); }), badFunc: _ => new ResultValue <string>(new ErrorCommon(ErrorConvertingType.FileNotSaved, $"Невозможно скопировать файл {fileSource}")));
/// <summary> /// Получить первый в очереди пакет на конвертирование /// </summary> public async Task <PackageDataRequestServer> GetFirstInQueuePackage(string identityServerName) { using var unitOfWork = _container.Resolve <IUnitOfWork>(); await _accessService.UpdateLastServerAccess(identityServerName); var packageDataEntity = await unitOfWork.Session.Query <PackageDataEntity>(). OrderBy(package => package.CreationDateTime). FirstOrDefaultAsync(ConditionConverting(identityServerName)); var packageDataRequest = ExecuteResultHandler.ExecuteBindResultValue( () => ConverterFilesDataEntitiesToDtoServer.PackageDataToRequest(packageDataEntity)); ValidatePackage(packageDataRequest, packageDataEntity, identityServerName); await unitOfWork.CommitAsync(); return(packageDataRequest.Value ?? PackageDataRequestServer.EmptyPackage); }
/// <summary> /// Удалить папки /// </summary> public static IResultCollection <string> DeleteDirectories(DirectoryInfo directoryInfo, DateTime timeNow, int hoursElapsed = -1) => directoryInfo.EnumerateDirectories(). Where(directory => (timeNow - directory.LastWriteTime).Ticks >= hoursElapsed). Select(directory => ExecuteResultHandler.ExecuteBindResultValue(() => { directory.Delete(true); return(directory.FullName); })). ToResultCollection();
/// <summary> /// Удалить файл /// </summary> public IResultValue <string> DeleteFile(string filePath) => ExecuteResultHandler.ExecuteBindResultValue(() => { File.Delete(filePath); return(filePath); });