private void btnValidate_Click(object sender, EventArgs e) { try { var error = new StringBuilder(1024 * 1024 * 6); TestStationDescription11 testStation = TestStationDescription; if (testStation != null) { if (!SchemaManager.ValidateXml(testStation.Serialize(), ATMLCommon.TestStationNameSpace, error)) { ATMLErrorForm.ShowValidationMessage( string.Format( "The \"{0}\" Test Station has failed validation against the ATML {1} schema.", testStation.name, ATMLCommon.TestStationNameSpace), error.ToString(), "Note: This error will not prevent you from continuing."); } else { MessageBox.Show(@"This Test Station generated valid ATML"); } } } catch (Exception err) { LogManager.Error(err); } }
private void SaveTestStation(TestStationDescription11 testStation) { if (testStation != null) { string content = testStation.Serialize(); Document document = DocumentManager.GetDocument(testStation.uuid); if (document != null) { document.DocumentContent = Encoding.UTF8.GetBytes(content); PersistanceController.Save(document); } } }
/** * */ public string InitializeTestStaion(string stationType, string station, string changeNo, string dateEntry, string fst) { string refNo = ""; bool usesRF = false; bool usesCNI = false; bool usesEO = false; bool usesHPDTS = false; bool usesSGMA = false; bool isHybrid = false; bool isRTCass = false; bool isECass = false; stationType = stationType.ToUpper(); station = station.ToUpper(); if (string.IsNullOrWhiteSpace(station)) { station = CASS; } if (string.IsNullOrWhiteSpace(stationType)) { stationType = station; } usesRF = stationType.Contains(RF); usesCNI = stationType.Contains(CNI); usesEO = stationType.Contains(EO); usesHPDTS = stationType.Contains(HPDTS); usesSGMA = stationType.Contains(SGMA); isHybrid = stationType.Contains(HYBRID); isRTCass = stationType.Contains(RTCASS); isECass = stationType.Contains(ECASS); if (!isRTCass && stationType.Contains(CASS)) { station = CASS; } else if (isRTCass) { station = RTCASS; } else if (isECass) { station = ECASS; } else if (isHybrid) { station = HYBRID; } if (usesRF) { station = station + "_" + RF; } if (usesCNI) { station = station + "_" + CNI; } if (usesEO) { station = station + "_" + EO; } if (usesHPDTS) { station = station + "_" + HPDTS; } if (usesSGMA) { station = station + "_" + SGMA; } const string assetType = "Model"; const string contentType = "text/xml"; string documentType = Enum.GetName(typeof(dbDocument.DocumentType), dbDocument.DocumentType.TEST_STATION_DESCRIPTION); AssetIdentificationBean asset = DocumentManager.FindAsset(assetType, station); if (asset != null) { refNo = asset.uuid.ToString(); } else { refNo = DocumentManager.CreateDocumentPlaceHolder ( station, //Part Number assetType, //Asset Type contentType, //Content Type documentType, //Document Type station + " 1671.6 Test Station Description" //Description ); var ts = new TestStationDescription11(); ts.Identification = new ItemDescriptionIdentification(); ts.name = station; ts.uuid = refNo; ts.Identification.ModelName = station; Document document = DocumentManager.GetDocument(refNo); document.DocumentContent = Encoding.UTF8.GetBytes(ts.Serialize()); DocumentManager.SaveDocument(document); } return(refNo); }