Beispiel #1
0
        /// <summary>
        ///     locate versions of what were once physical files utilizing form/DocTypeName/VersionNumber/*.*
        ///     from archives of what was once seen & now compressed as cab in the document database.
        ///     This allows older documents in the field to request resources that deployed a long time ago
        /// </summary>
        /// <param name="context"></param>
        public void ProcessRequest(HttpContext context)
        {
            // ensure the latest content has been processed & imported
            ImporterController.ImportDocModelsRunOnce();

            //TODO:move ~/web.config ManifestRewrite_Integrated & ManifestRewrite_Classic structures to ~/form/web.config so there is no need for this manifest.xsf httphandler switching logic section to
            if (context.Request.Url.ToString().ToLower().EndsWith("manifest.xsf"))
            {
                new ManifestRewriter().ProcessRequest(context);
            }
            else
            {
                string filename;
                using (MemoryStream _MemoryStream = TemplateController.Instance.OpenRead(context, out filename))
                {
                    context.Response.DisableKernelCache();
                    context.Response.Clear();
                    context.Response.ClearContent();
                    context.Response.ClearHeaders();

                    _MemoryStream.CopyTo(context.Response.OutputStream);

                    context.Response.ContentType = MimeExtensionHelper.GetMimeType(filename);
                    context.Response.AddHeader("content-disposition", "attachment; filename=\"" + filename + "\";");
                }
            }
        }
Beispiel #2
0
        /// <summary>
        ///     Types that can be actively served via WCF as "new" documents. There types must have a folder representation in the
        ///     file system. This list is cached internally. Before the list is constructed models and other contents are processed
        ///     & imported to the nosql database.
        /// </summary>
        /// <returns>current DocTypeNames known to this system</returns>
        public static List <Type> DocTypeServedItems()
        {
            return(CacheMan.Cache(() =>
            {
                ImporterController.ImportDocModelsRunOnce();

                return Directory
                .EnumerateDirectories(FilesystemTemplateController.DirectoryPath)
                .Select(path => new DirectoryInfo(path).Name)
                .Select(DocTypeName => DocInterpreter.Instance.Create(DocTypeName).GetType())
                .ToList();
            }, false, "DocTypes"));
        }
Beispiel #3
0
        /// <summary>
        ///     DocFileName changes the filename of the response
        /// </summary>
        /// <param name="context"></param>
        public void ProcessRequest(HttpContext context)
        {
            try
            {
                // ensure the latest content has been processed & imported
                ImporterController.ImportDocModelsRunOnce();

                string docData = Nav.FromQueryParameters(context.Request.Params);

                IDocTextInterpreter       _IDocDataInterpreter       = DocInterpreter.LocateInstance(docData);
                DocProcessingInstructions _DocProcessingInstructions = _IDocDataInterpreter.ReadDocPI(docData);
                _DocProcessingInstructions.href = BuildHref(context, _IDocDataInterpreter, _DocProcessingInstructions.DocTypeName, _DocProcessingInstructions.solutionVersion);

                docData = _IDocDataInterpreter.WritePI(docData, _DocProcessingInstructions);

                context.Response.DisableKernelCache();
                context.Response.Clear();
                context.Response.ClearContent();
                context.Response.ClearHeaders();
                context.Response.ContentType = _IDocDataInterpreter.ContentType;
                context.Response.AddHeader(
                    "content-disposition",
                    string.Format(
                        "attachment; filename=\"{0}\";",
                        GetFilename(
                            _DocProcessingInstructions,
                            _IDocDataInterpreter,
                            context.Request.Params["ContentFileExtension"])));

                context.Response.Write(docData);
            } catch (Exception ex)
            {
                context.Response.ClearHeaders();
                context.Response.ClearContent();
                context.Response.Status                 = "500 Internal Server Error";
                context.Response.StatusCode             = 500;
                context.Response.StatusDescription      = string.Format("500 Internal Server Error:\n{0}", ex.AsString());
                context.Response.TrySkipIisCustomErrors = true;
            }
        }