/// <summary> /// Publish the specified file. /// </summary> /// <param name="stream">The stream.</param> /// <param name="publishedPath">Where to publish the file.</param> public void PublishFile(Stream stream, String publishedPath) { String uri = this.session + "publish" + publishedPath; CloudRequest request = new CloudRequest(); request.PerformURLPOST(uri, stream); }
/// <summary> /// Validate the session. /// </summary> /// <param name="failOnError">True if an exception should be thrown on error.</param> public void ValidateSession(bool failOnError) { int max; if (failOnError) { max = 1; } else { max = 5; } for (int i = 0; i < max; i++) { CloudRequest request = new CloudRequest(); request.PerformURLGET(false, this.session); if ("success".Equals(request.Status)) { return; } } if (failOnError) { throw new EncogCloudError("Connection lost"); } }
/// <summary> /// Logout of the specified session. /// </summary> public void Logout() { CloudRequest request = new CloudRequest(); request.PerformURLGET(false, this.session + "logout"); this.session = null; }
/// <summary> /// Connect to the Encog cloud. /// </summary> /// <param name="uid">The user id.</param> /// <param name="pwd">The password.</param> public void Connect(String uid, String pwd) { CloudRequest request = new CloudRequest(); IDictionary <String, String> args = new Dictionary <String, String>(); args["uid"] = uid; args["pwd"] = pwd; request.PerformURLPOST(false, ConstructService("login"), args); if (!"success".Equals(request.Status)) { throw new EncogCloudError(request.Message); } this.session = request.Session; }
/// <summary> /// Set the status for this task. /// </summary> /// <param name="status">The status for this task.</param> public void SetStatus(String status) { if (this.taskURL == null) { throw new EncogCloudError("Can't set status for inactive task."); } CloudRequest request = new CloudRequest(); String url = this.taskURL + "update"; IDictionary <String, String> args = new Dictionary <String, String>(); args["status"] = status; request.PerformURLPOST(true, url, args); }
/// <summary> /// Setup this task. /// </summary> /// <param name="name">The name of this task.</param> public void Init(String name) { if (this.cloud.Session == null) { throw new EncogCloudError( "Session must be established before a task is created."); } CloudRequest request = new CloudRequest(); String url = this.cloud.Session; url += "task/create"; IDictionary<String, String> args = new Dictionary<String, String>(); args["name"] = name; args["status"] = "Starting..."; request.PerformURLPOST(false, url, args); this.taskURL = this.cloud.Session + "task/" + request.GetResponseProperty("id") + "/"; }
/// <summary> /// Setup this task. /// </summary> /// <param name="name">The name of this task.</param> public void Init(String name) { if (this.cloud.Session == null) { throw new EncogCloudError( "Session must be established before a task is created."); } CloudRequest request = new CloudRequest(); String url = this.cloud.Session; url += "task/create"; IDictionary <String, String> args = new Dictionary <String, String>(); args["name"] = name; args["status"] = "Starting..."; request.PerformURLPOST(false, url, args); this.taskURL = this.cloud.Session + "task/" + request.GetResponseProperty("id") + "/"; }
/// <summary> /// Stop this task. /// </summary> /// <param name="finalStatus">The final status for this task.</param> public void Stop(String finalStatus) { if (this.taskURL == null) { throw new EncogCloudError("Can't stop inactive task."); } // send final status CloudRequest request = new CloudRequest(); String url = this.taskURL + "update"; IDictionary <String, String> args = new Dictionary <String, String>(); args["status"] = finalStatus; request.PerformURLPOST(false, url, args); // stop url = this.taskURL + "stop"; request = new CloudRequest(); request.PerformURLGET(false, url); }
/// <summary> /// Connect to the Encog cloud. /// </summary> /// <param name="uid">The user id.</param> /// <param name="pwd">The password.</param> public void Connect(String uid, String pwd) { CloudRequest request = new CloudRequest(); IDictionary<String, String> args = new Dictionary<String, String>(); args["uid"] = uid; args["pwd"] = pwd; request.PerformURLPOST(false, ConstructService("login"), args); if (!"success".Equals(request.Status)) { throw new EncogCloudError(request.Message); } this.session = request.Session; }
/// <summary> /// Stop this task. /// </summary> /// <param name="finalStatus">The final status for this task.</param> public void Stop(String finalStatus) { if (this.taskURL == null) { throw new EncogCloudError("Can't stop inactive task."); } // send final status CloudRequest request = new CloudRequest(); String url = this.taskURL + "update"; IDictionary<String, String> args = new Dictionary<String, String>(); args["status"] = finalStatus; request.PerformURLPOST(false, url, args); // stop url = this.taskURL + "stop"; request = new CloudRequest(); request.PerformURLGET(false, url); }
/// <summary> /// Set the status for this task. /// </summary> /// <param name="status">The status for this task.</param> public void SetStatus(String status) { if (this.taskURL == null) { throw new EncogCloudError("Can't set status for inactive task."); } CloudRequest request = new CloudRequest(); String url = this.taskURL + "update"; IDictionary<String, String> args = new Dictionary<String, String>(); args["status"] = status; request.PerformURLPOST(true, url, args); }