コード例 #1
0
        /// <summary>
        /// Gets the branch position.
        /// </summary>
        private string GetBranchPosition(string parentId, string name)
        {
            string methodName = "IOPCHDA_Browser.GetBranchPosition";

            // need to move down to get the browse position.
            if (!String.IsNullOrEmpty(name))
            {
                if (!ChangeBrowsePosition(OPCHDA_BROWSEDIRECTION.OPCHDA_BROWSE_DOWN, name))
                {
                    return(null);
                }
            }

            string itemId = null;

            try
            {
                IOPCHDA_Browser server = BeginComCall <IOPCHDA_Browser>(methodName, true);
                server.GetBranchPosition(out itemId);
            }
            catch (Exception e)
            {
                ComCallError(methodName, e);
                return(null);
            }
            finally
            {
                EndComCall(methodName);

                // restore browse position.
                if (!String.IsNullOrEmpty(name))
                {
                    ChangeBrowsePosition(OPCHDA_BROWSEDIRECTION.OPCHDA_BROWSE_DIRECT, parentId);
                }
            }

            return(itemId);
        }
コード例 #2
0
ファイル: Browser.cs プロジェクト: ZSYMAX/OpcNetApi
        private string GetFullBranchName(string name)
        {
            string pszBranchPos = null;

            try
            {
                m_browser.ChangeBrowsePosition(OPCHDA_BROWSEDIRECTION.OPCHDA_BROWSE_DOWN, name);
            }
            catch
            {
                return(null);
            }

            try
            {
                m_browser.GetBranchPosition(out pszBranchPos);
            }
            catch
            {
            }

            m_browser.ChangeBrowsePosition(OPCHDA_BROWSEDIRECTION.OPCHDA_BROWSE_UP, "");
            return(pszBranchPos);
        }