protected void ControlsToData()
 {
     if (_hardwareItemDescription == null)
     {
         _hardwareItemDescription = new HardwareUUT();
     }
     base.ControlsToData();
     //hu.Warnings;
     //hu.StatusCodes;
 }
        public bool HasPowerRquirements(string uuid)
        {
            bool           hasPowerRequirements = false;
            UUTDescription uut = UutManager.FindUut(uuid);

            if (uut != null)
            {
                HardwareUUT hardwareUut = uut.Item as HardwareUUT;
                if (hardwareUut != null)
                {
                    hasPowerRequirements = hardwareUut.PowerRequirements.Count > 0;
                }
            }
            return(hasPowerRequirements);
        }
Esempio n. 3
0
        public string Create(string partNumber, string nomen, string model)
        {
            string      refUUID = null;
            DocumentDAO dao     = DataManager.getDocumentDAO();

            try
            {
                dao.StartTransaction();
                AssetIdentificationBean asset;
                var             description          = new UUTDescription();
                ItemDescription item                 = new HardwareUUT();
                var             identificationNumber = new ManufacturerIdentificationNumber();
                identificationNumber.number           = partNumber;
                identificationNumber.manufacturerName = "[Unknown]";
                identificationNumber.type             = IdentificationNumberType.Part;
                description.name                          = nomen;
                description.uuid                          = Guid.NewGuid().ToString();
                item.Identification                       = new ItemDescriptionIdentification();
                item.Identification.ModelName             = model;
                item.Identification.IdentificationNumbers = new List <IdentificationNumber>();
                item.Identification.IdentificationNumbers.Add(identificationNumber);
                description.Item = item;
                refUUID          = description.uuid;

                //------------------------------------------------------------------------------------//
                //--- Add document to document database                                            ---//
                //--- The UUT is a Model Number Asset so we will use a model name for the filename ---//
                //--- We will also use the ATML Standard number (1671.3) for part of the file name ---//
                //------------------------------------------------------------------------------------//
                string docName = string.Format("{0}{1}",
                                               FileUtils.MakeGoodFileName(model),
                                               ATMLContext.ATML_UUT_FILENAME_SUFFIX);

                var document = new Document();
                document.Description     = description.name;
                document.uuid            = refUUID;
                document.name            = docName;
                document.Item            = description.Serialize();
                document.DocumentContent = Encoding.UTF8.GetBytes(document.Item);
                document.ContentType     = ATMLContext.CONTEXT_TYPE_XML;
                document.DocumentType    = dbDocument.DocumentType.UUT_DESCRIPTION;
                Save(document);

                //----------------------------------------//
                //--- Add reference id to asset lookup ---//
                //----------------------------------------//
                asset             = new AssetIdentificationBean();
                asset.uuid        = Guid.Parse(refUUID);
                asset.assetType   = "Model";
                asset.assetNumber = model;
                asset.DataState   = BASEBean.eDataState.DS_ADD;
                asset.save();

                //Add uut document to atml directory - use part number as file name + 1671.3
                //TODO: Replace with an event
                //ProjectManager.SaveATMLDocument( docName, FileManager.AtmlFileType.AtmlTypeUut, document.DocumentContent,true );

                dao.CommitTransaction();
            }
            catch (Exception e)
            {
                dao.RollbackTransaction();
                throw e;
            }
            finally
            {
                dao.EndTransaction();
            }
            return(refUUID);
        }