Ejemplo n.º 1
0
        /// <summary>
        ///     Persists changes to LuceneController & SqlController
        /// </summary>
        /// <param name="DocTypeName"></param>
        /// <param name="DocId"></param>
        /// <param name="DocStatus"></param>
        /// <param name="RelayUrl"></param>
        /// <returns></returns>
        public virtual LightDoc Status(string DocTypeName, string DocId, bool DocStatus, string DocSubmittedBy, string RelayUrl = null)
        {
            LightDoc _LightDoc = LuceneController.Status(DocTypeName, DocId, DocStatus, DocSubmittedBy, RelayUrl);

            StartNewTask(() => SqlController.Status(DocTypeName, DocId, DocStatus, DocSubmittedBy, RelayUrl));
            return(_LightDoc);
        }
Ejemplo n.º 2
0
        /// <summary>
        ///     useful to understand what a LightDoc for a DOCREV's principle "Target Doc Type Name" is actually represents.
        /// </summary>
        /// <param name="lightdoc">LightDoc for a DOCREV document</param>
        /// <returns>
        ///     for IDocRev_Gen2's: TargetDocTypeVer, IDocRev_Gen1's: DocTypeVer, anything not actually a DOCREV
        ///     representative will simple be the DocTypeName
        /// </returns>
        public static string GetTargetDocName(this LightDoc lightdoc)
        {
            Dictionary <string, string> _DocKeys = lightdoc.GetDocKeys();

            return(_DocKeys.ContainsKey("TargetDocTypeName")
                       ? _DocKeys["TargetDocTypeName"]
                       : _DocKeys.ContainsKey("DocTypeName")
                             ? _DocKeys["DocTypeName"]
                             : lightdoc.DocTypeName);
        }
Ejemplo n.º 3
0
        /// <summary>
        ///     useful to understand what a LightDoc for a DOCREV's principle "Target Doc Type Name" is actually represents.
        /// </summary>
        /// <param name="lightdoc">LightDoc for a DOCREV document</param>
        /// <returns>
        ///     for IDocRev_Gen2's: TargetDocTypeVer, IDocRev_Gen1's: DocTypeVer, null if we are not dealing with a DOCREV
        ///     LightDoc listing item
        /// </returns>
        public static string GetTargetDocVer(this LightDoc lightdoc)
        {
            Dictionary <string, string> _DocKeys = lightdoc.GetDocKeys();

            return(_DocKeys.ContainsKey("TargetDocTypeVer")
                       ? _DocKeys["TargetDocTypeVer"]
                       : _DocKeys.ContainsKey("DocTypeVer")
                             ? _DocKeys["DocTypeVer"]
                             : null);
        }
Ejemplo n.º 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);
        }
Ejemplo n.º 5
0
        /// <summary>
        ///     Persists changes to LuceneController & SqlController without running validation checks
        /// </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 Import(string DocData, string DocSubmittedBy = null, string RelayUrl = null, bool?DocStatus = null, DateTime?SubmittedDate = null, Dictionary <string, string> DocKeys = null, string DocTitle = null)
        {
            //DocData = PIRewrite(DocData, DocStatus, SubmittedDate, DocKeys, DocTitle);
            LightDoc _LightDoc = LuceneController.Submit(DocData, DocSubmittedBy, RelayUrl, DocStatus, SubmittedDate, DocKeys, DocTitle);

            //when not in debug mode perform SQL operations on another thread since they seem to be costly
            SqlController.Submit(DocData, DocSubmittedBy, RelayUrl, DocStatus, SubmittedDate, DocKeys, DocTitle);
            if (_LightDoc.DocTypeName == "DOCREV")
            {
                BaseDoc _BaseDoc = DocInterpreter.Instance.Create(_LightDoc.GetTargetDocName());
                _BaseDoc.DocIdKeys = new Dictionary <string, string> {
                    { "DefaultAsOfDate", DateTime.UtcNow.ToShortDateString() }
                };
                SqlController.Submit(_BaseDoc.GetDocData(), "*****@*****.**");
            }
            return(_LightDoc);
        }
Ejemplo n.º 6
0
 public static Dictionary <string, string> GetDocKeys(this LightDoc lightdoc)
 {
     return(DocKey.DocIdToKeys(lightdoc.DocId));
 }