Ejemplo n.º 1
0
        public Stream GetStagedInputFile(string name, string inputName)
        {
            OutgoingWebResponseContext ctx = WebOperationContext.Current.OutgoingResponse;
            var e = DataMarshal.GetStagedInputFile(name, inputName);

            if (e == null)
            {
                var detail = new ErrorDetail(
                    ErrorDetail.Codes.DATAFORMAT_ERROR,
                    String.Format("simulation \"{0}\" input \"{1}\" does not exist", name, inputName)
                    );
                throw new WebFaultException <ErrorDetail>(detail,
                                                          System.Net.HttpStatusCode.NotFound);
            }
            if (e.Content == null)
            {
                return(new MemoryStream());
            }
            ctx.ContentType = "text/plain";
            if (e.InputFileType != null && e.InputFileType.Type != null)
            {
                ctx.ContentType = e.InputFileType.Type;
            }
            ctx.StatusCode = System.Net.HttpStatusCode.OK;
            return(new MemoryStream(e.Content));
        }
Ejemplo n.º 2
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="name">Simulation Name</param>
        /// <param name="inputName">input Name</param>
        /// <returns>Contents of input file</returns>
        public Stream GetStagedInputFile(string nameOrID, string inputName)
        {
            Debug.WriteLine(String.Format("GetStagedInputFile: {0}/input/{1}", nameOrID, inputName), this.GetType().Name);
            //OutgoingWebResponseContext ctx = WebOperationContext.Current.OutgoingResponse;
            Guid simulationid = Guid.Empty;
            bool isGuid       = Guid.TryParse(nameOrID, out simulationid);

            var e = DataMarshal.GetStagedInputFile(nameOrID, inputName, isGuid);

            if (e == null)
            {
                var detail = new ErrorDetail(
                    ErrorDetail.Codes.DATAFORMAT_ERROR,
                    String.Format("simulation \"{0}\" input \"{1}\" does not exist", nameOrID, inputName)
                    );
                throw new WebFaultException <ErrorDetail>(detail,
                                                          System.Net.HttpStatusCode.NotFound);
            }
            if (e.Content == null)
            {
                return(new MemoryStream());
            }
            this.OutgoingWebResponseContext_ContentType = "text/plain";
            if (e.InputFileType != null)
            {
                this.OutgoingWebResponseContext_ContentType = e.InputFileType;
            }
            this.OutgoingWebResponseContext_StatusCode = System.Net.HttpStatusCode.OK;
            return(new MemoryStream(e.Content));
        }