Esempio n. 1
0
        /// <summary>
        /// Creates the server. Will override old servers.
        /// </summary>
        /// <param name="address">If != null then use this addres (changes the address of the websocket pipe)</param>
        public void MakeServer(Uri address = null)
        {
            if (address == null)
            {
                address = Address;
            }

            // Stop the old if any.
            if (WSServer != null && WSServer.IsListening)
            {
                WSServer.Stop();
            }

            string serverURL = address.Scheme + "://" + address.Host + ":" + Address.Port;

            WSServer = new WebSocketSharp.Server.WebSocketServer(serverURL);

            // Creates a server.
            WSServer.AddWebSocketService <WebsocketConnection>(
                address.AbsolutePath, () => new WebsocketConnection(this));

            WSServer.Log.Output = (d, s) => WebsocketLogMessage(null, d.ToString());

            if (m_WaitTimeout == null)
            {
                m_WaitTimeout = WSServer.WaitTime;
            }
            else
            {
                WSServer.WaitTime = WaitTimeout;
            }
        }
Esempio n. 2
0
        static void Main(string[] args)
        {
            WorldGenerator generator = new WorldGenerator();
            var            World     = generator.GenerateWorldTerrain();

            generator.Populate(World);
            WorldResolver resolver = new WorldResolver();

            RabbitWrapper wrapper = new RabbitWrapper();

            wrapper.Connect();

            JsonConverter jsonwriter = new JsonConverter();

            var task = new Task(() => WSServer.Setup(null));

            task.RunSynchronously();

            resolver.World = World;
            while (true)
            {
                resolver.Resolve();
                //Console.WriteLine(World.Agents.Count);
                //wrapper.WriteAll(jsonwriter.WriteToJson(World.Agents));
                //wrapper.WriteAll(jsonwriter.WriteToJson(World.Terrain), "terrain_queue");
                Thread.Sleep(1000);
            }
        }
Esempio n. 3
0
        static void Init1()
        {
            ConsoleHelper.WriteLine("WSServer 正在初始化....", ConsoleColor.Green);
            _server            = new WSServer();
            _server.OnMessage += Server_OnMessage;
            _server.Start();
            ConsoleHelper.WriteLine("WSServer 就绪,回车启动客户端", ConsoleColor.Green);

            ConsoleHelper.ReadLine();

            WSClient client = new WSClient();

            client.OnPong         += Client_OnPong;
            client.OnMessage      += Client_OnMessage;
            client.OnError        += Client_OnError;
            client.OnDisconnected += Client_OnDisconnected;

            ConsoleHelper.WriteLine("WSClient 正在连接到服务器...", ConsoleColor.DarkGray);

            var connected = client.Connect();

            if (connected)
            {
                ConsoleHelper.WriteLine("WSClient 连接成功,回车测试消息", ConsoleColor.DarkGray);
                ConsoleHelper.ReadLine();
                //client.Close();
                //ConsoleHelper.ReadLine();


                var loop = true;

                Task.Run(() =>
                {
                    while (loop)
                    {
                        ConsoleHelper.WriteLine("WSClient 正在发送消息...", ConsoleColor.DarkGray);

                        client.Send($"hello world!{DateTime.Now.ToString("HH:mm:ss.fff")}");

                        Thread.Sleep(1000);
                    }
                });

                ConsoleHelper.ReadLine();
                loop = false;
                ConsoleHelper.WriteLine("WSClient 正在ping服务器...", ConsoleColor.DarkGray);
                Thread.Sleep(2000);
                client.Ping();


                ConsoleHelper.ReadLine();
                ConsoleHelper.WriteLine("WSClient 正在断开连接...");
                Thread.Sleep(1000);
                client.Close();
            }
            else
            {
                ConsoleHelper.WriteLine("WSClient 连接失败", ConsoleColor.DarkGray);
            }
        }
Esempio n. 4
0
        private List <DeviceDTO> getOnlineWSDev()
        {
            List <DeviceDTO> devices = new List <DeviceDTO>();

            var server = bootstrap.GetServerByName(WS_SERVER);

            if (server == null)
            {
                return(devices);
            }
            WSServer casicServer = server as WSServer;

            //    CasicSession session = casicServer.GetAllSessions() as CasicSession;
            foreach (WSSession session in casicServer.GetAllSessions())
            {
                String sessionId = session.SessionID;
                if (session.MacID != null)
                {
                    DeviceDTO devDto = new DeviceDTO();
                    devDto.SessionId  = sessionId;
                    devDto.Company    = "203所";
                    devDto.TypeName   = "有害气体监测仪";
                    devDto.Name       = session.MacID;
                    devDto.Tag        = "";
                    devDto.Status     = "在线";
                    devDto.ServerName = "WSServer";
                    devices.Add(devDto);
                }
            }


            return(devices);
        }
Esempio n. 5
0
    void InitNetwork()
    {
        WSServerState.Reset();

        if (DebugStandalone)
        {
            WSServer.Stop();
            WSServerState.Reset();
            WSClient.Disconnect();
            WSClientState.Reset();
            WSServer.StartFake();
            WSClient.ConnectFake();
        }
        else if (IsClient)
        {
            WSServer.Stop();
            WSServerState.Reset();
            WSClient.Connect();
        }
        else
        {
            WSClient.Disconnect();
            WSClientState.Reset();
            if (!WSServer.IsRunning)
            {
                WSServer.Start();
            }
        }
    }
        public void InitializeBis(string username, string password, uint controlSytemAuthentication, uint port, uint ssl, string certificateFileName,
                                  string privateKeyFileName, uint enableWebSocketServer, uint webSocketServerPort)
        {
            if (username != "//" || password != "//")
            {
                MqttSettings.Instance.Username = username;
                MqttSettings.Instance.Password = password;
            }
            MqttSettings.Instance.ControlSytemAuthentication = controlSytemAuthentication == 1 ? true : false;
            MqttSettings.Instance.Port = Convert.ToInt32(port);
            MqttSettings.Instance.SSLCertificateProvided = ssl == 0 ? false : true;
            MqttSettings.Instance.CertificateFileName    = certificateFileName;
            MqttSettings.Instance.PrivateKeyFileName     = privateKeyFileName;
            CrestronLogger.WriteToLog("INITIALIZE DEL BROKER BIS: " + port + " " + ssl + " " + certificateFileName + " " + privateKeyFileName +
                                      "\n Web Socket Server " + enableWebSocketServer + " Web Socket Port " + webSocketServerPort, 1);

            subscriptionManager = new SubscriptionManager();
            sessionManager      = new SessionManager(subscriptionManager);
            publishManager      = new PublishManager(subscriptionManager);
            clients             = new List <MqttClient>();
            rand = new Random();
            packetIdentifiers = new List <ushort>();

            TCPServer     tcpServer       = new TCPServer(clients, sessionManager, packetIdentifiers, rand, Convert.ToInt32(port), 60);
            WSServer      webSocketServer = new WSServer(clients, sessionManager, packetIdentifiers, rand, Convert.ToInt32(webSocketServerPort), 60);
            PacketManager pm = new PacketManager(rand, sessionManager, publishManager, subscriptionManager, clients, packetIdentifiers, tcpServer, webSocketServer);
        }
 public WebSocketsHelper(int port = 16666)
 {
     _wsServer                 = new WSServer(port);
     _wsServer.OnConnected    += _wsServer_OnConnected;
     _wsServer.OnMessage      += WsServer_OnMessage;
     _wsServer.OnDisconnected += WsServer_OnDisconnected;
 }
Esempio n. 8
0
 public void Stop()
 {
     if (_alchemy != null)
     {
         _alchemy.Stop();
         _alchemy = null;
     }
 }
Esempio n. 9
0
        private void Init()
        {
            mbApiInterface.MB_AddMenuItem("mnuTools/Webserver", "MusicBee Webserver", OpenServerWindow);

            //Create server instances!
            httpServer = new Server();
            wsServer   = new WSServer();
        }
Esempio n. 10
0
        static void Init1()
        {
            WebHost webHost = new WebHost(port: 18080, root: "Html");

            webHost.Start();


            ConsoleHelper.WriteLine("WSServer 正在初始化....", ConsoleColor.Green);
            _server                 = new WSServer();
            _server.OnMessage      += Server_OnMessage;
            _server.OnDisconnected += _server_OnDisconnected;
            _server.Start();
            ConsoleHelper.WriteLine("WSServer 就绪,回车启动客户端", ConsoleColor.Green);

            ConsoleHelper.ReadLine();

            WSClient client = new WSClient();

            client.OnPong         += Client_OnPong;
            client.OnMessage      += Client_OnMessage;
            client.OnError        += Client_OnError;
            client.OnDisconnected += Client_OnDisconnected;

            ConsoleHelper.WriteLine("WSClient 正在连接到服务器...", ConsoleColor.DarkGray);

            var connected = client.Connect();

            if (connected)
            {
                ConsoleHelper.WriteLine("WSClient 连接成功,回车测试消息", ConsoleColor.DarkGray);
                ConsoleHelper.ReadLine();
                //client.Close();
                //ConsoleHelper.ReadLine();


                ConsoleHelper.WriteLine("WSClient 正在发送消息...", ConsoleColor.DarkGray);

                client.Send($"hello world!{DateTime.Now.ToString("HH:mm:ss.fff")}");
                ConsoleHelper.ReadLine();


                ConsoleHelper.WriteLine("WSClient 正在ping服务器...", ConsoleColor.DarkGray);
                client.Ping();


                ConsoleHelper.ReadLine();
                ConsoleHelper.WriteLine("WSClient 正在断开连接...");
                client.Close();

                ConsoleHelper.ReadLine();
            }
            else
            {
                ConsoleHelper.WriteLine("WSClient 连接失败", ConsoleColor.DarkGray);
            }
        }
 void GetServer()
 {
     if (_server == null)
     {
         _server = GetComponent <WSServer>();
     }
     if (_server == null)
     {
         _server = GameObject.FindObjectOfType <WSServer>();
     }
 }
Esempio n. 12
0
 private void Awake()
 {
     if (instance == null)
     {
         instance = this;
     }
     else
     {
         Destroy(this);
     }
 }
Esempio n. 13
0
        static void Init2()
        {
            ConsoleHelper.WriteLine("WSSServer 正在初始化....", ConsoleColor.Green);

            var pfxPath = PathHelper.GetFullName("yswenli.pfx");

            _server            = new WSServer(39656, System.Security.Authentication.SslProtocols.Tls12, pfxPath, "yswenli");
            _server.OnMessage += Server_OnMessage2;
            _server.Start();

            ConsoleHelper.WriteLine("WSSServer 就绪,回车启动客户端", ConsoleColor.Green);
        }
Esempio n. 14
0
        private static void ServerInit()
        {
            ConsoleHelper.WriteLine("正在启动wsserver...");
            WSServer server = new WSServer();

            server.OnConnected      += Server_OnConnected;
            server.OnErrored        += Server_OnErrored;
            server.OnUnAccepted     += Server_OnUnAccepted;
            server.OnSocketReceived += Server_OnSocketReceived;
            server.Start(url);
            ConsoleHelper.WriteLine("wsserver正在运行...");
        }
Esempio n. 15
0
    public void Awake()
    {
        WebRTC.Initialize(EncoderType.Software);
        log = new Log();

        wss = new WSServer(8989);
        wss.OnClientConnect += onClientConnect;
        wss.OnTextData      += onTextData;
        wss.OnBinaryData    += onBinaryData;
        wss.OnClientClose   += onClientClose;
        wss.OnClientError   += onClientError;
        wss.Start();
    }
Esempio n. 16
0
        // Use this for initialization
        void Start()
        {
            // loadEffect
            foreach (var efkName in _EffectNames)
            {
                EffekseerSystem.LoadEffect(efkName);
            }

            _MainCamera = GameObject.Find("ConvertCamera").GetComponent <Camera>();

            _WSServer = GameObject.Find("WSServer").GetComponent <WSServer>();

            _WSServer.Like += _WSServer_Like;
        }
Esempio n. 17
0
        void Application_Start(object sender, EventArgs e)
        {
            ServicePointManager.SecurityProtocol = SecurityProtocolType.Ssl3 | SecurityProtocolType.Tls | SecurityProtocolType.Tls11 | SecurityProtocolType.Tls12;

            // Code that runs on application startup
            BundleConfig.RegisterBundles(BundleTable.Bundles);
            AuthConfig.RegisterOpenAuth();
            WSServer.Serve();

            RusCities.InitAllCities();

            RegisterRoutes(RouteTable.Routes);

            SqlServerTypes.Utilities.LoadNativeAssemblies(Server.MapPath("~/bin"));
        }
Esempio n. 18
0
    private void InitWebServices()
    {
        string htmlDoc = htmlTemplate.ToString().Replace("{", "{{").Replace("}", "}}").Replace("{{0}}", "{0}").Replace("{{1}}", "{1}");

        string htmlResponse = string.Format(
            htmlDoc,
            Regex.Match(httpUrls[2], "(http|https)(:\\/\\/)(.+)(:.\\d+)").Groups[3].Value,
            wsPort
            );

        httpService = new HttpServer(htmlResponse, httpUrls);
        wsService   = new WSServer(wsPort);
        httpService.Run();
        wsService.Run();
    }
        /// <summary>
        /// Constructor
        /// </summary>
        /// <param name="port"></param>
        /// <param name="numberOfConnections"></param>
        public PacketManager(Random rand, SessionManager sessionManager, PublishManager publishManager, SubscriptionManager subscriptionManager,
                             List <MqttClient> clients, List <ushort> packetIdentifiers, TCPServer tcpServer, WSServer wsServer)
        {
            this.rand           = rand;
            this.sessionManager = sessionManager;
            this.publishManager = publishManager;
            this.publishManager.PacketReadyToBeSent += Send;
            this.subscriptionManager = subscriptionManager;
            PacketManager.clients    = clients;
            this.packetIdentifiers   = packetIdentifiers;

            this.tcpServer = tcpServer;
            this.wsServer  = wsServer;
            this.tcpServer.PacketReceived += RouteControlPacketToMethodHandler;
            this.wsServer.PacketReceived  += RouteControlPacketToMethodHandler;
        }
Esempio n. 20
0
 public void Start()
 {
     if (_alchemy == null)
     {
         _alchemy = new WSServer(81, IPAddress.Any)
         {
             DefaultOnReceive    = OnReceive,
             DefaultOnSend       = OnSend,
             DefaultOnConnect    = OnConnect,
             DefaultOnConnected  = OnConnected,
             DefaultOnDisconnect = OnDisconnect,
             TimeOut             = new TimeSpan(0, 5, 0)
         };
         _alchemy.Start();
     }
 }
        public void init(WSServer wsserver)
        {
            this.wsserver = wsserver;
            string message;

            int recv;
            byte[] data = new byte[1024];
            IPEndPoint ipep = new IPEndPoint(this.udpip, this.udpp);

            Socket newsock = new Socket(AddressFamily.InterNetwork,
                            SocketType.Dgram, ProtocolType.Udp);

            try
            {
                newsock.Bind(ipep);
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);

            }
               // Console.WriteLine("Waiting for a client...");

            IPEndPoint sender = new IPEndPoint(IPAddress.Any, 0);
            EndPoint Remote = (EndPoint)(sender);

            Console.WriteLine(DateTime.Now + " [UdpServer] server started on: " + this.udpip+":"+this.udpp);
            //string m = "[Message]\nsender=eth1\ntimestamp=231.221\n[Location]\npos=3.12312,4.12421,7.21133\nori=355,90,0\nname=ufdhfdhfd";
            while(true)
            {
                try
                {
                    data = new byte[1024];
                    recv = newsock.ReceiveFrom(data, ref Remote);

                    message = Encoding.ASCII.GetString(data, 0, recv);
                    Console.WriteLine(DateTime.Now + " [UdpServer] Message received: \n" + message + "\n\n");
                    this.parseMessage(message);
                }
                catch (Exception ex)
                {
                    Console.WriteLine(ex.Message);

                }

            }
        }
    private void OnTriggerEnter2D(Collider2D collision)
    {
        if (collision.transform.tag == "item3")
        {
            Destroy(collision.gameObject);
            Player.PowerTimer();
            WSServer.PlayerPowerUp(DeviceId);
        }
        if (collision.transform.tag == "item4")
        {
            Destroy(collision.gameObject);
            Player.SpeedTimer();
        }
        if (collision.transform.tag == "item5")
        {
            body.drag = 6.5f;
        }
        if (collision.transform.tag == "item6")
        {
            GameObject white = GameObject.FindWithTag("item7");
            this.transform.position = white.transform.position;
            Destroy(collision.gameObject);
            Destroy(white.gameObject);
        }
        if (collision.transform.tag == "item8")
        {
            body.drag = 0.0f;
        }

        if (collision.transform.tag == "item9")
        {
            if (OnEatSmallNetItem != null)
            {
                OnEatSmallNetItem(DeviceId);
            }
            Destroy(collision.gameObject);
        }

        if (collision.transform.tag == "item10")
        {
            if (OnEatBigNetItem != null)
            {
                OnEatBigNetItem(DeviceId);
            }
            Destroy(collision.gameObject);
        }
    }
Esempio n. 23
0
        /// <summary>
        /// Listens (and creates a server if needed) to remote connections.
        /// </summary>
        public void Listen()
        {
            if (WS != null)
            {
                throw new Exception("Cannot both be a server and a client." +
                                    " Please use Connect if you are connecting to a server or Listen to create a server.");
            }

            if (WSServer == null)
            {
                MakeServer();
            }

            WSServer.Start();

            DataSocket.Initialize();
        }
Esempio n. 24
0
        //甄玉龙增加燃气校时配置帧
        public void calibraRQ(DeviceDTO dto)
        {
            var       server      = bootstrap.GetServerByName(WS_SERVER);
            WSServer  casicServer = server as WSServer;
            WSSession session     = casicServer.GetSessionByID(dto.SessionId) as WSSession;

            //下发校时信息
            String preTimeCal = "SewTiming:" + session.MacID + ",";
            String postTime   = DateTime.Now.ToString("yyyyMMddHHmmss");
            String timeCal    = preTimeCal + postTime;

            byte[] data1 = new byte[timeCal.Length + 2];
            Encoding.ASCII.GetBytes(timeCal, 0, timeCal.Length, data1, 0);
            data1[timeCal.Length]     = 0x0D;
            data1[timeCal.Length + 1] = 0x0A;
            session.Send(data1, 0, data1.Length);
            session.Logger.Info("校时信息:" + timeCal);
        }
Esempio n. 25
0
        /// <summary>
        /// Stops listening to remote connections.
        /// </summary>
        public void StopListening()
        {
            if (WS != null)
            {
                throw new Exception("Cannot both be a server and a client." +
                                    " Please use Disconnect if you are diconnecting from a server or StopListening to stop the server.");
            }

            if (WSServer == null)
            {
                return;
            }

            if (WSServer.IsListening)
            {
                WSServer.Stop();
            }

            DataSocket.Close();
        }
    private GameObject InstantiateItem(int itemType)
    {
        var prefab   = _gameManager.GetItemPrefab(itemType);
        var position = RandomPosition();
        var ret      = GameObject.Instantiate(prefab, position, Quaternion.identity);
        var item     = ret.GetComponent <ItemScript>();

        item.NetworkId = _itemNetworkId;
        WSServer.SpawnItem(new SerDeSpawnItem
        {
            ItemType  = itemType,
            Position  = position,
            NetworkId = _itemNetworkId,
        });

        item.DestroyCallback += networkId =>
                                WSServer.DestroyItem(networkId);

        ++_itemNetworkId;
        return(ret);
    }
Esempio n. 27
0
        public void Dispose()
        {
            if (WS != null && WS.IsAlive)
            {
                WS.Close();
            }
            if (WSServer != null && WSServer.IsListening)
            {
                WSServer.Stop();
            }

            if (DataSocket != null)
            {
                DataSocket.Close();
            }

            WS         = null;
            WSServer   = null;
            DataSocket = null;
            Serializer = null;
        }
        static void Main(string[] args)
        {
            if (args.Length != 1)
            {
                Console.WriteLine("usage: argument 1: ip\n UDP-Port : 4051\nWS-Port : 4123");
                return;
            }
                //parameter from console "-wsp" web-scoket port
                int wsp = 4123;
               // IPAddress wsip = IPAddress.Loopback;//IPAddress.Parse("10.218.9.30");//IPAddress.Parse("10.10.5.130");
                IPAddress wsip = IPAddress.Parse(args[0]);

                int udpp = 4051;
               // IPAddress udpip = IPAddress.Loopback;//IPAddress.Parse("10.218.9.30");//IPAddress.Parse("10.10.5.130");
                IPAddress udpip = IPAddress.Parse(args[0]);

                WSServer ws = new WSServer(wsip, wsp);
                UDPServer udp = new UDPServer(udpip, udpp);

                ws.init();
                udp.init(ws);
        }
    void OnCollisionEnter2D(Collision2D coll)
    {
        if (coll.transform.tag == "Ball")
        {
            // Debug.Log("collp");
            GameObject target = coll.gameObject;

            Vector3 inNormal = Vector3.Normalize(
                transform.position - target.transform.position);
            Vector3 bounceVector =
                Vector3.Reflect(coll.relativeVelocity, inNormal);
            // Debug.Log("inNormaly : " + inNormal.y + " bounceVectory : " + bounceVector.y);

            target.GetComponent <Rigidbody2D>().AddForce(-inNormal * Player.power, ForceMode2D.Impulse);
        }

        if (coll.transform.tag == "Player")
        {
            Player.GroggyTimer();
            WSServer.PlayerGroggy(DeviceId);
        }
    }
Esempio n. 30
0
        private bool sendWSConfig(DeviceDTO dto, Dictionary <String, String> settings)
        {
            var       server      = bootstrap.GetServerByName(WS_SERVER);
            WSServer  casicServer = server as WSServer;
            WSSession session     = casicServer.GetSessionByID(dto.SessionId) as WSSession;

            String period = settings["ws_period"];

            if (period == "")
            {
                return(false);
            }

            String sdata0 = "SewAcquireInterval:" + session.MacID + "," + period;

            byte[] data0 = new byte[sdata0.Length + 2];
            Encoding.ASCII.GetBytes(sdata0, 0, sdata0.Length, data0, 0);
            data0[sdata0.Length]     = 0x0D;
            data0[sdata0.Length + 1] = 0x0A;
            session.Send(data0, 0, data0.Length);
            session.Logger.Info("有害气体配置信息:" + sdata0);

            //下发校时信息

            /*
             * String preTimeCal = "SewTiming:" + session.MacID + ",";
             * String postTime = DateTime.Now.ToString("yyyyMMddHHmmss");
             * String timeCal = preTimeCal + postTime;
             *
             * byte[] data1 = new byte[timeCal.Length + 2];
             * Encoding.ASCII.GetBytes(timeCal, 0, timeCal.Length, data1, 0);
             * data1[timeCal.Length] = 0x0D;
             * data1[timeCal.Length + 1] = 0x0A;
             * session.Send(data1, 0, data1.Length);
             * session.Logger.Info("校时信息:" + timeCal);
             * */
            return(true);
        }
Esempio n. 31
0
        public ITransportListener StartConnectionListener(string uri, int port)
        {
            ServerConfig config = new ServerConfig();
            config.Port = port;
            config.MaxRequestLength = 100000;

            string host = uri;
            if (host != "Any")
            {
                IPAddress[] ipAddresses = Dns.GetHostAddresses(host);
                if (ipAddresses.Length == 0)
                    throw new Error(ErrorCode.CONNECTION_ERROR, "Cannot identify IP address by hostname.");
                config.Ip = ipAddresses[0].ToString();  // we take first entry as it does not matter which one is used
            }
            else
            {
                config.Ip = "Any";
            }
            var server = new WSServer();
            server.Setup(config);
            server.Start();
            return server as ITransportListener;
        }
Esempio n. 32
0
 void OnApplicationQuit()
 {
     WSServer.Stop();
     WSClient.Disconnect();
 }
Esempio n. 33
0
        public override void ProcessMessage()
        {
            try{
                string list_JianChaDXH = InObject.YIZHUID;//医嘱ID
                if (string.IsNullOrEmpty(list_JianChaDXH))
                {
                    throw new Exception("医技申请单号为空或传入节点有误");
                }

                string[] JianChaDanID = list_JianChaDXH.Split('|');

                for (int i = 0; i < JianChaDanID.Length; i++)
                {
                    var resource = new HISYY_Register();
                    resource.HospitalCode = ConfigurationManager.AppSettings["HospitalCode_Fck"].ToString();
                    resource.HospitalName = ConfigurationManager.AppSettings["HospitalName_Fck"].ToString();
                    string jcsqdSql = @"SELECT A.BINGRENXM,
                                   A.BINGRENSFZH,
                                   A.Shenqingdid,
                                   E.BINGRENID,
                                   A.BINGRENXB,
                                   A.CHUSHENGRQ AS CHUSHENRQ,
                                   A.BINGRENNL AS NIANLING,
                                   A.BINGRENLXDH AS LIANXIDH,
                                   A.BINGRENLXDZ AS DIZHI,
                                   E.JIUZHENKH,
                                   A.YIJISBDM AS SHEBEIDM,
                                   A.YIJISBMC AS SHEBEIMC,
                                   B.JIANCHASTBW,
                                   B.JIANCHAXMMC,
                                   F.FEIYONGHJ,
                                   H.FAPIAOHM,
                                   G.ZHIXINGKS,
                                   G.ZHIXINGKSMC,
                                   A.JIESHOURQ,
                                   A.YIJIYYRQ,
                                   A.YIJISQDH,
                                   A.YIJIYYH,
                                   A.SONGJIANKSDM,
                                   A.SONGJIANYSGH,
                                   A.YIJIXXAPSJ
                                    FROM SXZZ_JIANCHASQD A,SXZZ_JIANCHASQDMX B,GY_BINGRENXX E,  
                                         YJ_SHENQINGDAN F,MZ_YIJI1 G,MZ_FAPIAO1 H,MZ_YIJI2 I
                                WHERE A.JIANCHASQDID = B.JIANCHASQDID 
                                    AND A.BINGRENSFZH = E.SHENFENZH 
                                    AND A.Shenqingdid = F.SHENQINDANID 
                                    AND G.FAPIAOID = H.FAPIAOID
                                    AND G.YIJIID = I.YIJIID
                                    AND I.YIZHUID = F.YIZHUID
                                    AND I.YIZHUID = {0}
                                    AND ROWNUM = 1";
                    //,SXZZ_JIANCHASQDZD D  AND A.JIANCHASQDID = D.JIANCHASQDID
                    jcsqdSql = string.Format(jcsqdSql, JianChaDanID[i]);

                    DataTable jcsqdDt = DBVisitor.ExecuteTable(jcsqdSql);
                    if (jcsqdDt.Rows.Count == 0)
                    {
                        throw new Exception("HIS中检索不到相关记录:" + list_JianChaDXH);
                    }
                    foreach (DataRow dr in jcsqdDt.Rows)
                    {
                        resource.AdmissionSource   = "50";                         //病人类型
                        resource.PatientName       = dr["BINGRENXM"].ToString();
                        resource.IdNumber          = dr["BINGRENSFZH"].ToString(); //身份证号
                        resource.RequestNo         = dr["Shenqingdid"].ToString(); //申请单号
                        resource.AdmissionID       = dr["BINGRENID"].ToString();   //门诊/住院 号
                        resource.ExaminePartTime   = dr["YIJIXXAPSJ"].ToString();  //项目耗时
                        resource.PatientSex        = dr["BINGRENXB"].ToString();
                        resource.PatientBorn       = dr["CHUSHENRQ"].ToString();
                        resource.PatientAge        = dr["NIANLING"].ToString();
                        resource.PatientTel        = dr["LIANXIDH"].ToString();
                        resource.PatientAddress    = dr["DIZHI"].ToString();
                        resource.PatientCard       = dr["JIUZHENKH"].ToString(); //就诊卡号
                        resource.InPatientAreaName = "";                         //病区名称
                        resource.InPatientAreaCode = "";                         //病区代码
                        resource.BedNum            = "";                         //床号
                        resource.DeviceCode        = dr["SHEBEIDM"].ToString();  //设备代码
                        resource.DeviceName        = dr["SHEBEIMC"].ToString();  //设备名称
                        resource.StudiesExamine.Add(new StudiesExamine()
                        {
                            //HT  更改CODE取值
                            //ExamineCode = jcxmDt.Rows[i]["JIANCHAXMID"].ToString(),
                            ExamineCode  = dr["JIANCHASTBW"].ToString(),                         //检查项目代码
                            ExamineName  = XMLHandle.encodeString(dr["JIANCHAXMMC"].ToString()), //项目名称
                            Numbers      = "1",                                                  //数量
                            ExaminePrice = dr["FEIYONGHJ"].ToString()                            //单价
                        });
                        resource.ReceiptNum       = dr["FAPIAOHM"].ToString();                   //发票号码
                        resource.ZxDepartmentId   = dr["ZHIXINGKS"].ToString();                  //执行科室代码
                        resource.ZxDepartmentName = dr["ZHIXINGKSMC"].ToString();                //执行科室名称
                        resource.Sqrq             = dr["JIESHOURQ"].ToString();                  //。申请日期
                        resource.ExamineFY        = dr["FEIYONGHJ"].ToString();                  //检查费用
                        resource.YjsbCode         = "";                                          //设备代码
                        resource.BespeakDateTime  = dr["YIJIYYRQ"].ToString();                   //预约时间
                        resource.PDH = "";                                                       //排队号
                        resource.JCH = dr["YIJISQDH"].ToString();                                //检查号
                        resource.YYH = dr["YIJIYYH"].ToString();                                 //预约号
                        resource.RequestDepartmentId   = dr["SONGJIANKSDM"].ToString();          //申请科室代码
                        resource.RequestDepartmentName = "";                                     //申请科室名称
                        resource.RequestDoctorId       = dr["SONGJIANYSGH"].ToString();          //申请医生
                        resource.RequestDoctorName     = "";

                        string url = System.Configuration.ConfigurationManager.AppSettings["LaiDa_Url"];
                        string xml = XMLHandle.EntitytoXML <HISYY_Register>(resource);

                        logLaiDa.InfoFormat(this.GetType().Name + "设备登记调用莱达XML入参:" + xml);
                        //LogHelper.WriteLog(typeof(GG_ShuangXiangZzBLL), "设备预约调用莱达XML入参:" + xml);
                        string outxml = WSServer.Call <HISYY_Register>(url, xml).ToString();

                        logLaiDa.InfoFormat(this.GetType().Name + "设备预约调用莱达XML出参:" + outxml);
                        HISYY_Register_Result result = XMLHandle.XMLtoEntity <HISYY_Register_Result>(outxml);

                        if (result.Success == "False")
                        {
                            throw new Exception("预约登记失败,错误原因:" + result.Message);
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                throw new Exception(ex.Message);
            }
        }