Ejemplo n.º 1
0
        public ItemUrl[] TranslateToItemIDs(string sourceName, int eventCategory, string conditionName, string subConditionName, int[] attributeIDs)
        {
            lock (this)
            {
                if (m_server == null)
                {
                    throw new NotConnectedException();
                }

                IntPtr ppszAttrItemIDs = IntPtr.Zero;
                IntPtr ppszNodeNames   = IntPtr.Zero;
                IntPtr ppCLSIDs        = IntPtr.Zero;
                int    num             = (attributeIDs != null) ? attributeIDs.Length : 0;
                try
                {
                    ((IOPCEventServer)m_server).TranslateToItemIDs((sourceName != null) ? sourceName : "", eventCategory, (conditionName != null) ? conditionName : "", (subConditionName != null) ? subConditionName : "", num, (num > 0) ? attributeIDs : new int[0], out ppszAttrItemIDs, out ppszNodeNames, out ppCLSIDs);
                }
                catch (Exception e)
                {
                    throw OpcCom.Interop.CreateException("IOPCEventServer.TranslateToItemIDs", e);
                }

                string[]  unicodeStrings  = OpcCom.Interop.GetUnicodeStrings(ref ppszAttrItemIDs, num, deallocate: true);
                string[]  unicodeStrings2 = OpcCom.Interop.GetUnicodeStrings(ref ppszNodeNames, num, deallocate: true);
                Guid[]    gUIDs           = OpcCom.Interop.GetGUIDs(ref ppCLSIDs, num, deallocate: true);
                ItemUrl[] array           = new ItemUrl[num];
                for (int i = 0; i < num; i++)
                {
                    array[i]              = new ItemUrl();
                    array[i].ItemName     = unicodeStrings[i];
                    array[i].ItemPath     = null;
                    array[i].Url.Scheme   = "opcda";
                    array[i].Url.HostName = unicodeStrings2[i];
                    array[i].Url.Path     = $"{{{gUIDs[i]}}}";
                }

                return(array);
            }
        }
        public AddFavoriteDialog()
        {
            OkCommand = new DelegateCommand(() =>
            {
                if (string.IsNullOrWhiteSpace(ItemName) || string.IsNullOrWhiteSpace(ItemUrl))
                {
                    return;
                }

                var website = new Website(ItemName.Trim(), ItemUrl.Trim());
                GlobalData.Favorites.Add(website);
                _result = true;
                Close();
            });

            CancelCommand = new DelegateCommand(() =>
            {
                _result = false;
                Close();
            });

            InitializeComponent();
        }
Ejemplo n.º 3
0
 public ItemUrl[] TranslateToItemIDs(string sourceName, int eventCategory, string conditionName, string subConditionName, int[] attributeIDs)
 {
     lock (this)
     {
         if (base.m_server == null)
         {
             throw new NotConnectedException();
         }
         IntPtr zero = IntPtr.Zero;
         IntPtr ppszNodeNames = IntPtr.Zero;
         IntPtr ppCLSIDs = IntPtr.Zero;
         int dwCount = (attributeIDs != null) ? attributeIDs.Length : 0;
         try
         {
             ((IOPCEventServer) base.m_server).TranslateToItemIDs((sourceName != null) ? sourceName : "", eventCategory, (conditionName != null) ? conditionName : "", (subConditionName != null) ? subConditionName : "", dwCount, (dwCount > 0) ? attributeIDs : new int[0], out zero, out ppszNodeNames, out ppCLSIDs);
         }
         catch (Exception exception)
         {
             throw OpcCom.Interop.CreateException("IOPCEventServer.TranslateToItemIDs", exception);
         }
         string[] strArray = OpcCom.Interop.GetUnicodeStrings(ref zero, dwCount, true);
         string[] strArray2 = OpcCom.Interop.GetUnicodeStrings(ref ppszNodeNames, dwCount, true);
         Guid[] guidArray = OpcCom.Interop.GetGUIDs(ref ppCLSIDs, dwCount, true);
         ItemUrl[] urlArray = new ItemUrl[dwCount];
         for (int i = 0; i < dwCount; i++)
         {
             urlArray[i] = new ItemUrl();
             urlArray[i].ItemName = strArray[i];
             urlArray[i].ItemPath = null;
             urlArray[i].Url.Scheme = "opcda";
             urlArray[i].Url.HostName = strArray2[i];
             urlArray[i].Url.Path = string.Format("{{{0}}}", guidArray[i]);
         }
         return urlArray;
     }
 }