protected void saveResult(string OutFile, byte[] res, wsResultType resultType)
 {
     // Text data
     if (resultType.mediaType.StartsWith("text"))
     {
         if (OutFile == "-")
         {
             WriteTextFile(OutFile, res);
         }
         else
         {
             WriteTextFile(OutFile + "." + resultType.identifier + "." + resultType.fileSuffix, res);
         }
     }
     // Binary data
     else
     {
         if (OutFile == "-")
         {
             WriteBinaryFile(OutFile, res);
         }
         else
         {
             WriteBinaryFile(OutFile + "." + resultType.identifier + "." + resultType.fileSuffix, res);
         }
     }
 }
 // Implementation of abstract method (AbsractWsClient.GetResults()).
 /// <summary>Get the job results</summary>
 /// <param name="jobId">Job identifier to get the results from.</param>
 /// <param name="outformat">Selected output format or null for all formats.</param>
 /// <param name="outFileBase">Basename for the output file. If null the jobId will be used.</param>
 public override void GetResults(string jobId, string outformat, string outFileBase)
 {
     PrintDebugMessage("GetResults", "Begin", 1);
     PrintDebugMessage("GetResults", "jobId: " + jobId, 2);
     PrintDebugMessage("GetResults", "outformat: " + outformat, 2);
     PrintDebugMessage("GetResults", "outFileBase: " + outFileBase, 2);
     this.ServiceProxyConnect();             // Ensure we have a service proxy
     // Check status, and wait if not finished
     ClientPoll(jobId);
     // Use JobId if output file name is not defined
     if (outFileBase == null)
     {
         OutFile = jobId;
     }
     else
     {
         OutFile = outFileBase;
     }
     // Get list of data types
     wsResultType[] resultTypes = GetResultTypes(jobId);
     PrintDebugMessage("GetResults", "resultTypes: " + resultTypes.Length + " available", 2);
     // Get the data and write it to a file
     Byte[] res = null;
     if (outformat != null)
     {             // Specified data type
         wsResultType selResultType = null;
         foreach (wsResultType resultType in resultTypes)
         {
             if (resultType.identifier == outformat)
             {
                 selResultType = resultType;
             }
         }
         PrintDebugMessage("GetResults", "resultType:\n" + ObjectValueToString(selResultType), 2);
         res = GetResult(jobId, selResultType.identifier);
         // Text data
         if (selResultType.mediaType.StartsWith("text"))
         {
             if (OutFile == "-")
             {
                 WriteTextFile(OutFile, res);
             }
             else
             {
                 WriteTextFile(OutFile + "." + selResultType.identifier + "." + selResultType.fileSuffix, res);
             }
         }
         // Binary data
         else
         {
             if (OutFile == "-")
             {
                 WriteBinaryFile(OutFile, res);
             }
             else
             {
                 WriteBinaryFile(OutFile + "." + selResultType.identifier + "." + selResultType.fileSuffix, res);
             }
         }
     }
     else
     {             // Data types available
         // Write a file for each output type
         foreach (wsResultType resultType in resultTypes)
         {
             PrintDebugMessage("GetResults", "resultType:\n" + ObjectValueToString(resultType), 2);
             res = GetResult(jobId, resultType.identifier);
             // Text data
             if (resultType.mediaType.StartsWith("text"))
             {
                 if (OutFile == "-")
                 {
                     WriteTextFile(OutFile, res);
                 }
                 else
                 {
                     WriteTextFile(OutFile + "." + resultType.identifier + "." + resultType.fileSuffix, res);
                 }
             }
             // Binary data
             else
             {
                 if (OutFile == "-")
                 {
                     WriteBinaryFile(OutFile, res);
                 }
                 else
                 {
                     WriteBinaryFile(OutFile + "." + resultType.identifier + "." + resultType.fileSuffix, res);
                 }
             }
         }
     }
     PrintDebugMessage("GetResults", "End", 1);
 }
Beispiel #3
0
        // Implementation of abstract method (AbsractWsClient.GetResults()).
        /// <summary>Get the job results</summary>
        /// <param name="jobId">Job identifier to get the results from.</param>
        /// <param name="outformat">Selected output format or null for all formats.</param>
        /// <param name="outFileBase">Basename for the output file. If null the jobId will be used.</param>
        public override void GetResults(string jobId, string outformat, string outFileBase)
        {
            PrintDebugMessage("GetResults", "Begin", 1);
            PrintDebugMessage("GetResults", "jobId: " + jobId, 2);
            PrintDebugMessage("GetResults", "outformat: " + outformat, 2);
            PrintDebugMessage("GetResults", "outFileBase: " + outFileBase, 2);
            this.ServiceProxyConnect();             // Ensure we have a service proxy
            // Check status, and wait if not finished
            ClientPoll(jobId);
            // Use JobId if output file name is not defined
            if (outFileBase == null)
            {
                OutFile = jobId;
            }
            else
            {
                OutFile = outFileBase;
            }
            // Get list of data types
            wsResultType[] resultTypes = GetResultTypes(jobId);
            PrintDebugMessage("GetResults", "resultTypes: " + resultTypes.Length + " available", 2);

            int nchains = GetNChains(jobId);

            // Get the data and write it to a file
            Byte[] res = null;
            if (outformat != null)
            {             // Specified data type
                wsResultType selResultType = null;
                foreach (wsResultType resultType in resultTypes)
                {
                    if (resultType.identifier == outformat)
                    {
                        selResultType = resultType;
                    }
                }
                PrintDebugMessage("GetResults", "resultType:\n" + ObjectValueToString(selResultType), 2);
                res = GetResult(jobId, selResultType.identifier);

                saveResult(OutFile, res, selResultType);
            }
            else
            {               // Data types available
                // Write a file for each output type
                foreach (wsResultType resultType in resultTypes)
                {
                    if (resultType.identifier == "out" || resultType.identifier == "log")
                    {
                        for (int i = 1; i <= nchains; i++)
                        {
                            res = GetResultForChain(jobId, resultType.identifier, i);
                            saveResult(OutFile + "." + i, res, resultType);
                        }
                    }
                    else
                    {
                        PrintDebugMessage("GetResults", "resultType:\n" + ObjectValueToString(resultType), 2);
                        res = GetResult(jobId, resultType.identifier);
                        saveResult(OutFile, res, resultType);
                    }
                }
            }
            PrintDebugMessage("GetResults", "End", 1);
        }