From a715181089be0d31cd737a5367ffd02690b9d77f Mon Sep 17 00:00:00 2001
From: wxr <464027401@qq.com>
Date: 星期四, 12 十一月 2020 13:36:01 +0800
Subject: [PATCH] 20201112

---
 HDL_ON/DriverLayer/CommonPage.cs |  673 -------------------------------------------------------
 1 files changed, 2 insertions(+), 671 deletions(-)

diff --git a/HDL_ON/DriverLayer/CommonPage.cs b/HDL_ON/DriverLayer/CommonPage.cs
index d12e95e..af0ff35 100644
--- a/HDL_ON/DriverLayer/CommonPage.cs
+++ b/HDL_ON/DriverLayer/CommonPage.cs
@@ -1,677 +1,8 @@
-锘縰sing System;
-using System.Text;
-using HDL_ON.DAL.Net;
-using HDL_ON.Entity;
-using HDL_ON.UI;
-using Newtonsoft.Json;
-using Newtonsoft.Json.Linq;
-using Shared;
-using Shared.Net;
-
+锘�
 namespace HDL_ON.DAL
 {
-    public static class CommonPage
+    public class CommonPage
     {
 
-        public static bool IsRemote;
-        public static Action RefreshAir;
-        public static string FindGatewayChilrenIPAddress = new NetWiFi().BroadcastIpAddress.ToString();
-        private static string ip = "0.0.0.0";
-        public static System.Net.IPEndPoint EndPoint
-        {
-            get
-            {
-                try
-                {
-                    return new System.Net.IPEndPoint(System.Net.IPAddress.Parse(new NetWiFi().BroadcastIpAddress.ToString()), 6000);
-                }
-                catch
-                {
-                    //闃叉寮傚父瀵艰嚧绋嬪簭閫�鍑�
-                    return new System.Net.IPEndPoint(System.Net.IPAddress.Parse("127.0.0.1"), 6000);
-                }
-            }
-        }
-
-
-        public static System.Net.IPEndPoint GetGatewayIP_EndPoint
-        {
-            get
-            {
-                //闃叉寮傚父瀵艰嚧绋嬪簭閫�鍑�
-                return new System.Net.IPEndPoint(System.Net.IPAddress.Parse("224.0.168.188"), 6688);
-            }
-        }
-
-        ///淇濆瓨璁惧澶囨敞鎵嶇敤gb2312锛屽叾浠栨儏鍐电敤utf8
-        public static Encoding MyEncodingUTF8 = Encoding.UTF8;//Get
-        public static Encoding MyEncodingGB2312
-        {
-            get
-            {
-                try
-                {
-                    if (System.Globalization.CultureInfo.InstalledUICulture.EnglishName.ToUpper().StartsWith("CZECH"))
-                    {
-                        return Encoding.GetEncoding(1250);
-                    }
-                    else
-                    {
-                        return Encoding.GetEncoding("gb2312");
-                    }
-                }
-                catch (Exception ex)
-                {
-                    MainPage.Log("MyEncodingGB2312 Erorr : " + ex.Message);
-                    return Encoding.GetEncoding("gb2312");
-                }
-            }
-        }
-        public static bool isHttpListenerStart;
-        public static DateTime dt;
-
-        //public static byte currentSubnetID = 0;
-        public static void InitHttpListener()
-        {
-            if (isHttpListenerStart)
-            {
-                return;
-            }
-            Console.WriteLine("Init Http Listener !");
-            HttpListener.Start(new NetWiFi().IpAddress, 6002);
-            HttpListener.EventHandler -= httpListener_EventHandler;
-            HttpListener.EventHandler += httpListener_EventHandler;
-            isHttpListenerStart = true;
-        }
-        public static void CloseHttpListener()
-        {
-            //isHttpListenerStart = false;
-            //return;
-            if (!isHttpListenerStart)
-                return;
-            HttpListener.Close();
-            isHttpListenerStart = false;
-        }
-        /// <summary>
-        /// 鍒濆鍖栧鐞唖ocket鎺ユ敹鐨勬暟鎹� 
-        /// </summary>
-        public static void InitReceiveEvent()
-        {
-            Packet.ReceiveEvent += Packet_ReceiveEvent;
-        }
-
-        public static float floatChange(byte b1, byte b2, byte b3, byte b4)
-        {
-            byte[] byteTemp = { b4, b3, b2, b1 };
-            return BitConverter.ToSingle(byteTemp, 0);
-        }
-
-
-        static void Packet_ReceiveEvent(byte subnetID, byte deviceID, Command command, byte[] receiveBytes, string revGatewayIP)
-        {
-            try
-            {
-                if(revGatewayIP == "172.16.2.237")
-                {
-
-                }
-                Control.controlLostCount = 0;
-
-                switch (command)
-                {
-                    case Command.ReadLightSingleLoopBrightnessACK:
-                    case Command.SetSingleLightACK:
-                        foreach (var light in DB_ResidenceData.residenceData.functionList.lights)
-                        {
-                            if (light.GetBusId() == subnetID + "_" + deviceID + "_" + receiveBytes[0])
-                            {
-                                if (light.functionType != FunctionType.RGB)
-                                {
-                                    light.on_off = receiveBytes[2] == 0 ? "off" : "on";
-                                    if (light.on_off == "on")
-                                    {
-                                        light.brightness = receiveBytes[2];
-                                        light.lastState = Language.StringByID(StringId.Brightness) + " : " + receiveBytes[2] + "%";
-                                    }
-                                    HomePage.UpdataFunctionStates(light);
-                                    RoomPage.UpdataStates(light);
-                                    FunctionPage.UpdataStates(light);
-                                    ClassificationPage.UpdataInfo(light);
-                                    switch (light.functionType)
-                                    {
-                                        case FunctionType.Relay:
-                                            RelayPage.UpdataState(light);
-                                            break;
-                                        case FunctionType.Dimmer:
-                                            DimmerPage.UpdataStates(light);
-                                            break;
-                                    }
-                                }
-                            }
-                        }
-
-                        foreach (var e in DB_ResidenceData.residenceData.functionList.electricals)
-                        {
-                            if (e.GetBusId() == subnetID + "_" + deviceID + "_" + receiveBytes[0])
-                            {
-                                if (e.functionType == FunctionType.Fan)
-                                {
-                                    var fan = e as Fan;
-                                    fan.on_off = receiveBytes[2] == 0 ? "off" : "on";
-                                    if (fan.on_off == "on")
-                                    {
-                                        fan.openLevel = receiveBytes[2];
-                                        fan.lastState = Language.StringByID(StringId.Level) + " : " + receiveBytes[2];
-                                    }
-                                    HomePage.UpdataFunctionStates(fan);
-                                    RoomPage.UpdataStates(fan);
-                                    FunctionPage.UpdataStates(fan);
-                                    ClassificationPage.UpdataInfo(fan);
-                                    switch (fan.functionType)
-                                    {
-                                        case FunctionType.Fan:
-                                            FanPage.UpdataState(fan);
-                                            break;
-                                        case FunctionType.Socket:
-
-                                            break;
-                                    }
-                                }
-                            }
-                        }
-
-                        break;
-                    case Command.SetLogicLoopColorACK:
-                    case Command.ReadLogicLoopColorACK:
-                        foreach (var rgb in DB_ResidenceData.residenceData.functionList.lights)
-                        {
-                            if (rgb.GetBusId() == subnetID + "_" + deviceID + "_" + receiveBytes[0])
-                            {
-                                if (rgb.functionType == FunctionType.RGB)
-                                {
-                                    rgb.on_off = receiveBytes[1] > 0 ? "on" : "off";
-                                    if (receiveBytes[1] > 0)
-                                    {
-                                        rgb.brightness = receiveBytes[1];
-                                        rgb.lastState = Language.StringByID(StringId.Brightness) + " : " + receiveBytes[1] + "%";
-                                    }
-                                    rgb.redColor = receiveBytes[6];
-                                    rgb.greenColor = receiveBytes[7];
-                                    rgb.blueColor = receiveBytes[8];
-
-                                    HomePage.UpdataFunctionStates(rgb);
-                                    RoomPage.UpdataStates(rgb);
-                                    FunctionPage.UpdataStates(rgb);
-                                    ClassificationPage.UpdataInfo(rgb);
-                                    RGBPage.UpdataStates(rgb);
-                                }
-                            }
-                        }
-                        break;
-                    case Command.SetCurtainModelStutasACK:
-                    case Command.ReadCurtainStutasACK:
-                        foreach (var curtain in DB_ResidenceData.residenceData.functionList.curtains)
-                        {
-                            if (curtain.bus_Data.SubnetID == subnetID && curtain.bus_Data.DeviceID == deviceID)
-                            {
-                                if (receiveBytes[0] == 17)
-                                {
-                                    if (receiveBytes[1] > 1)
-                                    {
-                                        curtain.on_off = "on";
-                                    }
-                                    else
-                                    {
-                                        curtain.on_off = "off";
-                                    }
-                                    curtain.openLevel = receiveBytes[1];
-                                    curtain.lastState = Language.StringByID(StringId.Open) + curtain.openLevel + "%";
-                                }
-                                else
-                                {
-                                    if (curtain.bus_Data.LoopID != receiveBytes[0])
-                                        continue;
-                                    switch (receiveBytes[1])
-                                    {
-                                        case 0:
-                                            curtain.on_off = "stop";
-                                            break;
-                                        case 1:
-                                            curtain.on_off = "on";
-                                            curtain.lastState = Language.StringByID(StringId.Open);
-                                            break;
-                                        case 2:
-                                            curtain.on_off = "off";
-                                            curtain.lastState = Language.StringByID(StringId.Close);
-                                            break;
-                                    }
-                                }
-                                RoomPage.UpdataStates(curtain);
-                                FunctionPage.UpdataStates(curtain);
-                                HomePage.UpdataFunctionStates(curtain);
-                                ClassificationPage.UpdataInfo(curtain);
-                                RollingShutterPage.UpdataState(curtain);
-                                switch (curtain.functionType)
-                                {
-                                    case FunctionType.Curtain:
-                                        CurtainModulePage.UpdataState(curtain);
-                                        break;
-                                }
-                            }
-                        }
-                        break;
-                    case Command.SetACModeACK:
-                    case Command.ReadACModeACK:
-                        foreach (var ac in DB_ResidenceData.residenceData.functionList.aCs)
-                        {
-                            if (ac.GetBusId() == subnetID + "_" + deviceID + "_" + receiveBytes[0])
-                            {
-                                ac.curTempType = receiveBytes[1];
-                                ac.indoorTemp = receiveBytes[2];
-                                ac.on_off = receiveBytes[8] == 1 ? "on" : "off";
-                                ac.curModeIndex = receiveBytes[9];
-                                ac.curFanIndex = receiveBytes[10];
-                                ac.curTemp = receiveBytes[11];
-                                ac.lastState = "";
-                                switch (ac.trait_mode.curValues.ToString())
-                                {
-                                    case "cool":
-                                        ac.lastState = Language.StringByID(StringId.Cool);
-                                        break;
-                                    case "heat":
-                                        ac.lastState = Language.StringByID(StringId.Heat);
-                                        break;
-                                    case "dry":
-                                        ac.lastState = Language.StringByID(StringId.Dry);
-                                        break;
-                                    case "auto":
-                                        ac.lastState = Language.StringByID(StringId.Auto);
-                                        break;
-                                    case "fan":
-                                        ac.lastState = Language.StringByID(StringId.AirSupply);
-                                        break;
-                                }
-                                switch (ac.trait_fan.curValues.ToString())
-                                {
-                                    case "high":
-                                        ac.lastState += " " + Language.StringByID(StringId.HighWindSpeed);
-                                        break;
-                                    case "medium":
-                                        ac.lastState += " " + Language.StringByID(StringId.MiddleWindSpeed);
-                                        break;
-                                    case "low":
-                                        ac.lastState += " " + Language.StringByID(StringId.LowWindSpeed);
-                                        break;
-                                    case "auto":
-                                        ac.lastState += " " + Language.StringByID(StringId.Auto);
-                                        break;
-                                }
-                                ac.lastState += " " + ac.curTemp + ac.curTempTypeString;
-                                RoomPage.UpdataStates(ac);
-                                FunctionPage.UpdataStates(ac);
-                                HomePage.UpdataFunctionStates(ac);
-                                ClassificationPage.UpdataInfo(ac);
-                                ACPage.UpdataStates(ac);
-                            }
-                        }
-                        break;
-                    case Command.ReadFloorHeatACK:
-                    case Command.SetFloorHeatACK:
-                        foreach (var fh in DB_ResidenceData.residenceData.functionList.floorHeatings)
-                        {
-                            if (fh.GetBusId() == subnetID + "_" + deviceID + "_" + receiveBytes[0])
-                            {
-                                fh.curTempType = receiveBytes[2];
-                                fh.on_off = receiveBytes[1] % 2 == 0 ? "off" : "on";
-                                fh.curModeIndex = receiveBytes[3];
-                                if (fh.modeTemp.ContainsKey("ordinary"))
-                                {
-                                    fh.modeTemp["ordinary"] = receiveBytes[4];
-                                }
-                                else
-                                {
-                                    fh.modeTemp.Add("ordinary", receiveBytes[4]);
-                                }
-                                if (fh.modeTemp.ContainsKey("day"))
-                                {
-                                    fh.modeTemp["day"] = receiveBytes[5];
-                                }
-                                else
-                                {
-                                    fh.modeTemp.Add("day", receiveBytes[5]);
-                                }
-
-                                if (fh.modeTemp.ContainsKey("night"))
-                                {
-                                    fh.modeTemp["night"] = receiveBytes[6];
-                                }
-                                else
-                                {
-                                    fh.modeTemp.Add("night", receiveBytes[6]);
-                                }
-
-                                if (fh.modeTemp.ContainsKey("away"))
-                                {
-                                    fh.modeTemp["away"] = receiveBytes[7];
-                                }
-                                else
-                                {
-                                    fh.modeTemp.Add("away", receiveBytes[7]);
-                                }
-                                switch (fh.curMode)
-                                {
-                                    case "ordinary":
-                                        fh.lastState = Language.StringByID(StringId.Ordinary);
-                                        break;
-                                    case "day":
-                                        fh.lastState = Language.StringByID(StringId.Day);
-                                        break;
-                                    case "night":
-                                        fh.lastState = Language.StringByID(StringId.Night);
-                                        break;
-                                    case "timer":
-                                        fh.lastState = Language.StringByID(StringId.Auto);
-                                        if (receiveBytes[8] == 0)
-                                        {
-                                        }
-                                        else
-                                        {
-                                        }
-                                        break;
-                                    case "away":
-                                        fh.curTemp = receiveBytes[7];
-                                        fh.lastState = Language.StringByID(StringId.Away);
-                                        break;
-                                }
-                                fh.lastState += " " + fh.curTemp + fh.curTempTypeString;
-                                RoomPage.UpdataStates(fh);
-                                FunctionPage.UpdataStates(fh);
-                                HomePage.UpdataFunctionStates(fh);
-                                ClassificationPage.UpdataInfo(fh);
-                                FloorHeatingPage.UpdataStates(fh);
-                            }
-                        }
-                        break;
-                    case Command.ReadDeviceLoopInfoACK:
-                        FunctionType dt = (FunctionType)(11 * 256 + receiveBytes[1]);
-                        string tag = receiveBytes[1] + "_" + subnetID + "_" + deviceID + "_" + receiveBytes[2];
-
-                        foreach (var sensor in DB_ResidenceData.residenceData.functionList.sensorsEnvironmentalScience)
-                        {
-                            if (sensor.bus_Data != null)
-                            {
-                                if ((int)sensor.functionType % 256 == receiveBytes[1] && sensor.bus_Data.SubnetID == subnetID &&
-                                    sensor.bus_Data.DeviceID == deviceID && sensor.bus_Data.LoopID == receiveBytes[2])
-                                {
-                                    switch (dt)
-                                    {
-                                        case FunctionType.Temp:
-                                            byte[] tempBytes = new byte[] { receiveBytes[24], receiveBytes[25], receiveBytes[26], receiveBytes[27] };
-                                            sensor.values = Math.Round(BitConverter.ToSingle(tempBytes, 0), 1);
-                                            break;
-                                        case FunctionType.Humidity:
-                                            sensor.values = Convert.ToDouble(receiveBytes[24] * 256 + receiveBytes[25]) / 10;
-                                            break;
-                                        case FunctionType.TVOC:
-                                            sensor.values = Convert.ToDouble(receiveBytes[24] * 256 + receiveBytes[25]) / 100;
-                                            break;
-                                        case FunctionType.PM25:
-                                            sensor.values = Convert.ToInt32(receiveBytes[24] * 256 + receiveBytes[25]);
-                                            break;
-                                        case FunctionType.CO2:
-                                            sensor.values = Convert.ToInt32(receiveBytes[24] * 256 + receiveBytes[25]);
-                                            break;
-                                    }
-                                    EnvironmentalSciencePage.LoadEvent_UpdataStatus(sensor);
-                                }
-                            }
-                        }
-                        break;
-                    case Command.New_Analog_Quantity_BROADCAST:
-                        string tag1 = receiveBytes[1] + "_" + subnetID + "_" + deviceID + "_" + receiveBytes[2];
-                        foreach (var sensor in DB_ResidenceData.residenceData.functionList.sensorsEnvironmentalScience)
-                        {
-                            if (sensor.bus_Data != null)
-                            {
-                                if ((int)sensor.functionType % 256 == receiveBytes[1] && sensor.bus_Data.SubnetID == subnetID &&
-                                    sensor.bus_Data.DeviceID == deviceID && sensor.bus_Data.LoopID == receiveBytes[2])
-                                {
-                                    //0淇濈暀 1鏃犵鍙�4Byte鏁村舰  2鏈夌鍙�4Byte鏁村舰  3Float褰紙浠B憋級
-                                    switch (receiveBytes[3])
-                                    {
-                                        case 1:
-                                            sensor.values = (receiveBytes[5] * 256 * 256 * 256) + (receiveBytes[6] * 256 * 256) + (receiveBytes[7] * 256) + receiveBytes[8];
-                                            break;
-                                        case 2:
-                                            sensor.values = -1 * ((receiveBytes[5] * 256 * 256 * 256) + (receiveBytes[6] * 256 * 256) + (receiveBytes[7] * 256) + receiveBytes[8]);
-                                            break;
-                                        case 3:
-                                            byte[] tempBytes = new byte[] { receiveBytes[5], receiveBytes[6], receiveBytes[7], receiveBytes[8] };
-                                            sensor.values = Math.Round(BitConverter.ToSingle(tempBytes, 0), 1);
-                                            break;
-                                    }
-                                    switch (receiveBytes[4])
-                                    {
-                                        case 2:
-                                            if (receiveBytes[1] == 5)//TVOC闇�姹傞櫎浠�100000
-                                                sensor.values /= 100000;
-                                            break;
-                                    }
-                                    EnvironmentalSciencePage.LoadEvent_UpdataStatus(sensor);
-                                }
-                            }
-                        }
-                        break;
-                    case Command.InstructionPanelKeyACK:
-                    case Command.ReadInstructionPanelKeyACK:
-                        byte reACPanel = 0;
-                        if (receiveBytes.Length == 2)
-                        {
-                            reACPanel = 1;
-                        }
-                        else if (receiveBytes.Length == 3)
-                        {
-                            reACPanel = receiveBytes[2];
-                        }
-                        else
-                        {
-                            break;
-                        }
-                        foreach (var ac in DB_ResidenceData.residenceData.functionList.aCs)
-                        {
-                            if (ac.GetBusId() == subnetID + "_" + deviceID + "_" + reACPanel)
-                            {
-                                switch (receiveBytes[0])
-                                {
-                                    case 3://
-                                        ac.on_off = receiveBytes[1] == 1 ? "on" : "off";
-                                        break;
-                                    case 4:
-                                    case 7:
-                                    case 8:
-                                    case 19:
-                                        ac.curTemp = receiveBytes[1];
-                                        break;
-                                    case 5:
-                                        ac.curFanIndex = receiveBytes[1];
-                                        break;
-                                    case 6:
-                                        ac.curModeIndex = receiveBytes[1];
-                                        break;
-
-                                }
-                                ac.lastState = "";
-                                ac.lastState += " " + ac.curTemp + ac.curTempTypeString;
-                                RoomPage.UpdataStates(ac);
-                                FunctionPage.UpdataStates(ac);
-                                HomePage.UpdataFunctionStates(ac);
-                                ClassificationPage.UpdataInfo(ac);
-                                ACPage.UpdataStates(ac);
-                                //else if (common.Type == DeviceType.FoolHeatPanel)
-                                {
-                                    //switch (receiveBytes[0])
-                                    //{
-                                    //    case 20://
-                                    //        fh.Status = receiveBytes[1];
-                                    //        break;
-                                    //    case 21:
-                                    //        fh.TemperatureType = receiveBytes[1];
-                                    //        if (receiveBytes[1] == 5)
-                                    //        {
-                                    //            if (fh.Timer == 0)//鏃堕棿妯″紡鐨勬椂闂存鏍囧織 (0锛氱櫧澶╋紝1锛氬鏅�) (1byte)     //20110112鍔犳椂闂存鏍囧織
-                                    //                Control.ControlBytesSend(Command.ReadInstructionPanelKey, fh.SubnetID, fh.DeviceID, new byte[] { 26, 2, fh.LoopID }, SendCount.Zero);
-                                    //            else
-                                    //                Control.ControlBytesSend(Command.ReadInstructionPanelKey, fh.SubnetID, fh.DeviceID, new byte[] { 27, 3, fh.LoopID }, SendCount.Zero);
-                                    //        }
-                                    //        else
-                                    //            Control.ControlBytesSend(Command.ReadInstructionPanelKey, fh.SubnetID, fh.DeviceID, new byte[] { (byte)(receiveBytes[1] + 24), fh.LoopID }, SendCount.Zero);
-                                    //        break;
-                                    //    case 25:
-                                    //        fh.NormalTemperature = receiveBytes[1];
-                                    //        break;
-                                    //    case 26:
-                                    //        fh.DayTemperature = receiveBytes[1];
-                                    //        break;
-                                    //    case 27:
-                                    //        fh.NightTemperature = receiveBytes[1];
-                                    //        break;
-                                    //    case 28:
-                                    //        fh.AwayTemperature = receiveBytes[1];
-                                    //        break;
-                                    //}
-                                }
-                            }
-                        }
-                        break;
-                    case Command.ReadPanleTempACK://1944
-                    case Command.PanleBroadcastTemp:
-                        foreach (var ac in DB_ResidenceData.residenceData.functionList.aCs)
-                        {
-                            if (ac.GetBusId() == subnetID + "_" + deviceID + "_" + receiveBytes[0])
-                            {
-                                ac.indoorTemp = receiveBytes[1];
-                                FunctionPage.UpdataStates(ac);
-                            }
-                            //else if (common.Type == DeviceType.FoolHeatPanel)
-                            //    {
-                            //        var tempFH22 = common as FoolHeatPanel;
-                            //        tempFH22.IndoorTemperature = receiveBytes[1];
-                            //        UserFHPage.UpdateIndoorTemp(tempFH22.CommonLoopID, receiveBytes[1]);
-                            //    }
-                        }
-                        break;
-                }
-            }
-            catch (Exception ex)
-            {
-                MainPage.Log($"Bus Rev Erorr : {ex.Message}");
-            }
-        }
-        /// <summary>
-        /// byte 鍙樺瓧绗︿覆
-        /// </summary>
-        /// <returns>The to hex16.</returns>
-        /// <param name="b">The blue component.</param>
-        public static string byteToHex16(byte b)
-        {
-            string s = Convert.ToString(b, 16).ToUpper();
-            if (s.Length <= 1)
-            {
-                return "0" + s;
-            }
-            return s;//
-        }
-
-        static void httpListener_EventHandler(System.Collections.Specialized.NameValueCollection nameValueCollection, System.IO.Stream outputStream, System.IO.Stream inputStream)
-        {
-            try
-            {
-                if (nameValueCollection["Command"] != null && nameValueCollection["Command"].StartsWith("Get"))
-                {
-                    string tempFileName = nameValueCollection["Command"].Replace("Get", "");
-                    if ("AllFiles" == tempFileName)
-                    {
-                        byte[] bytes = Encoding.UTF8.GetBytes(JsonConvert.SerializeObject(FileUtils.ReadFiles()));
-                        outputStream.Write(bytes, 0, bytes.Length);
-                        outputStream.Flush();
-                    }
-                    else
-                    {
-                        byte[] bytes;
-                        if (!FileUtils.Exists(tempFileName))
-                        {
-                            bytes = Encoding.UTF8.GetBytes("鏂囦欢鍚嶄笉瀛樺湪锛�");
-                            outputStream.Write(bytes, 0, bytes.Length);
-                            outputStream.Flush();
-                            return;
-                        }
-                        System.IO.FileStream fs = new System.IO.FileStream(Application.RootPath + tempFileName, System.IO.FileMode.Open);
-                        bytes = new byte[fs.Length];
-                        fs.Read(bytes, 0, bytes.Length);
-                        fs.Close();
-                        outputStream.Write(bytes, 0, bytes.Length);
-                        outputStream.Flush();
-                    }
-                }
-                else if (nameValueCollection["Command"].StartsWith("Upload"))
-                {
-                    string path = Application.RootPath + nameValueCollection["Command"].Replace("Upload", "");
-                    string dePath = nameValueCollection["Command"].Replace("Upload", "");
-                    FileUtils.WriteFileByInputStream(path, inputStream);
-                    var reString = CommonPage.MyEncodingUTF8.GetString(FileUtils.ReadFile(path));
-                    var common = JsonConvert.DeserializeObject<AProtocolEntity>(reString);
-                    //Console.WriteLine(common.ToString());
-                    if(dePath == "FunctionList")
-                    {
-                        foreach(var obj in common.objects)
-                        {
-                            DB_ResidenceData.residenceData.functionList.AddFunction(obj);
-                        }
-                        DB_ResidenceData.residenceData.functionList.GetAllFunction();
-                    }
-                }
-                else
-                {
-                    byte[] bytes = System.Text.Encoding.UTF8.GetBytes("璇锋眰鍛戒护鏃犳晥锛�");
-                    outputStream.Write(bytes, 0, bytes.Length);
-                    outputStream.Flush();
-                }
-            }
-            catch (Exception ex)
-            {
-                MainPage.Log("httpListener_EventHandler" + ex.ToString());
-            }
-        }
-
-        /// <summary>
-        /// 鐩戝惉璇锋眰鐨凥ttp绔彛
-        /// </summary>
-        public static int Port = 5555;
-        static void httpListener_EventHandler(string rawUrl, System.IO.Stream outputStream, System.IO.Stream inputStream)
-        {
-            foreach (var musicInfo in MusicInfo.MusicInfoList)
-            {
-                if ("audio-item-" + musicInfo.ID == rawUrl.TrimStart('/'))
-                {
-                    var file = new System.IO.FileStream(musicInfo.Data, System.IO.FileMode.Open, System.IO.FileAccess.Read);
-                    byte[] bytes = new byte[1024];
-                    try
-                    {
-                        while (file.CanRead)
-                        {
-                            int len = file.Read(bytes, 0, bytes.Length);
-                            if (len == 0)
-                            {
-                                break;
-                            }
-                            outputStream.Write(bytes, 0, len);
-                        }
-                    }
-                    catch { }
-                    file.Close();
-                    break;
-                }
-            }
-        }
     }
 }
\ No newline at end of file

--
Gitblit v1.8.0