public PowerShellResults ProcessRequest(HttpContext context) { Identity identity = Identity.FromIdParameter(context.Request.QueryString["Identity"]); string text = context.Request.QueryString["Name"]; if (identity == null || string.IsNullOrEmpty(identity.RawIdentity)) { throw new BadQueryParameterException("Identity"); } if (string.IsNullOrEmpty(text)) { throw new BadQueryParameterException("Name"); } context.Response.ContentType = "text/csv"; context.Response.AddHeader("Content-Disposition", string.Format("attachment; filename=\"{0}\"", HttpUtility.UrlEncode(text))); Dictionary <string, object> dictionary = new Dictionary <string, object>(); dictionary["CsvStream"] = context.Response.OutputStream; DDIParameters properties = new DDIParameters { Parameters = new JsonDictionary <object>(dictionary) }; IDDIService iddiservice = (IDDIService) new WebServiceReference(EcpUrl.EcpVDirForStaticResource + "DDI/DDIService.svc?schema=MigrationReport&workflow=ExportMigrationReport").ServiceInstance; PowerShellResults powerShellResults = iddiservice.SingleObjectExecute(identity, properties); if (this.IsValidUserError(powerShellResults)) { powerShellResults = new PowerShellResults(); } return(powerShellResults); }
public PowerShellResults ProcessRequest(HttpContext context) { string text = context.Request.QueryString["identity"]; if (string.IsNullOrEmpty(text)) { throw new BadQueryParameterException("identity"); } PowerShellResults <JsonDictionary <object> > powerShellResults = null; Stream outputStream = context.Response.OutputStream; try { context.Response.ContentType = "text/plain"; context.Response.AddHeader("Content-Disposition", string.Format("attachment; filename=\"{0}\"", HttpUtility.UrlEncode(Strings.MigrationUserReportFileName + "_" + text + ".txt"))); context.Response.ContentEncoding = Encoding.UTF8; context.Response.Charset = "utf-8"; outputStream.Write(new byte[] { 239, 187, 191 }, 0, 3); byte[] bytes = Encoding.UTF8.GetBytes(new string('', 256).ToCharArray()); outputStream.Write(bytes, 0, bytes.Length); IDDIService iddiservice = (IDDIService) new WebServiceReference(EcpUrl.EcpVDirForStaticResource + "DDI/DDIService.svc?schema=MigrationBatchUser&workflow=DownloadReport").ServiceInstance; powerShellResults = iddiservice.SingleObjectExecute(new Identity(text), null); if (context.Response.IsClientConnected) { if (powerShellResults.Succeeded) { this.OutputSucceedResults(outputStream, powerShellResults); } else { this.OutputFailedResults(outputStream, powerShellResults); powerShellResults.ErrorRecords = new ErrorRecord[0]; } } } catch (IOException innerException) { throw new BadRequestException(innerException); } catch (HttpException innerException2) { throw new BadRequestException(innerException2); } finally { if (outputStream != null) { outputStream.Close(); } } return(powerShellResults); }