Ejemplo n.º 1
0
        private void btnImportCapabilityDocument_Click(object sender, EventArgs e)
        {
            String      xml;
            String      fileName;
            DocumentDAO dao = DataManager.getDocumentDAO();

            if (FileManager.OpenXmlFile(out xml, out fileName))
            {
                Capabilities1 capabilities = Capabilities1.Deserialize(xml);
                String        uuid         = capabilities.uuid;
                String        name         = capabilities.name;
                String        version      = capabilities.version;
                var           document     = new dbDocument();
                bool          isNew        = !dao.hasDocument(uuid);
                _documentReference.DocumentContent = Encoding.UTF8.GetBytes(xml);
                _documentReference.DocumentType    = dbDocument.DocumentType.CAPABILITY_LIBRARY;
                _documentReference.DocumentName    = document.documentName;
                _documentReference.ContentType     = document.contentType;
                if (capabilityListControl.InstrumentDescription != null &&
                    !capabilityListControl.InstrumentDescription.HasDoument(document.UUID.ToString()))
                {
                    Document doc = GetDocument(document, xml);
                    capabilityListControl.InstrumentDescription.AddDocument(doc);
                }
                else if (capabilityListControl.TestAdapterDescription != null &&
                         !capabilityListControl.TestAdapterDescription.HasDoument(document.UUID.ToString()))
                {
                    Document doc = GetDocument(document, xml);
                    capabilityListControl.TestAdapterDescription.AddDocument(doc);
                }
                else if (capabilityListControl.TestStationDescription != null &&
                         !capabilityListControl.TestStationDescription.HasDoument(document.UUID.ToString()))
                {
                    Document doc = GetDocument(document, xml);
                    capabilityListControl.TestStationDescription.AddDocument(doc);
                }
            }
        }
Ejemplo n.º 2
0
        private void DataToControls()
        {
            if (_documentReference != null)
            {
                Document document = null;

                edtName.Value    = _documentReference.ID;
                edtVersion.Value = "";
                edtUUID.Value    = _documentReference.uuid;
                if (DocumentManager.HasDocument(_documentReference.uuid))
                {
                    document = DocumentManager.GetDocument(_documentReference.uuid);
                    String        xml          = Encoding.UTF8.GetString(document.DocumentContent);
                    Capabilities1 capabilities = Capabilities1.Deserialize(xml);
                    capabilityListControl.CapabilityItems = capabilities.Items;
                    _documentReference.DocumentContent    = Encoding.UTF8.GetBytes(xml);
                    _documentReference.DocumentType       = dbDocument.DocumentType.CAPABILITY_LIBRARY;
                    _documentReference.DocumentName       = document.name;
                    _documentReference.ContentType        = document.ContentType;
                    if (capabilityListControl.InstrumentDescription != null &&
                        !capabilityListControl.InstrumentDescription.HasDoument(document.uuid))
                    {
                        capabilityListControl.InstrumentDescription.AddDocument(document);
                    }
                    else if (capabilityListControl.TestAdapterDescription != null &&
                             !capabilityListControl.TestAdapterDescription.HasDoument(document.uuid))
                    {
                        capabilityListControl.TestAdapterDescription.AddDocument(document);
                    }
                    else if (capabilityListControl.TestStationDescription != null &&
                             !capabilityListControl.TestStationDescription.HasDoument(document.uuid))
                    {
                        capabilityListControl.TestStationDescription.AddDocument(document);
                    }
                }
            }
        }