Пример #1
0
        public static Tuple <Instance, string> FindZ3950Instance(string strInstanceName)
        {
            Instance instance = ServerInfo.FindInstance(strInstanceName);

            if (instance == null)
            {
                return(new Tuple <Instance, string>(null, "实例 '" + strInstanceName + "' 不存在"));
            }
            if (instance.zhost == null)
            {
                return(new Tuple <Instance, string>(null, "实例 '" + strInstanceName + "' 没有启用 Z39.50 服务"));
            }
            return(new Tuple <Instance, string>(instance, ""));
        }
Пример #2
0
        // 获得一个实例的信息
        public ServiceControlResult GetInstanceInfo(string strInstanceName,
                                                    out InstanceInfo info)
        {
            info = null;
            ServiceControlResult result = new ServiceControlResult();

            try
            {
                // 查询 dp2Capo 运行状态
                if (strInstanceName == ".")
                {
                    info = new InstanceInfo();
                    info.InstanceName = strInstanceName;
                    info.State        = "running";
                    result.Value      = 1; // 表示 dp2capo 正在运行状态
                    return(result);
                }

                // 查询全局服务运行状态。全局服务包括 SIP 和 Z39.50 Service
                if (strInstanceName == ".global")
                {
                    info = new InstanceInfo();
                    info.InstanceName = strInstanceName;
                    info.State        = ServerInfo.GlobalServiceRunning ? "running" : "stopped";
                    result.Value      = 1;
                    return(result);
                }

                Instance instance = ServerInfo.FindInstance(strInstanceName);
                if (instance == null)
                {
                    result.Value = 0;
                    return(result);
                }

                info = new InstanceInfo();
                info.InstanceName = instance.Name;
                info.State        = instance.Running ? "running" : "stopped";
                result.Value      = 1;
                return(result);
            }
            catch (Exception ex)
            {
                result.Value     = -1;
                result.ErrorInfo = "GetInstanceInfo() 出现异常: " + ex.Message;
                return(result);
            }
        }