예제 #1
0
 private DataManager()
 {
     equpmentDAO = new EquipmentDAO();
     signalDAO = new SignalDAO();
     helpDAO = new HelpDAO();
     standardUnitMeasurementDAO = new StandardUnitMeasurementDAO();
     lookupTablesDAO = new LookupTablesDAO();
     documentDAO = new DocumentDAO();
     schemaDAO = new SchemaDAO();
 }
 public static void Save( string uuid, Capabilities capabilities )
 {
     SignalDAO dao = new SignalDAO();
     List<object> items = capabilities.Items;
     if (items != null)
     {
         foreach (object item in items)
         {
             Capability capability = item as Capability;
             DocumentReference documentReference = item as DocumentReference;
             if (capability != null)
                 ProcessCapability(uuid, capability);
             if( documentReference != null )
                 ProcessDocumentReference(uuid, documentReference);
         }
     }
 }
예제 #3
0
 public SignalMapper()
 {
     _signalDao = new SignalDAO();
     _signalMappingDao = new SignalMappingDAO();
 }
        private void signalComboBox_SelectedIndexChanged( object sender, EventArgs e )
        {
            try
            {
                HourGlass.Enabled = true;
                SignalModel signalModel = awbDropListTree.SelectedSignalModel;
                if (signalModel != null )
                {
                    var signal = signalModel.Signal;  //signalComboBox.SelectedItem as dbSignal;
                    if (signal != null)
                    {
                        //---------------------------------------------------//
                        //--- Find "name" in data grid and set it's value ---//
                        //---------------------------------------------------//
                        foreach (DataGridViewRow row in signalAttributes.Rows)
                        {
                            if (row.IsNewRow)
                                continue;

                            var name = row.Cells[0].Value as string;
                            var type = row.Cells[1].Value as string;
                            var value = row.Cells[2].Value as string;
                            if ("type".Equals( name ))
                            {
                                row.Cells[1].Value = edtName.Text;
                                break;
                            }
                        }
                        signalAttributes.Rows.Clear();

                        if (string.IsNullOrEmpty( edtName.Text ))
                            edtName.Text = signal.name;
                        var dao = new SignalDAO();
                        dbSignal dataSignal = dao.getSignal( signal.name, signalModel.SignalNameSpace );

                        string xmlns = signalModel.SignalNameSpace;
                        XmlSchemaComplexType complexType;
                        XmlSchemaElement element = null;
                        SchemaManager.GetComplexType( xmlns, signal.name, out complexType );
                        if (complexType == null)
                            SchemaManager.GetElement( xmlns, signal.name, out element );
                        if (complexType != null || element != null)
                        {
                            signalAttributes.Rows.Clear();
                            List<XmlSchemaAttribute> schemaAttributes = complexType != null
                                                                            ? SchemaManager.GetAttributes( complexType )
                                                                            : SchemaManager.GetAttributes( element );
                            List<dbSignalAttribute> dbAttributes = dao.getAllSignalAttributes( signal.name, signalModel.SignalNameSpace );
                            var foundAttributes = new Dictionary<string, dbSignalAttribute>();
                            foreach (dbSignalAttribute attribute in dbAttributes)
                            {
                                foundAttributes.Add( attribute.attributeName, attribute );
                                object value = null;
                                try
                                {
                                    if (_signalFunctionType != null)
                                    {
                                        PropertyInfo pi =
                                            _signalFunctionType.GetType().GetProperty( attribute.attributeName );
                                        if (pi != null)
                                            value = pi.GetValue( _signalFunctionType, null );
                                    }
                                }
                                catch (Exception err)
                                {
                                    LogManager.Error( err );
                                }
                                int idx =
                                    signalAttributes.Rows.Add( new[] {attribute.attributeName, attribute.type, value} );
                                signalAttributes.Rows[idx].Tag = attribute;
                            }

                            //-----------------------------------------------------------------------------//
                            //--- Check the database for each of the attributes found in the schema. If ---//
                            //--- the attribute does not exist in the database the add it.              ---//
                            //-----------------------------------------------------------------------------//
                            signalAttributes.Rows.Clear();
                            foreach (XmlSchemaAttribute attribute in schemaAttributes)
                            {
                                string name = attribute.Name;
                                if (!foundAttributes.ContainsKey( name ))
                                {
                                    var dbSignalAttribute = new dbSignalAttribute();
                                    dbSignalAttribute.signalId = dataSignal.signalId;
                                    dbSignalAttribute.attributeName = name;
                                    dbSignalAttribute.defaultValue = attribute.DefaultValue;
                                    dbSignalAttribute.fixedValue = attribute.FixedValue;
                                    if (attribute.AttributeSchemaType != null)
                                        dbSignalAttribute.type = attribute.AttributeSchemaType.Name;
                                    dbSignalAttribute.DataState = BASEBean.eDataState.DS_ADD;
                                    dbSignalAttribute.save();
                                    int idx = signalAttributes.Rows.Add( new[] {name, dbSignalAttribute.type, null} );
                                    signalAttributes.Rows[idx].Tag = attribute;
                                }
                            }
                        }
                    }
                }
            }
            finally
            {
                HourGlass.Enabled = false;
            }
        }
 private bool LoadSignalModel(dbSignal dbsignal)
 {
     bool loaded = false;
     if (dbsignal != null)
     {
         var dao = new SignalDAO();
         dbsignal = dao.getSignal(dbsignal.signalId);
         _currentSignalModel = SignalManager.GetSignalModel(dbsignal.xmlns, dbsignal.signalName);
         LoadSignalModel(_currentSignalModel);
         loaded = true;
     }
     return loaded;
 }
예제 #6
0
        public void SaveSignalModel()
        {
            //Check Database for _TSF.name
            //If not found add it
            //walk through attributes
            //check for attribute names
            //if not found add them

            var dao = new SignalDAO();
            dbSignal dataSignal = dao.getSignal( _name, _signalNameSpace );
            dbSignal baseSignal = dao.getSignal( _baseSignalName, _baseSignalNameSpace );
            if (dataSignal == null)
            {
                dataSignal = new dbSignal();
                dataSignal.parentSignalId = baseSignal != null ? baseSignal.signalId : 0;
                dataSignal.xmlns = _signalNameSpace;
                dataSignal.signalName = _name;
                dataSignal.uuid = Guid.Parse( _tsf.uuid );
                dataSignal.save();
            }

            foreach (SignalAttribute attr in _attributes)
            {
                bool hasAttribute = dao.hasAttribute( dataSignal.signalId, attr.Name );
                dbSignalAttribute dbAttribute;
                if (!hasAttribute)
                    dbAttribute = new dbSignalAttribute();
                else
                    dbAttribute = dao.GetAttribute( dataSignal.signalId, attr.Name );

                dbAttribute.DataState = hasAttribute ? BASEBean.eDataState.DS_EDIT : BASEBean.eDataState.DS_ADD;
                dbAttribute.attributeName = attr.Name;
                dbAttribute.signalId = dataSignal.signalId;
                dbAttribute.defaultValue = attr.DefaultValue;
                dbAttribute.fixedValue = attr.FixedValue;
                dbAttribute.type = attr.SchemaType;
                dbAttribute.save();
            }
        }
예제 #7
0
 public void LoadSignalModelLibraryCache()
 {
     SignalDAO dao = new SignalDAO();
     List<dbTSFLibrary> list = dao.getTSFLibraries();
     _signalModelLibraryCache.Clear();
     foreach (dbTSFLibrary library in list)
     {
         string xmlns = library.targetNamespace;
         string content = library.content;
         if (string.IsNullOrEmpty(xmlns))
         {
             LogManager.Warn("A namespace does not exist for {0} and therefore not added to the schema cache.", library.libraryName );
         }
         else
         {
             MemoryStream ms = new MemoryStream(Encoding.UTF8.GetBytes(content));
             SignalModelLibrary sml = new SignalModelLibrary(ms);
             _signalModelLibraryCache.Add(xmlns, sml);
         }
     }
 }
예제 #8
0
        public static SignalModel GetSignalModel(string nameSpace, string signalName)
        {
            SignalModel model = null;
            SignalModelLibrary library = null;
            SignalManager sm = Instance;
            if (sm._signalModelLibraryCache.ContainsKey(nameSpace))
            {
                library = sm._signalModelLibraryCache[nameSpace];
            }
            else
            {
                SignalDAO dao = new SignalDAO();
                dbTSFLibrary tsfLib = dao.getTSFLibraryByNameSpace(nameSpace);
                if (tsfLib != null)
                {
                    string content = tsfLib.content;
                    MemoryStream ms = new MemoryStream(Encoding.UTF8.GetBytes(content));
                    library = new SignalModelLibrary(ms);
                    sm._signalModelLibraryCache.Add(nameSpace, library);
                }
            }
            if (library != null)
                model = library.GetSignalModel(signalName);

            return model;
        }