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); } } }
public void FileCreated(object sender, FileSystemEventArgs fileSystemEventArgs) { string fileName = fileSystemEventArgs.FullPath; UUTDescription uut = UutManager.GetUutFromFile(fileName); ProjectManager.ProcessUutChanges(uut); }
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 btnSaveConfiguration_Click(object sender, EventArgs e) { //_editMode = false; //ControlsToData(); SetControlStates(); //OnAtmlAction(TestConfiguration, AtmlActionType.Edit); if (uutListControl.Items.Count > 0) { var lvi = uutListControl.Items[0]; var uutRef = lvi.Tag as ItemDescriptionReference; if (uutRef != null) { var pi = ProjectManager.ProjectInfo; var itemDescription = uutRef.Item as ItemDescription; var docRef = uutRef.Item as DocumentReference; if (itemDescription != null) { pi.UutName = itemDescription.Identification.ModelName; pi.UutId = null; } else if (docRef != null) { UUTDescription uut = UutManager.FindUut(uutRef); pi.UutName = uut.name; pi.UutId = uut.uuid; } ProjectManager.ProjectInfo = pi; } } OnTestConfigurationSaved(TestConfiguration); }
public static void Save(UUTDescription uut) { string uuid; if (uut != null) { string model = uut.Item.Identification.ModelName; string documentName = BuildAtmlFileName(model); uuid = uut.uuid; Document document = DocumentManager.GetDocument(uuid); if (document != null) { document.DocumentContent = Encoding.UTF8.GetBytes(uut.Serialize()); document.DataState = BASEBean.eDataState.DS_EDIT; document.name = documentName; DocumentManager.SaveDocument(document); } else { AssetIdentificationBean bean = new AssetIdentificationBean(); document = new Document(); document.name = documentName; document.DocumentContent = Encoding.UTF8.GetBytes(uut.Serialize()); document.DocumentType = dbDocument.DocumentType.UUT_DESCRIPTION; document.ContentType = "text/xml"; DocumentManager.SaveDocument(document); bean.assetNumber = model; bean.assetType = "Part"; bean.uuid = Guid.Parse(uuid); bean.DataState = BASEBean.eDataState.DS_ADD; bean.save(); } } }
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); }
public static String toATML(CASS_MTPSI tpsi) { StringWriter tw = new StringWriter(); TestConfiguration testConfig = new TestConfiguration(); ManufacturerData configManager = testConfig.ConfigurationManager; List <CASS_MTPSICASS_MTPSI_page> pages = tpsi.CASS_MTPSI_page; foreach (CASS_MTPSICASS_MTPSI_page page in pages) { CASS_MTPSICASS_MTPSI_pageUUT uut = page.UUT; String partNo = uut.UUT_ID.Part_Number; //UUTInstance instance = new UUTInstance(); UUTDescription item = new UUTDescription(); //item.Item.name = uut.UUT_ID.Part_Number; //Lookup UUT Information ItemDescriptionReference reference = new ItemDescriptionReference(); DocumentReference docRef = new DocumentReference(); //docRef.ID = uut.UUT_ID.Part_Number; docRef.uuid = "{SOMEUUIDHERE}"; reference.Item = docRef;// item.Item; //testConfig.TestedUUTs.Add(reference); TestConfigurationTestEquipmentItem testEquipment = new TestConfigurationTestEquipmentItem(); foreach (CASS_MTPSICASS_MTPSI_pageATE_assets asset in page.ATE_assets) { ItemDescriptionReference refEquip = new ItemDescriptionReference(); ItemDescription instrument = new ItemDescription(); instrument.name = asset.Asset_Identifier; refEquip.Item = instrument; //testEquipment.Instrumentation.Add(refEquip); } // testConfig.TestEquipment.Add(testEquipment); try { XmlSerializer serializerObj = new XmlSerializer(typeof(TestConfiguration)); serializerObj.Serialize(tw, testConfig); } catch (Exception e) { Exception ie = e.InnerException; while (ie != null) { Trace.WriteLine(ie.Message); ie = ie.InnerException; } } break; } return(tw.ToString()); }
private static void OnEditUut(IDocumentEditor source, Document document, UUTDescription obj, bool saveDocumentOnCompletion) { bool ret = false; EditDocumentDelegate handler = EditUUT; if (handler != null) { handler(source, document, obj, saveDocumentOnCompletion); } }
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); }
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); }
public static void ProcessUutChanges(UUTDescription uut) { TestProgramSet currentTestProgramSet = Instance.CurrentTestProgramSet; if (currentTestProgramSet != null) { ProjectInfo pi = currentTestProgramSet.ProjectInfo; if (pi != null) { pi.UutId = uut.uuid; pi.UutName = uut.Item.Identification.ModelName; SaveProjectInfo(pi, currentTestProgramSet); } } }
private void AddUutDocumentReference(UUTDescription uut) { var docRef = new DocumentReference(); var document = DocumentManager.GetDocument(uut.uuid); docRef.ID = "UUT" + uutListControl.Items.Count + 1; docRef.uuid = uut.uuid; docRef.DocumentType = document.DocumentType; docRef.DocumentContent = document.DocumentContent; docRef.ContentType = document.ContentType; docRef.DocumentName = document.name; var idr = new ItemDescriptionReference { Item = docRef }; uutListControl.AddListViewObject(idr); }
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); }
public static void Delete(UUTDescription uut) { var dao = new DocumentDAO(); if (!string.IsNullOrWhiteSpace(uut.uuid)) { if (!dao.hasDocument(uut.uuid)) { LogManager.Error("Failed to locate UUT \"{0}\" ({1}) in the document dabase.", uut.name, uut.uuid); } else { var document = new Document(dao.openDatabaseDocument(uut.uuid)); document.DataState = BASEBean.eDataState.DS_DELETE; Save(document); } } }
private void btnValidate_Click(object sender, EventArgs e) { StringBuilder error = new StringBuilder(1024 * 1024 * 6); UUTDescription uut = UUTDescription; if (!SchemaManager.ValidateXml(uut.Serialize(), ATMLCommon.UUTNameSpace, error)) { ATMLErrorForm.ShowValidationMessage( string.Format("The \"{0}\" UUT has failed validation against the {1} ATML schema.", uut.name, ATMLCommon.UUTNameSpace), error.ToString(), "Note: This error will not prevent you from continuing."); } else { MessageBox.Show(@"This UUT generated valid ATML"); } }
public void Edit(Document uutDocument, object obj, bool saveOnCompletion) { UUTDescription uut = obj as UUTDescription; if (uut != null) { UUTDescriptionForm form = new UUTDescriptionForm(); form.UUTDescription = uut; if (DialogResult.OK == form.ShowDialog()) { uut = form.UUTDescription; uutDocument.DocumentContent = Encoding.UTF8.GetBytes(uut.Serialize()); if (saveOnCompletion) { Save(uut); } } } }
/** * To create a new project we need to have a UUT selected - this should be the same UUT identifier located * in the TPSI file. TODO: Should we create a project from the TPSI file - open the TPSI here? */ private void btnSelectUUT_Click(object sender, EventArgs e) { var form = new ATMLLibraryForm(typeof(UUTDescriptionListControl)); if (DialogResult.OK == form.ShowDialog()) { errorProvider1.SetError(edtProjectName, ""); errorProvider1.SetError(edtUUT, ""); _uutDescription = form.SelectedObject as UUTDescription; if (_uutDescription != null) { edtUUT.Value = _uutDescription.ToString(); if (!edtProjectName.HasValue()) { edtProjectName.Value = _uutDescription.Item.Identification.ModelName; } } } }
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); }
public static void CreateProject() { var form = new ATMLProjectCreationForm(); //ObjectNameForm("Create Test Program Set Name"); //form.RegularExpression = @"^([A-Z]|[a-z]|[0-9]|_|-|\.|\s)+$"; if (DialogResult.OK == form.ShowDialog()) { UUTDescription uut = form.UutDescription; CreateProject(form.ProjectInfo); //UutManager.FindUUT() //--- Check if uut exists or not ---// var bean = new AssetIdentificationBean(); bean.assetType = "Part"; bean.assetNumber = uut.name; bean.uuid = Guid.Parse(uut.uuid); //DocumentManager.SaveDocument( new Document()); } }
private static ProjectInfo CreateProjectInfoFile() { var pi = new ProjectInfo(); pi.ProjectName = Instance.CurrentTestProgramSet.TestSetName; pi.Uuid = Guid.NewGuid().ToString(); if (UutManager.ProjectHasUUT(pi.ProjectName)) { UUTDescription uut = UutManager.GetProjectUUT(pi.ProjectName); if (uut != null) { pi.UutName = uut.name; pi.UutId = uut.uuid; } } string fileName = Path.Combine(ATMLContext.TESTSET_PATH, pi.ProjectName, "project-info.xml"); FileManager.WriteFile(fileName, Encoding.UTF8.GetBytes(pi.Serialize())); LogManager.Warn( "Failed to find the project information file so a new file has been created."); return(pi); }
private void ControlsToData() { if (_uut == null) { _uut = new UUTDescription(); } _uut.name = edtName.Text; _uut.version = edtVersion.GetValue <string>(); _uut.uuid = edtUUID.GetValue <string>(); _uut.Classified = securityClassificationControl.Classified; _uut.SecurityClassification = securityClassificationControl.SecurityClassification; if (rbHardware.Checked) { _uut.Item = hardwareUUTControl.HardwareUUT; } else if (rbSoftware.Checked) { _uut.Item = softwareUUTControl.SoftwareUUT; } }
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); } } } }
public void dataToControls(UUTDescription uutDescription) { ItemDescription itemDesc = uutDescription.Item; }
public static UUTDescription GetUutFromFile(string fileName) { return(UUTDescription.Deserialize(StringUtils.RemoveByteOrderMarkUTF8(Encoding.UTF8.GetString(FileManager.ReadFile(fileName))))); }
private static UUTDescription ProcessAction(UUTDescription obj, AtmlActionType actionType, EventArgs args) { IAtmlController <UUTDescription> controller = UUTController.Instance; return(Process(obj, actionType, controller, args)); }