Ejemplo n.º 1
0
        private Document GetDoc(out string DocSrc, string DocTypeName, string DocId = null, string RelayUrl = null, string IndexDirectory = null)
        {
            Dictionary <string, List <string> > _RequiredDocKeys = new Dictionary <string, List <string> >();

            foreach (KeyValuePair <string, string> _Item in DocKey.DocIdToKeys(DocId))
            {
                _RequiredDocKeys[_Item.Key] = new List <string>
                {
                    _Item.Value
                }
            }
            ;

            //TODO:GetDoc needs to query by the exact key, not that a subset of DocKeys exist
            Document _Document = ListDocuments(new List <string>
            {
                DocTypeName
            },
                                               _RequiredDocKeys,
                                               null,
                                               null,
                                               1,
                                               0,
                                               RelayUrl,
                                               IndexDirectory).FirstOrDefault();

            DocSrc = _Document == null
                         ? null
                         : Nav.ToUrl(DocTypeName,
                                     DocId,
                                     RelayUrl);

            return(_Document);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// </summary>
        /// <param name="DocSrc"></param>
        /// <param name="DocKeysFromDocId"></param>
        /// <param name="DocTypeName"></param>
        /// <param name="DocKeys">have precedence over DocId when is not null</param>
        /// <param name="DocId"></param>
        /// <param name="RelayUrl"></param>
        /// <returns></returns>
        public object Get(out string DocSrc, out Dictionary <string, string> DocKeysFromDocId, string DocTypeName, Dictionary <string, string> DocKeys = null, string DocId = null, string RelayUrl = null)
        {
            DocSrc           = null;
            DocKeysFromDocId = new Dictionary <string, string>();
            BaseDoc _BaseDoc = null;
            Dictionary <string, List <string> > _RequiredDocKeys = new Dictionary <string, List <string> >();

            DocKeys = DocKeys ?? DocKey.DocIdToKeys(DocId);

            foreach (KeyValuePair <string, string> _Item in DocKeys)
            {
                _RequiredDocKeys[_Item.Key] = new List <string> {
                    _Item.Value
                }
            }
            ;

            //BUG:DocStatus is not persisted by in the DocData; this band-aid gets it from the LightDoc in order to return it to the calling DataContract method
            foreach (Document _Document in ListDocuments(new List <string> {
                DocTypeName
            }, _RequiredDocKeys, null, null, 1, 0, RelayUrl, DirectoryPath))
            {
                _BaseDoc = DocInterpreter.Instance.Read(_Document.AsDocSubmissions().Last().Value);
                if (_BaseDoc.DocIdKeys.Count == DocKeys.Count)
                {
                    DocSrc           = Nav.ToUrl(DocTypeName, DocId, RelayUrl);
                    DocKeysFromDocId = _BaseDoc.DocIdKeys;
                    // there is a chance the DocStatus may not be set when it comes to items like DOCREV BaseDocType(s)
                    _BaseDoc.DocStatus = bool.Parse(_Document.Get(Parm.DocStatus) ?? Boolean.FalseString);
                    break;
                }
            }

            return(_BaseDoc);
        }