private void lbSAPServer_SelectedIndexChanged(object sender, System.EventArgs e)
        {
            string  strSAPName = null;
            XmlNode oNode      = null;

            strSAPName = (String)lbSAPServer.SelectedItem;

            if (strSAPName == null || m_strConfigXML == null)
            {
                return;
            }

            SAPServerConfig.SAPSeverInfo oInfo = (SAPServerConfig.SAPSeverInfo)pgServerConfig.SelectedObject;
            SAPServerConfig oSCfg = oInfo.owner;

            oNode = oSCfg.SearchConfiguration(m_strConfigXML, strSAPName)[0];

            oInfo.NAME   = oNode.Attributes["NAME"].Value;
            oInfo.LANG   = oNode.Attributes["LANG"].Value;
            oInfo.ASHOST = oNode.Attributes["ASHOST"].Value;
            oInfo.CLIENT = oNode.Attributes["CLIENT"].Value;
            oInfo.SYSNR  = oNode.Attributes["SYSNR"].Value;

            pgServerConfig.Refresh();
        }
        /// <summary>
        /// Form 컨트롤을 초기화한다.
        /// </summary>
        private void InitializeFormControl()
        {
            string strFilePath = null;
            int    nPos        = 0;

            string[] arrNames = null;

            SAPServerConfig oSCfg = new SAPServerConfig();

            SAPServerConfig.SAPSeverInfo oInfo = new SAPServerConfig.SAPSeverInfo(oSCfg);

            RFCFilter oFilter = new RFCFilter();

            // XML 환경 파일을 읽는다.
            strFilePath  = Application.ExecutablePath;
            nPos         = strFilePath.LastIndexOf("\\");
            strFilePath  = strFilePath.Substring(0, ++nPos);
            strFilePath += SAP_CONFIG_FILE;
            ReadConfigurationFile(strFilePath);

            // lbSAPServer - 서버 목록 표시하는 리스트 박스를 초기화한다.
            lbSAPServer.Sorted        = true;
            lbSAPServer.SelectionMode = SelectionMode.One;

            // 서버 목록을 표시한다.
            arrNames = oSCfg.GetServerNames(m_strConfigXML);
            lbSAPServer.Items.Clear();
            if (arrNames != null)
            {
                for (int i = 0; i < arrNames.Length; ++i)
                {
                    lbSAPServer.Items.Add(arrNames[i]);
                }
            }

            // btnPrevious - 이전 단계를 수행하는 버튼 상태를 비활성화한다.
            btnPrevious.Visible = false;

            // pgServerConfig - Property Grid 속성을 설정한다.
            pgServerConfig.SelectedObject = oInfo;

            // 검색 필터 관련. PropertyGrid 컨트롤을 설정한다.
            pgRFCFilter.SelectedObject = oFilter;

            // 네임스페이스 이름을 초기화 한다.
            txtNamespace.Text = "ProxyBuilder";

            // 클라이언트 형태의 Proxy 모듈로 기본 선택한다.
            radioClient.Checked = true;
            radioServer.Checked = false;

            // PG Help 상자 보이기
            pgServerConfig.HelpVisible = true;
            pgRFCFilter.HelpVisible    = true;
        }
        /// <summary>
        /// SAP 서버 정보 구성 파일을 읽는다.
        /// </summary>
        /// <param name="strConfigFile">SAP 서버 정보 구성 파일</param>
        private void ReadConfigurationFile(string strConfigFile)
        {
            SAPServerConfig oCfg = null;

            try
            {
                oCfg           = new SAPServerConfig();
                m_strConfigXML = oCfg.LoadConfigFile(strConfigFile);
            }
            catch (Exception exp)
            {
                throw exp;
            }
        }
        private void btnSaveConfig_Click(object sender, System.EventArgs e)
        {
            string strFilePath = null;
            int    nPos        = 0;

            SAPServerConfig.SAPSeverInfo oInfo = (SAPServerConfig.SAPSeverInfo)pgServerConfig.SelectedObject;
            SAPServerConfig oSCfg = oInfo.owner;

            strFilePath  = Application.ExecutablePath;
            nPos         = strFilePath.LastIndexOf("\\");
            strFilePath  = strFilePath.Substring(0, ++nPos);
            strFilePath += SAP_CONFIG_FILE;

            oSCfg.SaveConfigFile(strFilePath, m_strConfigXML);
        }
        private void btnRemoveServer_Click(object sender, System.EventArgs e)
        {
            string strMsg = "";

            SAPServerConfig.SAPSeverInfo oInfo = (SAPServerConfig.SAPSeverInfo)pgServerConfig.SelectedObject;
            SAPServerConfig oSCfg = oInfo.owner;

            if ((oInfo.NAME.Trim().Length == 0) ||
                !String.Equals((string)lbSAPServer.SelectedItem, oInfo.NAME) ||
                !oSCfg.RemoveConfiguration(ref m_strConfigXML))
            {
                strMsg = "Please select a server from the list.";
                MessageBox.Show(this, strMsg, this.Name, MessageBoxButtons.OK, MessageBoxIcon.Warning);
                return;
            }

            lbSAPServer.Items.Remove(lbSAPServer.SelectedItem);
        }
Пример #6
0
        private void InitializeFormControl()
        {
            string strFilePath = null;
            int    nPos        = 0;

            string[] arrNames = null;

            SAPServerConfig oSCfg = new SAPServerConfig();

            SAPServerConfig.SAPSeverInfo oInfo = new SAPServerConfig.SAPSeverInfo(oSCfg);

            RFCFilter oFilter = new RFCFilter();

            strFilePath  = Application.ExecutablePath;
            nPos         = strFilePath.LastIndexOf("\\");
            strFilePath  = strFilePath.Substring(0, ++nPos);
            strFilePath += SAP_CONFIG_FILE;
            ReadConfigurationFile(strFilePath);

            lbSAPServer.Sorted        = true;
            lbSAPServer.SelectionMode = SelectionMode.One;

            arrNames = oSCfg.GetServerNames(m_strConfigXML);
            lbSAPServer.Items.Clear();
            if (arrNames != null)
            {
                for (int i = 0; i < arrNames.Length; ++i)
                {
                    lbSAPServer.Items.Add(arrNames[i]);
                }
            }

            btnPrevious.Visible           = false;
            pgServerConfig.SelectedObject = oInfo;
            pgRFCFilter.SelectedObject    = oFilter;

            txtNamespace.Text = "ProxyBuilder";

            radioClient.Checked = true;
            radioServer.Checked = false;

            pgServerConfig.HelpVisible = true;
            pgRFCFilter.HelpVisible    = true;
        }
        private void btnTestConn_Click(object sender, System.EventArgs e)
        {
            SAPServerConfig.SAPSeverInfo oInfo = (SAPServerConfig.SAPSeverInfo)pgServerConfig.SelectedObject;
            SAPServerConfig oSCfg = oInfo.owner;

            CallSAPProxy oProxy = new CallSAPProxy();

            Cursor.Current = Cursors.WaitCursor;

            try
            {
                if (!ValidateSAPServerInfo())
                {
                    MessageBox.Show(this, "SAP Check the server connection settings.", this.Name, MessageBoxButtons.OK, MessageBoxIcon.Warning);
                    Cursor.Current = Cursors.Arrow;
                    return;
                }

                oProxy.SetConnectionInfo("3", oInfo.ASHOST, Convert.ToInt16(oInfo.SYSNR), Convert.ToInt16(oInfo.CLIENT),
                                         oInfo.LANG, txtUserID.Text, txtPassword.Text);
                if (oProxy.ConnectSAPServer())
                {
                    MessageBox.Show(this, "SAP Server Connection Success", this.Name, MessageBoxButtons.OK, MessageBoxIcon.Information);
                }
                else
                {
                    MessageBox.Show(this, "SAP Server Connection Failed", this.Name, MessageBoxButtons.OK, MessageBoxIcon.Warning);
                }
            }
            catch (Exception exp)
            {
                MessageBox.Show(this, exp.Message, this.Name, MessageBoxButtons.OK, MessageBoxIcon.Warning);
            }
            finally
            {
                if (oProxy != null)
                {
                    oProxy.DisconnectSAPServer();
                }
            }
            Cursor.Current = Cursors.Arrow;
        }
        private void btnAddServer_Click(object sender, System.EventArgs e)
        {
            string strMsg = "";

            SAPServerConfig.SAPSeverInfo oInfo = (SAPServerConfig.SAPSeverInfo)pgServerConfig.SelectedObject;
            SAPServerConfig oSCfg = oInfo.owner;

            if (oInfo.NAME.Trim().Length == 0)
            {
                return;
            }

            if (!oSCfg.AddConfiguration(ref m_strConfigXML))
            {
                strMsg = "The name was already in use . Please specify a different name";
                MessageBox.Show(this, strMsg, this.Name, MessageBoxButtons.OK, MessageBoxIcon.Warning);
                return;
            }

            lbSAPServer.Items.Add(oInfo.NAME);
        }
 public SAPSeverInfo(SAPServerConfig owner)
 {
     this.owner = owner;
 }
        private void btnGetRFCFunctions_Click(object sender, System.EventArgs e)
        {
            string strFuncNameFilter  = "*";
            string strGroupNameFilter = "";
            string strLanguageFilter  = "EN";

            string       strErrMsg = "";
            DataTable    oDT       = null; // 데이터 테이블 개체
            CallSAPProxy oProxy    = null;

            SAPServerConfig.SAPSeverInfo oInfo = (SAPServerConfig.SAPSeverInfo)pgServerConfig.SelectedObject;
            SAPServerConfig oSCfg = oInfo.owner;

            RFCFilter oFilter = (RFCFilter)pgRFCFilter.SelectedObject;

            Cursor.Current = Cursors.WaitCursor;

            try
            {
                // 목록 초기화
                lbRFCFunctions.Items.Clear();
                txtSelectedFuncName.Text = "";

                if (!ValidateSAPServerInfo())
                {
                    MessageBox.Show(this, "SAP Check the server connection settings.", this.Name, MessageBoxButtons.OK, MessageBoxIcon.Warning);
                    Cursor.Current = Cursors.Arrow;
                    return;
                }

                strFuncNameFilter  = String.IsNullOrEmpty(oFilter.NameFilter) ? "*" : oFilter.NameFilter;
                strGroupNameFilter = oFilter.GroupFilter;
                strLanguageFilter  = String.IsNullOrEmpty(oFilter.Language) ? "EN" : oFilter.Language;

                oProxy = new CallSAPProxy(); // Proxy 개체를 생성한다.
                oProxy.SetConnectionInfo("3", oInfo.ASHOST, Convert.ToInt16(oInfo.SYSNR), Convert.ToInt16(oInfo.CLIENT),
                                         oInfo.LANG, txtUserID.Text, txtPassword.Text);

                if (!oProxy.ConnectSAPServer())
                {
                    MessageBox.Show(this, "SAP Cannot connect to server.", this.Name, MessageBoxButtons.OK, MessageBoxIcon.Warning);
                    Cursor.Current = Cursors.Arrow;
                    return;
                }

                oDT = oProxy.get_RFCFunctionNames(strFuncNameFilter, strGroupNameFilter, strLanguageFilter);

                // Add to Function Names
                for (int nCnt = 0; nCnt < oDT.Rows.Count; ++nCnt)
                {
                    lbRFCFunctions.Items.Add(oDT.Rows[nCnt].ItemArray[0].ToString());
                }
            }
            catch (Exception exp)
            {
                strErrMsg = exp.Message;

                if (strErrMsg.Length == 0)
                {
                    strErrMsg = "No results found with the condition . Reset the search terms.";
                }

                MessageBox.Show(this, strErrMsg, this.Name, MessageBoxButtons.OK, MessageBoxIcon.Warning);
            }
            finally
            {
                if (oProxy != null)
                {
                    oProxy.DisconnectSAPServer();
                }
            }

            Cursor.Current = Cursors.Arrow;

            return;
        }