Пример #1
0
 public SubscriptionTreeNodes(OPCCliConfiguration.SubscriptionsRow subscription)
     : base(new SubscriptionWrapperForPropertyGrid(subscription), subscription.Name)
 {
     foreach (OPCCliConfiguration.ItemsRow item in subscription.GetItemsRows())
     {
         this.Nodes.Add(new ItemTreeNode(item));
     }
 }
 /// <summary>
 /// Initializes a new instance of the <see cref="SubscriptionTreeNode"/> class.
 /// </summary>
 /// <param name="subscription">The subscription <see cref="OPCCliConfiguration.SubscriptionsRow"/>.</param>
 /// <param name="parent">The parent tree node  <see cref="OPCSessionServer"/>.</param>
 internal SubscriptionTreeNodeSession(OPCCliConfiguration.SubscriptionsRow subscription, OPCSessionServer parent) :
     base("", null, parent)
 {
     Text    = subscription.Name;
     m_Menu  = new ContextMenuSubscription(this);
     Enabled = subscription.Enabled;
     State   = subscription.CreateSubscriptionState;
     foreach (var item in subscription.GetItemsRows())
     {
         new TagTreeNode(item, this);
     }
     AssignImageIndex();
 }
Пример #3
0
        protected override void DoTheImport()
        {
            int changes_number = 0;

            #region IMPORT
            //robimy jakies importowanie:
            //dodajemy grupe:
            OPCCliConfiguration.SubscriptionsRow grow = null;
            try
            {
                if (m_ImportTagsInfo.GroupID != null)
                {
                    foreach (OPCCliConfiguration.SubscriptionsRow tempgr in m_database.Subscriptions)
                    {
                        if (m_ImportTagsInfo.GroupID == tempgr.ID)
                        {
                            grow = tempgr;
                            break;
                        }
                    }
                }
                if (grow == null)
                {
                    grow            = m_database.Subscriptions.NewSubscriptionsRow();
                    grow.ID_server  = m_ImportTagsInfo.ServerID;
                    grow.UpdateRate = m_ImportTagsInfo.SamplingRate;
                    grow.Name       = "ImportedGroup" + m_ImportTagsInfo.ServerID.ToString();
                    m_database.Subscriptions.AddSubscriptionsRow(grow);
                }
                if (m_ImportTagsInfo.ClearGroup)
                {
                    foreach (OPCCliConfiguration.ItemsRow itrow in grow.GetItemsRows())
                    {
                        m_database.Items.RemoveItemsRow(itrow);
                    }
                }
            }
            catch
            {
                AppendToLog("Problem with adding for server: " + m_ImportTagsInfo.ServerID.ToString());
                return;
            }
            //teraz otworzymy plik i dodamy wszystkie tagi:
            System.IO.StreamReader plik = new System.IO.StreamReader(m_ImportTagsInfo.Filename, System.Text.Encoding.Default);
            string plikzawartosc        = plik.ReadToEnd();
            plik.Close();
            string Tagname = "-- unknowname --";
            while (plikzawartosc.Length > 0)
            {
                try
                {
                    int pos = plikzawartosc.IndexOf("\r\n");
                    if (pos >= 0)
                    {
                        Tagname       = plikzawartosc.Substring(0, pos);
                        plikzawartosc = plikzawartosc.Remove(0, pos + 2);
                    }
                    else
                    {
                        if (plikzawartosc.Length > 0)
                        {
                            Tagname       = plikzawartosc;
                            plikzawartosc = "";
                        }
                    }
                    Tagname = Tagname.Trim();
                    if (Tagname.Length > 0) //only if the line is not empty
                    {
                        //dodajemy taga:
                        OPCCliConfiguration.ItemsRow itemrow = m_database.Items.NewItemsRow();
                        itemrow.Name            = Tagname;
                        itemrow.ID_Subscription = grow.ID;
                        itemrow.MaxAge          = m_ImportTagsInfo.MaxAge;
                        m_database.Items.AddItemsRow(itemrow);
                        changes_number++;
                    }
                }
                catch (
                    Exception
#if DEBUG
                    ex
#endif
                    )
                {
                    AppendToLog("problem with tag:" + Tagname + " :"
#if DEBUG
                                + ex.Message.ToString()
#endif
                                );
                }
            }
            #endregion IMPORT
            AppendToLog("Number of changed tags: " + changes_number.ToString());
        }