private void RegisterRequest <T>() where T : SynologyRequest { Logger.LogDebug($"Registering Request {typeof(T).Name}"); var builder = new ContainerBuilder(); var apiName = SynologyRequest.GetApiName <T>(); if (!string.IsNullOrEmpty(apiName)) { builder.RegisterType <T>().Named <SynologyRequest>(apiName).Named <T>(apiName).AsSelf().As <SynologyRequest>(); } else { builder.RegisterType <T>().AsSelf().As <SynologyRequest>(); } builder.Update(_container); }
protected SynologyParameters(SynologyRequest request, [CallerMemberName] string methodName = null) { var method = request.GetType().GetMethod(methodName); if (method != null) { var attr = method.GetCustomAttribute(typeof(RequestMethodAttribute)) as RequestMethodAttribute; if (attr != null) { Method = attr.Name; } else { throw new Exception("RequestMethodAttribute not found on caller method."); } } else { throw new Exception("Caller Method not found."); } Version = 1; }
public SynologyPostParameters(SynologyRequest request) : base(request) { }
private SynologyAPIInfo<SynologyTaskResponse> StartSearch(string searchName) { string queryString = string.Format("/webapi/FileStation/file_find.cgi?api={0}&version={1}&method=start&folder_path=%2Fvideo&recursive=true&pattern=1&_sid={2}", SynologyFileCommand.FILESEARCH, 1, this.synologyLogin.SID); SynologyAPIInfo<SynologyTaskResponse> searchResponse = new SynologyRequest<SynologyTaskResponse>(client).SendRequest(queryString); SynologyAPIInfo<SynologyFileList> searchFiles; while (true) { searchFiles = GetSearchResults(searchResponse.Data.TaskID); CancelSearch(searchResponse.Data.TaskID); ClearSearch(searchResponse.Data.TaskID); if (searchFiles.Data.FinishedSearch) { break; } } return searchResponse; }
private void MoveFile(string sourceFiles, string destDirName) { string queryString = string.Format("/webapi/FileStation/file_MVCP.cgi?api={0}&version={1}&method=start&path={2}&dest_folder_path={3}&overwrite=true&remove_src=true", SynologyFileCommand.FILECOPYMOVE, 1, sourceFiles, destDirName); SynologyAPIInfo<SynologyTaskResponse> copyMoveTask = new SynologyRequest<SynologyTaskResponse>(client).SendRequest(queryString); SynologyCopyMoveResponse copyMoveStatus; while (true) { copyMoveStatus = CheckFileMoveStatus(copyMoveTask.Data.TaskID); if (copyMoveStatus.Finished) { break; } } }
private SynologyAPIInfo<SynologyFileList> GetSearchResults(string searchID) { string queryString = string.Format("/webapi/FileStation/file_find.cgi?api={0}&version=1&method=list&taskid={1}&_sid={2}", SynologyFileCommand.FILESEARCH, searchID, this.synologyLogin.SID); SynologyAPIInfo<SynologyFileList> searchResponse = new SynologyRequest<SynologyFileList>(client).SendRequest(queryString); return searchResponse; }
private SynologyCopyMoveResponse CheckFileMoveStatus(string taskID) { string queryString = string.Format("/webapi/FileStation/file_MVCP.cgi?api={0}&version={1}&method=status&taskid={2}", SynologyFileCommand.FILECOPYMOVE, 1, taskID); SynologyAPIInfo<SynologyCopyMoveResponse> copyStatus = new SynologyRequest<SynologyCopyMoveResponse>(client).SendRequest(queryString); return copyStatus.Data; }
public void Login() { //string loginURI = string.Format("/webapi/auth.cgi?api=SYNO.API.Auth&version=3&method=login&account=admin&passwd=12345&session=FileStation&format=cookie"); string queryString = string.Format("/webapi/{0}?api=SYNO.API.Auth&version={1}&method=login&account={2}&passwd={3}&session=FileStation&format=cookie", this.synologyLogin.URIDetails.Path, this.synologyLogin.URIDetails.MaxVersion, this.synologyLogin.Username, this.synologyLogin.Password); SynologyAPIInfo<SynologyLogin> loginSID = new SynologyRequest<SynologyLogin>(client).SendRequest(queryString); if (loginSID.Success) { this.synologyLogin.SID = loginSID.Data.SID; this.IsLoggedIn = true; } }
public SynologyAPIInfo<SynologyFileList> GetVideoFileList() { string queryString = string.Format("/webapi/FileStation/file_share.cgi?api={0}&version={1}&method=list&additional=real_path%2Csize%2Cowner%2Ctime%2Cperm%2Ctype&folder_path=%2Fvideo", SynologyFileCommand.LISTFILES, 1); SynologyAPIInfo<SynologyFileList> files = new SynologyRequest<SynologyFileList>(client).SendRequest(queryString); ; return files; }
public List<string> GetFolderList() { string queryString = string.Format("/webapi/FileStation/file_share.cgi?api={0}&version={1}&method=list_share&additional=real_path%2Cowner%2Ctime", SynologyFileCommand.LISTFILES, 1); SynologyAPIInfo<SynologyLogin> loginSID = new SynologyRequest<SynologyLogin>(client).SendRequest(queryString); if (loginSID.Success) { this.synologyLogin.SID = loginSID.Data.SID; } return null; }
public void GetFileAPIList() { try { this.logger.Log("Start connection"); // List all products. string queryString = "/webapi/query.cgi?api=SYNO.API.Info&version=1&method=query&query=SYNO.API.Auth,SYNO.FileStation"; SynologyAPIInfo<SynologyDataSources> apiInfo = new SynologyRequest<SynologyDataSources>(client).SendRequest(queryString); if (apiInfo.Success) { this.synologyLogin.InitialiseLoginInfo(apiInfo); } } catch (Exception ex) { this.logger.Log(ex.ToString()); } }