public static Comment ReadExtendPropertiesOfComment(Comment comment) { int recordCount = 0; comment.Attachments = FileSystemService.GetFilesBy("", "", comment.CommentID, "", "", FileStates.Normal, FileTypes.File, "", false, 0, 0x270f, out recordCount); return(comment); }
public void GetFolderPath_Returns500StatusCodeIfOneOfFoldersIsNull() { // arrange string currFolderId = "20"; string userId = "1234"; Folder folder1 = new Folder { Id = "1", ParentFolderId = null, OwnerId = userId, Path = "C:\\Folder1" }; Folder folder2 = null; Folder folder3 = new Folder { Id = "20", ParentFolderId = "5", OwnerId = userId, Path = "C:\\Folder1\\Folder2\\Folder3" }; var mock = new Mock <IUnitOfWork>(); mock.Setup(a => a.GetRepository <Folder>().Get("1")).Returns(folder1); mock.Setup(a => a.GetRepository <Folder>().Get("5")).Returns(folder2); mock.Setup(a => a.GetRepository <Folder>().Get("20")).Returns(folder3); FileSystemService service = new FileSystemService(mock.Object, _mapper); int expected = 500; // act StatusCodeException ex = Assert.Throws <StatusCodeException>(() => service.GetFolderPath(currFolderId, userId)); // assert Assert.AreEqual(expected, ex.Data["Status code"]); }
/// <summary> /// Initializes a new instance of the BASSSoundEffect class. /// </summary> /// <param name="uv">The Ultraviolet context.</param> /// <param name="filename">The filename of the sample to load.</param> public BASSSoundEffect(UltravioletContext uv, String filename) : base(uv) { var fileSystemService = FileSystemService.Create(); var fileData = default(Byte[]); using (var stream = fileSystemService.OpenRead(filename)) { fileData = new Byte[stream.Length]; stream.Read(fileData, 0, fileData.Length); } sample = BASSNative.SampleLoad(fileData, 0, (UInt32)fileData.Length, UInt16.MaxValue, 0); if (!BASSUtil.IsValidHandle(sample)) { throw new BASSException(); } if (!BASSNative.SampleGetInfo(sample, out this.sampleInfo)) { throw new BASSException(); } this.data = Marshal.AllocHGlobal((int)sampleInfo.length); if (!BASSNative.SampleGetData(sample, this.data)) { throw new BASSException(); } }
public void Move(string sourcePath, string destinationPath) { string text = Path.Combine(RootDirectoryPath, PreparePath(sourcePath)); string text2 = Path.Combine(RootDirectoryPath, PreparePath(destinationPath), Path.GetFileName(text)); if (text == text2) { throw new Exception("Source and destination paths should be different."); } if (text2.StartsWith(text)) { throw new Exception("Incorrect destination path for the move operation."); } if (FileSystemService.DirectoryExists(text)) { FileSystemService.MoveDirectory(text, text2); } else if (FileSystemService.FileExists(text)) { FileSystemService.MoveFile(text, text2); } else { FileManagementExceptionExecutor.ThrowFileNotFound(text); } }
/// <summary> /// Function to create a project view model. /// </summary> /// <param name="projectData">The project data to assign to the project view model.</param> /// <returns>The project view model.</returns> /// <exception cref="ArgumentNullException">Thrown when the <paramref name="projectData"/> parameter is <b>null</b>.</exception> public async Task <IProjectVm> CreateProjectViewModelAsync(IProject projectData) { if (projectData == null) { throw new ArgumentNullException(nameof(projectData)); } var result = new ProjectVm(); var fileSystemService = new FileSystemService(projectData.FileSystemDirectory); await Task.Run(() => { FileExplorerVm fileExplorer = CreateFileExplorerViewModel(projectData, fileSystemService); result.ContentFileManager = fileExplorer; result.FileExplorer = fileExplorer; }); var previewer = new ContentPreviewVm(); var thumbDirectory = new DirectoryInfo(Path.Combine(projectData.TempDirectory.FullName, "thumbs")); if (!thumbDirectory.Exists) { thumbDirectory.Create(); thumbDirectory.Refresh(); } previewer.Initialize(new ContentPreviewVmParameters(result.FileExplorer, result.ContentFileManager, thumbDirectory, this)); result.ContentPreviewer = previewer; result.Initialize(new ProjectVmParameters(projectData, this)); // Empty this list, it will be rebuilt when we save, and having it lying around is a waste. projectData.ProjectItems.Clear(); return(result); }
public string deleteAttachmentByID() { HandlerResponse response = null; ResponseTypes tip; TipTypes information; string str = base.Request.QueryString["fileID"]; if (StringHelper.isNullOrEmpty(str)) { tip = ResponseTypes.Tip; information = TipTypes.Information; response = new HandlerResponse("FILE_ID_EMPTY", str, tip.ToString(), information.ToString(), "", "", ""); base.Response.Write(response.GenerateJsonResponse()); return(null); } KaYi.FileSystem.Model.File fileByID = FileSystemService.GetFileByID(str); if (fileByID != null) { fileByID.FileState = FileStates.Deleted; FileSystemService.UpdateFile(fileByID); tip = ResponseTypes.Tip; information = TipTypes.Information; response = new HandlerResponse("FILE_DELETE_SUCCESSED", fileByID.OriginalFileName, tip.ToString(), information.ToString(), "", "", fileByID.FileID); base.Response.Write(response.GenerateJsonResponse()); return(null); } tip = ResponseTypes.Tip; information = TipTypes.Information; response = new HandlerResponse("FILE_NOT_FOUND", str, tip.ToString(), information.ToString(), "", "", ""); base.Response.Write(response.GenerateJsonResponse()); return(null); }
public void Rename(string key, string newName) { CheckThatDirOrFileNameIsNotEmpty(key, "key"); CheckThatDirOrFileNameIsNotEmpty(newName, "newName"); ValidateFileItemNameSymbols(newName); string text = Path.Combine(RootDirectoryPath, PreparePath(key)); string path = Path.GetDirectoryName(text) ?? string.Empty; if (FileSystemService.DirectoryExists(text)) { if (string.Equals(Path.GetFullPath(RootDirectoryPath), Path.GetFullPath(text), StringComparison.OrdinalIgnoreCase)) { FileManagementExceptionExecutor.ThrowNoAccess(); } string destDirName = Path.Combine(path, newName); FileSystemService.MoveDirectory(text, destDirName); } else if (FileSystemService.FileExists(text)) { string extension = Path.GetExtension(text); if (!newName.Contains(".")) { newName += extension; } string destFileName = Path.Combine(path, newName); FileSystemService.MoveFile(text, destFileName); } else { FileManagementExceptionExecutor.ThrowFileNotFound(text); } }
public void GetFileById_ReturnsFileVMWithCorrectContentType(string extension, string expected) { // arrange File fileFromDB = new File { Id = "23", Path = "C:\\User\\MyFolder\\file" + extension, FolderId = "1", IsShared = false }; Folder folderFromDB = new Folder { Id = "1", Path = "C:\\User\\MyFolder", OwnerId = "User", ParentFolderId = null, IsShared = false }; var mock = new Mock <IUnitOfWork>(); mock.Setup(a => a.GetRepository <File>().Get("23")).Returns(fileFromDB); mock.Setup(a => a.GetRepository <Folder>().Get("1")).Returns(folderFromDB); FileSystemService service = new FileSystemService(mock.Object, _mapper); // act FileVM fileVM = service.GetFileById("23"); string result = fileVM.ContentType; // assert Assert.AreEqual(expected, result); }
public void HasSharedChildren_ReturnsTrueIfHasSharedFile() { // arrange Folder parentFolderFromDB = new Folder { Id = "1", IsShared = false }; IEnumerable <Folder> foldersListFromDB = new List <Folder>(); IEnumerable <File> filesListFromDB = new List <File> { new File { Id = "12", IsShared = true, FolderId = "1" } }; var mock = new Mock <IUnitOfWork>(); mock.Setup(a => a.GetRepository <Folder>().Get("1")).Returns(parentFolderFromDB); mock.Setup(a => a.GetRepository <Folder>().Find(It.IsAny <Func <Folder, bool> >())).Returns(foldersListFromDB); mock.Setup(a => a.GetRepository <File>().Find(It.IsAny <Func <File, bool> >())).Returns(filesListFromDB); FileSystemService service = new FileSystemService(mock.Object, _mapper); // act bool result = service.HasSharedChildren("1"); // assert Assert.IsTrue(result); }
public void CreateFolder_ReturnsFolderIfItIsNew() { // arrange string userId = "1234"; string name = "newFolder"; FolderVM folder = new FolderVM { Id = "1", Path = _rootPath, OwnerId = userId, ParentFolderId = null, IsShared = false }; var mock = new Mock <IUnitOfWork>(); mock.Setup(a => a.GetRepository <Folder>().Create(It.IsAny <Folder>())); FileSystemService service = new FileSystemService(mock.Object, _mapper); ElementVM expected = new ElementVM { ElemName = name, IsFolder = true, IsShared = false, LastModified = DateTime.Now.ToShortDateString(), Size = null, Type = ElementVM.FileType.Folder }; // act ElementVM result = service.CreateFolder(folder, name, userId); expected.Id = result.Id; // assert Assert.AreEqual(expected, result); }
private ChromelyResponse GetDirectories(ChromelyRequest request) { try { IDictionary <string, object> requestParams = request.Parameters; string path = (string)requestParams["path"]; bool includeFiles = (bool)requestParams["includeFiles"]; FileSystemService fileSystemService = FileSystemService.getInstance(); List <FsDirectory> directories = fileSystemService.GetDirectories(path); List <FsFile> files = new List <FsFile>(); if (includeFiles) { files = fileSystemService.GetFiles(path); } FsView fsView = new FsView(); fsView.directories = directories; fsView.files = files; string fsJson = JsonConvert.SerializeObject(fsView); ChromelyResponse response = new ChromelyResponse(); response.Data = fsJson; return(response); } catch (Exception e) { Log.Error(e); return(null); } }
public MainWindow() { logger = NLogBuilder.ConfigureNLog("nlog.config").GetCurrentClassLogger(); telemetryWriter = new TelemetryWriter(); logger.Info("\n\nApp start"); telemetryWriter.WriteAppStart(); messageBoxService = new MessageBoxService(); dbService = new DbService(); drawService = new DrawService(logger); throwService = new ThrowService(logger); configService = new ConfigService(logger, dbService); scoreBoardService = new ScoreBoardService(logger, configService, drawService); camsDetectionBoard = new CamsDetectionBoard(configService, logger, drawService); fileSystemService = new FileSystemService(); versionChecker = new VersionChecker(appVersion, fileSystemService, dbService, configService, messageBoxService); detectionService = new DetectionService(drawService, configService, throwService, logger, camsDetectionBoard); manualThrowPanel = new ManualThrowPanel(logger, detectionService); gameService = new GameService(scoreBoardService, camsDetectionBoard, detectionService, logger, dbService, manualThrowPanel); InitializeComponent(); viewModel = new MainWindowViewModel(logger, messageBoxService, dbService, versionChecker, scoreBoardService, camsDetectionBoard, drawService, detectionService, manualThrowPanel, gameService, configService); DataContext = viewModel; }
internal static Command Parse(string[] args) { if (args.Length < 1) { return(Command.Error); } if (args[0] == "-h" || args[0] == "--help") { return(Command.Help); } if (args.Length > 1) { IFileSystemService fileSystem = new FileSystemService(); bool isValid1 = fileSystem.IsPathValid(args[0]).Result == Result.Success; bool isValid2 = fileSystem.IsPathValid(args[1]).Result == Result.Success; if (isValid1 && isValid2) { return(Command.Run); } else { return(Command.Error); } } return(Command.Error); }
public static FMOD_RESULT UserOpen(String name, UInt32 *filesize, void **handle, void *userdata) { var fss = FileSystemService.Create(); if (fss.FileExists(name)) { var iostream = default(Stream); try { iostream = fss.OpenRead(name); } catch (FileNotFoundException) { return(FMOD_ERR_FILE_NOTFOUND); } var fmodstream = new FMODFileStream(iostream); var handlenum = Interlocked.Increment(ref nexthandle); var handlemem = Marshal.AllocHGlobal(sizeof(Int64));; *(Int64 *)handlemem = handlenum; *filesize = (UInt32)iostream.Length; *handle = (void *)handlemem; lockSlim.EnterWriteLock(); try { streams[handlenum] = fmodstream; } finally { lockSlim.ExitWriteLock(); } return(FMOD_OK); } else { return(FMOD_ERR_FILE_NOTFOUND); } }
public virtual void RegisterService(String token, FileSystemService service) { BSyncResult <Object> asyncResult = new BSyncResult <Object>(); RegisterService(token, service, BAsyncResultHelper.ToDelegate <Object>(asyncResult)); asyncResult.GetResult(); }
public ProviderService(FileSystemService fileSystemService) { _services = new List <IProviderService> { fileSystemService }; }
public void GetFolderById_ReturnsFolderVM() { // arrange Folder folderFromDB = new Folder { Id = "23", Path = "C:\\User\\MyFolder", OwnerId = "User", ParentFolderId = "1", IsShared = false }; var mock = new Mock <IUnitOfWork>(); mock.Setup(a => a.GetRepository <Folder>().Get("23")).Returns(folderFromDB); FileSystemService service = new FileSystemService(mock.Object, _mapper); FolderVM expected = new FolderVM { Id = "23", Path = "C:\\User\\MyFolder", OwnerId = "User", ParentFolderId = "1", IsShared = false }; // act FolderVM result = service.GetFolderById("23"); // assert Assert.AreEqual(expected, result); }
private void EnsureTempDirectoryCreated() { if (!FileSystemService.DirectoryExists(FileSystemConfiguration.UploadTempPath)) { FileSystemService.CreateDirectory(FileSystemConfiguration.UploadTempPath); } }
public AccountController() { FSservice = ServiceLocator.GetService <FileSystemService>(); _pdfService = ServiceLocator.GetService <PDFServiceSoapClient>(); _conSrv = ServiceLocator.GetService <ConfirmationService>(); _userActionLogSrv = ServiceLocator.GetService <UserActionService>(); }
/// <summary> /// Creates a BASS stream that represents the song. /// </summary> /// <param name="flags">The flags to apply to the stream that is created.</param> /// <returns>The handle to the BASS stream that was created.</returns> public UInt32 CreateInstance(UInt32 flags) { var fileSystemService = FileSystemService.Create(); var instance = fileSystemService.OpenRead(file); var instanceID = this.nextInstanceID++; instances.Add(instanceID, instance); var stream = 0u; try { var procs = new BASS_FILEPROCS(fnClose, fnLength, fnRead, fnSeek); unsafe { stream = BASSNative.StreamCreateFileUser(1, BASSNative.BASS_STREAM_DECODE, &procs, new IntPtr((int)instanceID)); if (!BASSUtil.IsValidHandle(stream)) { throw new BASSException(); } } } catch { instance.Dispose(); instances.Remove(instanceID); throw; } return(stream); }
public Index GetIndexConfig(string alias) { var cacheName = "DEXTER_INDEX_" + alias; Index indexConfig = CacheProvider.Get <Index>(cacheName); if (indexConfig != null) { return(indexConfig); } indexConfig = FileSystemService.MapFile($"{DEFAULTINDEXFILEPATH}{alias}.index.json").ReadAsJson <Index>(); var indexAllContentType = indexConfig.ContentTypes.FirstOrDefault(x => string.IsNullOrWhiteSpace(x.Alias)); if (indexAllContentType != null) { foreach (var type in indexConfig.ContentTypes.Where(x => !string.IsNullOrWhiteSpace(x.Alias))) { type.Properties.AddRange(indexAllContentType.Properties); } } indexConfig.Alias = IndexResolver.GetIndexName(alias); CacheProvider.Set(cacheName, indexConfig); return(indexConfig); }
// checkpoint byps.gen.cs.GenRemoteStub:133 public async Task RegisterServiceAsync(String token, FileSystemService service){ BRequest_DispatcherService_registerService req = new BRequest_DispatcherService_registerService(); req.tokenValue = token; req.serviceValue = service; Task<Object> task = Task<Object>.Factory.FromAsync(transport.BeginSend<Object>, transport.EndSend<Object>, req, null); await task; }
public void ChangeAccess_Returns403StatusCodeIfYouAreNotOwner() { // arrange string userId = "4321"; string currFolderId = "1"; string[] foldersId = { "22" }; string[] filesId = { }; var mock = new Mock <IUnitOfWork>(); mock.Setup(a => a.GetRepository <Folder>().Get("1")).Returns(new Folder { Id = "1", OwnerId = "1234", ParentFolderId = currFolderId }); mock.Setup(a => a.GetRepository <Folder>().Get("22")).Returns(new Folder { Id = "22", OwnerId = "1234", ParentFolderId = currFolderId }); mock.Setup(a => a.GetRepository <Folder>().Find(It.IsAny <Func <Folder, bool> >())).Returns(new List <Folder>()); mock.Setup(a => a.GetRepository <File>().Find(It.IsAny <Func <File, bool> >())).Returns(new List <File>()); FileSystemService service = new FileSystemService(mock.Object, _mapper); int expected = 403; // act StatusCodeException ex = Assert.Throws <StatusCodeException>(() => service.ChangeAccess(currFolderId, userId, foldersId, filesId, true)); // assert Assert.AreEqual(expected, ex.Data["Status code"]); }
public void ChangeAccess_ReturnsSharedFolderIdIfItIsTheOnlyOne() { // arrange string userId = "4321"; string currFolderId = "1"; string[] foldersId = { "22" }; string[] filesId = { }; var mock = new Mock <IUnitOfWork>(); mock.Setup(a => a.GetRepository <Folder>().Get("1")).Returns(new Folder { Id = currFolderId, OwnerId = userId }); mock.Setup(a => a.GetRepository <Folder>().Get("22")).Returns(new Folder { Id = "22", OwnerId = userId, ParentFolderId = currFolderId }); mock.Setup(a => a.GetRepository <Folder>().Find(It.IsAny <Func <Folder, bool> >())).Returns(new List <Folder>()); mock.Setup(a => a.GetRepository <File>().Find(It.IsAny <Func <File, bool> >())).Returns(new List <File>()); FileSystemService service = new FileSystemService(mock.Object, _mapper); string expected = "22"; // act string result = service.ChangeAccess(currFolderId, userId, foldersId, filesId, true); // assert Assert.AreEqual(expected, result); }
void CreateNewDocument(string folderPath, string docType) { if (string.IsNullOrEmpty(folderPath)) { folderPath = "Files"; } string documentName; if (docType == "richtext") { documentName = "Document.rtf"; } else if (docType == "worksheet") { documentName = "Worksheet.xlsx"; } else { throw new Exception("Incorrect document type."); } Item newDocument = FileSystemService.CreateNewFileItem(folderPath, documentName); CurrentDocument = newDocument; }
/// <summary> /// Initializes a new instance of the <see cref="HolodeckFixture"/> class. /// </summary> public HolodeckFixture() { if (Holodeck.HolodeckALocations == null) { throw new ConfigurationErrorsException("Holodeck A could not be found on this machine"); } if (Holodeck.HolodeckBLocations == null) { throw new ConfigurationErrorsException("Holodeck B could not be found on this machine"); } var service = new FileSystemService(); service.CleanUpFiles(Holodeck.HolodeckALocations.InputPath); service.CleanUpFiles(Holodeck.HolodeckBLocations.InputPath); service.CleanUpFiles(Holodeck.HolodeckALocations.PModePath); service.CleanUpFiles(Holodeck.HolodeckBLocations.PModePath); service.CleanUpFiles(Holodeck.HolodeckALocations.OutputPath); service.CleanUpFiles(Holodeck.HolodeckBLocations.OutputPath); ////service.RemoveDirectory(Holodeck.HolodeckALocations.DbPath); ////service.RemoveDirectory(Holodeck.HolodeckBLocations.DbPath); Process holodeckA = StartHolodeck(Holodeck.HolodeckALocations.BinaryPath); Process holodeckB = StartHolodeck(Holodeck.HolodeckBLocations.BinaryPath); _parentProcess = new ParentProcess(holodeckA, holodeckB); // Make sure the Holodeck MSH's are started before continuing. System.Threading.Thread.Sleep(6000); }
public ValidationResult Validate(NewSubcommand command) { if (command.IsValidResolvedSolution) { return(ValidationResult.Success); } if (command.ResolvedSolution.IsNotProvidedByUser()) { return(command.ResolvedSolutionErrorMessage.Exists() ? ValidationResult.Error(command.ResolvedSolutionErrorMessage) : ValidationResult.Error(Resources.New.SearchSolutionPathErrors.Instance.WorkingDirectoryDoesNotContainAnyFile)); } var response = FileSystemService.GetSolutionPath(command.ResolvedSolution); if (!response.IsSuccessful) { return(ValidationResult.Error(response.Message)); } var dependencyGraph = DependencyGraphService.GenerateDependencyGraph(response?.Payload ?? string.Empty); if (dependencyGraph == null) { return(ValidationResult.Error(Resources.New.Errors.InvalidSolution)); } command.ResolvedSolutionIsValid(); return(ValidationResult.Success); }
public void OnRootsRequested() { // Send Roots List <DiskDriveInfo> diskDrives = FileSystemService.GetRoots(); NetClientService.SendFileSystemRoots(diskDrives); }
public async Task CanPublishApps() { var repository = vContainer.Resolve <IDvinRepository>(); var fileSystemService = new FileSystemService(); var errorsAndInfos = new ErrorsAndInfos(); var apps = await repository.LoadAsync(errorsAndInfos); Assert.IsFalse(errorsAndInfos.AnyErrors(), errorsAndInfos.ErrorsToString()); // ReSharper disable once LoopCanBePartlyConvertedToQuery foreach (var app in apps) { if (!app.HasAppBeenBuiltAfterLatestSourceChanges(fileSystemService)) { continue; } app.Publish(fileSystemService, errorsAndInfos); if (errorsAndInfos.Errors.Any(e => e.StartsWith("No folders specified"))) { continue; } Assert.IsFalse(errorsAndInfos.AnyErrors(), errorsAndInfos.ErrorsToString()); break; } }
public Database(ILoggerFactory loggerFactory, DatatentSettings settings, IDataProcessingPipeline processingPipeline) { _settings = settings; _processingPipeline = processingPipeline; _fileSystemService = new FileSystemService(_settings, loggerFactory.CreateLogger <FileSystemService>()); _defaultScheduler = new DefaultScheduler(_fileSystemService); }
public virtual void Initialize() { Data = new EntityDataService(this); FileSystem = new FileSystemService(this); Document = new DocumentService(this); User = new UserService(this); Image = new ImageService(this); }
private void initStubs(BTransport transport) { dispatcherServiceVal = new BStub_DispatcherService(transport); fileSystemNotifyVal = new BStub_FileSystemNotify(transport); fileSystemServiceVal = new BStub_FileSystemService(transport); }
public virtual void RegisterService(String token, FileSystemService service, BAsyncResult<Object> asyncResult) { BRequest_DispatcherService_registerService req = new BRequest_DispatcherService_registerService(); req.tokenValue = token; req.serviceValue = service; transport.sendMethod(req, asyncResult); }
private void Initialize() { _fileSystemSerivce = new FileSystemService(); DependenciesRegistryUpdateEvent = new EmptyArgsEventHandler(); ItsNewFileEntries = new List<FileEntry>(); _tempFiles = new List<FileEntry>(); ItsIncludedFileEntriesDict = new Dictionary<int, FileEntry>(); ItsExcludedFileEntries = new List<FileEntry>(); _excludedExtensions = new List<string> { "*.pdb", "*.manifest", "*.vshost.exe.*","*.vshost.exe", "*.xml"}; }
public virtual void RegisterService(String token, FileSystemService service) { BSyncResult<Object> asyncResult = new BSyncResult<Object>(); RegisterService(token, service, BAsyncResultHelper.ToDelegate<Object>(asyncResult)); asyncResult.GetResult(); }