/// <summary> /// Handles request only for manifest.xsf files. A manifest.xsf response requires the URL requested to be written to /// the csd file itself so the remaing files it documents can be downloaded in other requests the Microsoft InfoPath /// Filler application performs. /// </summary> /// <param name="context"></param> public override void ProcessRequest(HttpContext context) { TemplateFileInfo _TemplateFileInfo = TemplateController.ParseTemplateFileInfo(context); if (!_TemplateFileInfo.FileName.Equals(HrefVirtualFilename(_TemplateFileInfo.DocTypeName, _TemplateFileInfo.solutionVersion), StringComparison.InvariantCultureIgnoreCase)) { base.ProcessRequest(context); } else { context.Response.DisableKernelCache(); context.Response.Clear(); context.Response.ClearContent(); context.Response.ClearHeaders(); Regex regPublishUrl = new Regex("(?<=publishUrl=\")(.*?)(?=\")", RegexOptions.Multiline); // The publish URL within this file needs to be updated to the current requested URL for the InfoPath application form to like it //string ManifestPath = context.Request.MapPath(new Uri(RequestPaths.AbsoluteUri).LocalPath); string UrlReferrer_AbsoluteUri = context.Request.UrlReferrer == null ? "" : context.Request.UrlReferrer.AbsoluteUri; string filename; string[] lines = TemplateController.Instance.OpenText(context, out filename) .Split('\n', '\r'); // render the publishUrl as the calling request or that of a registered listener string publishUrl = UrlReferrer_AbsoluteUri.Contains("/" + ReverseProxy.DirectoryName) ? UrlReferrer_AbsoluteUri : RequestPaths.AbsoluteUri; context.Response.ClearContent(); for (int i = 0; i < lines.Length; i++) { context.Response.Write( regPublishUrl.IsMatch(lines[i]) ? regPublishUrl.Replace(lines[i], publishUrl) : lines[i]); } context.Response.ContentType = "text/xml"; } }
public virtual void ProcessRequest(HttpContext context) { // ensure the latest content has been processed & imported ImporterController.TryDocRevImporting(); TemplateFileInfo _TemplateFileInfo = TemplateController.ParseTemplateFileInfo(context); if (!string.IsNullOrWhiteSpace(_TemplateFileInfo.DocTypeName) && !string.IsNullOrWhiteSpace(_TemplateFileInfo.solutionVersion) && !string.IsNullOrWhiteSpace(_TemplateFileInfo.FileName)) { // serve a supporting template file up (the the target Interpreter may need to alter it in some way, qazi-dynamic) InstanceLocatorByName <DocBaseInterpreter>(_TemplateFileInfo.DocTypeName, _TemplateFileInfo.solutionVersion) .ProcessRequest(context); } else { // serve a filled & stored document rendered previously context.Response.DisableKernelCache(); context.Response.Clear(); context.Response.ClearContent(); context.Response.ClearHeaders(); object docData; if (context.Request.Params.AllKeys.Any(m => m == Parm.DocId.ToString())) { docData = DocExchange.LuceneController.GetDocData( context.Request.Params[Parm.DocTypeName], context.Request.Params[Parm.DocId], HttpUtility.UrlDecode(context.Request.Params[Parm.RelayUrl]), long.Parse(context.Request.Params[Parm.LogSequenceNumber] ?? "0")); } else { docData = ((BaseDoc)(context.Request.Params.AllKeys.Any(m => m == Parm.DocCache) ? HttpRuntime.Cache[context.Request.Params[Parm.DocCache]] : Compressor.DecompressFromBase64String(HttpUtility.UrlDecode(context.Request.Params[Parm.DocBin])) .FromBytes <BaseDoc>())); } DocBaseInterpreter _DocBaseInterpreter = null; DocProcessingInstructions _DocProcessingInstructions; //TODO:need to tidy up this code block as its really hard to follow.. In the end, that docData may be a POCO, raw bytes or text... Need to rewrites it's PI here before it's shoved over the repsonse.stream if (docData is BaseDoc) { // get the interpreter & convert docData from poco to its raw form _DocBaseInterpreter = InstanceLocatorByName <DocBaseInterpreter>(((BaseDoc)docData).DocTypeName, ((BaseDoc)docData).solutionVersion); if (_DocBaseInterpreter is DocByteInterpreter) { docData = ((DocByteInterpreter)_DocBaseInterpreter).WriteByte((BaseDoc)docData); } else { docData = ((DocTextInterpreter)_DocBaseInterpreter).WriteText((BaseDoc)docData); } } if (docData is byte[]) { _DocBaseInterpreter = _DocBaseInterpreter ?? LocateInstance((byte[])docData); _DocProcessingInstructions = Instance.ReadDocPI((byte[])docData); docData = Instance.ModPI((byte[])docData, href: DocBaseInterpreter.BuildHref(context, _DocProcessingInstructions.DocTypeName, _DocProcessingInstructions.solutionVersion)); context.Response.BinaryWrite((byte[])docData); } else { _DocBaseInterpreter = _DocBaseInterpreter ?? LocateInstance((string)docData); _DocProcessingInstructions = Instance.ReadDocPI((string)docData); docData = Instance.ModPI((string)docData, href: DocBaseInterpreter.BuildHref(context, _DocProcessingInstructions.DocTypeName, _DocProcessingInstructions.solutionVersion)); context.Response.Write((string)docData); } context.Response.ContentType = _DocBaseInterpreter.ContentInfo.ContentType; context.Response.AddHeader( "content-disposition", string.Format( "attachment; filename=\"{0}\";", DocBaseInterpreter.GetFilename(_DocProcessingInstructions, context.Request.Params["ContentFileExtension"]))); } }