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); }
public bool ConfirmConnectivity() { Query.CreateStandardConnectivityTest(); NetworkRequest = new NetworkGetRequest(Query.GetUri()); NetworkRequest.SendGetRequest(); return(NetworkRequest.GetResponseStatusCode()); }
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()); }
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); }