Beispiel #1
0
        public string Login()
        {
            string username = ConfigurationManager.AppSettings["username"].ToString();
            string password = ConfigurationManager.AppSettings["password"].ToString();
            NameValueCollection collection = new NameValueCollection();

            collection["account"] = username;
            collection["passwd"]  = password;
            collection["session"] = Session;
            collection["format"]  = "sid";
            Query = new Query();
            Query.SetPath("webapi/auth.cgi");
            Query.BuildQueryWithParameters("SYNO.API.Auth", "4", "login", collection);
            NetworkRequest = new NetworkGetRequest(Query.GetUri());
            string jsonResponse = NetworkRequest.SendGetRequest();

            if (NetworkRequest.GetResponseStatusCode())
            {
                AuthenticationAPINetworkResponse networkResponse = APIResult.RetrieveResultsOfBasicAPINetworkResponse(jsonResponse);
                var entry = networkResponse.Data.Where(a => a.Key == "sid").ToList();
                if (entry.Count > 0)
                {
                    return(entry.First().Value);
                }
            }
            return(String.Empty);
        }
Beispiel #2
0
 public bool ConfirmConnectivity()
 {
     Query.CreateStandardConnectivityTest();
     NetworkRequest = new NetworkGetRequest(Query.GetUri());
     NetworkRequest.SendGetRequest();
     return(NetworkRequest.GetResponseStatusCode());
 }
Beispiel #3
0
        private void InitiateCollection()
        {
            query.CreateGeneralInfoQuery();
            NetworkGetRequest             networkRequest = new NetworkGetRequest(query.GetUri());
            string                        response       = networkRequest.SendGetRequest();
            APIGeneralInfoNetworkResponse apiResponse    = APIResult.RetrieveResultsOfGeneralInfoNetworkResponse(response);

            Collection = apiResponse.Data;
        }
Beispiel #4
0
        public bool Logout()
        {
            NameValueCollection collection = new NameValueCollection();

            collection["session"] = Session;
            Query.SetPath("webapi/auth.cgi");
            Query.BuildQueryWithParameters("SYNO.API.Auth", "4", "logout", collection);
            NetworkRequest = new NetworkGetRequest(Query.GetUri());
            NetworkRequest.SendGetRequest();
            return(NetworkRequest.GetResponseStatusCode());
        }
Beispiel #5
0
        public List <SharedFileOrFolderInfo> GetAllFieldsFromFolder(string SID)
        {
            query = new Query();
            query.SetPath("webapi/entry.cgi");
            NameValueCollection collection = new NameValueCollection();

            collection["folder_path"] = Info.Path;
            collection["_sid"]        = SID;
            query.BuildQueryWithParameters("SYNO.FileStation.List", FileStationAPI.APIVersions["SYNO.FileStation.List"], "list", collection);
            request = new NetworkGetRequest(query.GetUri());
            string jsonResponse = request.SendGetRequest();
            List <SharedFileOrFolderInfo> FilesAndFolders = APIResult.RetrieveResultsOfFileLevelListNetworkResponse(jsonResponse).Data.Files;

            return(FilesAndFolders.Where(a => !a.IsDirectory).ToList());
        }
Beispiel #6
0
        public StartFolderSearchResponse StartFolderSearch(string SID)
        {
            query = new Query();
            query.SetPath("webapi/entry.cgi");
            NameValueCollection collection = new NameValueCollection();

            collection["folder_path"] = Info.Path;
            collection["_sid"]        = SID;
            query.BuildQueryWithParameters(FileStationSearch, FileStationAPI.APIVersions[FileStationSearch], "start", collection);
            request = new NetworkGetRequest(query.GetUri());
            string jsonResponse = request.SendGetRequest();
            StartFolderSearchResponse startResponse = APIResult.RetrieveResultsOfStartFolderNetworkResponse(jsonResponse);

            TaskID = startResponse.GetTaskID();
            return(APIResult.RetrieveResultsOfStartFolderNetworkResponse(jsonResponse));
        }
Beispiel #7
0
        public string GetAllFilesFromSearch(string SID)
        {
            if (String.IsNullOrEmpty(TaskID))
            {
                StartFolderSearch(SID);
                return("Commencing Search");
            }
            query = new Query();
            query.SetPath("webapi/entry.cgi");
            NameValueCollection collection = new NameValueCollection();

            collection["taskid"] = TaskID;
            collection["_sid"]   = SID;
            query.BuildQueryWithParameters(FileStationSearch, FileStationAPI.APIVersions[FileStationSearch], "list", collection);
            request = new NetworkGetRequest(query.GetUri());
            string jsonResponse = request.SendGetRequest();

            return(jsonResponse);
        }
Beispiel #8
0
        public TopLevelSharedFolderListInfo RetrieveListOfSharedFolders()
        {
            Query = new Query();
            Query.SetPath("webapi/entry.cgi");
            NameValueCollection collection = new NameValueCollection();

            collection["_sid"] = SID;
            Query.BuildQueryWithParameters(FileStationList, APIVersions[FileStationList], "list_share", collection);
            NetworkRequest = new NetworkGetRequest(Query.GetUri());
            string jsonResponse = NetworkRequest.SendGetRequest();

            if (NetworkRequest.GetResponseStatusCode())
            {
                APITopLevelSharedFoldersNetworkResponse networkResponse = APIResult.RetrieveResultsOfSharedFoldersInfoNetworkResponse(jsonResponse);
                SharedFoldersTopLevelData = networkResponse.Data;
                PopulateSharedFolderCollection(SharedFoldersTopLevelData);
            }
            return(SharedFoldersTopLevelData);
        }