示例#1
0
        //-----------------------------------------------------------------------------------------------

        //Gets the XML representing a job
        private static string XmlFromJob(GJob job)
        {
            XmlStringWriter xsw = new XmlStringWriter();

            xsw.Writer.WriteStartElement("job");
            xsw.Writer.WriteAttributeString("id", job.Id.ToString());
            xsw.Writer.WriteStartElement("input");
            xsw.Writer.WriteFullEndElement(); // close input
            xsw.Writer.WriteStartElement("work");
            xsw.Writer.WriteFullEndElement(); // close work
            xsw.Writer.WriteStartElement("output");

            foreach (EmbeddedFileDependency fileDep in job.OutputFiles)
            {
                xsw.Writer.WriteStartElement("embedded_file");
                xsw.Writer.WriteAttributeString("name", fileDep.FileName);
                xsw.Writer.WriteString(fileDep.Base64EncodedContents);
                xsw.Writer.WriteFullEndElement(); // close embedded_file element
            }

            xsw.Writer.WriteEndElement(); // close output
            xsw.Writer.WriteEndElement(); // close task

            return(xsw.GetXmlString());
        }
示例#2
0
        //Gets the XML representing a job
        private static string XmlFromJob(GJob job)
        {
            XmlStringWriter xsw = new XmlStringWriter();

            xsw.Writer.WriteStartElement("job");
            xsw.Writer.WriteAttributeString("id", job.Id.ToString());
            xsw.Writer.WriteStartElement("input");
            xsw.Writer.WriteFullEndElement(); // close input
            xsw.Writer.WriteStartElement("work");
            xsw.Writer.WriteFullEndElement(); // close work
            xsw.Writer.WriteStartElement("output");

            foreach (EmbeddedFileDependency fileDep in job.OutputFiles)
            {
                xsw.Writer.WriteStartElement("embedded_file");
                xsw.Writer.WriteAttributeString("name", fileDep.FileName);
                xsw.Writer.WriteString(fileDep.Base64EncodedContents);
                xsw.Writer.WriteFullEndElement(); // close embedded_file element
            }

            /*
             * //in the new API for GJob, the stderr, stdout are properties.
             * //put them into XML as output elements
             */
            //stdout
            xsw.Writer.WriteStartElement("embedded_file");
            xsw.Writer.WriteAttributeString("name", "stdout.txt");
            xsw.Writer.WriteString(Utils.EncodeBase64(job.Stdout));
            xsw.Writer.WriteFullEndElement(); // close embedded_file element
            logger.Debug("Stdout " + job.Stdout);

            //stderr
            xsw.Writer.WriteStartElement("embedded_file");
            xsw.Writer.WriteAttributeString("name", "stderr.txt");
            xsw.Writer.WriteString(Utils.EncodeBase64(job.Stderr));
            xsw.Writer.WriteFullEndElement(); // close embedded_file element
            logger.Debug("Stderr " + job.Stderr);

            //log
            xsw.Writer.WriteStartElement("embedded_file");
            xsw.Writer.WriteAttributeString("name", "log.txt");
            xsw.Writer.WriteString(Utils.EncodeBase64(job.Log));
            xsw.Writer.WriteFullEndElement(); // close embedded_file element
            logger.Debug("Log " + job.Log);

            xsw.Writer.WriteEndElement(); // close output
            xsw.Writer.WriteEndElement(); // close task

            return(xsw.GetXmlString());
        }
示例#3
0
        //-----------------------------------------------------------------------------------------------

        /// <summary>
        /// Gets the finished jobs as an xml string
        /// </summary>
        /// <param name="manager"></param>
        /// <param name="sc">security credentials used to perform this operation</param>
        /// <param name="taskId"></param>
        /// <returns>XML string representing the job</returns>
        public static string GetFinishedJobs(IManager manager, SecurityCredentials sc, string taskId)
        {
            byte[][] FinishedThreads = manager.Owner_GetFinishedThreads(sc, taskId);

            XmlStringWriter xsw = new XmlStringWriter();

            xsw.Writer.WriteStartElement("task");
            xsw.Writer.WriteAttributeString("id", taskId);

            for (int i = 0; i < FinishedThreads.Length; i++)
            {
                GJob job = (GJob)Utils.DeserializeFromByteArray(FinishedThreads[i]);
                xsw.Writer.WriteRaw("\n" + CrossPlatformHelper.XmlFromJob(job) + "\n");
                logger.Debug("Writing thread:" + job.Id);
            }
            xsw.Writer.WriteEndElement(); // close job

            return(xsw.GetXmlString());
        }