예제 #1
0
        public static string GetFilename(string docData)
        {
            IDocTextInterpreter       _IDocDataInterpreter       = DocInterpreter.LocateInstance(docData);
            DocProcessingInstructions _DocProcessingInstructions = _IDocDataInterpreter.ReadDocPI(docData);

            return(GetFilename(_DocProcessingInstructions, _IDocDataInterpreter));
        }
예제 #2
0
        internal static string PIRewrite(string DocData, bool?DocStatus = null, DateTime?SubmittedDate = null, Dictionary <string, string> DocKeys = null, string DocTitle = null, String DocSubmittedBy = null)
        {
            //TODO:Rethink this logic & relocate it somewhere better
            if (DocKeys != null || !string.IsNullOrWhiteSpace(DocTitle) || DocStatus != null || !string.IsNullOrWhiteSpace(DocSubmittedBy))
            {
                DocProcessingInstructions _DocProcessingInstructions = DocInterpreter.Instance.ReadDocPI(DocData);

                if (DocKeys != null)
                {
                    _DocProcessingInstructions.DocIdKeys = DocKeys;
                }

                if (DocStatus != null)
                {
                    _DocProcessingInstructions.DocStatus = DocStatus;
                }

                if (!string.IsNullOrWhiteSpace(DocTitle))
                {
                    _DocProcessingInstructions.DocTitle = DocTitle;
                }

                if (!string.IsNullOrWhiteSpace(DocSubmittedBy))
                {
                    _DocProcessingInstructions.DocSubmittedBy = DocSubmittedBy;
                }

                DocData = DocInterpreter.Instance.WritePI(DocData, _DocProcessingInstructions);
            }
            return(DocData);
        }
예제 #3
0
 private static string GetFilename(DocProcessingInstructions _DocProcessingInstructions, IDocTextInterpreter _IDocDataInterpreter, string ContentFileExtension = null)
 {
     return(string.Format(
                "{0}.{1}",
                FileSystem.CleanFileName(_DocProcessingInstructions.DocTitle).Trim(),
                string.IsNullOrWhiteSpace(ContentFileExtension)
             ? _IDocDataInterpreter.ContentFileExtension
             : ContentFileExtension));
 }
예제 #4
0
        /// <summary>
        ///     Persists changes to LuceneController & SqlController
        /// </summary>
        /// <param name="DocData"></param>
        /// <param name="DocSubmittedBy"></param>
        /// <param name="RelayUrl"></param>
        /// <param name="SubmittedDate"></param>
        /// <param name="DocKeys"></param>
        /// <param name="DocTitle"></param>
        /// <returns></returns>
        public LightDoc Submit(string DocData, string DocSubmittedBy, string RelayUrl = null, bool?DocStatus = null, DateTime?SubmittedDate = null, Dictionary <string, string> DocKeys = null, string DocTitle = null)
        {
            DocProcessingInstructions _DocProcessingInstructions = DocInterpreter.Instance.ReadDocPI(DocData);
            //TODO:Before production, need to implemented proper way of including signature(s) to calc
            int DocChecksum = CalcDocChecksum(DocData, DocStatus);

            // make sure something has changed since this doc was served up
            if (_DocProcessingInstructions.DocChecksum == DocChecksum)
            {
                throw new NoChangesSinceRenderedException();
            }
            else
            {
                _DocProcessingInstructions.DocChecksum = DocChecksum;
            }

            //TODO:Rethink this logic & relocate it somewhere better
            if (DocKeys != null || !string.IsNullOrWhiteSpace(DocTitle) || DocStatus != null || !string.IsNullOrWhiteSpace(DocSubmittedBy))
            {
                if (DocKeys != null)
                {
                    _DocProcessingInstructions.DocIdKeys = DocKeys;
                }

                if (DocStatus != null)
                {
                    _DocProcessingInstructions.DocStatus = DocStatus;
                }

                if (!string.IsNullOrWhiteSpace(DocTitle))
                {
                    _DocProcessingInstructions.DocTitle = DocTitle;
                }

                if (!string.IsNullOrWhiteSpace(DocSubmittedBy))
                {
                    _DocProcessingInstructions.DocSubmittedBy = DocSubmittedBy;
                }
            }

            DocData = DocInterpreter.Instance.WritePI(DocData, _DocProcessingInstructions);



            // validate the content against it's XSD if it's being "approved" as good captured information for the organization
            // now is a good time to do this as the exception we want the user to see first would have hacazd there chance
            DocInterpreter.Instance.Validate(DocData);
            LightDoc _LightDoc = LuceneController.Submit(DocData, DocSubmittedBy, RelayUrl, DocStatus, SubmittedDate, DocKeys, DocTitle);

            StartNewTask(() => SqlController.Submit(DocData, DocSubmittedBy, RelayUrl, DocStatus, SubmittedDate, DocKeys, DocTitle));
            return(_LightDoc);
        }
예제 #5
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;
            }
        }