ATMLDataAccessLibrary.db.daos.DocumentDAO.hasDocument C# (CSharp) 메소드

hasDocument() 공개 메소드

public hasDocument ( String uuid ) : bool
uuid String
리턴 bool
        public bool hasDocument(String uuid)
        {
            Int32 count = 0;
            String sql = "SELECT count(*) FROM " + DocumentBean._TABLE_NAME + " WHERE " + DocumentBean._UUID + "=?";
            OleDbParameter[] parameters = {new OleDbParameter(DocumentBean._UUID, Guid.Parse(uuid))};
            OleDbDataReader reader = ExecuteSqlQuery(sql, parameters);
            if (reader != null)
            {
                if (reader.Read())
                {
                    count = reader.GetInt32(0);
                }
                reader.Close();
                reader.Dispose();
            }
            return count > 0;
        }

Same methods

DocumentDAO::hasDocument ( string fileName, int documentType ) : bool

Usage Example

        public void Save()
        {
            string content = Serialize();
            var document = new dbDocument();
            var dao = new DocumentDAO();
            bool documentExists = dao.hasDocument(uuid);
            //if( !documentExists )
            //    LogManager.Trace("Creating new Test Adapter Description with uuid of {0}", uuid);
            //else
            //    LogManager.Trace("Saving Test Adapter Description with uuid of {0}", uuid);

            document.contentType = "text/xml";
            document.documentDescription = "Test Adapter";
            document.documentName = Identification.ModelName;
            document.documentVersion = version;
            document.documentSize = content.Length;
            document.documentTypeId = (int) dbDocument.DocumentType.TEST_ADAPTER_DESCRIPTION;
            document.documentContent = Encoding.UTF8.GetBytes(content);
            document.UUID = Guid.Parse(uuid);
            document.DataState = documentExists ? BASEBean.eDataState.DS_EDIT : BASEBean.eDataState.DS_ADD;
            document.save();

            foreach (IdentificationNumber idNumber in Identification.IdentificationNumbers)
            {
                string type = Enum.GetName(typeof (IdentificationNumberType), idNumber.type);
                string number = idNumber.number;
                var asset = new AssetIdentificationBean();
                asset.assetNumber = number;
                asset.assetType = type;
                asset.uuid = Guid.Parse(uuid);
                asset.DetermineDataState();
                asset.save();
            }
        }