예제 #1
0
        private string IsInstalDispatchHander(out string statusCode, out string errMsg)
        {
            statusCode = "0000";
            errMsg     = "";

            if (!File.Exists(dispatchIotServerPath))
            {
                errMsg     = dispatchServerName + "注册失败:未找到服务文件" + dispatchIotServerPath;
                statusCode = "4104";
                return("");
            }
            if (ServiceToolEx.IsServiceExist(dispatchServerName))
            {
                errMsg     = dispatchServerName + "服务已存在";
                statusCode = "4100";
                return("");
            }
            ServiceController service = ServiceToolEx.InstallService(dispatchIotServerPath, dispatchServerName, dispatchServerName, dispatchServerDescribe, System.ServiceProcess.ServiceStartMode.Manual);

            if (service == null)
            {
                errMsg     = dispatchServerName + "服务注册失败";
                statusCode = "4101";
                return("");
            }
            if (!ServiceToolEx.IsServiceExist(dispatchServerName))
            {
                errMsg     = dispatchServerName + "服务注册失败!" + ErrorPolicy;
                statusCode = "4105";
                return("");
            }
            return(dispatchServerName + "服务注册成功");
        }
예제 #2
0
        // 注册服务--核心服务和调度服务
        public string IsInstalCoreHander(out string statusCode, out string errMsg)
        {
            statusCode = "0000";
            errMsg     = "";

            if (!File.Exists(iotServerPath))
            {
                errMsg     = serverName + "注册失败:未找到服务文件" + iotServerPath;
                statusCode = "4004";
                return("");
            }
            if (ServiceToolEx.IsServiceExist(serverName))
            {
                errMsg     = serverName + "服务已存在";
                statusCode = "4000";
                return("");
            }

            ServiceController service = ServiceToolEx.InstallService(iotServerPath, serverName, serverName, serverDescribe, System.ServiceProcess.ServiceStartMode.Manual);

            if (service == null)
            {
                errMsg     = serverName + "服务注册失败";
                statusCode = "4001";
                return("");
            }
            if (!ServiceToolEx.IsServiceExist(serverName))
            {
                errMsg     = serverName + "服务注册失败!" + ErrorPolicy;
                statusCode = "4005";
                return("");
            }
            string dispatchInfo = IsInstalDispatchHander(out statusCode, out errMsg);

            return(serverName + "服务注册成功;" + dispatchInfo);
        }