public async Task <TempShare> GetFileStationList()
        {
            var array = new JsonArray();

            array.Add("real_path");
            array.Add("owner");
            array.Add("time");
            array.Add("perm");
            array.Add("mount_point_type");
            array.Add("sync_share");
            array.Add("volume_status");
            array.Add("indexed");

            var loginRequest = new SynologyRestRequest(Resource);

            loginRequest.AddParameter("api", ServiceApiName);
            loginRequest.AddParameter("version", "2");
            loginRequest.AddParameter("method", "list_share");
            loginRequest.AddParameter("node", "fm_root");
            loginRequest.AddParameter("enum_cluster", true);
            loginRequest.AddParameter("additional", array);
            loginRequest.AddParameter("sort_by", "name");
            loginRequest.AddParameter("check_dir", true);
            loginRequest.AddParameter("filetype", "dir");

            loginRequest.AddParameter("sid", _client.Sid);

            var response = await _client.ExecuteAsync <SynologyResponse <TempShare> >(loginRequest)
                           .ConfigureAwait(false);

            return(response.Data.Data);
        }
示例#2
0
        public async Task <bool> LoginAsync(string username, string password)
        {
            if (_client.ApiInfo == null)
            {
                var obj = new SynoInfoClient(_client);
                _client.ApiInfo = await obj.GetSynologyApiServicesInfo();
            }

            var info = _client.ApiInfo[ServiceApiName];

            if (info.MaxVersion >= 7)
            {
                var logintype = await GetType(username);

                if (logintype?.Type != "passwd")
                {
                    throw new NotSupportedException($"login type \"{logintype?.Type}\" not supported");
                }

                return(await LoginAsyncV7(username, password));
            }

            //format=cookie
            var loginRequest = new SynologyRestRequest(Resource);

            loginRequest.AddParameter("api", ServiceApiName);
            loginRequest.AddParameter("version", "3");
            loginRequest.AddParameter("method", "login");
            loginRequest.AddParameter("account", username);
            loginRequest.AddParameter("passwd", password);
            loginRequest.AddParameter("session", "FileStation");//webui
            loginRequest.AddParameter("format", "cookie");



            try
            {
                var response = await _client.ExecuteAsync <SynologyResponse <SynoLoginInfo> >(loginRequest);

                //.ConfigureAwait(false);


                if (response.Data.Success)
                {
                    _client.Sid          = response.Data.Data.Sid;
                    _client.LoggedInTime = DateTime.Now;
                    return(true);
                }
            }
            catch (Exception e)
            {
                Console.WriteLine(e);
                throw;
            }

            return(false);
        }
示例#3
0
        public void LogOut()
        {
            var request = new SynologyRestRequest(Resource);

            request.AddParameter("api", ServiceApiName);
            request.AddParameter("version", "1");
            request.AddParameter("method", "logout");
            request.AddParameter("session", "FileStation");
            _client.Execute(request);
            _client.Sid = null;
        }
示例#4
0
        public async Task <SynoAuthType> GetType(string username)
        {
            var loginRequest = new SynologyRestRequest(Resource);

            loginRequest.AddParameter("api", ServiceApiName + ".Type");
            loginRequest.AddParameter("version", "1");
            loginRequest.AddParameter("method", "get");
            loginRequest.AddParameter("account", username);
            var response = await _client.ExecuteAsync <SynologySimpleResponse <List <SynoAuthType> > >(loginRequest);

            return(response.Data.Data.FirstOrDefault());
        }
        public async Task <SynologyProcessInfo> GetProcessInfo()
        {
            var loginRequest = new SynologyRestRequest(Resource);

            loginRequest.AddParameter("api", ServiceApiName + ".Process");
            loginRequest.AddParameter("version", "1");
            loginRequest.AddParameter("method", "list");


            var response = await _client.ExecuteAsync <SynologyResponse <SynologyProcessInfo> >(loginRequest)
                           .ConfigureAwait(false);

            return(response.Data.Data);
        }
示例#6
0
        public async Task <SynologyUpgradeStatus> GetUpgradeStatus()
        {
            var loginRequest = new SynologyRestRequest(Resource);

            loginRequest.AddParameter("api", ServiceApiName);
            loginRequest.AddParameter("version", "1");
            loginRequest.AddParameter("method", "status");
            loginRequest.AddParameter("sid", _client.Sid);

            var response = await _client.ExecuteAsync <SynologyResponse <SynologyUpgradeStatus> >(loginRequest)
                           .ConfigureAwait(false);

            return(response.Data.Data);
        }
示例#7
0
        public async Task <SynologyStorageInfo> GetFullStorageInfo()
        {
            var loginRequest = new SynologyRestRequest(Resource);

            loginRequest.AddParameter("api", ServiceApiName);
            loginRequest.AddParameter("version", "1");
            loginRequest.AddParameter("method", "load_info");
            loginRequest.AddParameter("sid", _client.Sid);

            var response = await _client.ExecuteAsync <SynologyResponse <SynologyStorageInfo> >(loginRequest)
                           .ConfigureAwait(false);

            return(response.Data.Data);
        }
        public async Task <SynolgySharesInfo> GetSharedFoldersInfo()
        {
            var loginRequest = new SynologyRestRequest(Resource);

            loginRequest.AddParameter("api", ServiceApiName);
            loginRequest.AddParameter("version", "1");
            loginRequest.AddParameter("method", "list");
            loginRequest.AddParameter("shareType", "all");
            loginRequest.AddParameter("sid", _client.Sid);

            var response = await _client.ExecuteAsync <SynologyResponse <SynolgySharesInfo> >(loginRequest)
                           .ConfigureAwait(false);

            return(response.Data.Data);
        }
        public async Task <SynologyUtilizationInfo> GetUtilizationInfo()
        {
            var loginRequest = new SynologyRestRequest(Resource);

            loginRequest.AddParameter("api", ServiceApiName + ".Utilization");
            loginRequest.AddParameter("version", "1");
            loginRequest.AddParameter("method", "get");
            loginRequest.AddParameter("type", "current");


            var response = await _client.ExecuteAsync <SynologyResponse <SynologyUtilizationInfo> >(loginRequest)
                           .ConfigureAwait(false);

            return(response.Data.Data);
        }
        public async Task <SynologyUserServices> GetUserServices()
        {
            var loginRequest = new SynologyRestRequest(Resource);

            loginRequest.AddParameter("api", ServiceApiName + ".Initdata");
            loginRequest.AddParameter("version", "1");
            loginRequest.AddParameter("method", "get_user_service");
            loginRequest.AddParameter("SynoToken", _client.Synotoken);
            loginRequest.AddParameter("sid", _client.Sid);

            var t        = loginRequest.Timeout;
            var response = await _client.ExecuteAsync <SynologySimpleResponse <SynologyUserServices> >(loginRequest)
                           .ConfigureAwait(false);

            return(response.Data.Data);
        }
        public async Task <SynologyPackageInfo> GetPackagesInfo()
        {
            var loginRequest = new SynologyRestRequest(Resource);

            loginRequest.AddParameter("api", ServiceApiName);
            loginRequest.AddParameter("version", "1");
            loginRequest.AddParameter("method", "list");
            loginRequest.AddArrayParameter("additional", "startable", "dependent_packages", "installed_info", "description", "description_enu");
            loginRequest.AddParameter("sid", _client.Sid);


            var response = await _client.ExecuteAsync <SynologyResponse <SynologyPackageInfo> >(loginRequest)
                           .ConfigureAwait(false);

            return(response.Data.Data);
        }
        public async Task <IDictionary <string, SynologyApiServicesInfo> > GetSynologyApiServicesInfo()
        {
            var loginRequest = new SynologyRestRequest(Resource);

            loginRequest.AddParameter("api", ServiceApiName);
            loginRequest.AddParameter("version", "1");
            loginRequest.AddParameter("method", "query");
            loginRequest.AddParameter("query", "all");
            loginRequest.AddParameter("sid", _client.Sid);


            var response = await _client
                           .ExecuteAsync <SynologySimpleResponse <Dictionary <string, SynologyApiServicesInfo> > >(loginRequest)
                           .ConfigureAwait(false);

            return(response.Data.Data);
        }
示例#13
0
        public async Task <SynologyPackageServer> GetPackagesServerInfo()
        {
            var loginRequest = new SynologyRestRequest(Resource);

            loginRequest.AddParameter("api", ServiceApiName);
            loginRequest.AddParameter("version", "2");
            loginRequest.AddParameter("blforcereload", false);
            loginRequest.AddParameter("blloadothers", false);
            loginRequest.AddParameter("method", "list");
            loginRequest.AddParameter("sid", _client.Sid);


            var response = await _client.ExecuteAsync <SynologyResponse <SynologyPackageServer> >(loginRequest)
                           .ConfigureAwait(false);

            return(response.Data.Data);
        }
        public async Task <SynologyServiceInfo> GetServicesInfo()
        {
            var array = new JsonArray();

            array.Add("status");
            array.Add("allow_control");

            var loginRequest = new SynologyRestRequest(Resource);

            loginRequest.AddParameter("api", ServiceApiName);
            loginRequest.AddParameter("version", "1");
            loginRequest.AddParameter("method", "get");
            loginRequest.AddParameter("additional", array);
            loginRequest.AddParameter("sid", _client.Sid);


            var response = await _client.ExecuteAsync <SynologyResponse <SynologyServiceInfo> >(loginRequest)
                           .ConfigureAwait(false);

            return(response.Data.Data);
        }
        public async Task <TempShare> GetSharedFolders()
        {
            var array = new JsonArray();

            array.Add("indexed");

            var loginRequest = new SynologyRestRequest(Resource);

            loginRequest.AddParameter("api", ServiceApiName);
            loginRequest.AddParameter("version", "2");
            loginRequest.AddParameter("method", "list_share");
            loginRequest.AddParameter("sort_direction", "ASC");
            loginRequest.AddParameter("sort_by", "name");
            loginRequest.AddParameter("additional", array);

            loginRequest.AddParameter("sid", _client.Sid);

            var response = await _client.ExecuteAsync <SynologyResponse <TempShare> >(loginRequest)
                           .ConfigureAwait(false);

            return(response.Data.Data);
        }
        public async Task <TempShare> ListileStationFolder(string folderPath)
        {
            var loginRequest = new SynologyRestRequest(Resource);

            loginRequest.AddParameter("api", ServiceApiName);
            loginRequest.AddParameter("version", "2");
            loginRequest.AddParameter("method", "list");
            loginRequest.AddParameter("folder_path", folderPath);
            loginRequest.AddParameter("filetype", "all");
            loginRequest.AddArrayParameter("additional",
                                           "real_path", "size", "owner", "time", "perm", "type", "mount_point_type", "description", "indexed");
            loginRequest.AddParameter("sort_by", "mtime");
            loginRequest.AddParameter("check_dir", true);
            loginRequest.AddParameter("action", "list");
            loginRequest.AddParameter("limit", 1000);
            loginRequest.AddParameter("offset", 0);
            loginRequest.AddParameter("sid", _client.Sid);

            var response = await _client.ExecuteAsync <SynologyResponse <TempShare> >(loginRequest)
                           .ConfigureAwait(false);

            return(response.Data.Data);
        }
示例#17
0
        private async Task <bool> LoginAsyncV7(string username, string password)
        {
            var loginRequest = new SynologyRestRequest(Resource);

            loginRequest.AddParameter("api", ServiceApiName);
            loginRequest.AddParameter("version", "7");
            loginRequest.AddParameter("method", "login");
            loginRequest.AddParameter("account", username);
            loginRequest.AddParameter("passwd", password);
            loginRequest.AddParameter("session", "FileStation");//webui
            loginRequest.AddParameter("enable_syno_token", "yes");
            loginRequest.AddParameter("enable_device_token", "no");
            loginRequest.AddParameter("rememberme", "0");
            try
            {
                var response = await _client.ExecuteAsync <SynologySimpleResponse <SynoLoginResult> >(loginRequest);

                //.ConfigureAwait(false);


                if (response.Data.Success)
                {
                    _client.Sid          = response.Data.Data.Sid;
                    _client.Synotoken    = response.Data.Data.Synotoken;
                    _client.LoggedInTime = DateTime.Now;
                    return(true);
                }
            }
            catch (Exception e)
            {
                Console.WriteLine(e);
                throw;
            }

            return(false);
        }