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); } }
public void EditDocumentObject() { try { ControlsToData(); if (_document.DataState == BASEBean.eDataState.DS_ADD && string.IsNullOrWhiteSpace(edtItem.Text)) { if (_document.DocumentType == dbDocument.DocumentType.INSTRUMENT_DESCRIPTION) { var instrument = new InstrumentDescription(); instrument.name = edtDocumentName.GetValue <string>(); instrument.uuid = edtUUID.GetValue <string>(); instrument.Description = edtDescription.GetValue <string>(); _document.DocumentContent = Encoding.UTF8.GetBytes(instrument.Serialize()); } edtItem.Text = Encoding.UTF8.GetString(_document.DocumentContent); SaveDocument(); } if (DocumentManager.EditDocument(this, _document, edtUUID.GetValue <string>(), Encoding.UTF8.GetString(_document.DocumentContent), false)) { edtItem.Text = _document.Item; } } catch (Exception e) { ATMLErrorForm.ShowError(e); } }
private void btnValidate_Click(object sender, EventArgs e) { try { HourGlass.Start(); var error = new StringBuilder(1024 * 1024 * 6); if (!SchemaManager.ValidateXml(atmlPreviewPanel.Text, ATMLCommon.TestDescriptionNameSpace, error)) { HourGlass.Stop(); ATMLErrorForm.ShowValidationMessage( string.Format("The Test Description has failed validation against the ATML schema."), error.ToString(), "Note: This error will not prevent you from continuing."); } else { HourGlass.Stop(); MessageBox.Show(@"This Test Description has generated a valid ATML document."); } } finally { HourGlass.Stop(); } }
public void EditDocumentObject() { try { DocumentManager.EditDocument(this, _document, edtUUID.GetValue <string>(), Encoding.UTF8.GetString(_document.DocumentContent), true); } catch (Exception e) { ATMLErrorForm.ShowError(e); } }
public static bool ValidateToSchema(object item) { bool validated = true; HourGlass.Enabled = true; try { //---------------------------------------// //--- Will Validate at the form level ---// //---------------------------------------// //SchemaManager.ValidateToSchema(item); /* * MethodInfo miValidate = item.GetType().GetMethod("Validate"); * if (miValidate == null) * throw new Exception(string.Format("{0} does not support the Validate Method", item.GetType().Name)); * * var errors = new SchemaValidationResult(); * object[] p = { errors }; * miValidate.Invoke(item, p); * if (errors.HasErrors()) * { * ATMLErrorForm.ShowValidationMessage(errors.ErrorMessage, errors.Errors.ToString(), "Note: This error will not prevent you from continuing."); * } * else * { * MessageBox.Show(string.Format( * "This {0} has passed all validation against the ATML Schema.", * item.GetType().Name), @"V a l i d a t i o n", MessageBoxButtons.OK, MessageBoxIcon.Information); * } */ } catch (Exception e) { HourGlass.Enabled = false; validated = false; ATMLErrorForm.ShowValidationMessage( string.Format("{0} has failed validation against the ATML schema.", item == null ? "Unknown" : item.GetType().Name), e.Message, "Note: This error will not prevent you from continuing."); } finally { HourGlass.Enabled = false; } return(validated); }
private void btnValidate_Click(object sender, EventArgs e) { var error = new StringBuilder(1024 * 1024 * 6); TestAdapterDescription1 adapter = TestAdapterDescription; if (!SchemaManager.ValidateXml(adapter.Serialize(), ATMLCommon.TestAdapterNameSpace, error)) { string name = GetName(adapter); ATMLErrorForm.ShowValidationMessage( string.Format("The \"{0}\" Test Adapter has failed validation against the {1} ATML schema.", name, ATMLCommon.TestAdapterNameSpace), error.ToString(), "Note: This error will not prevent you from continuing."); } else { MessageBox.Show(@"This Test Adapter generated valid ATML"); } }