Exemple #1
0
        /// <summary>Handles the Load event of the Page control.</summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="EventArgs"/> instance containing the event data.</param>
        protected void Page_Load(object sender, EventArgs e)
        {
            GridView.DataSource = null;
            using (JobsService.JobsClient jobsService = new JobsService.JobsClient())
            {
                JobsService.Job[] jobs = jobsService.GetMany(Convert.ToInt32(NumRowsTextBox.Text));

                table = new DataTable();
                table.Columns.Add("Name", typeof(string));
                table.Columns.Add("Status", typeof(string));
                table.Columns.Add("XML", typeof(string));
                table.Columns.Add("URL", typeof(string));

                // Loop through all jobs
                foreach (JobsService.Job job in jobs)
                {
                    if (ShowAllCheckBox.Checked || job.Status != JobsService.StatusEnum.Completed)
                    {
                        DataRow newRow = table.NewRow();
                        table.Rows.Add(newRow);

                        newRow["Name"]   = job.Name;
                        newRow["Status"] = job.Status.ToString();
                        newRow["XML"]    = "XML";
                        newRow["URL"]    = job.URL;
                    }
                }
            }

            GridView.DataSource = table;
            GridView.DataBind();
        }
Exemple #2
0
        /// <summary>Uploads a job specified by the the yield prophet.</summary>
        /// <param name="fileName">The name of the file.</param>
        private void UploadFarm4Prophet(string fileName)
        {
            Farm4Prophet farm4Prophet = Farm4ProphetUtility.Farm4ProphetFromFile(fileName);

            using (JobsService.JobsClient jobsService = new JobsService.JobsClient())
            {
                jobsService.AddFarm4Prophet(farm4Prophet);
            }
        }
Exemple #3
0
        /// <summary>Uploads a job specified by the the yield prophet.</summary>
        /// <param name="fileName">The name of the file.</param>
        private void UploadAPSIM(string fileName)
        {
            XmlDocument doc = new XmlDocument();

            doc.Load(fileName);
            XmlReader reader = new XmlNodeReader(doc.DocumentElement);

            reader.Read();
            XmlSerializer             serial = new XmlSerializer(typeof(List <APSIMSpecification>));
            List <APSIMSpecification> apsim  = (List <APSIMSpecification>)serial.Deserialize(reader);

            using (JobsService.JobsClient jobsService = new JobsService.JobsClient())
            {
                jobsService.AddSimulations(apsim.ToArray());
            }
        }
        /// <summary>
        /// We're about to render the page - search for the soils and write names to the
        /// response. The iPad soil app uses this method.
        /// </summary>
        protected void Page_PreRender(object sender, EventArgs e)
        {
            Response.Clear();

            if (Request.QueryString["Name"] != null)
            {
                using (JobsService.JobsClient jobsService = new JobsService.JobsClient())
                {
                    string          jobName = Request.QueryString["Name"];
                    JobsService.Job job     = jobsService.Get(jobName);

                    if (Request.QueryString["Type"] != null)
                    {
                        string type = Request.QueryString["Type"];
                        if (type == "XML")
                        {
                            Response.ContentType     = "text/xml";
                            Response.ContentEncoding = System.Text.Encoding.UTF8;
                            Response.Output.Write(jobsService.GetJobXML(jobName));
                        }
                        else
                        {
                            Response.ContentType = "text/plain";
                            Response.Output.Write(job.ErrorText);
                        }

                        Response.End();
                    }
                }
            }
            else
            {
                using (JobsService.JobsClient jobsService = new JobsService.JobsClient())
                {
                    string  text = string.Empty;
                    DataSet log  = jobsService.GetLogMessages();
                    foreach (DataRow row in log.Tables[0].Rows)
                    {
                        text += Convert.ToDateTime(row["DATE"]).ToString("yyyy-MM-dd hh:mm:ss tt") + ": " + row["MESSAGE"] + "\r\n";
                    }
                    Response.ContentType = "text/plain";
                    Response.Output.Write(text);

                    Response.End();
                }
            }
        }
Exemple #5
0
        /// <summary>Called when the user clicks an image or link on a particular row of the grid.</summary>
        /// <param name="sender">The sender.</param>
        /// <param name="e">The <see cref="GridViewCommandEventArgs"/> instance containing the event data.</param>
        protected void OnGridRowCommand(object sender, GridViewCommandEventArgs e)
        {
            // Retrieve the row index stored in the
            // CommandArgument property.
            int index = Convert.ToInt32(e.CommandArgument);

            if (e.CommandName == "Status")
            {
                string status = table.Rows[index]["Status"].ToString();
                if (status == "Error")
                {
                    string name = table.Rows[index]["Name"].ToString();
                    using (JobsService.JobsClient jobsService = new JobsService.JobsClient())
                    {
                        JobsService.Job job = jobsService.Get(name);
                        Response.Redirect("ShowJobDetail.aspx?Name=" + name + "&Type=Error");
                    }
                }
            }
            else if (e.CommandName == "XML")
            {
                string name = table.Rows[index]["Name"].ToString();
                Response.Redirect("ShowJobDetail.aspx?Name=" + name + "&Type=XML");
            }
            else if (e.CommandName == "ReRun")
            {
                using (JobsService.JobsClient jobsService = new JobsService.JobsClient())
                {
                    string name = table.Rows[index]["Name"].ToString();
                    jobsService.ReRun(name);
                    Response.Redirect("Main.aspx");
                }
            }
            else if (e.CommandName == "Delete")
            {
                using (JobsService.JobsClient jobsService = new JobsService.JobsClient())
                {
                    string name = table.Rows[index]["Name"].ToString();
                    jobsService.Delete(name);
                    Response.Redirect("Main.aspx");
                }
            }
        }
Exemple #6
0
        /// <summary>Uploads a job specified by the the yield prophet.</summary>
        /// <param name="fileName">The name of the file.</param>
        private void UploadYieldProphet(string fileName)
        {
            YieldProphet yieldProphet = YieldProphetUtility.YieldProphetFromFile(fileName);

            DateTime nowDate = DateTime.Now;

            if (NowEditBox.Text != "")
            {
                nowDate = DateTime.ParseExact(NowEditBox.Text, "d/M/yyyy", CultureInfo.InvariantCulture);
            }

            foreach (Paddock paddock in yieldProphet.Paddock)
            {
                paddock.NowDate = nowDate;
            }

            using (JobsService.JobsClient jobsService = new JobsService.JobsClient())
            {
                jobsService.Add(yieldProphet);
            }
        }