コード例 #1
0
        public override int VerifyItem(
            LibraryHost host,
            string strAction,
            XmlDocument itemdom,
            out string strError)
        {
            strError = "";

            // 执行函数
            try
            {
                return(host.VerifyOrder(strAction,
                                        itemdom,
                                        out strError));
            }
            catch (Exception ex)
            {
                strError = "执行脚本函数 '" + "VerifyOrder" + "' 时出错:" + ExceptionUtil.GetDebugText(ex);
                return(-1);
            }

            // return 0;
        }
コード例 #2
0
        public override int VerifyItem(
            LibraryHost host,
            string strAction,
            XmlDocument itemdom,
            out string strError)
        {
            strError = "";

            // 执行函数
            try
            {
                return(host.VerifyComment(strAction,
                                          itemdom,
                                          out strError));
            }
            catch (Exception ex)
            {
                strError = "执行脚本函数 '" + "VerifyComment" + "' 时出错:" + ex.Message;
                return(-1);
            }

            return(0);
        }
コード例 #3
0
ファイル: MainForm.cs プロジェクト: renyh1013/dp2
 void dp2Library_stop()
 {
     if (library_host != null)
     {
         library_host.Stop();
         library_host = null;
     }
 }
コード例 #4
0
ファイル: MainForm.cs プロジェクト: renyh1013/dp2
        // parameters:
        //      bAutoStart  是否自动启动。如果为 false,表示会重新启动,假如以前启动过的话
        int dp2Library_start(
            bool bAutoStart,
            out string strError)
        {
            strError = "";

            Debug.Assert(string.IsNullOrEmpty(this.LibraryDataDir) == false, "");

            string strFilename = Path.Combine(this.LibraryDataDir, "library.xml");
            if (File.Exists(strFilename) == false)
            {
                strError = "dp2Library XE 尚未初始化";
                return 0;
            }

            if (bAutoStart == true && library_host != null)
            {
                strError = "dp2Library 先前已经启动了";
                return 0;
            }

            dp2Library_stop();

            // 获得 监听 URL
#if NO
            if (this.IsServer == true)
            {
                string strUrl = this.AppInfo.GetString("main_form", "listening_url", "");
                if (string.IsNullOrEmpty(strUrl) == true)
                {
                    string strNewUrl = InputDlg.GetInput(
    this,
    "请指定服务器绑定的 URL",
    "URL: ",
    "http://localhost:8001/dp2library/xe",
    this.Font);
                    if (strNewUrl == null)
                    {
                        strNewUrl = "http://localhost:8001/dp2library/xe";
                        MessageBox.Show(this, "自动使用缺省的 URL " + strNewUrl);
                    }

                    this.AppInfo.SetString("main_form", "listening_url", strNewUrl);

                    this.LibraryServerUrl = strNewUrl;
                }
                else
                    this.LibraryServerUrl = strUrl;
            }
            else
            {
                this.LibraryServerUrl = "net.pipe://localhost/dp2library/xe";
            }
#endif

            // 检查监听 URL
            if (this.IsServer == true)
            {
                this.LibraryServerUrlList = this.AppInfo.GetString("main_form", "listening_url", "");
                if (string.IsNullOrEmpty(this.LibraryServerUrlList) == true)
                {
                    strError = "尚未正确配置监听URL, dp2library server 无法启动";
                    return -1;
                }

                // TODO: 必须是 http net.tcp 协议之一
            }
            else
            {
                // 强制设置为固定值
                this.LibraryServerUrlList = LibraryHost.default_single_url; //  "net.pipe://localhost/dp2library/xe";
            }

#if NO
            if (this.IsServer == true)
                this.LibraryServerUrl = "http://localhost/dp2library/xe";
            else
                this.LibraryServerUrl = "net.pipe://localhost/dp2library/xe";
#endif

            library_host = new LibraryHost();
            library_host.DataDir = this.LibraryDataDir;
            library_host.HostUrl = this.LibraryServerUrlList;
            int nRet = library_host.Start(out strError);
            if (nRet == -1)
                return -1;

            if (this.library_host != null)
            {
                // this.library_host.SetTestMode(this.TestMode);
                if (this.TestMode == true)
                    this.library_host.SetMaxClients(5); // 社区版限定 5 个前端
                else
                    this.library_host.SetMaxClients(this.MaxClients);
                this.library_host.SetLicenseType(this.LicenseType);
                this.library_host.SetFunction(this.Function);
            }

            return 1;
        }