Exemplo n.º 1
0
        private Document GetDoc(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 DocKeyEncrypter.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();

            return(_Document);
        }
Exemplo 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 BaseDoc Get(string DocTypeName, Dictionary <string, string> DocKeys = null, string DocId = null, string RelayUrl = null)
        {
            BaseDoc _BaseDoc = null;
            Dictionary <string, List <string> > _RequiredDocKeys = new Dictionary <string, List <string> >();

            DocKeys = DocKeys ?? DocKeyEncrypter.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 = _Document.AsDocSubmissions().Last().Key.DocIsBinary
                    ? DocInterpreter.Instance.Read((byte[])_Document.AsDocSubmissions().Last().Value, true)
                    : DocInterpreter.Instance.Read((string)_Document.AsDocSubmissions().Last().Value, true);

                if (_BaseDoc.DocKeys.Count == DocKeys.Count)
                {
                    _BaseDoc.DocSrc = Nav.ToUrl(DocTypeName, DocId, RelayUrl);
                    // 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) ?? bool.FalseString);
                    break;
                }
            }

            return(_BaseDoc);
        }