You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
949 lines
30 KiB
949 lines
30 KiB
using GLTFast; |
|
using Newtonsoft.Json; |
|
using System; |
|
using System.Collections; |
|
using System.Collections.Generic; |
|
using System.IO; |
|
using System.Runtime.InteropServices; |
|
using System.Text; |
|
using UnityEngine; |
|
using UnityEngine.Networking; |
|
|
|
public class HttpManager : Singleton<HttpManager> |
|
{ |
|
#region Path |
|
/// <summary> |
|
/// 截屏目录 |
|
/// </summary> |
|
private string m_ScreenshotPath = $"{Application.streamingAssetsPath}/Screenshots/"; |
|
public string ScreenshotPath |
|
{ |
|
get |
|
{ |
|
if (!Directory.Exists(m_ScreenshotPath)) |
|
{ |
|
Directory.CreateDirectory(m_ScreenshotPath); |
|
} |
|
return m_ScreenshotPath; |
|
} |
|
} |
|
/// <summary> |
|
/// 模型旋转角度 |
|
/// </summary> |
|
public string GetInitialAnge |
|
{ |
|
get { return $"{Application.streamingAssetsPath}/Data/InitialAngle.json"; } |
|
} |
|
/// <summary> |
|
/// 设备列表 |
|
/// </summary> |
|
public string GetDeiveceList |
|
{ |
|
get { return $"{Application.streamingAssetsPath}/Data/DevicesList.json"; } |
|
} |
|
/// <summary> |
|
/// 楼层按钮 |
|
/// </summary> |
|
public string GetFloorButtons |
|
{ |
|
get { return $"{Application.streamingAssetsPath}/Data/Floors.json"; } |
|
} |
|
/// <summary> |
|
/// 单位基本信息 |
|
/// </summary> |
|
public string GetBuildingBasicInfos |
|
{ |
|
get { return $"{Config.ServerAddress}/api/BuildingBasicInfos?name={Config.CompanyName}"; } |
|
} |
|
public string PostBuildingBasicInfos |
|
{ |
|
get { return $"{Config.ServerAddress}/api/BuildingBasicInfos?name={Config.CompanyName}"; } |
|
} |
|
/// <summary> |
|
/// 高度相机位置 |
|
/// </summary> |
|
public string GetHeightLocation |
|
{ |
|
get { return $"{Application.streamingAssetsPath}/Data/HeightLocation.json"; } |
|
} |
|
/// <summary> |
|
/// 毗邻相机位置 |
|
/// </summary> |
|
public string GetAdjacentLocation |
|
{ |
|
get { return $"{Application.streamingAssetsPath}/Data/AdjacentLocation.json"; } |
|
} |
|
|
|
/// <summary> |
|
/// 建筑特点 |
|
/// </summary> |
|
public string GetBuildingFeatures |
|
{ |
|
get { return $"{Config.ServerAddress}/api/BuildingFeatures?name={Config.CompanyName}"; } |
|
} |
|
public string PostBuildingFeatures |
|
{ |
|
get { return $"{Config.ServerAddress}/api/BuildingFeatures?name={Config.CompanyName}"; } |
|
} |
|
/// <summary> |
|
/// 毗邻信息 |
|
/// </summary> |
|
public string GetAllBuildingAdjoins |
|
{ |
|
get { return $"{Config.ServerAddress}/api/BuildingAdjoins?name={Config.CompanyName}"; } |
|
} |
|
public string GetBuildingAdjoinsById |
|
{ |
|
get { return $"{Config.ServerAddress}/api/BuildingAdjoins/{{0}}?name={Config.CompanyName}"; } |
|
} |
|
public string PostBuildingAdjoinsById |
|
{ |
|
get { return $"{Config.ServerAddress}/api/BuildingAdjoins/{{0}}?name={Config.CompanyName}"; } |
|
} |
|
/// <summary> |
|
/// 登高作业面 |
|
/// </summary> |
|
public string GetAllFireClimbingSites |
|
{ |
|
get { return $"{Config.ServerAddress}/api/ClimbingSurfaces?name={Config.CompanyName}"; } |
|
} |
|
public string PostAllFireClimbingSites |
|
{ |
|
get { return $"{Config.ServerAddress}/api/ClimbingSurfaces?name={Config.CompanyName}"; } |
|
} |
|
public string GetFireClimbingSitesById |
|
{ |
|
get { return $"{Config.ServerAddress}/api/ClimbingSurfaces/{{0}}?name={Config.CompanyName}"; } |
|
} |
|
public string PostFireClimbingSitesById |
|
{ |
|
get { return $"{Config.ServerAddress}/api/ClimbingSurfaces/{{0}}?name={Config.CompanyName}"; } |
|
} |
|
/// <summary> |
|
/// 危险源 |
|
/// </summary> |
|
public string GetAllHazardSources |
|
{ |
|
get { return $"{Config.ServerAddress}/api/Hazards?name={Config.CompanyName}"; } |
|
} |
|
public string PostAllHazardSources |
|
{ |
|
get { return $"{Config.ServerAddress}/api/Hazards?name={Config.CompanyName}"; } |
|
} |
|
public string GetHazardSourcesById |
|
{ |
|
get { return $"{Config.ServerAddress}/api/Hazards/{{0}}?name={Config.CompanyName}"; } |
|
} |
|
public string PostHazardSourcesById |
|
{ |
|
get { return $"{Config.ServerAddress}/api/Hazards/{{0}}?name={Config.CompanyName}"; } |
|
} |
|
/// <summary> |
|
/// 禁停区 |
|
/// </summary> |
|
public string GetAllNoParkingAreas |
|
{ |
|
get { return $"{Config.ServerAddress}/api/NoParkingAreas?name={Config.CompanyName}"; } |
|
} |
|
public string PostAllNoParkingAreas |
|
{ |
|
get { return $"{Config.ServerAddress}/api/NoParkingAreas?name={Config.CompanyName}"; } |
|
} |
|
public string GetNoParkingAreasById |
|
{ |
|
get { return $"{Config.ServerAddress}/api/NoParkingAreas/{{0}}?name={Config.CompanyName}"; } |
|
} |
|
public string PostNoParkingAreasById |
|
{ |
|
get { return $"{Config.ServerAddress}/api/NoParkingAreas/{{0}}?name={Config.CompanyName}"; } |
|
} |
|
/// <summary> |
|
/// 重点区域 |
|
/// </summary> |
|
public string GetAllImportantLocations |
|
{ |
|
get { return $"{Config.ServerAddress}/api/ImportantLocations?name={Config.CompanyName}"; } |
|
} |
|
public string PostAllImportantLocations |
|
{ |
|
get { return $"{Config.ServerAddress}/api/ImportantLocations?name={Config.CompanyName}"; } |
|
} |
|
public string GetImportantLocationsById |
|
{ |
|
get { return $"{Config.ServerAddress}/api/ImportantLocations/{{0}}?name={Config.CompanyName}"; } |
|
} |
|
public string PostImportantLocationsById |
|
{ |
|
get { return $"{Config.ServerAddress}/api/ImportantLocations/{{0}}?name={Config.CompanyName}"; } |
|
} |
|
/// <summary> |
|
/// 图片标记信息 |
|
/// </summary> |
|
public string GetAllImageMarkers |
|
{ |
|
get { return $"{Config.ServerAddress}/api/ImageMarkers?name={Config.CompanyName}"; } |
|
} |
|
public string PostAllImageMarkers |
|
{ |
|
get { return $"{Config.ServerAddress}/api/ImageMarkers?name={Config.CompanyName}"; } |
|
} |
|
public string GetImageMarkersById |
|
{ |
|
get { return $"{Config.ServerAddress}/api/ImageMarkers/{{0}}?name={Config.CompanyName}"; } |
|
} |
|
public string PostImageMarkersById |
|
{ |
|
get { return $"{Config.ServerAddress}/api/ImageMarkers/{{0}}?name={Config.CompanyName}"; } |
|
} |
|
/// <summary> |
|
/// 逃生窗 |
|
/// </summary> |
|
public string GetAllEscapeWins |
|
{ |
|
get { return $"{Config.ServerAddress}/api/EscapeWindows?name={Config.CompanyName}"; } |
|
} |
|
public string PostAllEscapeWins |
|
{ |
|
get { return $"{Config.ServerAddress}/api/EscapeWindows?name={Config.CompanyName}"; } |
|
} |
|
public string GetEscapeWinsById |
|
{ |
|
get { return $"{Config.ServerAddress}/api/EscapeWindows/{{0}}?name={Config.CompanyName}"; } |
|
} |
|
public string PostEscapeWinsById |
|
{ |
|
get { return $"{Config.ServerAddress}/api/EscapeWindows/{{0}}?name={Config.CompanyName}"; } |
|
} |
|
/// <summary> |
|
/// 破拆点 |
|
/// </summary> |
|
public string GetAllBreakPoints |
|
{ |
|
get { return $"{Config.ServerAddress}/api/BreakPoints?name={Config.CompanyName}"; } |
|
} |
|
public string PostAllBreakPoints |
|
{ |
|
get { return $"{Config.ServerAddress}/api/BreakPoints?name={Config.CompanyName}"; } |
|
} |
|
public string GetBreakPointsById |
|
{ |
|
get { return $"{Config.ServerAddress}/api/BreakPoints/{{0}}?name={Config.CompanyName}"; } |
|
} |
|
public string PostBreakPointsById |
|
{ |
|
get { return $"{Config.ServerAddress}/api/BreakPoints/{{0}}?name={Config.CompanyName}"; } |
|
} |
|
/// <summary> |
|
/// 微型消防站 |
|
/// </summary> |
|
public string GetMiniFireStations |
|
{ |
|
get { return $"{Config.ServerAddress}/api/MiniFireStations?name={Config.CompanyName}"; } |
|
} |
|
public string PostMiniFireStations |
|
{ |
|
get { return $"{Config.ServerAddress}/api/MiniFireStations?name={Config.CompanyName}"; } |
|
} |
|
/// <summary> |
|
/// 消防控制室 |
|
/// </summary> |
|
public string GetAllFireControlRooms |
|
{ |
|
get { return $"{Config.ServerAddress}/api/FireControlRooms?name={Config.CompanyName}"; } |
|
} |
|
public string PostAllFireControlRooms |
|
{ |
|
get { return $"{Config.ServerAddress}/api/FireControlRooms?name={Config.CompanyName}"; } |
|
} |
|
public string GetFireControlRoomsById |
|
{ |
|
get { return $"{Config.ServerAddress}/api/FireControlRooms/{{0}}?name={Config.CompanyName}"; } |
|
} |
|
public string PostFireControlRoomsById |
|
{ |
|
get { return $"{Config.ServerAddress}/api/FireControlRooms/{{0}}?name={Config.CompanyName}"; } |
|
} |
|
/// <summary> |
|
/// 送风机 |
|
/// </summary> |
|
public string GetAllForcedDraftFans |
|
{ |
|
get { return $"{Config.ServerAddress}/api/Blowers?name={Config.CompanyName}"; } |
|
} |
|
public string PostAllForcedDraftFans |
|
{ |
|
get { return $"{Config.ServerAddress}/api/Blowers?name={Config.CompanyName}"; } |
|
} |
|
public string GetForcedDraftFansById |
|
{ |
|
get { return $"{Config.ServerAddress}/api/Blowers/{{0}}?name={Config.CompanyName}"; } |
|
} |
|
public string PostForcedDraftFansById |
|
{ |
|
get { return $"{Config.ServerAddress}/api/Blowers/{{0}}?name={Config.CompanyName}"; } |
|
} |
|
/// <summary> |
|
/// 送风口 |
|
/// </summary> |
|
public string GetAllAirVents |
|
{ |
|
get { return $"{Config.ServerAddress}/api/Outlets?name={Config.CompanyName}"; } |
|
} |
|
public string PostAllAirVents |
|
{ |
|
get { return $"{Config.ServerAddress}/api/Outlets?name={Config.CompanyName}"; } |
|
} |
|
public string GetAirVentsById |
|
{ |
|
get { return $"{Config.ServerAddress}/api/Outlets/{{0}}?name={Config.CompanyName}"; } |
|
} |
|
public string PostAirVentsById |
|
{ |
|
get { return $"{Config.ServerAddress}/api/Outlets/{{0}}?name={Config.CompanyName}"; } |
|
} |
|
/// <summary> |
|
/// 排烟风机 |
|
/// </summary> |
|
public string GetAllSmokeExtractionFans |
|
{ |
|
get { return $"{Config.ServerAddress}/api/ExhasustingVentilators?name={Config.CompanyName}"; } |
|
} |
|
public string PostAllSmokeExtractionFans |
|
{ |
|
get { return $"{Config.ServerAddress}/api/ExhasustingVentilators?name={Config.CompanyName}"; } |
|
} |
|
public string GetSmokeExtractionFansById |
|
{ |
|
get { return $"{Config.ServerAddress}/api/ExhasustingVentilators/{{0}}?name={Config.CompanyName}"; } |
|
} |
|
public string PostSmokeExtractionFansById |
|
{ |
|
get { return $"{Config.ServerAddress}/api/ExhasustingVentilators/{{0}}?name={Config.CompanyName}"; } |
|
} |
|
/// <summary> |
|
/// 排烟口 |
|
/// </summary> |
|
public string GetAllSmokeVents |
|
{ |
|
get { return $"{Config.ServerAddress}/api/SmokeOutlets?name={Config.CompanyName}"; } |
|
} |
|
public string PostAllSmokeVents |
|
{ |
|
get { return $"{Config.ServerAddress}/api/SmokeOutlets?name={Config.CompanyName}"; } |
|
} |
|
public string GetSmokeVentsById |
|
{ |
|
get { return $"{Config.ServerAddress}/api/SmokeOutlets/{{0}}?name={Config.CompanyName}"; } |
|
} |
|
public string PostSmokeVentsById |
|
{ |
|
get { return $"{Config.ServerAddress}/api/SmokeOutlets/{{0}}?name={Config.CompanyName}"; } |
|
} |
|
/// <summary> |
|
/// 泵房水箱 |
|
/// </summary> |
|
public string GetPumpRooms |
|
{ |
|
get { return $"{Config.ServerAddress}/api/PumpRooms?name={Config.CompanyName}"; } |
|
} |
|
public string PostPumpRooms |
|
{ |
|
get { return $"{Config.ServerAddress}/api/PumpRooms?name={Config.CompanyName}"; } |
|
} |
|
public string GetPumpRoomsById |
|
{ |
|
get { return $"{Config.ServerAddress}/api/PumpRooms/{{0}}?name={Config.CompanyName}"; } |
|
} |
|
public string PostPumpRoomsById |
|
{ |
|
get { return $"{Config.ServerAddress}/api/PumpRooms/{{0}}?name={Config.CompanyName}"; } |
|
} |
|
/// <summary> |
|
/// 室外消火栓 |
|
/// </summary> |
|
public string GetAllOutdoorFireHydrants |
|
{ |
|
get { return $"{Config.ServerAddress}/api/OutdoorFireHydrants?name={Config.CompanyName}"; } |
|
} |
|
public string PostAllOutdoorFireHydrants |
|
{ |
|
get { return $"{Config.ServerAddress}/api/OutdoorFireHydrants?name={Config.CompanyName}"; } |
|
} |
|
public string GetOutdoorFireHydrantsById |
|
{ |
|
get { return $"{Config.ServerAddress}/api/OutdoorFireHydrants/{{0}}?name={Config.CompanyName}"; } |
|
} |
|
public string PostOutdoorFireHydrantsById |
|
{ |
|
get { return $"{Config.ServerAddress}/api/OutdoorFireHydrants/{{0}}?name={Config.CompanyName}"; } |
|
} |
|
/// <summary> |
|
/// 水泵接合器 |
|
/// </summary> |
|
public string GetAllSiameseConnections |
|
{ |
|
get { return $"{Config.ServerAddress}/api/SiameseConnections?name={Config.CompanyName}"; } |
|
} |
|
public string PostAllSiameseConnections |
|
{ |
|
get { return $"{Config.ServerAddress}/api/SiameseConnections?name={Config.CompanyName}"; } |
|
} |
|
public string GetSiameseConnectionsById |
|
{ |
|
get { return $"{Config.ServerAddress}/api/SiameseConnections/{{0}}?name={Config.CompanyName}"; } |
|
} |
|
public string PostSiameseConnectionsById |
|
{ |
|
get { return $"{Config.ServerAddress}/api/SiameseConnections/{{0}}?name={Config.CompanyName}"; } |
|
} |
|
/// <summary> |
|
/// 供水关系图 |
|
/// </summary> |
|
public string GetWaterSupplyDiagrams |
|
{ |
|
get { return $"{Config.ServerAddress}/api/WaterSupplyDiagrams?name={Config.CompanyName}"; } |
|
} |
|
public string PostWaterSupplyDiagrams |
|
{ |
|
get { return $"{Config.ServerAddress}/api/WaterSupplyDiagrams?name={Config.CompanyName}"; } |
|
} |
|
/// <summary> |
|
/// 消防泵 |
|
/// </summary> |
|
public string GetPumpById |
|
{ |
|
get { return $"{Config.ServerAddress}/api/Pumps/{{0}}?name={Config.CompanyName}"; } |
|
} |
|
public string PostPumpById |
|
{ |
|
get { return $"{Config.ServerAddress}/api/Pumps/{{0}}?name={Config.CompanyName}"; } |
|
} |
|
/// <summary> |
|
/// 安全出口 |
|
/// </summary> |
|
public string GetAllFireEscapes |
|
{ |
|
get { return $"{Config.ServerAddress}/api/Exits?name={Config.CompanyName}"; } |
|
} |
|
public string PostAllFireEscapes |
|
{ |
|
get { return $"{Config.ServerAddress}/api/Exits?name={Config.CompanyName}"; } |
|
} |
|
public string GetFireEscapesById |
|
{ |
|
get { return $"{Config.ServerAddress}/api/Exits/{{0}}?name={Config.CompanyName}"; } |
|
} |
|
public string PostFireEscapesById |
|
{ |
|
get { return $"{Config.ServerAddress}/api/Exits/{{0}}?name={Config.CompanyName}"; } |
|
} |
|
/// <summary> |
|
/// 疏散楼梯 |
|
/// </summary> |
|
public string GetAllEscapeStairs |
|
{ |
|
get { return $"{Config.ServerAddress}/api/ProtectedStairways?name={Config.CompanyName}"; } |
|
} |
|
public string PostAllEscapeStairs |
|
{ |
|
get { return $"{Config.ServerAddress}/api/ProtectedStairways?name={Config.CompanyName}"; } |
|
} |
|
public string GetEscapeStairsById |
|
{ |
|
get { return $"{Config.ServerAddress}/api/ProtectedStairways/{{0}}?name={Config.CompanyName}"; } |
|
} |
|
public string PostEscapeStairsById |
|
{ |
|
get { return $"{Config.ServerAddress}/api/ProtectedStairways/{{0}}?name={Config.CompanyName}"; } |
|
} |
|
/// <summary> |
|
/// 消防电梯 |
|
/// </summary> |
|
public string GetAllFireLifts |
|
{ |
|
get { return $"{Config.ServerAddress}/api/FireLifts?name={Config.CompanyName}"; } |
|
} |
|
public string PostAllFireLifts |
|
{ |
|
get { return $"{Config.ServerAddress}/api/FireLifts?name={Config.CompanyName}"; } |
|
} |
|
public string GetFireLiftsById |
|
{ |
|
get { return $"{Config.ServerAddress}/api/FireLifts/{{0}}?name={Config.CompanyName}"; } |
|
} |
|
public string PostFireLiftsById |
|
{ |
|
get { return $"{Config.ServerAddress}/api/FireLifts/{{0}}?name={Config.CompanyName}"; } |
|
} |
|
/// <summary> |
|
/// 周边水源 |
|
/// </summary> |
|
public string GetWaterSources |
|
{ |
|
get { return $"{Config.ServerAddress}/api/PeripheralWaterSources?name={Config.CompanyName}"; } |
|
} |
|
public string PostWaterSources |
|
{ |
|
get { return $"{Config.ServerAddress}/api/PeripheralWaterSources?name={Config.CompanyName}"; } |
|
} |
|
/// <summary> |
|
/// 行车路线 |
|
/// </summary> |
|
public string GetDriveRoutes |
|
{ |
|
get { return $"{Config.ServerAddress}/api/DriveRoutes?name={Config.CompanyName}"; } |
|
} |
|
public string PostDriveRoutes |
|
{ |
|
get { return $"{Config.ServerAddress}/api/DriveRoutes?name={Config.CompanyName}"; } |
|
} |
|
/// <summary> |
|
/// 态势标会 |
|
/// </summary> |
|
public string GetDisposalPlanList |
|
{ |
|
get { return $"{Config.ServerAddress}/api/SituationPlotting?name={Config.CompanyName}"; } |
|
} |
|
public string PostDisposalPlanList |
|
{ |
|
get { return $"{Config.ServerAddress}/api/SituationPlotting?name={Config.CompanyName}"; } |
|
} |
|
/// <summary> |
|
/// 态势标绘力量 |
|
/// </summary> |
|
public string GetPowerButtons |
|
{ |
|
get { return $"{Application.streamingAssetsPath}/Data/PowerButtons.json"; } |
|
} |
|
/// <summary> |
|
/// 任务列表 |
|
/// </summary> |
|
public string GetPowerTasks |
|
{ |
|
get { return $"{Application.streamingAssetsPath}/Data/TaskList.json"; } |
|
} |
|
/// <summary> |
|
/// 单位组织指挥 |
|
/// </summary> |
|
public string GetOrgCmds |
|
{ |
|
get { return $"{Config.ServerAddress}/api/OrgCmds?name={Config.CompanyName}"; } |
|
} |
|
public string PostOrgCmds |
|
{ |
|
get { return $"{Config.ServerAddress}/api/OrgCmds?name={Config.CompanyName}"; } |
|
} |
|
/// <summary> |
|
/// 社会联动 |
|
/// </summary> |
|
public string GetSocialLinkages |
|
{ |
|
get { return $"{Config.ServerAddress}/api/SocialLinkages?name={Config.CompanyName}"; } |
|
} |
|
public string PostSocialLinkages |
|
{ |
|
get { return $"{Config.ServerAddress}/api/SocialLinkages?name={Config.CompanyName}"; } |
|
} |
|
/// <summary> |
|
/// 社会联勤 |
|
/// </summary> |
|
public string GetSocialJointServices |
|
{ |
|
get { return $"{Config.ServerAddress}/api/SocialJointServices?name={Config.CompanyName}"; } |
|
} |
|
public string PostSocialJointServices |
|
{ |
|
get { return $"{Config.ServerAddress}/api/SocialJointServices?name={Config.CompanyName}"; } |
|
} |
|
/// <summary> |
|
/// 战勤保障 |
|
/// </summary> |
|
public string GetCombatSupport |
|
{ |
|
get { return $"{Config.ServerAddress}/api/CombatSupport?name={Config.CompanyName}"; } |
|
} |
|
public string PostCombatSupport |
|
{ |
|
get { return $"{Config.ServerAddress}/api/CombatSupport?name={Config.CompanyName}"; } |
|
} |
|
/// <summary> |
|
/// 通信保障 |
|
/// </summary> |
|
public string GetCommunicationSupport |
|
{ |
|
get { return $"{Config.ServerAddress}/api/CommunicationSupport?name={Config.CompanyName}"; } |
|
} |
|
public string PostCommunicationSupport |
|
{ |
|
get { return $"{Config.ServerAddress}/api/CommunicationSupport?name={Config.CompanyName}"; } |
|
} |
|
/// <summary> |
|
/// 人员定位历史轨迹 |
|
/// </summary> |
|
public string GetPersonnelHistoryData |
|
{ |
|
get { return $"{Config.ServerAddress}/api/AutomaticSprinklers?name={Config.CompanyName}"; } |
|
} |
|
public string PostPersonnelHistoryData |
|
{ |
|
get { return $"{Config.ServerAddress}/api/AutomaticSprinklers?name={Config.CompanyName}"; } |
|
} |
|
/// <summary> |
|
/// 点位绑定 |
|
/// </summary> |
|
public string GetAllIOilTank |
|
{ |
|
get { return $"{Config.ServerAddress}/api/OilTank?name={Config.CompanyName}"; } |
|
} |
|
public string PostAllIOilTank |
|
{ |
|
get { return $"{Config.ServerAddress}/api/OilTank?name={Config.CompanyName}"; } |
|
} |
|
public string GetOilTankById |
|
{ |
|
get { return $"{Config.ServerAddress}/api/OilTank/{{0}}?name={Config.CompanyName}"; } |
|
} |
|
public string PostIOilTankById |
|
{ |
|
get { return $"{Config.ServerAddress}/api/OilTank/{{0}}?name={Config.CompanyName}"; } |
|
} |
|
/// <summary> |
|
/// 获取设备模型 |
|
/// </summary> |
|
public string GetEquipmentModel |
|
{ |
|
get { return $"{Config.ServerAddress}/ModelBase/Equipments/{{0}}/{{1}}.gltf"; } |
|
} |
|
|
|
/// <summary> |
|
/// 获取态势标绘模型 |
|
/// </summary> |
|
public string GetPowerModel |
|
{ |
|
get { return $"{Config.ServerAddress}/ModelBase/Powers/{{0}}/{{1}}.gltf"; } |
|
} |
|
/// <summary> |
|
/// 获取周边水源行车路线标绘模型 |
|
/// </summary> |
|
public string GetAnnotatioModel |
|
{ |
|
get { return $"{Config.ServerAddress}/ModelBase/Annotatios/{{0}}/{{1}}.gltf"; } |
|
} |
|
|
|
/// <summary> |
|
/// 城市代码 |
|
/// </summary> |
|
public string GetCityCode |
|
{ |
|
get { return $"{Application.streamingAssetsPath}/Data/CityCode.json"; } |
|
} |
|
/// <summary> |
|
/// 系统设置 |
|
/// </summary> |
|
public string GetGameSetting |
|
{ |
|
get { return $"{Application.streamingAssetsPath}/Data/GameSettings.json"; } |
|
} |
|
/// <summary> |
|
/// 分辨率 |
|
/// </summary> |
|
public string GetResolution |
|
{ |
|
get { return $"{Application.streamingAssetsPath}/Data/Resolution.json"; } |
|
} |
|
#endregion |
|
/// <summary> |
|
/// 文件、图片 |
|
/// </summary> |
|
public string GetVerifyObject |
|
{ |
|
get { return $"{Config.ServerAddress}/api/Objects/VerifyObject?md5={{0}}"; } |
|
} |
|
/// <summary> |
|
/// /api/Objects/{bucketName}/{directoryName} |
|
/// </summary> |
|
public string PostObjects |
|
{ |
|
get { return $"{Config.ServerAddress}/api/Objects/{{0}}/{Config.AreaName}/{Config.CompanyName}"; } |
|
} |
|
/// <summary> |
|
/// todo 桶名/{区域名}/{Config.CompanyName}/文件 |
|
/// </summary> |
|
public string GetObjects |
|
{ |
|
get { return $"{Config.ServerAddress}/api/Objects/{{0}}/{{1}}"; } |
|
} |
|
public string DeleteImageByName |
|
{ |
|
get { return $"{Config.ServerAddress}/api/Objects/{{0}}?x-image-process={{1}}"; } |
|
} |
|
|
|
public string ProcessImage = "?x-image-process=image/resize,m_lfit,h_200,w_300"; |
|
|
|
[DllImport("__Internal")] |
|
private static extern string StringReturnValueFunction(); |
|
public override void Awake() |
|
{ |
|
base.Awake(); |
|
Debug.Log("ServerAddress" + Config.ServerAddress); |
|
} |
|
public void Get<T>(string url, Action<T> action) |
|
{ |
|
Debug.Log(Config.ServerAddress); |
|
StartCoroutine(GetCoroutine<T>(url, action)); |
|
} |
|
private IEnumerator GetCoroutine<T>(string url, Action<T> action) |
|
{ |
|
UnityWebRequest uwr = UnityWebRequest.Get(url); |
|
yield return uwr.SendWebRequest(); |
|
|
|
if (uwr.isNetworkError || uwr.isHttpError) |
|
{ |
|
Debug.Log(uwr.error); |
|
} |
|
else |
|
{ |
|
//Debug.Log(uwr.downloadHandler.text); |
|
string json = uwr.downloadHandler.text; |
|
T obj = JsonConvert.DeserializeObject<T>(json); |
|
if (obj != null) |
|
{ |
|
action?.Invoke(obj); |
|
Debug.Log(obj?.ToString() + "加载完成"); |
|
} |
|
} |
|
} |
|
|
|
public void PostLocal<T>(string url, T obj) |
|
{ |
|
var jsonParam = JsonConvert.SerializeObject(obj, Formatting.Indented); |
|
File.WriteAllText(url, jsonParam); |
|
} |
|
|
|
public void PostData<T>(string url, T obj) |
|
{ |
|
var jsonParam = JsonConvert.SerializeObject(obj, Formatting.Indented); |
|
File.WriteAllText(url, jsonParam); |
|
Debug.Log($"数据保存完成"); |
|
} |
|
public void Post<T>(string url, T obj, Action action = null) |
|
{ |
|
StartCoroutine(PostCoroutine<T>(url, obj, action)); |
|
} |
|
private IEnumerator PostCoroutine<T>(string url, T obj, Action action = null) |
|
{ |
|
string jsonParam = JsonConvert.SerializeObject(obj); |
|
byte[] body = Encoding.UTF8.GetBytes(jsonParam); |
|
UnityWebRequest uwr = new UnityWebRequest(url, "POST"); |
|
uwr.uploadHandler = new UploadHandlerRaw(body); |
|
uwr.SetRequestHeader("Content-Type", "application/json;charset=utf-8"); |
|
yield return uwr.SendWebRequest(); |
|
if (uwr.isHttpError || uwr.isNetworkError) |
|
{ |
|
Debug.Log(uwr.error); |
|
Debug.Log(jsonParam); |
|
} |
|
else |
|
{ |
|
action?.Invoke(); |
|
Debug.Log($"数据上传完成"); |
|
Debug.Log(jsonParam); |
|
} |
|
} |
|
|
|
|
|
public void Post<T>(string url, Action<T> action) |
|
{ |
|
StartCoroutine(PostCoroutine<T>(url, action)); |
|
} |
|
private IEnumerator PostCoroutine<T>(string url, Action<T> action) |
|
{ |
|
using (UnityWebRequest uwr = UnityWebRequest.Post(url, "")) |
|
{ |
|
yield return uwr.SendWebRequest(); |
|
if (uwr.isHttpError || uwr.isNetworkError) |
|
{ |
|
Debug.Log(uwr.error); |
|
} |
|
else |
|
{ |
|
string json = uwr.downloadHandler.text; |
|
T obj = JsonConvert.DeserializeObject<T>(json); |
|
action?.Invoke(obj); |
|
} |
|
|
|
} |
|
} |
|
|
|
|
|
//删除 |
|
public void Delete(string url, Action action = null) |
|
{ |
|
StartCoroutine(DeleteCoroutine(url, action)); |
|
} |
|
private IEnumerator DeleteCoroutine(string url, Action action = null) |
|
{ |
|
UnityWebRequest uwr = UnityWebRequest.Delete(url); |
|
yield return uwr.SendWebRequest(); |
|
if (uwr.isHttpError || uwr.isNetworkError) |
|
{ |
|
Debug.Log(uwr.error); |
|
} |
|
else |
|
{ |
|
action?.Invoke(); |
|
Debug.Log($"数据上传完成"); |
|
} |
|
} |
|
//上传文件 |
|
public void PostFile<T>(string fileName, T obj, Action<NodeWebResult> actionResult) |
|
{ |
|
StartCoroutine(PostFileCoroutine<T>(fileName, obj, actionResult)); |
|
} |
|
IEnumerator PostFileCoroutine<T>(string fileName, T obj, Action<NodeWebResult> actionResult) |
|
{ |
|
JsonSerializerSettings settings = new JsonSerializerSettings |
|
{ |
|
TypeNameHandling = TypeNameHandling.All |
|
}; |
|
string json = JsonConvert.SerializeObject(obj, settings); |
|
//序列化 |
|
byte[] bArray = Encoding.UTF8.GetBytes(json); |
|
|
|
List<IMultipartFormSection> formData = new List<IMultipartFormSection>(); |
|
formData.Add(new MultipartFormFileSection("file", bArray, fileName, "application/octet-stream")); |
|
//formData.Add(new MultipartFormFileSection(fileName,bArray)); |
|
//请求服务器 |
|
using (UnityWebRequest http = UnityWebRequest.Post(string.Format(PostObjects, "WebPlan"), formData)) |
|
{ |
|
yield return http.SendWebRequest(); |
|
if (http.isHttpError || http.isNetworkError) |
|
{ |
|
Debug.Log(http.error); |
|
} |
|
else |
|
{ |
|
Debug.Log(http.downloadHandler.text); |
|
var temp = JsonConvert.DeserializeObject<NodeWebResult>(http.downloadHandler.text); |
|
actionResult(temp); |
|
} |
|
} |
|
} |
|
//上传文件 |
|
public void GetFile<T>(string fileName, Action<T> actionResult) |
|
where T : class |
|
{ |
|
StartCoroutine(GetFileCoroutine<T>(fileName, actionResult)); |
|
} |
|
IEnumerator GetFileCoroutine<T>(string fileName, Action<T> actionResult) |
|
where T : class |
|
{ |
|
Debug.Log(string.Format(GetObjects, "WebPlan", fileName)); |
|
//请求服务器 |
|
using (UnityWebRequest http = UnityWebRequest.Get(string.Format(GetObjects, "WebPlan", fileName))) |
|
{ |
|
yield return http.SendWebRequest(); |
|
if (http.isHttpError || http.isNetworkError) |
|
{ |
|
Debug.Log(http.error); |
|
} |
|
else |
|
{ |
|
string json = Encoding.UTF8.GetString(http.downloadHandler.data); |
|
Debug.Log(json); |
|
JsonSerializerSettings settings = new JsonSerializerSettings |
|
{ |
|
TypeNameHandling = TypeNameHandling.All |
|
}; |
|
T t = JsonConvert.DeserializeObject<T>(json, settings); |
|
actionResult?.Invoke(t); |
|
} |
|
} |
|
} |
|
//上传图片 |
|
public void PostImage(string fileName, Texture2D texture2d, Action<NodeWebResult> actionResult) |
|
{ |
|
if (!texture2d.name.Equals("DefualtSprite")) |
|
{ |
|
StartCoroutine(PostImageCoroutine(fileName, texture2d, actionResult)); |
|
} |
|
else |
|
{ |
|
actionResult(null); |
|
} |
|
} |
|
IEnumerator PostImageCoroutine(string fileName, Texture2D texture2d, Action<NodeWebResult> actionResult) |
|
{ |
|
//序列化 |
|
byte[] bArray = texture2d.EncodeToJPG(); |
|
//设置表单数据 |
|
WWWForm form = new WWWForm(); |
|
form.AddBinaryData("file", bArray, fileName); |
|
Debug.Log(string.Format(PostObjects, "WebPlan")); |
|
//请求服务器 |
|
using (UnityWebRequest http = UnityWebRequest.Post(string.Format(PostObjects, "WebPlan"), form)) |
|
{ |
|
yield return http.SendWebRequest(); |
|
if (http.isHttpError || http.isNetworkError) |
|
{ |
|
Debug.Log($"访问失败:{http.error}\r\n地址:{http.uri}"); |
|
} |
|
else |
|
{ |
|
Debug.Log(http.downloadHandler.text); |
|
var temp = JsonConvert.DeserializeObject<NodeWebResult>(http.downloadHandler.text); |
|
actionResult(temp); |
|
} |
|
} |
|
} |
|
public void PostScreenshot(string fileName, Texture2D texture2d) |
|
{ |
|
byte[] bytes; |
|
bytes = texture2d.EncodeToPNG(); |
|
File.WriteAllBytes($"{ScreenshotPath}{fileName}.png", bytes); |
|
} |
|
//下载图片 |
|
public void GetImage(string fileName, Action<Texture2D> actionResult) |
|
{ |
|
StartCoroutine(GetImageCoroutine(fileName, actionResult)); |
|
} |
|
IEnumerator GetImageCoroutine(string fileName, Action<Texture2D> actionResult) |
|
{ |
|
Debug.Log($"图片下载地址:{string.Format(GetObjects, "WebPlan", fileName)}"); |
|
//请求服务器 |
|
using (UnityWebRequest http = UnityWebRequestTexture.GetTexture(string.Format(GetObjects, "WebPlan", fileName))) |
|
{ |
|
yield return http.SendWebRequest(); |
|
if (http.isHttpError || http.isNetworkError) |
|
{ |
|
Debug.Log($"访问失败:{http.error}\r\n地址:{http.uri}"); |
|
} |
|
else |
|
{ |
|
Texture2D texture = ((DownloadHandlerTexture)http.downloadHandler).texture; |
|
//Debug.Log(texture); |
|
actionResult?.Invoke(texture); |
|
} |
|
} |
|
} |
|
/// <summary> |
|
/// 加载GLTF模型 |
|
/// </summary> |
|
/// <param name="path"></param> |
|
/// <param name="action"></param> |
|
public async void LoadGltf(string path, Action<GameObject> action = null) |
|
{ |
|
var gltf = new GLTFast.GltfImport(); |
|
var success = await gltf.Load(path, new ImportSettings()); |
|
if (success) |
|
{ |
|
var root = new GameObject("Root"); |
|
gltf.InstantiateMainScene(root.transform); |
|
action?.Invoke(root); |
|
} |
|
else |
|
{ |
|
Debug.LogError("Loading glTF failed!"); |
|
} |
|
} |
|
} |