Example #1
0
        /// <summary>
        ///     Creates a new instance of the Doc parameter's type passed; merged/automapped/overlayed with another instance of
        ///     that same type constructed straight from the current template.xml located in the ~/form/{DocTypeName}/template.xml
        ///     of this application. Other properties specific not defined in the template.xml's text specific to this solution's
        ///     BaseDoc super-class & the current HttpContext are also inflated.
        /// </summary>
        /// <param name="DocSrc"></param>
        /// <param name="Doc"></param>
        /// <param name="DocKeys"></param>
        /// <param name="RelayUrl"></param>
        /// <param name="ProcessTemplate"></param>
        /// <returns></returns>
        public virtual object Create(out string DocSrc, object Doc, Dictionary <string, string> DocKeys = null, string RelayUrl = null, bool ProcessTemplate = true)
        {
            string DocTypeName = ((BaseDoc)Doc).DocTypeName;

            // apply ~/form/{DocTypeName}/template.xml values to document passed into us
            if (ProcessTemplate)
            {
                Doc = PropertyOverlay.Overlay(Doc, DocInterpreter.Instance.Create(DocTypeName));
            }


            if (DocKeys != null)
            {
                if (DocKeys.Count > 0)
                {
                    ((IDocIdentifiers)Doc).DocId = DocKey.DocIdFromKeys(DocKeys);
                }
            }

            //TODO:need to type-safe all the "object Doc" parameter methods
            ((BaseDoc)Doc).DocChecksum = CalcDocChecksum((BaseDoc)Doc);

            DocSrc = Nav.ToUrl((BaseDoc)Doc, RelayUrl);

            return(Doc);
        }
Example #2
0
 /// <summary>
 ///     simple helper method to assign values from a DocProcessingInstruction type to a BaseDoc
 /// </summary>
 /// <param name="dstBaseDoc"></param>
 /// <param name="pi"></param>
 /// <param name="DocTypeName"></param>
 /// <param name="DocRev"></param>
 /// <returns></returns>
 public static BaseDoc SetPI(BaseDoc dstBaseDoc, DocProcessingInstructions pi, string DocTypeName = null, string DocRev = null)
 {
     dstBaseDoc                 = (BaseDoc)PropertyOverlay.Overlay(pi, dstBaseDoc);
     dstBaseDoc.DocTypeName     = DocTypeName ?? pi.DocTypeName;
     dstBaseDoc.solutionVersion = DocRev ?? pi.solutionVersion;
     return(dstBaseDoc);
 }
Example #3
0
        /// <summary>
        ///     Creates a new instance of the Doc parameter's type passed; merged/automapped/overlayed with another instance of
        ///     that same type constructed straight from the current template.xml located in the ~/form/{DocTypeName}/template.xml
        ///     of this application. Other properties specific not defined in the template.xml's text specific to this solution's
        ///     BaseDoc super-class & the current HttpContext are also inflated.
        /// </summary>
        /// <param name="DocSrc"></param>
        /// <param name="Doc"></param>
        /// <param name="DocKeys"></param>
        /// <param name="RelayUrl"></param>
        /// <param name="ProcessTemplate"></param>
        /// <returns></returns>
        public virtual BaseDoc Create(BaseDoc Doc, string RelayUrl = null, bool ProcessTemplate = true)
        {
            string DocTypeName = Doc.DocTypeName;

            // apply ~/form/{DocTypeName}/template.xml values to document passed into us
            if (ProcessTemplate)
            {
                Doc = PropertyOverlay.Overlay(Doc, DocInterpreter.Instance.Create(DocTypeName));
            }

            //TODO:need to type-safe all the "object Doc" parameter methods
            Doc.DocChecksum = DocInterpreter.Instance.CalcDocChecksum(Doc);

            Doc.DocSrc = Nav.ToUrl(Doc, RelayUrl);

            return(Doc);
        }
Example #4
0
        /// <summary>
        /// </summary>
        /// <param name="DocData"></param>
        /// <param name="DocRevStrict"></param>
        /// <returns></returns>
        public BaseDoc Read(string DocData, bool DocRevStrict = false)
        {
            if (String.IsNullOrWhiteSpace(DocData))
            {
                return(null);
            }

            string
                CollapsedElementsDocXml = CollapseDefaultValueElements(DocData),
                DocTypeName             = ReadDocTypeName(DocData),
                DocRev = ReadRevision(DocData);

            BaseDoc dstBaseDoc = null;

            Type BaseDocType = Runtime.ActivateBaseDoc(
                DocTypeName,
                DocRevStrict
                    ? DocRev
                    : TemplateController.Instance.TopDocRev(DocTypeName)).GetType();

            try
            {
                dstBaseDoc = XsdIntEgerFixDstBaseDocKnownTypes.Contains(BaseDocType)
                                 ? TryXsdIntEgerFixDstBaseDoc(DocRevStrict, DocTypeName, DocRev, CollapsedElementsDocXml, BaseDocType)
                                 : (BaseDoc)Serialization.ReadObject(CollapsedElementsDocXml, BaseDocType);
                //} catch (InvalidOperationException)
            }
            catch (Exception)
            {
                dstBaseDoc = TryXsdIntEgerFixDstBaseDoc(DocRevStrict, DocTypeName, DocRev, CollapsedElementsDocXml, BaseDocType);

                if (dstBaseDoc == null)
                {
                    throw;
                }

                XsdIntEgerFixDstBaseDocKnownTypes.Add(dstBaseDoc.GetType());
            }

            dstBaseDoc = (BaseDoc)PropertyOverlay.Overlay(ReadDocPI(CollapsedElementsDocXml), dstBaseDoc);

            return(dstBaseDoc);
        }