Esempio n. 1
0
        private void awbDropListTree_SignalSelected(object sender, XmlDocument tsfDocument)
        {
            var signal = sender as dbSignal;

            _currentSignalModel = sender as SignalModel;
            try
            {
                HourGlass.Start();
                Clear();
                if (!LoadSignalModel(signal))
                {
                    if (!LoadSignalModel(_currentSignalModel))
                    {
                        XmlNode node = SignalManager.Instance.SignalTree.SelectSingleNode("");
                        //--- ============================================================ ---//
                        //--- TODO: Determine what to do if the Signal Model does not load ---//
                        //--- ============================================================ ---//
                    }
                }
            }
            finally
            {
                HourGlass.Stop();
            }
        }
        private void ValidateToSchema()
        {
            HourGlass.Start();
            var error = new StringBuilder(1024 * 1024 * 6);
            InstrumentDescription instrument = InstrumentDescription;

            try
            {
                if (!SchemaManager.ValidateXml(instrument.Serialize(), ATMLCommon.InstrumentNameSpace, error))
                {
                    HourGlass.Stop();
                    string name = GetName(instrument);
                    ATMLErrorForm.ShowValidationMessage(
                        string.Format("The \"{0}\" Instrument has failed validation against the {1} ATML schema.", name,
                                      ATMLCommon.InstrumentNameSpace),
                        error.ToString(), "Note: This error will not prevent you from continuing.");
                }
                else
                {
                    HourGlass.Stop();
                    MessageBox.Show(@"This Instrument generated valid ATML");
                }
            }
            catch (Exception)
            {
                HourGlass.Stop();
            }
        }
 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();
     }
 }
Esempio n. 4
0
        /**
         * Physically remove the project from the project folder. The project must be opened
         * on order to delete it. If the user accepts the verification to delete the project
         * the project will be unloaded then all folders and files will be removed. This process
         * does NOT remove any related files from the document library.
         */
        public static void DeleteProject()
        {
            TestProgramSet testSet = Instance.CurrentTestProgramSet;

            if (testSet != null)
            {
                string testSetName = testSet.TestSetName;
                string fullName    = testSet.TestSetDirectory.FullName;
                if (DialogResult.Yes ==
                    MessageBox.Show(
                        string.Format("Are you sure you want to delete Test Set Project \"{0}\"?", testSetName),
                        @"V E R I F Y",
                        MessageBoxButtons.YesNo, MessageBoxIcon.Question))
                {
                    HourGlass.Start();
                    try
                    {
                        CloseProject();
                        GC.Collect();
                        if (FileManager.DeleteDirectory(fullName, true))
                        {
                            LogManager.Trace("Test Set Project \"{0}\" has been deleted.", testSetName);
                        }
                    }
                    catch (Exception err)
                    {
                        LogManager.Error(err.Message);
                    }
                    finally
                    {
                        HourGlass.Stop();
                    }
                }
            }
        }
Esempio n. 5
0
 private void btnTranslateAIXML_Click(object sender, EventArgs e)
 {
     try
     {
         HourGlass.Start();
         _translator.TranslateAIXML();
     }
     catch (Exception err)
     {
         LogManager.SourceError(ATMLTranslator.SOURCE, err);
         throw;
     }
     finally
     {
         HourGlass.Stop();
     }
 }
Esempio n. 6
0
        public static void ImportTestProgramSet()
        {
            String testSetPath = ATMLContext.TESTSET_PATH;
            var    dlg         = new OpenFileDialog();

            dlg.DefaultExt = ATMLContext.TESTSET_ARCHIVE_EXT;
            if (DialogResult.OK == dlg.ShowDialog())
            {
                string name = dlg.SafeFileName;
                name = name.Substring(0, name.LastIndexOf(".", StringComparison.Ordinal));
                string path = Path.Combine(testSetPath, name);

                bool ok2save     = true;
                bool hasExisting = false;
                if (Directory.Exists(path))
                {
                    hasExisting = true;
                    ok2save     = DialogResult.Yes ==
                                  MessageBox.Show(
                        "Test Program Set \"" + name + "\" already exists. Would you like to over write it?",
                        "V E R I F Y", MessageBoxButtons.YesNo, MessageBoxIcon.Question);
                }
                if (ok2save)
                {
                    HourGlass.Start();
                    try
                    {
                        CloseProject();
                        ZipFile zip = ZipFile.Read(dlg.FileName);
                        zip.ExtractAll(path, ExtractExistingFileAction.OverwriteSilently);
                        LogManager.Trace("The Test Program Set has been unarchived to \"{0}\"", path);
                        OpenProject(name);
                    }
                    catch (Exception exception)
                    {
                        LogManager.Error(exception);
                    }
                    finally
                    {
                        HourGlass.Stop();
                    }
                }
            }
        }
Esempio n. 7
0
        private void btnBuildSignalMap_Click(object sender, EventArgs e)
        {
            try
            {
                HourGlass.Start();
                var mapper = new SignalMapper();
                //var xmlPath = (String) ATMLContext.GetProperty( "translator.parser.xml-path" );
                string projectName = ProjectManager.ProjectName;
                if (string.IsNullOrEmpty(projectName))
                {
                    throw new Exception("You must open a project in order to map signals.");
                }
                //string projectPath = Path.Combine( ATMLContext.TESTSET_PATH, projectName );
                string xmlPath = Path.Combine(ATMLContext.ProjectTranslatorAixmlPath, projectName + ".aixml.xml");
                if (!File.Exists(xmlPath))
                {
                    throw new TranslationException("Mapping Failed: Missing AIXML File.");
                }

                mapper.Process(FileManager.ReadFile(xmlPath));

                var form = new ATMLSignalMappingForm(mapper.UsedSignalsList)
                {
                    TreeModel = SignalManager.Instance.TSFSignalTree
                };
                HourGlass.Stop();
                form.ShowDialog(this);
            }
            catch (Exception err)
            {
                LogManager.SourceError(ATMLTranslator.SOURCE, err);
            }
            finally
            {
                HourGlass.Stop();
            }
        }
Esempio n. 8
0
        private void awbDropListTree_SignalSelected(object sender, XmlDocument tsfDocument)
        {
            var signal = sender as dbSignal;

            _currentSignalModel = sender as SignalModel;
            var bscName = sender as string;

            try
            {
                HourGlass.Start();
                Clear();
                if (!string.IsNullOrWhiteSpace(bscName))
                {
                }
                else if (!LoadSignalModel(signal, tsfDocument))
                {
                    LoadSignalModel(_currentSignalModel, tsfDocument);
                }
            }
            finally
            {
                HourGlass.Stop();
            }
        }
Esempio n. 9
0
 private void btnAnalyze_Click(object sender, EventArgs e)
 {
     HourGlass.Start();
     try{ ATMLAllocator.Instance.AnalyzeRequiredSignals(edtTestDescription.Text); }
     finally{ HourGlass.Stop(); }
 }
Esempio n. 10
0
        protected void EditSelectedObject(Type _type, String dataObjectName)
        {
            if (HasSelected)
            {
                HourGlass.Start();
                ListViewItem lvi = SelectedListViewItem;
                if (_openForms.ContainsKey(SelectedListViewItem))
                {
                    Form f = _openForms[SelectedListViewItem];
                    if (f.IsDisposed)
                    {
                        _openForms.Remove(SelectedListViewItem);
                    }
                    else
                    {
                        _openForms[SelectedListViewItem].Focus();
                        HourGlass.Stop();
                        return;
                    }
                }

                object instance = Activator.CreateInstance(_type);
                if (instance is ATMLForm)
                {
                    var form = (ATMLForm)instance;
                    form.Tag = SelectedListViewItem;
                    if (!form.IsDisposed)
                    {
                        OnInitializeForm(form);
                        if (!string.IsNullOrWhiteSpace(_formTitle))
                        {
                            form.Text = @"Change " + _formTitle;
                        }

                        RegisterForm(form);
                        _openForms.Add(SelectedListViewItem, form);
                        PropertyInfo pi = form.GetType().GetProperty(dataObjectName);
                        if (pi == null)
                        {
                            throw new Exception("Invalid Object Name: " + dataObjectName);
                        }
                        if (SelectedObject is BASEBean)
                        {
                            ((BASEBean)SelectedObject).DataState = BASEBean.eDataState.DS_EDIT;
                        }
                        else if (SelectedObject is ATMLCommon)
                        {
                            ((ATMLCommon)SelectedObject).DataState = BASEBean.eDataState.DS_EDIT;
                        }
                        pi.SetValue(form, SelectedObject, null);
                        form.Saved += delegate(object sndr, EventArgs ee)
                        {
                            try
                            {
                                var f = sndr as Form;
                                if (f != null)
                                {
                                    pi = f.GetType().GetProperty(dataObjectName);
                                    if (pi == null)
                                    {
                                        throw new Exception("Invalid Object Name: " + dataObjectName);
                                    }
                                    object obj = pi.GetValue(f, null);
                                    if (obj == null)
                                    {
                                        throw new Exception(
                                                  string.Format("Invalid Data Object Value: {0} in form: {1}",
                                                                dataObjectName, f.Text));
                                    }
                                    int idx = 0;
                                    foreach (string fieldName in _fieldNames)
                                    {
                                        Type         objType = obj.GetType();
                                        PropertyInfo piField = objType.GetProperty(fieldName);
                                        if (piField == null && !"Type".Equals(fieldName) &&
                                            !"ToString()".Equals(fieldName))
                                        {
                                            throw new Exception("Invalid Field Name: " + fieldName);
                                        }
                                        object fieldValue = "ToString()".Equals(fieldName)
                                                                ? obj.ToString()
                                                                : (piField == null && "Type".Equals(fieldName)
                                                                       ? obj.GetType().Name
                                                                       : piField != null
                                                                             ? piField.GetValue(obj, null)
                                                                             : null);
                                        string value = GetFieldValue(fieldValue);
                                        if (lvi != null)
                                        {
                                            ListViewItem.ListViewSubItem subItem = lvi.SubItems[idx++];
                                            if (subItem != null)
                                            {
                                                subItem.Text = value;
                                            }
                                        }
                                    }
                                    if (lvi != null)
                                    {
                                        lvi.Tag = obj;
                                    }
                                    //ValidateToSchema(obj);
                                    OnCompletedEdit(obj);
                                }
                            }
                            catch (Exception err)
                            {
                                MessageBox.Show(@"Error: " + err.Message, @"E R R O R");
                                LogManager.Error(err);
                            }
                        };

                        form.Closed += delegate(object sndr, EventArgs ee)
                        {
                            _openForms.Remove((ListViewItem)form.Tag);
                            UnRegisterForm((Form)sndr);
                            if (ee is FormClosedEventArgs)
                            {
                                var f = (Form)sndr;
                                pi = f.GetType().GetProperty(dataObjectName);
                            }
                        };
                        form.Show();
                    }
                }
                HourGlass.Stop();
            }
        }
Esempio n. 11
0
        private void SaveSelectedSignalModel()
        {
            HourGlass.Start();
            try
            {
                SignalDAO dao = DataManager.getSignalDAO();
                if (_signalModelLibrary != null)
                {
                    dao.DeleteTSFLibrary(_signalModelLibrary.TSFLibrary.uuid,
                                         _signalModelLibrary.TSFLibrary.targetNamespace);
                    var library = new dbTSFLibrary();
                    library.IncludeKeyOnInsert = true;
                    library.lastUpdate         = DateTime.UtcNow;
                    library.id              = Guid.Parse(_signalModelLibrary.TSFLibrary.uuid);
                    library.content         = _signalModelLibrary.XmlContent;
                    library.targetNamespace = _signalModelLibrary.TSFLibrary.targetNamespace;
                    library.libraryName     = _signalModelLibrary.TSFLibrary.name;
                    library.DataState       = (!dao.hasTSFLibrary(_signalModelLibrary.TSFLibrary.uuid))
                                            ? BASEBean.eDataState.DS_ADD
                                            : BASEBean.eDataState.DS_EDIT;
                    library.save();

                    foreach (SignalModel sm in _signalModelLibrary.SignalModels.Values)
                    {
                        TSFType  tsf        = sm.TSF;
                        dbSignal dataSignal = dao.getSignal(sm.Name, library.targetNamespace);
                        if (dataSignal == null)
                        {
                            //Add Signal to the database

                            string   baseSignalName = sm.BaseSignalName;
                            dbSignal baseSignal     = dao.getSignal(baseSignalName, sm.BaseSignalNameSpace);
                            dataSignal = new dbSignal();
                            dataSignal.ParentSignal = baseSignal;
                            dataSignal.signalName   = sm.Name;
                            dataSignal.uuid         = Guid.Parse(tsf.uuid);
                            dataSignal.xmlns        = library.targetNamespace;
                            foreach (SignalAttribute attribute in sm.Attributes)
                            {
                                var a = new dbSignalAttribute();
                                a.attributeName = attribute.Name;
                                a.defaultValue  = attribute.DefaultValue;
                                a.DataState     = BASEBean.eDataState.DS_ADD;
                                a.type          = attribute.SchemaType;
                                a.fixedValue    = attribute.FixedValue;
                                if (dataSignal.Attributes == null)
                                {
                                    dataSignal.Attributes = new List <dbSignalAttribute>();
                                }
                                dataSignal.Attributes.Add(a);
                            }
                            dataSignal.DataState = BASEBean.eDataState.DS_ADD;
                        }
                        else
                        {
                            dataSignal.xmlns = library.targetNamespace;
                            dataSignal.uuid  = Guid.Parse(tsf.uuid);
                            List <dbSignalAttribute> attributes = dataSignal.Attributes;
                            var attrMap   = new Dictionary <string, SignalAttribute>();
                            var dbAttrMap = new Dictionary <string, dbSignalAttribute>();
                            foreach (SignalAttribute sa in sm.Attributes)
                            {
                                attrMap.Add(sa.Name, sa);
                            }

                            foreach (dbSignalAttribute dbAttribute in attributes)
                            {
                                string an = dbAttribute.attributeName;
                                dbAttrMap.Add(an, dbAttribute);
                                if (attrMap.ContainsKey(an))
                                {
                                    SignalAttribute sa = attrMap[an];
                                    dbAttribute.type         = sa.SchemaType;
                                    dbAttribute.defaultValue = sa.DefaultValue;
                                    dbAttribute.fixedValue   = sa.FixedValue;
                                    dbAttribute.DataState    = BASEBean.eDataState.DS_EDIT;
                                }
                                else
                                {
                                    dbAttribute.DataState = BASEBean.eDataState.DS_DELETE;
                                }
                            }

                            foreach (SignalAttribute sa in sm.Attributes)
                            {
                                if (!dbAttrMap.ContainsKey(sa.Name))
                                {
                                    var dbAttribute = new dbSignalAttribute();
                                    dbAttribute.type         = sa.SchemaType;
                                    dbAttribute.defaultValue = sa.DefaultValue;
                                    dbAttribute.fixedValue   = sa.FixedValue;
                                    dbAttribute.DataState    = BASEBean.eDataState.DS_ADD;
                                    dataSignal.Attributes.Add(dbAttribute);
                                }
                            }
                            dataSignal.DataState = BASEBean.eDataState.DS_EDIT;
                        }
                        dataSignal.xmlns = _signalModelLibrary.TSFLibrary.targetNamespace;
                        dataSignal.save();
                    }

                    foreach (ListViewItem item in lvSignals.Items)
                    {
                        var model = item.Tag as SignalModel;
                        if (model != null)
                        {
                            var signal = new dbTSFSignal();
                            signal.signalName    = model.Name;
                            signal.id            = Guid.Parse(model.TSF.uuid);
                            signal.signalContent = model.TSF.Serialize();
                            signal.libraryUuid   = _signalModelLibrary.TSFLibrary.uuid;
                            signal.DataState     = (!dao.hasTSFSignal(model.TSF.uuid)
                                                     ? BASEBean.eDataState.DS_ADD
                                                     : BASEBean.eDataState.DS_EDIT);
                            signal.lastUpdate = DateTime.UtcNow;
                            try
                            {
                                signal.save();
                            }
                            catch (Exception e)
                            {
                                if (e.Message.ToLower().Contains("duplicate"))
                                {
                                    TestSignalBean otherSignal = dao.getTSFSignal(model.Name,
                                                                                  _signalModelLibrary.TSFLibrary.uuid);
                                    LogManager.Error("UUID Conflict between document data and the database for Signal {0} in Signal Library {1} ",
                                                     model.Name, library.libraryName);
                                    if (otherSignal != null)
                                    {
                                        LogManager.Error("\tDocument signal uuid {0}, Database signal uuid {{{1}}} ",
                                                         model.TSF.uuid, otherSignal.id.ToString().ToUpper());

                                        if (dao.changeTSFSignalId(otherSignal.id, Guid.Parse(model.TSF.uuid)))
                                        {
                                            LogManager.Info(
                                                "The Database signal uuid has been changed to reflect the Document signal uuid");
                                            signal.DataState = BASEBean.eDataState.DS_EDIT;
                                            signal.save();
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }
            catch (Exception e)
            {
                LogManager.Error(e, "An error has occured saving the signal model library: {0}", e.Message);
            }
            finally
            {
                HourGlass.Stop();
                if (_signalModelLibrary == null)
                {
                    MessageBox.Show(Resources.A_Signal_Model_must_be_selected_to_save_);
                }
                else
                {
                    LogManager.Trace(Resources.Completed_Saving_Selected_Signal_Model);
                    MessageBox.Show(Resources.Completed_Saving_Selected_Signal_Model);
                }
            }
        }