public bool PingPanorama(string folderPath, string username, string password) { try { var uri = PanoramaUtil.Call(ServerUri, "targetedms", folderPath, "autoQCPing", "", true); using (var webClient = new WebClientWithCredentials(ServerUri, username, password)) { webClient.Post(uri, null); } } catch (WebException ex) { var response = ex.Response as HttpWebResponse; if (response != null && response.StatusCode == HttpStatusCode.NotFound) { return(false); } else { throw; } } return(true); }
public FolderState IsValidFolder(string folderPath, string username, string password) { try { var uri = PanoramaUtil.GetContainersUri(ServerUri, folderPath, false); using (var webClient = new WebClientWithCredentials(username, password)) { var folderInfo = webClient.UploadString(uri, PanoramaUtil.FORM_POST, string.Empty); JToken response = JObject.Parse(folderInfo); // User needs write permissions to publish to the folder if (!PanoramaUtil.CheckFolderPermissions(response)) { return(FolderState.nopermission); } // User can only upload to a TargetedMS folder type. if (!PanoramaUtil.CheckFolderType(response)) { return(FolderState.notpanorama); } } } catch (WebException ex) { var response = ex.Response as HttpWebResponse; if (response != null && response.StatusCode == HttpStatusCode.NotFound) { return(FolderState.notfound); } else { throw; } } return(FolderState.valid); }