Esempio n. 1
0
        protected override void LoadList()
        {
            Clear();
            _uutDescriptions.Clear();
            List <Document> instruments =
                DocumentManager.GetDocumentsByType((int)dbDocument.DocumentType.UUT_DESCRIPTION);

            foreach (Document document in instruments)
            {
                try
                {
                    UUTDescription ud = UUTDescription.Deserialize(Encoding.UTF8.GetString(document.DocumentContent));
                    _uutDescriptions.Add(ud);
                }
                catch (Exception e)
                {
                    string msg = "";
                    try
                    {
                        var d = new XmlDocument();
                        d.LoadXml(Encoding.UTF8.GetString(document.DocumentContent));
                    }
                    catch (Exception ex)
                    {
                        msg = ex.Message;
                        if (ex.InnerException != null)
                        {
                            msg += Resources.HTML_BR + ex.InnerException.Message;
                        }
                    }
                    LogManager.Error(Resources.Deserialize_document_error, document.name, msg);
                }
            }
            DataToControls();
        }
        private void AddUutDocumentReference(ItemDescriptionReference idr)
        {
            string model  = "";
            string partNo = "";

            var id = idr.Item as DocumentReference;

            if (id != null)
            {
                Document document = DocumentManager.GetDocument(id.uuid);
                if (document != null)
                {
                    string content =
                        StringUtils.RemoveByteOrderMarkUTF8(Encoding.UTF8.GetString(document.DocumentContent));
                    UUTDescription uut = UUTDescription.Deserialize(content);
                    if (uut != null)
                    {
                        model = GetIdentity(uut.Item, model, ref partNo);
                    }
                    var lvi = new ListViewItem(model);
                    lvi.SubItems.Add(partNo);
                    lvi.SubItems.Add(id.uuid);
                    lvi.Tag = idr;
                    uutListControl.Items.Add(lvi);
                }
            }
        }
Esempio n. 3
0
        public static bool EditDocument(IDocumentEditor source, Document _document, string uuid, string documentContent,
                                        bool saveDocumentOnCompletion)
        {
            bool     documentSaved = false;
            Document document      = GetDocument(uuid);

            if (document != null)
            {
                string content = Encoding.UTF8.GetString(_document.DocumentContent);

                switch (document.DocumentType)
                {
                case dbDocument.DocumentType.INSTRUMENT_DESCRIPTION:
                {
                    InstrumentDescription obj =
                        InstrumentDescription.Deserialize(content);
                    OnEditInstrument(source, document, obj, saveDocumentOnCompletion);
                    break;
                }

                case dbDocument.DocumentType.TEST_ADAPTER_DESCRIPTION:
                {
                    TestAdapterDescription1 obj =
                        TestAdapterDescription1.Deserialize(content);
                    OnEditTestAdapter(source, document, obj, saveDocumentOnCompletion);
                    break;
                }

                case dbDocument.DocumentType.TEST_STATION_DESCRIPTION:
                {
                    TestStationDescription11 obj =
                        TestStationDescription11.Deserialize(content);
                    OnEditTestStation(source, document, obj, saveDocumentOnCompletion);
                    break;
                }

                case dbDocument.DocumentType.UUT_DESCRIPTION:
                {
                    UUTDescription obj =
                        UUTDescription.Deserialize(content);
                    OnEditUut(source, document, obj, saveDocumentOnCompletion);
                    break;
                }

                default:
                {
                    MessageBox.Show(
                        string.Format("There is currently no editor available for document type \"{0}\".",
                                      document.DocumentType));
                    break;
                }
                }
            }

            return(documentSaved);
        }
Esempio n. 4
0
        public static UUTDescription FindUut(string uuid)
        {
            UUTDescription uut = null;

            if (!string.IsNullOrWhiteSpace(uuid))
            {
                Document document = DocumentManager.GetDocument(uuid);
                if (document != null && document.DocumentContent != null)
                {
                    uut = UUTDescription.Deserialize(Encoding.UTF8.GetString(document.DocumentContent));
                }
            }
            return(uut);
        }
Esempio n. 5
0
        public static UUTDescription FindUut(ItemDescriptionReference uutReference)
        {
            UUTDescription uut = null;
            string         uuid;

            if (uutReference != null && uutReference.Item is DocumentReference)
            {
                uuid = ((DocumentReference)uutReference.Item).uuid;
                Document document = DocumentManager.GetDocument(uuid);
                if (document != null && document.DocumentContent != null)
                {
                    uut = UUTDescription.Deserialize(Encoding.UTF8.GetString(document.DocumentContent));
                }
            }

            return(uut);
        }
Esempio n. 6
0
        public static UUTDescription GetProjectUUT(string projectName)
        {
            UUTDescription uut      = null;
            string         path     = System.IO.Path.Combine(ATMLContext.TESTSET_PATH, projectName, "atml");
            string         fileName = Path.Combine(path, BuildAtmlFileName(projectName));

            if (File.Exists(fileName))
            {
                uut = UUTDescription.Deserialize(Encoding.UTF8.GetString(FileManager.ReadFile(fileName)));
            }
            else
            {
                foreach (string fileSystemEntry in Directory.GetFileSystemEntries(path, FILTER))
                {
                    uut = UUTDescription.Deserialize(Encoding.UTF8.GetString(FileManager.ReadFile(fileSystemEntry)));
                    break;
                }
            }
            return(uut);
        }
        private void uutListControl_OnFind()
        {
            var selectedUUTs = new List <string>();

            foreach (ListViewItem lvi in uutListControl.Items)
            {
                var itemRef = lvi.Tag as ItemDescriptionReference;
                if (itemRef != null)
                {
                    var docRef = itemRef.Item as DocumentReference;
                    if (docRef != null)
                    {
                        selectedUUTs.Add(docRef.uuid);
                    }
                }
            }
            var form = new DocumentLibrarySelectionForm(selectedUUTs, dbDocument.DocumentType.UUT_DESCRIPTION);

            if (DialogResult.OK == form.ShowDialog())
            {
                Document document = form.SelectedDocument;
                if (document != null)
                {
                    try
                    {
                        UUTDescription uut = UUTDescription.Deserialize(document.Item);
                        if (uut != null)
                        {
                            AddUutDocumentReference(uut);
                        }
                    }
                    catch (Exception e)
                    {
                        LogManager.SourceError(ATMLReader.SOURCE, e);
                    }
                }
            }
        }
Esempio n. 8
0
 public static UUTDescription GetUutFromFile(string fileName)
 {
     return(UUTDescription.Deserialize(StringUtils.RemoveByteOrderMarkUTF8(Encoding.UTF8.GetString(FileManager.ReadFile(fileName)))));
 }