Exemple #1
0
        public bool LoadServer(dbServerItem srv)
        {
            try
            {
                configuredServer = new dbServerItem();
                configuredServer = srv;

                selectedOPCserver.Host        = srv.opcHost;
                selectedOPCserver.UrlString   = srv.opcURL;
                selectedOPCserver.isReconnect = srv.opcRecconect;

                foreach (dbTagItem tag in srv.opcMonitoredTags)
                {
                    mTag t = new mTag(tag.Name, tag.Path);
                    opcSubscribedTags.Add(t);
                }
                addLogRecord("Server configuration loaded successfully");
                addLogRecord("Server url is: " + selectedOPCserver.UrlString);
                addLogRecord("Tags count for subscribtion: " + opcSubscribedTags.Count.ToString());
                return(true);
            }
            catch (Exception ex)
            {
                addLogRecord("Fail to load server configuration...");
                addLogRecord(ex.Message);
                return(false);
            }
        }
Exemple #2
0
        public bool  insert(List <mTag> items)
        {
            FIX_STAN789_T ent = new FIX_STAN789_T();

            try
            {
                foreach (var p in ent.GetType().GetProperties())
                {
                    if (items.Any(k => k.NameInDb == p.Name))
                    {
                        mTag t = items.First(k => k.NameInDb == p.Name);

                        var targetType = IsNullableType(p.PropertyType) ? Nullable.GetUnderlyingType(p.PropertyType) : p.PropertyType;

                        //Returns an System.Object with the specified System.Type and whose value is
                        //equivalent to the specified object.
                        object propertyVal = Convert.ChangeType(t.Value, targetType);

                        //Set the value of the property
                        p.SetValue(ent, propertyVal, null);
                    }
                }
            }
            catch (Exception ex)
            {
            }

            ent.INCOMIN_DATE = DateTime.Now; // ! change!!!
            ent.WHEN         = DateTime.Now;


            return(AddRecord(ent));
        }
        private void dgrid_Subscribed_MouseDoubleClick(object sender, MouseButtonEventArgs e)
        {
            mTag tag = (mTag)dgrid_Subscribed.SelectedItem;

            if (tag != null)
            {
                tag.onChange = !tag.onChange;
            }
        }
        private void OraTableInit()
        {
            Model.opcSubscribedTags.Clear();

            if (oraEx != null)
            {
                foreach (string s in oraEx.GetFields())
                {
                    mTag tag = new mTag();
                    tag.NameInDb = s;
                    Model.opcSubscribedTags.Add(tag);
                }
            }
        }
        private void SelectTagsForMonitor()
        {
            mItem selectedTag = (mItem)dgrid_Tags.SelectedItem;
            mTag  tag         = new mTag(selectedTag.Name, selectedTag.Path);

            var contain = Model.opcSubscribedTags.Any(t => t.Name == tag.Name);

            if (!contain)
            {
                mTag newTag = (mTag)dgrid_Subscribed.SelectedItem as mTag;

                var mt = Model.opcSubscribedTags.FirstOrDefault(t => t.NameInDb == newTag.NameInDb);
                mt.Name = tag.Name;
                mt.Path = tag.Path;
            }
        }
Exemple #6
0
        private dbLocalRecord TagsToRecordEntity(ObservableCollection <mTag> items)
        {
            dbLocalRecord ent = new dbLocalRecord();

            if (items.Count > 0)
            {
                try
                {
                    foreach (var p in ent.GetType().GetProperties())
                    {
                        if (items.Any(k => k.NameInDb == p.Name))
                        {
                            mTag t = items.First(k => k.NameInDb == p.Name);

                            var targetType = G.IsNullableType(p.PropertyType) ? Nullable.GetUnderlyingType(p.PropertyType) : p.PropertyType;

                            //Returns an System.Object with the specified System.Type and whose value is
                            //equivalent to the specified object.
                            object propertyVal = Convert.ChangeType(t.Value, targetType);

                            //Set the value of the property
                            p.SetValue(ent, propertyVal, null);
                        }
                    }
                }
                catch (Exception ex)
                {
                }

                ent.INCOMIN_DATE = DateTime.Now;
                ent.WHEN         = DateTime.Now;
                ent.flagIsSent   = false;
            }

            return(ent);
        }