public AssetIdentificationBean DetermineDataState()
 {
     var dao = new DocumentDAO();
     if (dao.HasAsset(assetType, assetNumber, uuid.ToString() ) )
         DataState = eDataState.DS_EDIT;
     else
         DataState = eDataState.DS_ADD;
     return this;
 }
 private DataManager()
 {
     equpmentDAO = new EquipmentDAO();
     signalDAO = new SignalDAO();
     helpDAO = new HelpDAO();
     standardUnitMeasurementDAO = new StandardUnitMeasurementDAO();
     lookupTablesDAO = new LookupTablesDAO();
     documentDAO = new DocumentDAO();
     schemaDAO = new SchemaDAO();
 }
 public AssetIdentificationBean DetermineDataState(String type, String number, String uuid)
 {
     assetNumber = number;
     assetType = type;
     this.uuid = Guid.Parse(uuid);
     var dao = new DocumentDAO();
     if (dao.HasAsset(type, number, uuid))
         DataState = eDataState.DS_EDIT;
     else
         DataState = eDataState.DS_ADD;
     return this;
 }
        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();
            }
        }