An Encog cloud request. Sends a request to the Encog cloud and handles the response.
Ejemplo n.º 1
0
        /// <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);
        }
Ejemplo n.º 2
0
        /// <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");
            }
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Logout of the specified session.
        /// </summary>
        public void Logout()
        {
            CloudRequest request = new CloudRequest();

            request.PerformURLGET(false, this.session + "logout");
            this.session = null;
        }
Ejemplo n.º 4
0
        /// <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;
        }
Ejemplo n.º 5
0
        /// <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);
        }
Ejemplo n.º 6
0
        /// <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") + "/";
        }
Ejemplo n.º 7
0
        /// <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") + "/";
        }
Ejemplo n.º 8
0
        /// <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);
        }
Ejemplo n.º 9
0
 /// <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;
 }
Ejemplo n.º 10
0
        /// <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");
            }
        }
Ejemplo n.º 11
0
        /// <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);

        }
Ejemplo n.º 12
0
 /// <summary>
 /// Logout of the specified session.
 /// </summary>
 public void Logout()
 {
     CloudRequest request = new CloudRequest();
     request.PerformURLGET(false, this.session + "logout");
     this.session = null;
 }
Ejemplo n.º 13
0
        /// <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);
        }
Ejemplo n.º 14
0
        /// <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);

        }