/// <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();
                }
            }
        }
예제 #2
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");
                }
            }
        }