Esempio n. 1
0
        public List <Loan> FindLoansByTaxon(string taxon, bool findOpenLoansOnly)
        {
            taxon = EscapeSearchTerm(taxon, true);

            var sql = @"SELECT DISTINCT L.*, REQ.vchrTitle AS [RequestorTitle], REQ.vchrGivenName AS [RequestorGivenName], REQ.vchrName AS [RequestorName], 
			            REC.vchrTitle AS [ReceiverTitle], REC.vchrGivenName AS [ReceiverGivenName], REC.vchrName AS [ReceiverName],
			            ORIG.vchrTitle AS [OriginatorTitle], ORIG.vchrGivenName AS [OriginatorGivenName], ORIG.vchrName AS [OriginatorName]
		                FROM ((((tblLoan L INNER JOIN tblLoanMaterial LM ON L.intLoanID = LM.intLoanID)
			                LEFT OUTER JOIN tblContact REQ ON L.intRequestorID = REQ.intContactID)
			                LEFT OUTER JOIN tblContact REC ON L.intReceiverID = REC.intContactID)
			                LEFT OUTER JOIN tblContact ORIG ON L.intOriginatorID = ORIG.intContactID)			
		                    WHERE (LM.vchrTaxonName like @taxonName or LM.vchrMaterialDescription like @taxonName)"        ;

            if (findOpenLoansOnly)
            {
                sql += " AND L.bitLoanClosed = 0";
            }
            var mapper = new GenericMapperBuilder <Loan>().build();
            var list   = new List <Loan>();

            SQLReaderForEach(sql, (reader) => {
                list.Add(mapper.Map(reader));
            }, _P("@taxonName", taxon));
            return(list);
        }
        public GenusAvailableName GetGenusAvailableName(int taxonId)
        {
            var mapper = new GenericMapperBuilder <GenusAvailableName>().build();
            GenusAvailableName result = null;

            StoredProcReaderFirst("spGANGet", (reader) => {
                result = mapper.Map(reader);
            }, _P("intBiotaID", taxonId));
            return(result);
        }
        public XMLIOMultimedia GetMultimedia(int mediaId)
        {
            var             mapper = new GenericMapperBuilder <XMLIOMultimedia>().build();
            XMLIOMultimedia ret    = null;

            StoredProcReaderFirst("spXMLExportMultimediaGet", (reader) => {
                ret = mapper.Map(reader);
            }, _P("intMultimediaID", mediaId));

            return(ret);
        }
        public bool UpdateTaxon(XMLImportTaxon taxon)
        {
            string strRankCode;
            string strKingdomCode;
            bool   bRankAdded;
            bool   bKingdomAdded;

            if (!GetRankCodeFromName(taxon.Rank, out strRankCode, out bRankAdded))
            {
                Logger.Debug("Failed to get rank code for taxon: RankName={0}, TaxonGUID={1}", taxon.Rank, taxon.GUID);
                return(false);
            }

            if (!GetKingdomCodeFromName(taxon.Kingdom, out strKingdomCode, out bKingdomAdded))
            {
                Logger.Debug("Failed to get kingdom code for taxon: KingdomName={0}, TaxonGUID={1}", taxon.Kingdom, taxon.GUID);
            }

            var UpdateStr = taxon.UpdateClause + ", chrElemType='" + strRankCode + "'";

            var  mapper    = new GenericMapperBuilder <XMLImportTaxon>().build();
            bool succeeded = false;

            StoredProcReaderFirst("spXMLImportBiotaUpdate", (reader) => {
                mapper.Map(reader, taxon);
                succeeded = true;
            }, _P("vchrBiotaID", taxon.ID), _P("txtUpdateSetClause", UpdateStr));

            if (!succeeded)
            {
                // ErrorMsg = "[BIXMLIOServer.TaxonUpdate()] Failed to update Biota details! (TaxonID=" & TaxonID & ",UpdateStr='" & UpdateStr & "') - " & user.LastError
                return(false);
            }
            else
            {
                return(true);
            }
        }