1个文件已删除
86个文件已修改
1 文件已重命名
| | |
| | | api.SendReq(req); |
| | | } |
| | | /// <summary>
/// 所有初始化全部在这个方法实现
/// </summary>
void initAll()
{ |
| | | string checkFile = System.IO.Path.Combine(Shared.IO.FileUtils.RootPath, Shared.Phone.UserCenter.DirNameResourse.OpenGbsFile);
|
| | | Shared.Application.IsGpsEnable = System.IO.File.Exists(checkFile); |
| | | |
| | | //设置极光调试模式,为false时只打印警告信息 |
| | | // System.Console.WriteLine($"AAA : {System.DateTime.Now.ToString()}"); |
| | | Shared.Application.IsGpsEnable = false;
|
| | |
|
| | | //设置极光调试模式,为false时只打印警告信息
|
| | | // System.Console.WriteLine($"AAA : {System.DateTime.Now.ToString()}");
|
| | | #if Release
JPushInterface.SetDebugMode(false); |
| | | //保存手机名称到本地文件 |
| | | //System.Console.WriteLine($"BBB : {System .DateTime .Now .ToString ()}"); |
| | |
| | | JPushInterface.Init(this); |
| | | //System.Console.WriteLine($"CCC : {System.DateTime.Now.ToString()}"); |
| | | #endif |
| | | |
| | | |
| | | BaseActivity.BackKeyAction = () => { |
| | | try |
| | | { |
| | |
| | | Shared.Application.FontSize = 12; |
| | | AppCenter.Start("4802834a-e7e9-4dd8-93f1-c2f88f0bd464", typeof(Analytics), typeof(Crashes));
#if Release
//保存获取的极光服务器上的注册ID到本地文件
var registrationId = JPushInterface.GetRegistrationID(activity); |
| | | System.Console.WriteLine("registrationId-极光id=" + registrationId); |
| | | if (!string.IsNullOrEmpty(registrationId))
{
Shared.Common.Config.Instance.RegistrationID = registrationId;
Shared.Common.Config.Instance.Save();
}
#endif
};
BaseActivity.RefreshUIAction += (activity) => {
Shared.Language.CurrentLanguage = "Chinese";
Shared.Common.CommonPage.Instance.Show();
};
BaseActivity.OnResumeAction += (activity) => {
};
BaseActivity.NetworkStateChanged += (v) =>
{
//网络状态变化处理事件 |
| | | Shared.Common.CommonPage.nowNetworkMode = v;
};
BaseActivity.OnDestroyAction += (activity) => {
//socket停止连接
//ZigBee.Device.ZbGateway.FindGateWaySocket.Stop();
};
HDLUtils.SetAuthoritiesName("com.hdl.home.fileProvider");
}
public static bool IsShowTip = true;
JpushNotificationReceiver myReceiver = new JpushNotificationReceiver { };
/// <summary>
/// 项目启动时网络查询
/// </summary>
void checkSomeInfo()
{
var status = isNetworkAvailable(this);
string internetStatus = "Available";
if (!status)
{
internetStatus = "UnaVailable";
}
else
{
var isWifi = isWifiConnected(this);
if (isWifi)
{
internetStatus = "WiFiConnect";
}
else
{
internetStatus = "MobileConnect";
}
}
int connectState = 0;
if (internetStatus == "UnaVailable")
{
connectState = 0;
}
else if (internetStatus == "WiFiConnect")
{
connectState = 2;
}
else
{
connectState = 1;
}
//ZigBee.Device.ZbGateway.CheckConnection(connectState);
}
/// <summary>
/// 网络是否可用
/// </summary>
/// <returns><c>true</c>, if network available was ised, <c>false</c> otherwise.</returns>
/// <param name="context">Context.</param>
bool isNetworkAvailable(Context context)
{
var cm = (ConnectivityManager)context.GetSystemService(ConnectivityService);
if (cm == null || cm.ActiveNetworkInfo == null)
{
//当前网络不可用
return false;
}
else
{
return cm.ActiveNetworkInfo.IsAvailable;
}
}
/// <summary>
/// 网络是否连接
/// </summary>
/// <returns><c>true</c>, if wifi connected was ised, <c>false</c> otherwise.</returns>
/// <param name="context">Context.</param>
bool isWifiConnected(Context context)
{
if (context != null)
{
var cm = (ConnectivityManager)context.GetSystemService(ConnectivityService);
var mWiFiNetworkInfo = cm.GetNetworkInfo(ConnectivityType.Wifi);
if (Android.Net.NetworkInfo.State.Connected == mWiFiNetworkInfo.GetState())
{
//当前网络是Wi-Fi连接
return true;
}
var moWiFiNetworkInfo = cm.GetNetworkInfo(ConnectivityType.Mobile);
if (Android.Net.NetworkInfo.State.Connected == moWiFiNetworkInfo.GetState())
{
//当前网络是Mobile连接
return false;
}
}
return false;
} |
| | | if (!string.IsNullOrEmpty(registrationId))
{
Shared.Common.Config.Instance.RegistrationID = registrationId;
Shared.Common.Config.Instance.Save();
}
#endif
};
BaseActivity.RefreshUIAction += (activity) => {
Shared.Language.CurrentLanguage = "Chinese";
Shared.Common.CommonPage.Instance.Show();
};
BaseActivity.NetworkStateChanged += (v) =>
{
};
BaseActivity.OnDestroyAction += (activity) => {
//socket停止连接
//ZigBee.Device.ZbGateway.FindGateWaySocket.Stop();
};
HDLUtils.SetAuthoritiesName("com.hdl.home.fileProvider");
}
public static bool IsShowTip = true;
JpushNotificationReceiver myReceiver = new JpushNotificationReceiver { };
/// <summary>
/// 项目启动时网络查询
/// </summary>
void checkSomeInfo()
{
var status = isNetworkAvailable(this);
string internetStatus = "Available";
if (!status)
{
internetStatus = "UnaVailable";
}
else
{
var isWifi = isWifiConnected(this);
if (isWifi)
{
internetStatus = "WiFiConnect";
}
else
{
internetStatus = "MobileConnect";
}
}
int connectState = 0;
if (internetStatus == "UnaVailable")
{
connectState = 0;
}
else if (internetStatus == "WiFiConnect")
{
connectState = 2;
}
else
{
connectState = 1;
}
//ZigBee.Device.ZbGateway.CheckConnection(connectState);
}
/// <summary>
/// 网络是否可用
/// </summary>
/// <returns><c>true</c>, if network available was ised, <c>false</c> otherwise.</returns>
/// <param name="context">Context.</param>
bool isNetworkAvailable(Context context)
{
var cm = (ConnectivityManager)context.GetSystemService(ConnectivityService);
if (cm == null || cm.ActiveNetworkInfo == null)
{
//当前网络不可用
return false;
}
else
{
return cm.ActiveNetworkInfo.IsAvailable;
}
}
/// <summary>
/// 网络是否连接
/// </summary>
/// <returns><c>true</c>, if wifi connected was ised, <c>false</c> otherwise.</returns>
/// <param name="context">Context.</param>
bool isWifiConnected(Context context)
{
if (context != null)
{
var cm = (ConnectivityManager)context.GetSystemService(ConnectivityService);
var mWiFiNetworkInfo = cm.GetNetworkInfo(ConnectivityType.Wifi);
if (Android.Net.NetworkInfo.State.Connected == mWiFiNetworkInfo.GetState())
{
//当前网络是Wi-Fi连接
return true;
}
var moWiFiNetworkInfo = cm.GetNetworkInfo(ConnectivityType.Mobile);
if (Android.Net.NetworkInfo.State.Connected == moWiFiNetworkInfo.GetState())
{
//当前网络是Mobile连接
return false;
}
}
return false;
}
|
| | |
|
| | | |
| | | } |
| | | |
| | | public class JpushNotificationReceiver : BroadcastReceiver |
| | |
| | | 15873=拍照 |
| | | 15874=从相册中选择 |
| | | 15875=抱歉,程序出现错误 |
| | | 15876=请输入手势a |
| | | 15876=请输入手势 |
| | | 15877=请再次输入手势 |
| | | 15878=更改手势,请输入手势 |
| | | 15879=确认手势错误,请重新设置 |
| | |
| | | 16132=蜂鸣器开关 |
| | | 16133=小夜灯开关 |
| | | 16134=设置设备功能类型失败 |
| | | 16135=获取场景列表失败,网关回复超时 |
| | | 16136=需重新绑定 |
| | | |
| | | ;★★★★下面这些是接口的返回信息翻译,从18000开始★★★★
|
| | | 18004=指定网关已经被绑定
|
| | |
| | | <?xml version="1.0" encoding="utf-8"?> |
| | | <manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.hdl.home" android:versionCode="0120070302" android:installLocation="auto" android:versionName="1.1.0120070302"> |
| | | <manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.hdl.home" android:versionCode="0120070901" android:installLocation="auto" android:versionName="1.1.0120070901"> |
| | | <uses-sdk android:minSdkVersion="23" android:targetSdkVersion="26" /> |
| | | <permission android:name="com.hdl.home.permission.JPUSH_MESSAGE" android:protectionLevel="signature" /> |
| | | <uses-permission android:name="android.permission.WAKE_LOCK" /> |
| | |
| | | 15873=拍照 |
| | | 15874=从相册中选择 |
| | | 15875=抱歉,程序出现错误 |
| | | 15876=请输入手势a |
| | | 15876=请输入手势 |
| | | 15877=请再次输入手势 |
| | | 15878=更改手势,请输入手势 |
| | | 15879=确认手势错误,请重新设置 |
| | |
| | | 16132=蜂鸣器开关 |
| | | 16133=小夜灯开关 |
| | | 16134=设置设备功能类型失败 |
| | | 16135=获取场景列表失败,网关回复超时 |
| | | 16136=需重新绑定 |
| | | |
| | | ;★★★★下面这些是接口的返回信息翻译,从18000开始★★★★
|
| | | 18004=指定网关已经被绑定
|
| | |
| | | /// <summary> |
| | | /// 版本号 |
| | | /// </summary> |
| | | public static string CodeIDString = "1.1.0120070302"; |
| | | public static string CodeIDString = "1.1.0120070901"; |
| | | /// <summary> |
| | | /// 注册来源(0:HDL On 1:Zigbee) |
| | | /// </summary> |
| | |
| | | /// 用于验证邮箱正则表达式 |
| | | /// </summary> |
| | | public static string EmailRegexStr = "^\\s*([A-Za-z0-9_-]+(\\.\\w+)*@(\\w+\\.)+\\w{2,5})\\s*$"; |
| | | /// <summary> |
| | | /// 当前网络连接的模式 0:没有网络 1:远程连接,也叫3G,4G 2:WIFI |
| | | /// </summary> |
| | | public static int nowNetworkMode = 0; |
| | | /// <summary>
|
| | | /// 安卓的系统返回按键能否按下(比如在备份还原时,不能按下返回键)
|
| | | /// </summary> |
| | |
| | | private void InitRealDeviceRoomId()
|
| | | {
|
| | | this.dicDeviceRoomId = new Dictionary<string, string>();
|
| | | string fullName = UserCenterLogic.CombinePath(DirNameResourse.DeviceRoomIdFile);
|
| | | var strData = UserCenterLogic.LoadFileContent(fullName);
|
| | | string fullName = DirNameResourse.DeviceRoomIdFile;
|
| | | var strData = HdlFileLogic.Current.ReadFileTextContent(fullName);
|
| | | if (strData != null)
|
| | | {
|
| | | this.dicDeviceRoomId = Newtonsoft.Json.JsonConvert.DeserializeObject<Dictionary<string, string>>(strData);
|
| | | }
|
| | | }
|
| | |
|
| | | /// <summary>
|
| | | /// 获取全部物理设备所属房间的记录
|
| | | /// </summary>
|
| | | /// <returns></returns>
|
| | | public Dictionary<string, string> GetAllRealDeviceRoomData()
|
| | | {
|
| | | return this.dicDeviceRoomId;
|
| | | }
|
| | |
|
| | | /// <summary>
|
| | |
| | | if (save == true)
|
| | | {
|
| | | //保存记录
|
| | | string fullName = UserCenterLogic.CombinePath(DirNameResourse.DeviceRoomIdFile);
|
| | | UserCenterLogic.SaveFileContent(fullName, this.dicDeviceRoomId);
|
| | | HdlFileLogic.Current.SaveFileContent(DirNameResourse.DeviceRoomIdFile, this.dicDeviceRoomId);
|
| | |
|
| | | //添加自动备份
|
| | | HdlAutoBackupLogic.AddOrEditorFile(DirNameResourse.DeviceRoomIdFile);
|
| | |
| | | return Language.StringByID(R.MyInternationalizationString.uDeviceNotAssignedRoom);
|
| | | }
|
| | | var room = HdlRoomLogic.Current.GetRoomById(this.dicDeviceRoomId[device.DeviceAddr]);
|
| | | return HdlRoomLogic.Current.GetFloorRoomName(room);
|
| | | return HdlRoomLogic.Current.GetRoomName(room);
|
| | | }
|
| | |
|
| | | /// <summary>
|
| | |
| | | return;
|
| | | }
|
| | | //保存记录
|
| | | string fullName = UserCenterLogic.CombinePath(DirNameResourse.DeviceRoomIdFile);
|
| | | UserCenterLogic.SaveFileContent(fullName, this.dicDeviceRoomId);
|
| | | HdlFileLogic.Current.SaveFileContent(DirNameResourse.DeviceRoomIdFile, this.dicDeviceRoomId);
|
| | |
|
| | | //添加自动备份
|
| | | HdlAutoBackupLogic.AddOrEditorFile(DirNameResourse.DeviceRoomIdFile);
|
| | |
| | | else if (mainDevice.Type == DeviceType.OnOffOutput)
|
| | | {
|
| | | //2020.05.13变更:继电器都默认为灯光
|
| | | //var myType = this.GetHdlMyDeviceEnumInfo(mainDevice);
|
| | | //if (myType != null && myType.ConcreteType == DeviceConcreteType.Relay_ThreeLoad)
|
| | | if (mainDevice.DfunctionType == DeviceFunctionType.A未定义)
|
| | | {
|
| | | if (mainDevice.DfunctionType == DeviceFunctionType.A未定义)
|
| | | mainDevice.DfunctionType = DeviceFunctionType.A灯光;
|
| | | if (device.DeviceInfo.FunctionType != (int)DeviceFunctionType.A灯光)
|
| | | {
|
| | | mainDevice.DfunctionType = DeviceFunctionType.A灯光;
|
| | | if (device.DeviceInfo.FunctionType != (int)DeviceFunctionType.A灯光)
|
| | | {
|
| | | //继电器默认为灯光
|
| | | this.SendDeviceFunctionTypeToGateway(mainDevice, DeviceFunctionType.A灯光);
|
| | | }
|
| | | }
|
| | | if (mainDevice.IsCustomizeImage == false)
|
| | | {
|
| | | mainDevice.IconPath = "Device/Light.png";
|
| | | //继电器默认为灯光
|
| | | this.SendDeviceFunctionTypeToGateway(mainDevice, DeviceFunctionType.A灯光);
|
| | | }
|
| | | }
|
| | | //根据功能类型,重新设置设备回路图标
|
| | | this.ResetIconPathByDeviceFunctionType(mainDevice);
|
| | | }
|
| | | //如果是空气开关的话
|
| | | else if (mainDevice.Type == DeviceType.AirSwitch)
|
| | |
| | | this.SendDeviceFunctionTypeToGateway(mainDevice, DeviceFunctionType.A开关);
|
| | | }
|
| | | }
|
| | | if (mainDevice.IsCustomizeImage == false)
|
| | | {
|
| | | mainDevice.IconPath = "Device/Switch.png";
|
| | | }
|
| | | //根据功能类型,重新设置设备回路图标
|
| | | this.ResetIconPathByDeviceFunctionType(mainDevice);
|
| | | }
|
| | | //如果是彩灯的话
|
| | | else if (mainDevice.Type == DeviceType.ColorDimmableLight)
|
| | |
| | | }
|
| | |
|
| | | /// <summary>
|
| | | /// 根据功能类型,重新设置设备回路图标
|
| | | /// </summary>
|
| | | /// <param name="device"></param>
|
| | | private void ResetIconPathByDeviceFunctionType(CommonDevice device)
|
| | | {
|
| | | if (device.IsCustomizeImage == true)
|
| | | {
|
| | | return;
|
| | | }
|
| | | if (device.DfunctionType == DeviceFunctionType.A开关)
|
| | | {
|
| | | device.IconPath = "Device/Switch.png";
|
| | | }
|
| | | else if (device.DfunctionType == DeviceFunctionType.A插座)
|
| | | {
|
| | | device.IconPath = "Device/Socket1.png";
|
| | | }
|
| | | else
|
| | | {
|
| | | device.IconPath = "Device/Light.png";
|
| | | }
|
| | | }
|
| | |
|
| | | /// <summary>
|
| | | /// 根据设备Type创建对应的设备对象
|
| | | /// </summary>
|
| | | /// <param name="deviceType">设备Type</param>
|
| | |
| | | /// </summary> |
| | | public string ResidenceAddressName = string.Empty; |
| | | /// <summary> |
| | | /// 房间列表(房间的ID) |
| | | /// </summary> |
| | | public List<string> ListRooms = new List<string>(); |
| | | /// <summary> |
| | | /// 楼层字典 |
| | | /// key:FloorId |
| | | /// value:FloorName |
| | |
| | | |
| | | #endregion |
| | | |
| | | #region ◆ 添加房间路径_________________________ |
| | | |
| | | /// <summary> |
| | | /// 添加房间ID |
| | | /// </summary> |
| | | /// <returns><c>true</c>, if room list file path was added, <c>false</c> otherwise.</returns> |
| | | /// <param name="roomFilePath">Room file path.</param> |
| | | public void AddRoomId(string roomId) |
| | | { |
| | | if (ListRooms.Contains(roomId) == false) |
| | | {
|
| | | ListRooms.Add(roomId);
|
| | | this.Save(); |
| | | } |
| | | } |
| | | |
| | | #endregion |
| | | |
| | | #region ◆ 删除房间路径_________________________ |
| | | |
| | | /// <summary> |
| | | /// 移除房间Id |
| | | /// </summary> |
| | | /// <returns><c>true</c>, if room list file path was added, <c>false</c> otherwise.</returns> |
| | | /// <param name="roomFilePath">Room file path.</param> |
| | | public void RemoveRoomId(string roomId) |
| | | { |
| | | if (ListRooms.Contains(roomId)==true) |
| | | {
|
| | | ListRooms.Remove(roomId);
|
| | | Save(); |
| | | } |
| | | } |
| | | |
| | | #endregion |
| | | |
| | | #region ◆ 保存____________________________ |
| | | |
| | | /// <summary> |
| | |
| | | System.IO.Directory.CreateDirectory(path); |
| | | } |
| | | path = System.IO.Path.Combine(path, FileName); |
| | | Shared.IO.FileUtils.WriteFileByBytes(path, System.Text.Encoding.UTF8.GetBytes(Newtonsoft.Json.JsonConvert.SerializeObject(this))); |
| | | HdlFileLogic.Current.SaveFileContent(path, this); |
| | | |
| | | if (autoBackup == true && Id == Config.Instance.HomeId) |
| | | { |
| | | HdlAutoBackupLogic.AddOrEditorFile(FileName); |
| | |
| | |
|
| | | //场景,功能,自动化的切换控件
|
| | | var switchContr = new SceneFunctionSwitchControl();
|
| | | switchContr.Y = Application.GetRealHeight(40);
|
| | | switchContr.Width = Application.GetRealWidth(650);
|
| | | switchContr.Gravity = Gravity.CenterVertical;
|
| | | frameSwitchBack.AddChidren(switchContr);
|
| | |
| | | {
|
| | | //在外面清空(特效的问题)
|
| | | this.functionSceneBodyView.RemoveAll();
|
| | | //刷新场景的时候,关闭左划菜单的未分配界面
|
| | | MainPage.LeftListRoomViewFrom.Instance?.CloseUnallocatedRoomForm();
|
| | |
|
| | | HdlThreadLogic.Current.RunMainInThread(() =>
|
| | | {
|
| | | //刷新场景分支控件
|
| | |
| | | }; |
| | | backgroundFL.AddChidren(floorLayout); |
| | | |
| | | var floorCount = Config.Instance.Home.FloorDics.Count; |
| | | var dicFloor = UserCenter.HdlRoomLogic.Current.GetFloorSortList(); |
| | | int floorCount = dicFloor.Count; |
| | | |
| | | if (floorCount > 0) |
| | | { |
| | |
| | | floorLayout.Height = this.GetPictrueRealSize(150 * floorCount); |
| | | } |
| | | |
| | | foreach (var floor in Config.Instance.Home.FloorDics) |
| | | foreach (var floor in dicFloor.Keys) |
| | | { |
| | | AddFloor(floorLayout, floor); |
| | | AddFloor(floorLayout, floor, dicFloor[floor]); |
| | | } |
| | | } |
| | | } |
| | |
| | | /// AddFloor |
| | | /// </summary> |
| | | /// <param name="verticalScrolView"></param> |
| | | private void AddFloor(VerticalScrolViewLayout verticalScrolView, KeyValuePair<string, string> floor,bool isLast=false) |
| | | private void AddFloor(VerticalScrolViewLayout verticalScrolView, string floorId, string floorName) |
| | | { |
| | | var frow = new Device.CommonForm.LeftIconButtonRow(449, 150); |
| | | frow.Width = this.GetPictrueRealSize(449); |
| | | frow.Height = this.GetPictrueRealSize(150); |
| | | frow.Tag = floor.Key; |
| | | frow.Init("Floor/Floor.png", "Floor/FloorSelected.png", floor.Value); |
| | | frow.Init("Floor/Floor.png", "Floor/FloorSelected.png", floorName); |
| | | verticalScrolView.AddChidren(frow); |
| | | |
| | | if (string.IsNullOrEmpty(CurFloorId)) |
| | | { |
| | | if (Config.Instance.Home.CurrentFloorId == floor.Key) |
| | | if (Config.Instance.Home.CurrentFloorId == floorId) |
| | | { |
| | | frow.IsSelected = true; |
| | | } |
| | | } |
| | | else |
| | | { |
| | | if (CurFloorId == floor.Key) |
| | | if (CurFloorId == floorId) |
| | | { |
| | | frow.IsSelected = true; |
| | | } |
| | | } |
| | | |
| | | frow.ButtonClickEvent += SelectFloor_MouseUpEvent; |
| | | } |
| | | |
| | | /// <summary> |
| | | /// SelectFloor_MouseUpEvent |
| | | /// </summary> |
| | | /// <param name="sender"></param> |
| | | /// <param name="mouseEventArgs"></param> |
| | | private void SelectFloor_MouseUpEvent(object sender, MouseEventArgs mouseEventArgs) |
| | | { |
| | | (sender as Device.CommonForm.LeftIconButtonRow).IsSelected = true; |
| | | if (changeFloor) |
| | | frow.ButtonClickEvent += (sender, e) => |
| | | { |
| | | Config.Instance.Home.CurrentFloorId = (sender as Device.CommonForm.LeftIconButtonRow).Tag.ToString(); |
| | | Config.Instance.Home.Save(false); |
| | | UserCenter.HdlRoomLogic.Current.RefreshRoomListView(); |
| | | } |
| | | RemoveView(); |
| | | FloorAction?.Invoke((sender as Device.CommonForm.LeftIconButtonRow).Tag.ToString()); |
| | | |
| | | frow.IsSelected = true; |
| | | if (changeFloor) |
| | | { |
| | | Config.Instance.Home.CurrentFloorId = floorId; |
| | | Config.Instance.Home.Save(false); |
| | | UserCenter.HdlRoomLogic.Current.RefreshRoomListView(); |
| | | } |
| | | RemoveView(); |
| | | FloorAction?.Invoke(floorId); |
| | | }; |
| | | } |
| | | |
| | | /// <summary> |
| | |
| | | /// 检测界面的错误
|
| | | /// </summary>
|
| | | /// <returns></returns>
|
| | | public bool CheckForm()
|
| | | public virtual bool CheckForm()
|
| | | {
|
| | | //检测控件
|
| | | return this.CheckControl(this);
|
| | |
| | | frame.AddChidren(btnReLoad);
|
| | | btnReLoad.ButtonClickEvent += (sender, e) =>
|
| | | {
|
| | | //点击重新加载时,允许再次联网
|
| | | HdlWifiLogic.Current.CanAccessHttp = true;
|
| | |
|
| | | //清除全部控件
|
| | | this.ClearBodyFrame();
|
| | |
|
| | |
| | | |
| | | } |
| | | #region ◆ 自动化__________________________ |
| | | |
| | | static bool If_once = true; |
| | | /// <summary> |
| | | /// 自动化功能代码入口 |
| | | /// </summary> |
| | |
| | | if (!Config.Instance.Home.IsVirtually) |
| | | {//虚拟的不获取网关逻辑列表 |
| | | //重新刷新logic列表 |
| | | If_once = true; |
| | | Common.Logic.LogicList.Clear(); |
| | | Read(logicScrolView, no); |
| | | } |
| | |
| | | { |
| | | if (!Config.Instance.Home.IsVirtually)//虚拟的不获取网关逻辑列表 |
| | | { |
| | | if (Common.Logic.LogicList.Count == 0) |
| | | { |
| | | var Idlist1 = await Send.GetLogicId(0);// |
| | | var Idlist2 = await Send.GetLogicId(2);//门锁常开模式 |
| | | if (Idlist1.Count != 0) |
| | | { |
| | | var listlogic1 = await Send.ReadList(Idlist1.Count, 0); |
| | | for (int j = 0; j < listlogic1.Count; j++) |
| | | { |
| | | var logic = listlogic1[j]; |
| | | if (logic.LogicType != 0) |
| | | { |
| | | continue; |
| | | } |
| | | Common.Logic.LogicList.Add(logic); |
| | | } |
| | | } |
| | | if (Idlist2.Count != 0) |
| | | { |
| | | var listlogic2 = await Send.ReadList(Idlist2.Count, 2); |
| | | for (int j = 0; j < listlogic2.Count; j++) |
| | | { |
| | | var logic = listlogic2[j]; |
| | | if (logic.LogicType != 2) |
| | | { |
| | | continue; |
| | | } |
| | | Common.Logic.LogicList.Add(logic); |
| | | } |
| | | if (If_once)
|
| | | {
|
| | | If_once = false;
|
| | | if (Common.Logic.LogicList.Count == 0)
|
| | | {
|
| | | var Idlist1 = await Send.GetLogicId(0);//
|
| | | var Idlist2 = await Send.GetLogicId(2);//门锁常开模式
|
| | | if (Idlist1.Count != 0)
|
| | | {
|
| | | var listlogic1 = await Send.ReadList(Idlist1.Count, 0);
|
| | | for (int j = 0; j < listlogic1.Count; j++)
|
| | | {
|
| | | var logic = listlogic1[j];
|
| | | if (logic.LogicType != 0)
|
| | | {
|
| | | continue;
|
| | | }
|
| | | Common.Logic.LogicList.Add(logic);
|
| | | }
|
| | | }
|
| | | if (Idlist2.Count != 0)
|
| | | {
|
| | | var listlogic2 = await Send.ReadList(Idlist2.Count, 2);
|
| | | for (int j = 0; j < listlogic2.Count; j++)
|
| | | {
|
| | | var logic = listlogic2[j];
|
| | | if (logic.LogicType != 2)
|
| | | {
|
| | | continue;
|
| | | }
|
| | | Common.Logic.LogicList.Add(logic);
|
| | | }
|
| | | }
|
| | | } |
| | | } |
| | | } |
| | |
| | | Latitude = lat |
| | | }; |
| | | var requestJson = Newtonsoft.Json.JsonConvert.SerializeObject(requestObj); |
| | | var revertObj = await RequestHttpsZigbeeAsync("ProcessRange/ReceiveAppLatAndLon", System.Text.Encoding.UTF8.GetBytes(requestJson)); |
| | | var revertObj = RequestHttpsZigbeeAsync("ProcessRange/ReceiveAppLatAndLon", System.Text.Encoding.UTF8.GetBytes(requestJson)); |
| | | } |
| | | catch { } |
| | | } |
| | |
| | | /// <param name="requestUrl">请求Url</param> |
| | | /// <param name="byteData">请求的的数据</param> |
| | | /// <returns>得到响应的数据</returns> |
| | | private async System.Threading.Tasks.Task<Shared.Common.ResponseEntity.ResponsePack> RequestHttpsZigbeeAsync(string requestUrl, byte[] byteData) |
| | | public Shared.Common.ResponseEntity.ResponsePack RequestHttpsZigbeeAsync(string requestUrl, byte[] byteData) |
| | | { |
| | | string result = await RequestHttpsZigbeeResultAsync(requestUrl, byteData); |
| | | string result = RequestHttpsZigbeeResultAsync(requestUrl, byteData); |
| | | if (result != null) |
| | | { |
| | | try |
| | |
| | | /// <param name="requestUrl">请求Url</param> |
| | | /// <param name="byteData">请求的的数据</param> |
| | | /// <returns>得到响应的数据</returns> |
| | | private async System.Threading.Tasks.Task<string> RequestHttpsZigbeeResultAsync(string requestUrl, byte[] byteData) |
| | | public string RequestHttpsZigbeeResultAsync(string requestUrl, byte[] byteData) |
| | | { |
| | | var result = await RequestHttpsZigbeeBytesResultAsync(requestUrl, byteData); |
| | | var result = RequestHttpsZigbeeBytesResultAsync(requestUrl, byteData); |
| | | if (result != null) |
| | | { |
| | | return Encoding.UTF8.GetString(result); |
| | |
| | | /// <param name="byteData">请求的的数据</param> |
| | | /// <param name="requestMethod">POST 或者 GET 等等</param> |
| | | /// <returns>得到响应的数据</returns> |
| | | private async System.Threading.Tasks.Task<byte[]> RequestHttpsZigbeeBytesResultAsync(string requestUrl, byte[] byteData, string requestMethod = "POST") |
| | | public byte[] RequestHttpsZigbeeBytesResultAsync(string requestUrl, byte[] byteData, string requestMethod = "POST") |
| | | { |
| | | //请求Url的完成路径 |
| | | var requestHost = "https://global.hdlcontrol.com/GeofenceService"; |
| | |
| | | Instance = this;
|
| | |
|
| | | //先初始化左滑房间列表界面(在反射里面初始化)
|
| | | if (ListRoomViewFrom.Instance == null) { }
|
| | | if (LeftListRoomViewFrom.Instance == null) { }
|
| | |
|
| | | //整个背景的上下滑动控件
|
| | | if (this.listBodyContr == null)
|
File was renamed from ZigbeeApp/Shared/Phone/MainPage/ListRoomViewFrom.cs |
| | |
| | | /// <summary>
|
| | | /// 左滑菜单的的房间列表界面
|
| | | /// </summary> |
| | | public class ListRoomViewFrom : EditorCommonForm |
| | | public class LeftListRoomViewFrom : EditorCommonForm |
| | | {
|
| | | #region ■ 变量声明___________________________
|
| | |
|
| | | private static ListRoomViewFrom roomManagement = null; |
| | | private static LeftListRoomViewFrom roomManagement = null; |
| | | /// <summary>
|
| | | /// 左滑菜单的的房间对象
|
| | | /// </summary> |
| | | public static ListRoomViewFrom Instance |
| | | public static LeftListRoomViewFrom Instance |
| | | { |
| | | get |
| | | {
|
| | | if (roomManagement == null)
|
| | | {
|
| | | //初始化左滑菜单
|
| | | roomManagement = new ListRoomViewFrom();
|
| | | roomManagement = new LeftListRoomViewFrom();
|
| | | CommonPage.Instance.AddLeftView(roomManagement);
|
| | | } |
| | | return roomManagement; |
| | |
| | | /// 卡片控件集合
|
| | | /// </summary>
|
| | | private Dictionary<string, Controls.ListRoomCardControl> dicCardControl = new Dictionary<string, Controls.ListRoomCardControl>();
|
| | | /// <summary>
|
| | | /// 未分配界面(用于对应别人乱搞,在打开未分配界面不关时,去刷新场景,然后提bug说没有场景)
|
| | | /// </summary>
|
| | | private UnallocatedRoomForm unalloctedRoom = null;
|
| | |
|
| | | #endregion
|
| | |
|
| | |
| | | /// <summary> |
| | | /// 画面显示 |
| | | /// </summary> |
| | | public void ShowForm() |
| | | private void ShowForm() |
| | | {
|
| | | //初始化头部信息 |
| | | this.InitTopFrame(); |
| | |
| | | /// </summary>
|
| | | public void RefreshListRoom()
|
| | | {
|
| | | //保险起见,这里要关闭未分配界面
|
| | | this.CloseUnallocatedRoomForm();
|
| | |
|
| | | //如果还没有初始化完成界面的话
|
| | | if (this.isInitFinish == false)
|
| | | {
|
| | |
| | | return;
|
| | | }
|
| | | //未分配
|
| | | var unalloctedRoom = new UnallocatedRoomForm();
|
| | | this.unalloctedRoom = new UnallocatedRoomForm();
|
| | | this.AddChidren(unalloctedRoom);
|
| | | unalloctedRoom.ShowForm();
|
| | | unalloctedRoom.FormCloseEvent += () =>
|
| | | {
|
| | | //手动点击关闭的话,直接置空
|
| | | this.unalloctedRoom = null;
|
| | | };
|
| | | };
|
| | | }
|
| | |
|
| | | #endregion
|
| | |
|
| | | #region ■ 关闭未分配界面_____________________
|
| | |
|
| | | /// <summary>
|
| | | /// 关闭未分配界面
|
| | | /// </summary>
|
| | | public void CloseUnallocatedRoomForm()
|
| | | {
|
| | | //关闭界面
|
| | | this.unalloctedRoom?.CloseForm();
|
| | | this.unalloctedRoom = null;
|
| | | }
|
| | |
|
| | | #endregion
|
| | |
|
| | | #region ■ 刷新指定房间_______________________
|
| | |
|
| | | /// <summary>
|
| | |
| | | #region ■ 变量声明___________________________
|
| | |
|
| | | /// <summary>
|
| | | /// 界面关闭事件
|
| | | /// </summary>
|
| | | public Action FormCloseEvent = null;
|
| | | /// <summary>
|
| | | /// 添加到 的背景图控件
|
| | | /// </summary>
|
| | | private FrameLayoutStatuControl frameAddBackGroud = null;
|
| | |
| | | frameAddBackGroud.AddChidren(btnAdd, ChidrenBindMode.BindEvent);
|
| | | frameAddBackGroud.ButtonClickEvent += (sender, e) =>
|
| | | {
|
| | | var selectZone = new SelectZone(); |
| | | selectZone.title = Language.StringByID(R.MyInternationalizationString.AddTo); |
| | | selectZone.Init(); |
| | | selectZone.ZoneAction += (selectRoom) => |
| | | HdlControlLogic.Current.ShowBottomListRoomView(string.Empty, Language.StringByID(R.MyInternationalizationString.AddTo), (selectId, selectName) => |
| | | { |
| | | //变更了当前房间的东西,主页需要刷新 |
| | | if (HdlRoomLogic.Current.NowMainPageRoom.Id == selectRoom.Id)
|
| | | if (HdlRoomLogic.Current.NowMainPageRoom.Id == selectId)
|
| | | {
|
| | | this.dataHadChanged = true;
|
| | | } |
| | | //保存选择的设备和场景 |
| | | this.SaveSelectDeviceAndScene(selectRoom); |
| | | };
|
| | | var room = HdlRoomLogic.Current.GetRoomById(selectId); |
| | | this.SaveSelectDeviceAndScene(room); |
| | | });
|
| | | };
|
| | | }
|
| | |
|
| | |
| | | /// </summary>
|
| | | public override void CloseFormBefore()
|
| | | {
|
| | | //调用回调事件
|
| | | this.FormCloseEvent?.Invoke();
|
| | | this.FormCloseEvent = null;
|
| | |
|
| | | if (this.dataHadChanged == true)
|
| | | {
|
| | | HdlThreadLogic.Current.RunMainInThread(() =>
|
| | |
| | | string oldGestureAuthentication = GestureAuthentication;
|
| | | GestureAuthentication = UserCenterLogic.EncryptPassword(hdlKey, oldGestureAuthentication);
|
| | |
|
| | | var data = Newtonsoft.Json.JsonConvert.SerializeObject(this);
|
| | | var byteData = System.Text.Encoding.UTF8.GetBytes(data);
|
| | | string fullName = System.IO.Path.Combine(Shared.IO.FileUtils.RootPath, Common.Config.Instance.Guid, DirNameResourse.AccountOptionFile);
|
| | | //写入内容
|
| | | Shared.IO.FileUtils.WriteFileByBytes(fullName, byteData);
|
| | | HdlFileLogic.Current.SaveFileContent(DirNameResourse.AccountOptionFile, this);
|
| | | //还原明码
|
| | | PswAuthentication = oldPswAuthentication;
|
| | | GestureAuthentication = oldGestureAuthentication;
|
| | |
| | | /// <returns></returns>
|
| | | public AccountOptionClass Load()
|
| | | {
|
| | | string fileName = System.IO.Path.Combine(Shared.IO.FileUtils.RootPath, Common.Config.Instance.Guid, DirNameResourse.AccountOptionFile);
|
| | | string fileName = DirNameResourse.AccountOptionFile;
|
| | | if (System.IO.File.Exists(fileName) == false)
|
| | | {
|
| | | return new AccountOptionClass();
|
| | | }
|
| | | try
|
| | | {
|
| | | var varByte = Shared.IO.FileUtils.ReadFile(fileName);
|
| | | var varByte = HdlFileLogic.Current.ReadFileByteContent(fileName);
|
| | | string strValue = System.Text.Encoding.UTF8.GetString(varByte);
|
| | | var info = Newtonsoft.Json.JsonConvert.DeserializeObject<AccountOptionClass>(strValue);
|
| | | //解密密码
|
| | |
| | | /// </summary>
|
| | | public void Save()
|
| | | {
|
| | | try
|
| | | {
|
| | | var data = Newtonsoft.Json.JsonConvert.SerializeObject(this);
|
| | | var byteData = System.Text.Encoding.UTF8.GetBytes(data);
|
| | | string fullName = UserCenterLogic.CombinePath(DirNameResourse.LocalMemoryDirectory, DirNameResourse.ResidenceOptionFile);
|
| | | //写入内容
|
| | | Shared.IO.FileUtils.WriteFileByBytes(fullName, byteData);
|
| | | }
|
| | | catch (Exception ex)
|
| | | {
|
| | | HdlLogLogic.Current.WriteLog(ex);
|
| | | }
|
| | | //写入内容
|
| | | HdlFileLogic.Current.SaveFileContent(DirNameResourse.ResidenceOptionFile, this);
|
| | | }
|
| | |
|
| | | /// <summary>
|
| | |
| | | /// <returns></returns>
|
| | | public ResidenceOptionClass Load()
|
| | | {
|
| | | string fileName = UserCenterLogic.CombinePath(DirNameResourse.LocalMemoryDirectory, DirNameResourse.ResidenceOptionFile);
|
| | | string fileName = DirNameResourse.ResidenceOptionFile;
|
| | | if (System.IO.File.Exists(fileName) == false)
|
| | | {
|
| | | return new ResidenceOptionClass();
|
| | | }
|
| | | try
|
| | | {
|
| | | var varByte = Shared.IO.FileUtils.ReadFile(fileName);
|
| | | var varByte = HdlFileLogic.Current.ReadFileByteContent(fileName);
|
| | | string strValue = System.Text.Encoding.UTF8.GetString(varByte);
|
| | | var info = Newtonsoft.Json.JsonConvert.DeserializeObject<ResidenceOptionClass>(strValue);
|
| | |
|
| | |
| | | /// <summary>
|
| | | /// 登陆权限编号的翻译名:1:主账号自己(本人) 2:赋予管理员权限的成员 3:成员
|
| | | /// </summary>
|
| | | [Newtonsoft.Json.JsonIgnore]
|
| | | public string AuthorityText = string.Empty;
|
| | | /// <summary>
|
| | | /// 用户头像数据(临时用,会置空)
|
| | |
| | | /// 是否将发送及接收到的数据写入到Log中 1->写入
|
| | | /// </summary>
|
| | | public int WriteSendAndReceveDataToFile = 0;
|
| | | /// <summary>
|
| | | /// 是否将SocketReceive的数据写入到Log中 1->写入
|
| | | /// </summary>
|
| | | public int WriteSocketReceiveDataToFile = 0;
|
| | | }
|
| | | #endregion
|
| | |
|
| | |
| | | namespace Shared.Phone.UserCenter
|
| | | {
|
| | | /// <summary>
|
| | | /// 行控件里面子控件的位置对齐方式
|
| | | /// </summary> |
| | | public enum UViewAlignment
|
| | | {
|
| | | /// <summary>
|
| | | /// 位于上部(等间距离居中:位于上部,以中间横线为基准,但是上下空白一致)
|
| | | /// </summary>
|
| | | Top = 1,
|
| | | /// <summary>
|
| | | /// 位于正中间
|
| | | /// </summary>
|
| | | Center = 2,
|
| | | /// <summary>
|
| | | /// 位于底部(等间距离居中:位于上部,以中间横线为基准,上下空白一致)
|
| | | /// </summary>
|
| | | Bottom = 3
|
| | | }
|
| | |
|
| | | /// <summary>
|
| | | /// 状态控件添加子控件事件的绑定模式
|
| | | /// </summary>
|
| | | public enum ChidrenBindMode
|
| | |
| | | /// 不绑定事件,也不显示选择状态
|
| | | /// </summary>
|
| | | NotBind = 2
|
| | | }
|
| | |
|
| | | /// <summary>
|
| | | /// 控件自动调整高度大小模式
|
| | | /// </summary>
|
| | | public enum HeightAutoMode
|
| | | {
|
| | | /// <summary>
|
| | | /// 什么事都不做
|
| | | /// </summary>
|
| | | None = 1,
|
| | | /// <summary>
|
| | | /// 自动增加高度,只对当前容器进行判定(由控件的bottomSpace的值进行判定)
|
| | | /// </summary>
|
| | | IncreaseOnly = 2,
|
| | | /// <summary>
|
| | | /// 自动调整高度,只对当前容器进行判定,请慎用此模式(增加或者减少,由控件的bottomSpace的值进行判定)
|
| | | /// </summary>
|
| | | AutoOnly = 3,
|
| | | /// <summary>
|
| | | /// 自动增加高度,包含全部父容器进行判定(由控件的bottomSpace的值进行判定)
|
| | | /// </summary>
|
| | | IncreaseAll = 4,
|
| | | /// <summary>
|
| | | /// 自动调整高度,包含全部父容器进行判定,请慎用此模式(增加或者减少,由控件的bottomSpace的值进行判定)
|
| | | /// </summary>
|
| | | AutoAll = 5
|
| | | }
|
| | |
|
| | | /// <summary>
|
| | | /// 进度条的添加模式
|
| | | /// </summary>
|
| | | public enum ProBarAddMode
|
| | | {
|
| | | /// <summary>
|
| | | /// 完全遮住画面,不能进行任何操作
|
| | | /// </summary>
|
| | | FullForm = 1,
|
| | | /// <summary>
|
| | | /// 进度条只盖住Body,但能操作头部菜单,允许用户取消
|
| | | /// </summary>
|
| | | BodyFrame = 2
|
| | | }
|
| | |
|
| | | /// <summary>
|
| | | /// 弹窗画面的模式
|
| | | /// </summary>
|
| | | public enum DialogFrameMode
|
| | | {
|
| | | /// <summary>
|
| | | /// <para>不做任何处理,子控件由自定义添加,子控件添加完成后</para>
|
| | | /// <para>请调用【FinishInitControl】函数完成最后的初始化</para>
|
| | | /// </summary>
|
| | | None = 1,
|
| | | /// <summary>
|
| | | /// <para>只有一个输入框,由InputText属性获取输入值</para>
|
| | | /// <para>由SetTipText函数设置输入框灰色字体说明(如果有需要)</para>
|
| | | /// </summary>
|
| | | OnlyInput = 2,
|
| | | /// <summary>
|
| | | /// <para>只有一个输入框(密码模式)</para>
|
| | | /// <para>由InputText属性获取输入值,由SetTipText函数设置输入框灰色字体说明</para>
|
| | | /// </summary>
|
| | | OnlyPassword = 3,
|
| | | /// <summary>
|
| | | /// <para>只有一个输入框(密码模式),右边有一个可以看见密码的图标</para>
|
| | | /// <para>由InputText属性获取输入值,由SetTipText函数设置输入框灰色字体说明</para>
|
| | | /// </summary>
|
| | | PasswordView = 4
|
| | | }
|
| | |
|
| | | /// <summary> |
| | |
| | | }
|
| | |
|
| | | /// <summary>
|
| | | /// 验证模式
|
| | | /// </summary>
|
| | | public enum ValidatedMode
|
| | | {
|
| | | /// <summary>
|
| | | /// 不验证
|
| | | /// </summary>
|
| | | NO = 0,
|
| | | /// <summary>
|
| | | /// 验证
|
| | | /// </summary>
|
| | | YES = 1
|
| | | }
|
| | |
|
| | | /// <summary>
|
| | | /// 固件阶级分类
|
| | | /// </summary>
|
| | | public enum FirmwareLevelType
|
| | |
| | | /// WIFI
|
| | | /// </summary>
|
| | | WIFI = 2
|
| | | }
|
| | |
|
| | | /// <summary>
|
| | | /// 获取名字模式
|
| | | /// </summary>
|
| | | public enum GetNameMode
|
| | | {
|
| | | /// <summary>
|
| | | /// 什么特效都不加,直接获取
|
| | | /// </summary>
|
| | | None = 0,
|
| | | /// <summary>
|
| | | /// <para>设备名字加特效</para>
|
| | | /// <para>多回路时:XXXX(NN回路)</para>
|
| | | /// </summary>
|
| | | SpecialDevice = 1,
|
| | | /// <summary>
|
| | | /// 网关名称加特效
|
| | | /// </summary>
|
| | | SpecialGateway = 2
|
| | | }
|
| | |
|
| | | /// <summary>
|
| | | /// 水平滑动滚动条的类型模式
|
| | | /// </summary>
|
| | | public enum SeekBarTypeMode
|
| | | {
|
| | | /// <summary>
|
| | | /// 单纯只在右边有一个百分比的文本(有效控件:seekBar,btnRight)
|
| | | /// </summary>
|
| | | OnlyPersent = 1,
|
| | | /// <summary>
|
| | | /// 左边有一个文本,右边有一个百分比的文本(有效控件:seekBar,btnLeft,btnRight)
|
| | | /// </summary>
|
| | | LeftAndPersent = 2,
|
| | | /// <summary>
|
| | | /// 左边和右边都有一个文本,但是无进度条(有效控件:seekBar,btnLeft,btnRight)
|
| | | /// </summary>
|
| | | LeftAndRight = 3
|
| | | }
|
| | |
|
| | | /// <summary>
|
| | |
| | | get { return m_CanClick; }
|
| | | set
|
| | | {
|
| | | if (m_CanClick == value) { return; }
|
| | |
|
| | | m_CanClick = value;
|
| | | //能够点击,则显示没有点击过的状态
|
| | | if (m_CanClick == true) { this.SetNotClickStatu(); }
|
| | |
| | | {
|
| | | base.RemoveFromParent();
|
| | | }
|
| | | }
|
| | |
|
| | | /// <summary>
|
| | | /// Y轴重置(真实数值,没有父容器无效)
|
| | | /// </summary>
|
| | | /// <param name="alignment">上下对齐方式</param>
|
| | | /// <param name="Space">上下两部分的间距</param>
|
| | | public void ReSetYaxis(UViewAlignment alignment, int Space = 0)
|
| | | {
|
| | | if (this.Parent == null)
|
| | | {
|
| | | return;
|
| | | }
|
| | | //Y轴重置
|
| | | this.Y = HdlControlLogic.Current.GetControlChidrenYaxis(this.Parent.Height, this.Height, alignment, Space);
|
| | | }
|
| | |
|
| | | /// <summary>
|
| | |
| | | #region ■ 一般方法___________________________
|
| | |
|
| | | /// <summary>
|
| | | /// Y轴重置(真实数值,没有父容器无效)
|
| | | /// </summary>
|
| | | /// <param name="alignment">上下对齐方式</param>
|
| | | /// <param name="Space">上下两部分的间距</param>
|
| | | public void ReSetYaxis(UViewAlignment alignment, int Space = 0)
|
| | | {
|
| | | if (this.Parent == null)
|
| | | {
|
| | | return;
|
| | | }
|
| | | //Y轴重置
|
| | | this.Y = HdlControlLogic.Current.GetControlChidrenYaxis(this.Parent.Height, this.Height, alignment, Space);
|
| | | }
|
| | |
|
| | | /// <summary>
|
| | | /// 计算图片的真实高宽度
|
| | | /// </summary>
|
| | | /// <param name="i_size"></param>
|
| | |
| | | /// </summary>
|
| | | public string RoomKey = string.Empty;
|
| | | /// <summary>
|
| | | /// 当前选择的楼层主键(没必要公开出去)
|
| | | /// 显示文本
|
| | | /// </summary>
|
| | | private string FloorKey = string.Empty;
|
| | | /// <summary>
|
| | | /// 楼层列表名字
|
| | | /// </summary>
|
| | | private List<string> listFloorName = new List<string>();
|
| | | /// <summary>
|
| | | /// 楼层列表主键
|
| | | /// </summary>
|
| | | private List<string> listFloorKeys = new List<string>();
|
| | | /// <summary>
|
| | | /// 房间名字
|
| | | /// </summary>
|
| | | private List<List<string>> listRoomName = new List<List<string>>();
|
| | | /// <summary>
|
| | | /// 房间主键
|
| | | /// </summary>
|
| | | private List<List<string>> listRoomKeys = new List<List<string>>();
|
| | | private NormalViewControl btnTextView = null;
|
| | |
|
| | | #endregion
|
| | |
|
| | |
| | | /// <param name="i_ChidrenYaxis">子控件Y轴偏移量(【列表控件的rowSpace/2】即可,不懂默认为0即可)</param>
|
| | | public BelongAreaControl(int i_ChidrenYaxis = 0) : base(i_ChidrenYaxis)
|
| | | {
|
| | | //初始化数据
|
| | | this.InitData();
|
| | | }
|
| | |
|
| | | /// <summary>
|
| | |
| | | {
|
| | | string roomName = i_Room.Name;
|
| | | this.RoomKey = i_Room.Id;
|
| | | this.FloorKey = i_Room.FloorId;
|
| | | if (Common.Config.Instance.Home.FloorDics.ContainsKey(i_Room.FloorId) == true)
|
| | | {
|
| | | //楼层+房间
|
| | |
| | | this.AddChidren(btnCaption, ChidrenBindMode.BindEvent);
|
| | |
|
| | | //显示框
|
| | | var txtView = new NormalViewControl(700, true);
|
| | | txtView.X = Application.GetRealWidth(294);
|
| | | txtView.Gravity = Gravity.CenterVertical;
|
| | | txtView.TextColor = UserCenterColor.Current.TextGrayColor1;
|
| | | txtView.Text = i_RoomName;
|
| | | this.AddChidren(txtView, ChidrenBindMode.BindEvent);
|
| | | this.btnTextView = new NormalViewControl(700, true);
|
| | | btnTextView.X = Application.GetRealWidth(294);
|
| | | btnTextView.Gravity = Gravity.CenterVertical;
|
| | | btnTextView.TextColor = UserCenterColor.Current.TextGrayColor1;
|
| | | btnTextView.Text = i_RoomName;
|
| | | this.AddChidren(btnTextView, ChidrenBindMode.BindEvent);
|
| | |
|
| | | if (chidrenYaxis != 0)
|
| | | {
|
| | | btnCaption.Y += chidrenYaxis;
|
| | | txtView.Y += chidrenYaxis;
|
| | | btnTextView.Y += chidrenYaxis;
|
| | | }
|
| | |
|
| | | if (IsSharedRoom == true)
|
| | |
| | | this.UseClickStatu = false;
|
| | | return;
|
| | | }
|
| | | if (this.listFloorKeys.Count == 0 && listRoomKeys.Count == 0)
|
| | | {
|
| | | //或者根本就没有创建房间,则不允许更改
|
| | | this.UseClickStatu = false;
|
| | | return;
|
| | | }
|
| | |
|
| | | //右箭头
|
| | | this.AddRightArrow();
|
| | |
|
| | | this.ButtonClickEvent += (sender, e) =>
|
| | | {
|
| | | //区域选择
|
| | | this.ShowSelectRoom(txtView, i_caption);
|
| | | this.ShowSelectRoom(btnTextView, i_caption);
|
| | | };
|
| | | }
|
| | |
|
| | | /// <summary>
|
| | | /// 初始化数据
|
| | | /// </summary>
|
| | | private void InitData()
|
| | | {
|
| | | var dicFloor = HdlRoomLogic.Current.GetFloorSortList();
|
| | | if (dicFloor.Count == 0)
|
| | | {
|
| | | //第一位默认添加未分配
|
| | | var listKeys = new List<string>() { "" };
|
| | | var listName = new List<string>() { Language.StringByID(R.MyInternationalizationString.uUndistributed) };
|
| | | //房间名字和主键收集
|
| | | var listRoom = HdlRoomLogic.Current.GetFloorSortRoom(string.Empty, false);
|
| | | foreach (var myRoom in listRoom)
|
| | | {
|
| | | listName.Add(myRoom.Name);
|
| | | listKeys.Add(myRoom.Id);
|
| | | }
|
| | | listRoomName.Add(listName);
|
| | | listRoomKeys.Add(listKeys);
|
| | | }
|
| | | else
|
| | | {
|
| | | //第一位默认添加未分配(未分配放在楼层那个菜单)
|
| | | var listKeys = new List<string>() { "" };
|
| | | var listName = new List<string>() { "" };
|
| | | listRoomName.Add(listName);
|
| | | listRoomKeys.Add(listKeys);
|
| | | this.listFloorKeys.Add("");
|
| | | this.listFloorName.Add(Language.StringByID(R.MyInternationalizationString.uUndistributed));
|
| | |
|
| | | foreach (string fKeys in dicFloor.Keys)
|
| | | {
|
| | | var listRoom = HdlRoomLogic.Current.GetFloorSortRoom(fKeys, false);
|
| | | if (listRoom.Count > 0)
|
| | | {
|
| | | //楼层名字和主键收集
|
| | | this.listFloorKeys.Add(fKeys);
|
| | | this.listFloorName.Add(dicFloor[fKeys]);
|
| | | //房间名字和主键收集
|
| | | listName = new List<string>();
|
| | | listKeys = new List<string>();
|
| | | foreach (var myRoom in listRoom)
|
| | | {
|
| | | listName.Add(myRoom.Name);
|
| | | listKeys.Add(myRoom.Id);
|
| | | }
|
| | | listRoomName.Add(listName);
|
| | | listRoomKeys.Add(listKeys);
|
| | | }
|
| | | }
|
| | | }
|
| | | }
|
| | |
|
| | | #endregion
|
| | |
| | | /// <param name="i_caption"></param>
|
| | | private void ShowSelectRoom(NormalViewControl txtView, string i_caption)
|
| | | {
|
| | | int index1 = this.listFloorKeys.IndexOf(FloorKey);
|
| | | if (index1 == -1) { index1 = 0; }
|
| | | int index2 = this.listRoomKeys[index1].IndexOf(RoomKey);
|
| | | if (index2 == -1) { index2 = 0; }
|
| | |
|
| | | if (this.listFloorKeys.Count == 0)
|
| | | //显示底部弹窗的房间列表
|
| | | var result = HdlControlLogic.Current.ShowBottomListRoomView(this.RoomKey, i_caption, (selectId, selectName) =>
|
| | | {
|
| | | //无楼层模式
|
| | | PickerView.Show(this.listRoomName[0], (value) =>
|
| | | {
|
| | | RoomKey = this.listRoomKeys[0][value];
|
| | | if (RoomKey != string.Empty)
|
| | | {
|
| | | //房间
|
| | | txtView.Text = this.listRoomName[0][value];
|
| | | }
|
| | | else
|
| | | {
|
| | | txtView.Text = Language.StringByID(R.MyInternationalizationString.uDeviceNotAssignedRoom);
|
| | | }
|
| | | this.SelectRoomEvent?.Invoke(RoomKey);
|
| | |
|
| | | }, index2, i_caption,
|
| | | Language.StringByID(R.MyInternationalizationString.uFinish),
|
| | | Language.StringByID(R.MyInternationalizationString.uCancel));
|
| | | }
|
| | | else
|
| | | this.RoomKey = selectId;
|
| | | txtView.Text = selectName;
|
| | | //调用回调函数
|
| | | this.SelectRoomEvent?.Invoke(RoomKey);
|
| | | });
|
| | | if (result == false)
|
| | | {
|
| | | //有楼层模式
|
| | | PickerView.ShowSecondary(this.listFloorName, this.listRoomName, (value1, value2) =>
|
| | | {
|
| | | FloorKey = this.listFloorKeys[value1];
|
| | | RoomKey = this.listRoomKeys[value1][value2];
|
| | | if (RoomKey != string.Empty)
|
| | | {
|
| | | //楼层+房间
|
| | | txtView.Text = this.listFloorName[value1] + " " + this.listRoomName[value1][value2];
|
| | | }
|
| | | else
|
| | | {
|
| | | txtView.Text = Language.StringByID(R.MyInternationalizationString.uDeviceNotAssignedRoom);
|
| | | }
|
| | | this.SelectRoomEvent?.Invoke(RoomKey);
|
| | |
|
| | | }, index1, index2, i_caption,
|
| | | Language.StringByID(R.MyInternationalizationString.uFinish),
|
| | | Language.StringByID(R.MyInternationalizationString.uCancel));
|
| | | //或者根本就没有创建房间,则不允许更改
|
| | | this.UseClickStatu = false;
|
| | | }
|
| | | }
|
| | |
|
| | | #endregion
|
| | |
|
| | | #region ■ 刷新控件___________________________
|
| | |
|
| | | /// <summary>
|
| | | /// 重新刷新控件
|
| | | /// </summary>
|
| | | /// <param name="i_RoomId">指定以哪个房间ID刷新控件</param>
|
| | | public void RefreshControl(string i_RoomId)
|
| | | {
|
| | | this.RoomKey = i_RoomId;
|
| | |
|
| | | var room = HdlRoomLogic.Current.GetRoomById(i_RoomId);
|
| | | this.btnTextView.Text = HdlRoomLogic.Current.GetRoomName(room);
|
| | | }
|
| | |
|
| | | #endregion
|
| | |
|
| | | #region ■ 控件摧毁___________________________
|
| | |
|
| | | /// <summary>
|
| | |
| | | /// </summary>
|
| | | private string textValue = string.Empty;
|
| | | /// <summary>
|
| | | /// 下部显示文本
|
| | | /// </summary>
|
| | | private string textBottomValue = null;
|
| | | /// <summary>
|
| | | /// 文本控件
|
| | | /// </summary>
|
| | | private NormalViewControl btnText = null;
|
| | |
| | | }
|
| | | }
|
| | | /// <summary>
|
| | | /// 处于非选中状态时,是否把字体变成灰色(默认变成灰色)
|
| | | /// 处于选中或者非选中状态时,是否变更字体颜色
|
| | | /// </summary>
|
| | | public bool ChangedTextColor = true;
|
| | |
|
| | |
| | | }
|
| | |
|
| | | /// <summary>
|
| | | /// 做成一个简单的选择控件
|
| | | /// </summary>
|
| | | /// <param name="i_topText">上部显示文本</param>
|
| | | /// <param name="i_bottomText">下部显示文本</param>
|
| | | /// <param name="i_ChidrenYaxis">子控件Y轴偏移量(【列表控件的rowSpace/2】即可,不懂默认为0即可)</param>
|
| | | public NormalSelectControl(string i_topText, string i_bottomText, int i_ChidrenYaxis = 0) : base(i_ChidrenYaxis)
|
| | | {
|
| | | this.textValue = i_topText;
|
| | | this.textBottomValue = i_bottomText;
|
| | | }
|
| | |
|
| | | /// <summary>
|
| | | /// 初始化内部控件
|
| | | /// </summary>
|
| | | /// <param name="iconParh">左侧图标</param>
|
| | |
| | | var btnIcon = this.AddLeftIcon();
|
| | | btnIcon.UnSelectedImagePath = iconParh;
|
| | | }
|
| | | //显示文本
|
| | | btnText = this.AddLeftCaption(this.textValue, 600);
|
| | | btnText.TextColor = UserCenterColor.Current.TextGrayColor3;
|
| | | if (this.textBottomValue == null)
|
| | | {
|
| | | //显示文本
|
| | | btnText = this.AddLeftCaption(this.textValue, 600);
|
| | | btnText.TextColor = UserCenterColor.Current.TextGrayColor3;
|
| | | }
|
| | | else
|
| | | {
|
| | | //显示文本
|
| | | btnText = this.AddTopView(this.textValue, 600);
|
| | | this.AddBottomView(this.textBottomValue, 600);
|
| | | }
|
| | | //选择控件
|
| | | btnSelect = this.AddMostRightEmptyIcon(58, 58);
|
| | | btnSelect.Visible = false;
|
| | |
| | | HdlThreadLogic.Current.RunMain(() =>
|
| | | {
|
| | | btnText.Text = msg;
|
| | | });
|
| | | }, ShowErrorMode.NO);
|
| | | }
|
| | |
|
| | | #endregion
|
| | |
| | | /// <param name="value">此值为百分比值(也就是小于或者等于1的)</param>
|
| | | public void SetValue(decimal value)
|
| | | {
|
| | | this.btnProgressBar.SetValue(value);
|
| | | this.btnProgressBar?.SetValue(value);
|
| | | }
|
| | |
|
| | | /// <summary>
|
| | |
| | | /// <param name="maxValue">最大值</param>
|
| | | public void SetValue(decimal value, decimal maxValue)
|
| | | {
|
| | | this.btnProgressBar.SetValue(value, maxValue);
|
| | | this.btnProgressBar?.SetValue(value, maxValue);
|
| | | }
|
| | |
|
| | | #endregion
|
| | |
| | | {
|
| | | //初始化进度条
|
| | | this.InitProgressFormBar();
|
| | | });
|
| | | }, ShowErrorMode.NO);
|
| | | }
|
| | | }
|
| | |
|
| | |
| | | //关闭事件
|
| | | this.CloseEvent?.Invoke();
|
| | | this.CloseEvent = null;
|
| | | });
|
| | | }, ShowErrorMode.NO);
|
| | | }
|
| | |
|
| | | #endregion
|
| | |
| | | #region ■ 变量声明___________________________
|
| | |
|
| | | /// <summary>
|
| | | /// 进图条能否往回走(默认可以)
|
| | | /// 进度条能否往回走(默认可以)
|
| | | /// </summary>
|
| | | public bool ProgressBarGoback = true;
|
| | | /// <summary>
|
| | |
| | | /// 模式区分
|
| | | /// </summary>
|
| | | private int m_ModeDiv = -1;
|
| | |
|
| | | /// <summary>
|
| | | /// 进度条是否可视
|
| | | /// </summary>
|
| | | public new bool Visible
|
| | | {
|
| | | get { return base.Visible; }
|
| | | set
|
| | | {
|
| | | if (this.frameProgressBack != null)
|
| | | {
|
| | | this.frameProgressBack.Visible = value;
|
| | | }
|
| | | base.Visible = value;
|
| | | }
|
| | | }
|
| | |
|
| | | #endregion
|
| | |
|
| | |
| | | /// <param name="value"></param>
|
| | | private void SetValueEx(decimal value)
|
| | | {
|
| | | if (btnProgressBar == null || this.m_ModeDiv != 1 || value > 1)
|
| | | if (btnProgressBar == null || this.m_ModeDiv != 1)
|
| | | {
|
| | | return;
|
| | | }
|
| | | if (value > 1) { value = 1; }
|
| | |
|
| | | HdlThreadLogic.Current.RunMain(() =>
|
| | | {
|
| | | int width = (int)(value * this.Width);
|
| | |
| | | public override void RemoveFromParent()
|
| | | {
|
| | | this.SelectTabEvent = null;
|
| | | if (this.Parent != null)
|
| | | {
|
| | | base.RemoveFromParent();
|
| | | }
|
| | | }
|
| | |
|
| | | base.RemoveFromParent();
|
| | | /// <summary>
|
| | | /// ☆☆移除全部控件☆☆
|
| | | /// </summary>
|
| | | public override void RemoveAll()
|
| | | {
|
| | | if (this.Parent != null)
|
| | | {
|
| | | base.RemoveAll();
|
| | | }
|
| | | }
|
| | |
|
| | | #endregion
|
| | |
| | | /// 添加左边图标
|
| | | /// </summary>
|
| | | /// <param name="i_Iconsize">图标大小</param>
|
| | | /// <param name="i_IconPath">图标地址</param>
|
| | | /// <returns></returns>
|
| | | public IconViewControl AddLeftIcon(int i_Iconsize = 81)
|
| | | public IconViewControl AddLeftIcon(int i_Iconsize = 81, string i_IconPath = null)
|
| | | {
|
| | | var btnIcon = new IconViewControl(i_Iconsize);
|
| | | btnIcon.X = ControlCommonResourse.XXLeft + LeftOffset;
|
| | | btnIcon.Gravity = Gravity.CenterVertical;
|
| | | if (i_IconPath != null)
|
| | | {
|
| | | btnIcon.UnSelectedImagePath = i_IconPath;
|
| | | }
|
| | | this.AddChidren(btnIcon, ChidrenBindMode.BindEvent);
|
| | | if (chidrenYaxis != 0)
|
| | | {
|
| | |
| | | this.InitFrameTable();
|
| | |
|
| | | //获取坐标底部最下面的那个控件的底部坐标
|
| | | int value = this.GetLocationMostLastViewBottom(this.m_frameTable);
|
| | | int value = this.GetLocationMostLastViewBottom(this.frameTable);
|
| | | if (value != -1)
|
| | | {
|
| | | view.Y = value + rowSpace;
|
| | | }
|
| | | this.m_frameTable.AddChidren(view);
|
| | | this.frameTable.AddChidren(view);
|
| | | //调整桌布高度
|
| | | if (this.m_frameTable.Height < view.Bottom)
|
| | | if (this.frameTable.Height < view.Bottom)
|
| | | {
|
| | | this.m_frameTable.Height = view.Bottom;
|
| | | this.frameTable.Height = view.Bottom;
|
| | | }
|
| | | }
|
| | |
|
| | |
| | | /// 调整子FrameLayout的真实高度
|
| | | /// </summary>
|
| | | /// <param name="frame"></param>
|
| | | public void AdjustChidrenFrameRealHeight(FrameLayout frame)
|
| | | /// <param name="minHeight">最小高度</param>
|
| | | public void AdjustChidrenFrameRealHeight(FrameLayout frame, int minHeight = -1)
|
| | | {
|
| | | //获取坐标底部最下面的那个控件的底部坐标
|
| | | int value = this.GetLocationMostLastViewBottom(frame);
|
| | | if (minHeight != -1 && value < minHeight)
|
| | | {
|
| | | //没有超过最小高度
|
| | | return;
|
| | | }
|
| | | if (value != -1)
|
| | | {
|
| | | //调整桌布高度
|
| | |
| | | }
|
| | |
|
| | | //获取坐标底部最下面的那个控件的底部坐标
|
| | | int value = this.GetLocationMostLastViewBottom(this.m_frameTable);
|
| | | int value = this.GetLocationMostLastViewBottom(this.frameTable);
|
| | | if (value != -1)
|
| | | {
|
| | | //调整桌布高度
|
| | | this.m_frameTable.Height = value;
|
| | | this.frameTable.Height = value;
|
| | | }
|
| | | else
|
| | | {
|
| | |
| | | this.AdjustTableHeight();
|
| | |
|
| | | var btnTemp = new BottomClickButton();
|
| | | if (btnTemp.Yaxis >= this.m_frameTable.Height + correctionsValue)
|
| | | if (btnTemp.Yaxis >= this.frameTable.Height + correctionsValue)
|
| | | {
|
| | | //没有超过
|
| | | return;
|
| | |
| | | //初始化桌布控件
|
| | | this.InitFrameTable();
|
| | |
|
| | | int value = this.GetLocationMostLastViewBottom(this.m_frameTable);
|
| | | int value = this.GetLocationMostLastViewBottom(this.frameTable);
|
| | | if (value != -1)
|
| | | {
|
| | | view.Y = value + rowSpace;
|
| | | }
|
| | | this.m_frameTable.AddChidren(view);
|
| | | this.frameTable.AddChidren(view);
|
| | | //调整桌布高度
|
| | | if (this.m_frameTable.Height < view.Bottom)
|
| | | if (this.frameTable.Height < view.Bottom)
|
| | | {
|
| | | this.m_frameTable.Height = view.Bottom;
|
| | | this.frameTable.Height = view.Bottom;
|
| | | }
|
| | | }
|
| | |
|
| | |
| | | this.InitFrameTable();
|
| | |
|
| | | //获取坐标底部最下面的那个控件的底部坐标
|
| | | int value = this.GetLocationMostLastViewBottom(this.m_frameTable);
|
| | | int value = this.GetLocationMostLastViewBottom(this.frameTable);
|
| | | if (value != -1)
|
| | | {
|
| | | view.Y = value;
|
| | | }
|
| | | this.m_frameTable.AddChidren(view);
|
| | | this.frameTable.AddChidren(view);
|
| | | if (rowSpace > 0)
|
| | | {
|
| | | view.Height += rowSpace;
|
| | | }
|
| | | //调整桌布高度
|
| | | if (this.m_frameTable.Height < view.Bottom)
|
| | | if (this.frameTable.Height < view.Bottom)
|
| | | {
|
| | | this.m_frameTable.Height = view.Bottom;
|
| | | this.frameTable.Height = view.Bottom;
|
| | | }
|
| | | }
|
| | |
|
| | |
| | | }
|
| | |
|
| | | //获取坐标底部最下面的那个控件的底部坐标
|
| | | int value = this.GetLocationMostLastViewBottom(this.m_frameTable);
|
| | | int value = this.GetLocationMostLastViewBottom(this.frameTable);
|
| | | if (value != -1)
|
| | | {
|
| | | //调整桌布高度
|
| | | this.m_frameTable.Height = value + buttomSpace;
|
| | | this.frameTable.Height = value + buttomSpace;
|
| | | }
|
| | | else
|
| | | {
|
| | |
| | | this.AdjustTableHeight();
|
| | |
|
| | | var btnTemp = new BottomClickButton();
|
| | | if (btnTemp.Yaxis >= this.m_frameTable.Height + correctionsValue)
|
| | | if (btnTemp.Yaxis >= this.frameTable.Height + correctionsValue)
|
| | | {
|
| | | //没有超过
|
| | | return;
|
| | |
| | | /// </summary>
|
| | | public Action CancelClickEvent = null;
|
| | | /// <summary>
|
| | | /// 点击背景是否关闭弹窗
|
| | | /// </summary>
|
| | | public bool CloseByClickBack = true;
|
| | | /// <summary>
|
| | | /// 信息类型
|
| | | /// </summary>
|
| | | private ShowMsgType msgType = ShowMsgType.Confirm;
|
| | |
| | | Common.CommonPage.Instance.AddChidren(frameMain);
|
| | | frameMain.MouseUpEventHandler += (sender, e) =>
|
| | | {
|
| | | //移除界面
|
| | | frameMain.RemoveFromParent();
|
| | | this.ConfirmClickEvent = null;
|
| | | if (this.CloseByClickBack == true)
|
| | | {
|
| | | //移除界面
|
| | | frameMain.RemoveFromParent();
|
| | | this.ConfirmClickEvent = null;
|
| | | }
|
| | | };
|
| | |
|
| | | //白色背景框
|
| | |
| | |
|
| | | var form = new BottomItemSelectForm();
|
| | | form.CancelCallEvent = true;//允许取消
|
| | | form.AddForm(title, listText, nowSelectNo - 1);
|
| | | form.AddForm(title, listText, null, nowSelectNo - 1);
|
| | | form.FinishSelectEvent += (selectNo) =>
|
| | | {
|
| | | if (selectNo == nowSelectNo - 1)
|
| | |
| | | namespace Shared.Phone.UserCenter
|
| | | {
|
| | | /// <summary>
|
| | | /// 底部弹窗项目选择界面(列表数尽可能别弄那么多)
|
| | | /// 底部弹窗项目选择界面
|
| | | /// </summary>
|
| | | public class BottomItemSelectForm : DialogCommonForm
|
| | | {
|
| | | #region ■ 变量声明___________________________
|
| | |
|
| | | /// <summary>
|
| | | /// 完成选择的事件(参数为选择的是列表的第几行,从0开始)
|
| | | /// <para>完成选择的事件(参数为选择的是列表的第几行,从0开始)</para>
|
| | | /// <para>当CancelCallEvent=true时,点击确认按钮时,参数为:-1</para>
|
| | | /// </summary>
|
| | | public Action<int> FinishSelectEvent = null;
|
| | | /// <summary>
|
| | |
| | | /// </summary>
|
| | | public bool CancelCallEvent = false;
|
| | | /// <summary>
|
| | | /// 选择的行能否取消
|
| | | /// 选择的行能否取消(默认可以取消)
|
| | | /// </summary>
|
| | | public bool SelectRowCanCancel = true;
|
| | |
|
| | |
| | | /// 画面显示(底层会固定调用此方法,借以完成画面创建)
|
| | | /// </summary>
|
| | | /// <param name="i_topText">头部标题</param>
|
| | | /// <param name="i_listText">需要显示的列表信息(列表数尽可能别弄那么多)</param> |
| | | /// <param name="i_listText">需要显示的列表信息</param> |
| | | /// <param name="i_listBottomText">需要显示的列表信息(底部),如果只是单行显示,则此值设置为null(如果不为null,但是索引所指向的值为null,则该行强制单行显示)</param>
|
| | | /// <param name="i_selectNo">设置哪个文本为默认选择(不设置填-1)</param> |
| | | public void ShowForm(string i_topText, List<string> i_listText, int i_selectNo) |
| | | public void ShowForm(string i_topText, List<string> i_listText, List<string> i_listBottomText, int i_selectNo) |
| | | { |
| | | //初始化中部信息 |
| | | this.InitMiddleFrame(i_topText, i_listText, i_selectNo); |
| | | this.InitMiddleFrame(i_topText, i_listText, i_listBottomText, i_selectNo); |
| | | } |
| | | |
| | | /// <summary> |
| | |
| | | /// </summary> |
| | | /// <param name="i_topText">头部标题</param> |
| | | /// <param name="i_listText">需要显示的列表信息</param> |
| | | /// <param name="i_listBottomtext">需要显示的列表信息(底部)</param>
|
| | | /// <param name="i_selectNo">默认选择</param> |
| | | private void InitMiddleFrame(string i_topText, List<string> i_listText, int i_selectNo) |
| | | private void InitMiddleFrame(string i_topText, List<string> i_listText, List<string> i_listBottomtext, int i_selectNo) |
| | | {
|
| | | //弧度的圆的一半的高度(固定)
|
| | | int halfRoundHeigth = Application.GetRealHeight(116) / 2; |
| | | //头部高度 |
| | | int topHeight = Application.GetRealHeight(195);
|
| | | //底部高度
|
| | | int bottomHeight = Application.GetRealHeight(57); |
| | | //明细高度 |
| | | int detailHeight = (ControlCommonResourse.ListViewRowHeight + Application.GetRealHeight(12)) * i_listText.Count;
|
| | | //不能够滑动的东西
|
| | | FrameListControl listDetailView1 = null; |
| | | //能够滑动的东西 |
| | | VerticalListControl listDetailView2 = null;
|
| | |
|
| | | //搞一个透明的框
|
| | | var frameTransparent = new FrameLayout();
|
| | | frameTransparent.Y = bodyFrameLayout.Height - topHeight - bottomHeight - detailHeight; |
| | | frameTransparent.Height = topHeight + bottomHeight + detailHeight + halfRoundHeigth * 2;//高度就是要它超过,随便搞的
|
| | | frameTransparent.BackgroundColor = UserCenterColor.Current.Transparent; |
| | | bodyFrameLayout.AddChidren(frameTransparent);
|
| | | //★★从下往上添加控件★★ |
| | |
|
| | | //明细列表的桌布,白色背景(它与实际高度小了半个弧度的圆)
|
| | | var detailBackFrame = new FrameLayout(); |
| | | detailBackFrame.Y = halfRoundHeigth; |
| | | detailBackFrame.Height = frameTransparent.Height;
|
| | | detailBackFrame.BackgroundColor = UserCenterColor.Current.White; |
| | | frameTransparent.AddChidren(detailBackFrame);
|
| | | //明细高度(初始最多只显示9行) |
| | | int detailHeight = ControlCommonResourse.ListViewRowHeight + Application.GetRealHeight(12);
|
| | | if (i_listText.Count > 9)
|
| | | {
|
| | | //63:上部间距 58:下部间距
|
| | | detailHeight = detailHeight * 9 + Application.GetRealHeight(63 + 58);
|
| | | listDetailView2 = new VerticalListControl(12);
|
| | | listDetailView2.Height = detailHeight;
|
| | | listDetailView2.Gravity = Gravity.BottomCenter;
|
| | | listDetailView2.BackgroundColor = UserCenterColor.Current.White; |
| | | bodyFrameLayout.AddChidren(listDetailView2);
|
| | | }
|
| | | else
|
| | | { |
| | | //63:上部间距 58:下部间距 |
| | | detailHeight = detailHeight * i_listText.Count + Application.GetRealHeight(63 + 58);
|
| | | listDetailView1 = new FrameListControl(12);
|
| | | listDetailView1.Height = detailHeight;
|
| | | listDetailView1.Gravity = Gravity.BottomCenter;
|
| | | listDetailView1.BackgroundColor = UserCenterColor.Current.White; |
| | | bodyFrameLayout.AddChidren(listDetailView1);
|
| | | }
|
| | | //线
|
| | | int lineYY = listDetailView1 != null ? listDetailView1.Y : listDetailView2.Y;
|
| | | var btnLine = new NormalViewControl(bodyFrameLayout.Width, ControlCommonResourse.BottomLineHeight, false);
|
| | | btnLine.Y = lineYY - ControlCommonResourse.BottomLineHeight;
|
| | | btnLine.BackgroundColor = UserCenterColor.Current.ButtomLine;
|
| | | bodyFrameLayout.AddChidren(btnLine);
|
| | |
|
| | | //弧度的圆
|
| | | var rowRound = new FrameLayout(); |
| | | rowRound.Width = bodyFrameLayout.Width; |
| | | rowRound.Height = halfRoundHeigth * 2; |
| | | rowRound.BackgroundColor = UserCenterColor.Current.White; |
| | | rowRound.Radius = (uint)halfRoundHeigth; |
| | | frameTransparent.AddChidren(rowRound); |
| | | //头部白色背景
|
| | | var topBackFame = new FrameLayout(); |
| | | topBackFame.Y = btnLine.Y - Application.GetRealHeight(138); |
| | | topBackFame.BackgroundColor = UserCenterColor.Current.White; |
| | | topBackFame.Height = Application.GetRealHeight(138); |
| | | topBackFame.SetCornerWithSameRadius(Application.GetRealHeight(58), HDLUtils.RectCornerTopLeft | HDLUtils.RectCornerTopRight);
|
| | | bodyFrameLayout.AddChidren(topBackFame); |
| | | |
| | | //头部信息
|
| | | var btnTitle = new NormalViewControl(detailBackFrame.Width, Application.GetRealHeight(63), false); |
| | | btnTitle.Y = Application.GetRealHeight(35); |
| | | var btnTitle = new NormalViewControl(topBackFame.Width, Application.GetRealHeight(65), false); |
| | | btnTitle.Y = Application.GetRealHeight(34); |
| | | btnTitle.Text = i_topText; |
| | | btnTitle.TextColor = UserCenterColor.Current.TextColor4; |
| | | btnTitle.TextSize = 16; |
| | | btnTitle.TextAlignment = TextAlignment.Center; |
| | | rowRound.AddChidren(btnTitle); |
| | | topBackFame.AddChidren(btnTitle); |
| | | |
| | | //取消 |
| | | var btnCancel = new NormalViewControl(200, 58, true); |
| | |
| | | btnCancel.Y = Application.GetRealHeight(40); |
| | | btnCancel.TextColor = UserCenterColor.Current.TextGrayColor1; |
| | | btnCancel.TextID = R.MyInternationalizationString.uCancel; |
| | | rowRound.AddChidren(btnCancel); |
| | | topBackFame.AddChidren(btnCancel); |
| | | btnCancel.ButtonClickEvent += (sender, e) =>
|
| | | {
|
| | | this.CloseForm();
|
| | |
| | | btnFinish.TextAlignment = TextAlignment.CenterRight; |
| | | btnFinish.TextColor = 0xfffb744a; |
| | | btnFinish.TextID = R.MyInternationalizationString.uFinish; |
| | | rowRound.AddChidren(btnFinish); |
| | | topBackFame.AddChidren(btnFinish); |
| | | btnFinish.ButtonClickEvent += (sender, e) =>
|
| | | {
|
| | | if (FinishSelectEvent != null && oldSelectContr != null)
|
| | |
| | | this.CloseForm();
|
| | | };
|
| | |
|
| | | //线
|
| | | var btnLine = new NormalViewControl(detailBackFrame.Width, ControlCommonResourse.BottomLineHeight, false);
|
| | | btnLine.Y = Application.GetRealHeight(138) - ControlCommonResourse.BottomLineHeight - halfRoundHeigth;
|
| | | btnLine.BackgroundColor = UserCenterColor.Current.ButtomLine; |
| | | detailBackFrame.AddChidren(btnLine); |
| | | //添加一个白色的间距
|
| | | var frameSpace = new FrameLayout();
|
| | | frameSpace.Height = Application.GetRealHeight(63);
|
| | | listDetailView1?.AddChidren(frameSpace); |
| | | listDetailView2?.AddChidren(frameSpace); |
| | | |
| | | //列表控件
|
| | | var listView = new FrameListControl(12); |
| | | listView.Height = detailHeight + bottomHeight; |
| | | listView.Y = topHeight - halfRoundHeigth; |
| | | detailBackFrame.AddChidren(listView); |
| | | //明细列表控件
|
| | | int rowSpace = listDetailView1 != null ? listDetailView1.rowSpace : listDetailView2.rowSpace; |
| | | for (int i = 0; i < i_listText.Count; i++)
|
| | | {
|
| | | var btnRow = new NormalSelectControl(i_listText[i], listView.rowSpace / 2);
|
| | | NormalSelectControl btnRow = null;
|
| | | if (i_listBottomtext == null || i_listBottomtext[i] == null)
|
| | | {
|
| | | //只显示一行
|
| | | btnRow = new NormalSelectControl(i_listText[i], rowSpace / 2);
|
| | | }
|
| | | else
|
| | | {
|
| | | //显示上下两行
|
| | | btnRow = new NormalSelectControl(i_listText[i], i_listBottomtext[i], rowSpace / 2);
|
| | | }
|
| | | btnRow.LeftOffset = Application.GetRealWidth(81) - ControlCommonResourse.XXLeft;//向右偏移
|
| | | btnRow.RightOffset = ControlCommonResourse.XXLeft - Application.GetRealWidth(81);//向左偏移
|
| | | listView.AddChidren(btnRow);
|
| | | listDetailView1?.AddChidren(btnRow);
|
| | | listDetailView2?.AddChidren(btnRow);
|
| | |
|
| | | btnRow.InitControl();
|
| | | btnRow.MainKeys = i.ToString();
|
| | | btnRow.ButtonClickEvent += (sender, e) =>
|
| | |
| | | btnRow.AddBottomLine();
|
| | | }
|
| | | } |
| | | |
| | | //如果是滑动控件,则添加底部间距
|
| | | if (listDetailView2 != null)
|
| | | {
|
| | | var frameSpace2 = new FrameLayout();
|
| | | frameSpace2.Height = Application.GetRealHeight(58);
|
| | | listDetailView2?.AddChidren(frameSpace2);
|
| | | }
|
| | | }
|
| | |
|
| | | #endregion
|
| | |
| | | this.listDoorLockAlarmInfo.Clear();
|
| | | string fileName = DateTime.Now.ToString("yyyyMMdd");
|
| | |
|
| | | //判断有没有这个文件
|
| | | string fullName = UserCenterLogic.CombinePath(DirNameResourse.LocalMemoryDirectory, DirNameResourse.SafeguardAlarmDirectory, fileName);
|
| | | if (System.IO.File.Exists(fullName) == true)
|
| | | //安防报警
|
| | | string fullName = System.IO.Path.Combine(DirNameResourse.SafeguardAlarmDirectory, fileName);
|
| | | var data1 = HdlFileLogic.Current.ReadFileByteContent(fullName);
|
| | | if (data1 != null) |
| | | {
|
| | | lock (listSafetyAlarmInfo)
|
| | | this.listSafetyAlarmInfo = JsonConvert.DeserializeObject<List<SafeguardAlarmInfo>>(System.Text.Encoding.UTF8.GetString(data1));
|
| | | if (this.listSafetyAlarmInfo == null)
|
| | | {
|
| | | string dir = System.IO.Path.Combine(DirNameResourse.LocalMemoryDirectory, DirNameResourse.SafeguardAlarmDirectory);
|
| | | var data = Global.ReadFileByDirectory(dir, fileName);
|
| | | this.listSafetyAlarmInfo = JsonConvert.DeserializeObject<List<SafeguardAlarmInfo>>(System.Text.Encoding.UTF8.GetString(data));
|
| | | if (this.listSafetyAlarmInfo == null)
|
| | | {
|
| | | this.listSafetyAlarmInfo = new List<SafeguardAlarmInfo>();
|
| | | }
|
| | | this.listSafetyAlarmInfo = new List<SafeguardAlarmInfo>();
|
| | | }
|
| | | }
|
| | |
|
| | | //门锁记录
|
| | | fullName = UserCenterLogic.CombinePath(DirNameResourse.LocalMemoryDirectory, DirNameResourse.DoorLockAlarmDirectory, fileName);
|
| | | if (System.IO.File.Exists(fullName) == true)
|
| | | fullName = System.IO.Path.Combine(DirNameResourse.DoorLockAlarmDirectory, fileName);
|
| | | var data2 = HdlFileLogic.Current.ReadFileByteContent(fullName);
|
| | | if (data2 != null) |
| | | {
|
| | | lock (listDoorLockAlarmInfo)
|
| | | this.listDoorLockAlarmInfo = JsonConvert.DeserializeObject<List<DeviceAlarmInfo>>(System.Text.Encoding.UTF8.GetString(data2));
|
| | | if (this.listDoorLockAlarmInfo == null)
|
| | | {
|
| | | string dir = System.IO.Path.Combine(DirNameResourse.LocalMemoryDirectory, DirNameResourse.DoorLockAlarmDirectory);
|
| | | var data = Global.ReadFileByDirectory(dir, fileName);
|
| | | this.listDoorLockAlarmInfo = JsonConvert.DeserializeObject<List<DeviceAlarmInfo>>(System.Text.Encoding.UTF8.GetString(data));
|
| | | if (this.listDoorLockAlarmInfo == null)
|
| | | {
|
| | | this.listDoorLockAlarmInfo = new List<DeviceAlarmInfo>();
|
| | | }
|
| | | this.listDoorLockAlarmInfo = new List<DeviceAlarmInfo>();
|
| | | }
|
| | | }
|
| | | }
|
| | |
| | | }
|
| | |
|
| | | //保存到本地
|
| | | var saveData = JsonConvert.SerializeObject(this.listSafetyAlarmInfo);
|
| | | var byteData = System.Text.Encoding.UTF8.GetBytes(saveData);
|
| | | string dir = System.IO.Path.Combine(DirNameResourse.LocalMemoryDirectory, DirNameResourse.SafeguardAlarmDirectory);
|
| | | Global.WriteFileToDirectoryByBytes(dir, fileName, byteData);
|
| | | string fullName = System.IO.Path.Combine(DirNameResourse.SafeguardAlarmDirectory, fileName);
|
| | | HdlFileLogic.Current.SaveFileContent(fullName, this.listSafetyAlarmInfo);
|
| | |
|
| | | if (UserCenterResourse.DicActionForm.ContainsKey("SafetyManagementMainForm") == true)
|
| | | {
|
| | |
| | | }
|
| | |
|
| | | //保存到本地
|
| | | var saveData = JsonConvert.SerializeObject(this.listSafetyAlarmInfo);
|
| | | var byteData = System.Text.Encoding.UTF8.GetBytes(saveData);
|
| | | string dir = System.IO.Path.Combine(DirNameResourse.LocalMemoryDirectory, DirNameResourse.SafeguardAlarmDirectory);
|
| | | Global.WriteFileToDirectoryByBytes(dir, fileName, byteData);
|
| | | string fullName = System.IO.Path.Combine(DirNameResourse.SafeguardAlarmDirectory, fileName);
|
| | | HdlFileLogic.Current.SaveFileContent(fullName, this.listSafetyAlarmInfo);
|
| | | }
|
| | | }
|
| | |
|
| | |
| | | {
|
| | | lock (listSafetyAlarmInfo)
|
| | | {
|
| | | string fullPath = UserCenterLogic.CombinePath(DirNameResourse.LocalMemoryDirectory, DirNameResourse.SafeguardAlarmDirectory);
|
| | | //借用一下自动备份获取指定目录下面的文件的函数
|
| | | List<string> listFile = HdlAutoBackupLogic.GetFileFromDirectory(fullPath);
|
| | | string fullPath = DirNameResourse.SafeguardAlarmDirectory;
|
| | | //获取指定目录下面的文件
|
| | | List<string> listFile = HdlFileLogic.Current.GetFileFromDirectory(fullPath);
|
| | | //升序
|
| | | listFile.Sort();
|
| | | var dic = new Dictionary<string, List<SafeguardAlarmInfo>>();
|
| | | string dir = System.IO.Path.Combine(DirNameResourse.LocalMemoryDirectory, DirNameResourse.SafeguardAlarmDirectory);
|
| | | for (int i = listFile.Count - 1; i >= 0; i--)
|
| | | {
|
| | | var data = Global.ReadFileByDirectory(dir, listFile[i]);
|
| | | var data = HdlFileLogic.Current.ReadFileByteContent(System.IO.Path.Combine(fullPath, listFile[i]));
|
| | | var info = JsonConvert.DeserializeObject<List<SafeguardAlarmInfo>>(System.Text.Encoding.UTF8.GetString(data));
|
| | | if (info == null)
|
| | | {
|
| | |
| | | }
|
| | |
|
| | | //保存到本地
|
| | | var saveData = JsonConvert.SerializeObject(this.listDoorLockAlarmInfo);
|
| | | var byteData = System.Text.Encoding.UTF8.GetBytes(saveData);
|
| | | string dir = System.IO.Path.Combine(DirNameResourse.LocalMemoryDirectory, DirNameResourse.DoorLockAlarmDirectory);
|
| | | Global.WriteFileToDirectoryByBytes(dir, fileName, byteData);
|
| | | string fullName = System.IO.Path.Combine(DirNameResourse.DoorLockAlarmDirectory, fileName);
|
| | | HdlFileLogic.Current.SaveFileContent(fullName, this.listDoorLockAlarmInfo);
|
| | | |
| | | return true;
|
| | | }
|
| | | }
|
| | |
| | | {
|
| | | lock (listDoorLockAlarmInfo)
|
| | | {
|
| | | string fullPath = UserCenterLogic.CombinePath(DirNameResourse.LocalMemoryDirectory, DirNameResourse.DoorLockAlarmDirectory);
|
| | | //借用一下自动备份获取指定目录下面的文件的函数
|
| | | List<string> listFile = HdlAutoBackupLogic.GetFileFromDirectory(fullPath);
|
| | | string fullPath = DirNameResourse.DoorLockAlarmDirectory;
|
| | | //获取指定目录下面的文件
|
| | | List<string> listFile = HdlFileLogic.Current.GetFileFromDirectory(fullPath);
|
| | | //升序
|
| | | listFile.Sort();
|
| | | var dic = new Dictionary<string, List<DeviceAlarmInfo>>();
|
| | | string dir = System.IO.Path.Combine(DirNameResourse.LocalMemoryDirectory, DirNameResourse.DoorLockAlarmDirectory);
|
| | | for (int i = listFile.Count - 1; i >= 0; i--)
|
| | | {
|
| | | var data = Global.ReadFileByDirectory(dir, listFile[i]);
|
| | | var data = HdlFileLogic.Current.ReadFileByteContent(System.IO.Path.Combine(fullPath, listFile[i]));
|
| | | var info = JsonConvert.DeserializeObject<List<DeviceAlarmInfo>>(System.Text.Encoding.UTF8.GetString(data));
|
| | | if (info == null)
|
| | | {
|
| | |
| | | //删除全部的自动备份的本地文件
|
| | | DeleteAllAutoBackupFile();
|
| | | //如果没有自动备份数据,则把本地全部东西上传
|
| | | var pathTemp = UserCenterLogic.CombinePath(DirNameResourse.LocalMemoryDirectory, DirNameResourse.AutoBackupDirectory);
|
| | | var pathTemp = DirNameResourse.AutoBackupDirectory;
|
| | | //复制本地所有文件过去
|
| | | List<string> listAllFile = Global.FileListByHomeId();
|
| | | foreach (string fileName in listAllFile)
|
| | | {
|
| | | string oldFile = UserCenterLogic.CombinePath(fileName);
|
| | | string oldFile = System.IO.Path.Combine(Config.Instance.FullPath, fileName);
|
| | | string newFile = System.IO.Path.Combine(pathTemp, fileName);
|
| | | //复制文件
|
| | | System.IO.File.Copy(oldFile, newFile, true);
|
| | | HdlFileLogic.Current.CopyFile(oldFile, newFile);
|
| | | }
|
| | | }
|
| | |
|
| | |
| | | private static bool UpLoadBackupFileToDB(List<string> listFile)
|
| | | {
|
| | | int listFileCount = listFile.Count;
|
| | | string backUpDir = System.IO.Path.Combine(DirNameResourse.LocalMemoryDirectory, DirNameResourse.AutoBackupDirectory);
|
| | | string backUpDir = DirNameResourse.AutoBackupDirectory;
|
| | | for (int i = 0; i < listFile.Count; i++)
|
| | | {
|
| | | string file = listFile[i];
|
| | | var datainfo = new FileInfoData();
|
| | | datainfo.BackupFileName = file;
|
| | | datainfo.BackupFileContent = ReadDirctoryFileByName(backUpDir, file);
|
| | | datainfo.BackupFileContent = HdlFileLogic.Current.ReadFileByteContent(System.IO.Path.Combine(backUpDir, file));
|
| | | if (datainfo.BackupFileContent == null)
|
| | | {
|
| | | continue;
|
| | |
| | | }
|
| | |
|
| | | //删除文件
|
| | | string strroot = Common.Config.Instance.FullPath;
|
| | | var backPath = System.IO.Path.Combine(strroot, DirNameResourse.LocalMemoryDirectory, DirNameResourse.AutoBackupdeleteDirectory);
|
| | | var backPath = DirNameResourse.AutoBackupdeleteDirectory;
|
| | | foreach (var file in listData)
|
| | | {
|
| | | string fullName = System.IO.Path.Combine(backPath, file);
|
| | | System.IO.File.Delete(fullName);
|
| | | HdlFileLogic.Current.DeleteFile(fullName);
|
| | | }
|
| | | return true;
|
| | | }
|
| | |
| | | }
|
| | |
|
| | | //删除文件
|
| | | string strroot = Common.Config.Instance.FullPath;
|
| | | var backPath = System.IO.Path.Combine(strroot, DirNameResourse.LocalMemoryDirectory, DirNameResourse.AutoBackupDirectory);
|
| | | var backPath = DirNameResourse.AutoBackupDirectory;
|
| | | foreach (var file in listData)
|
| | | {
|
| | | string fullName = System.IO.Path.Combine(backPath, file.BackupFileName);
|
| | | System.IO.File.Delete(fullName);
|
| | | HdlFileLogic.Current.DeleteFile(fullName);
|
| | | }
|
| | |
|
| | | return true;
|
| | |
| | |
|
| | | #region ■ 获取文件___________________________
|
| | |
|
| | | /// <summary> |
| | | /// 获取指定文件夹下面的文件内容 |
| | | /// </summary> |
| | | /// <param name="dirctory">指定文件夹的名字(不是全路径)</param> |
| | | /// <param name="fileName">File name.</param> |
| | | private static byte[] ReadDirctoryFileByName(string dirctory, string fileName) |
| | | { |
| | | var path = UserCenterLogic.CombinePath(dirctory, fileName); |
| | | if (System.IO.File.Exists(path) == false)
|
| | | {
|
| | | return null;
|
| | | } |
| | | return Shared.IO.FileUtils.ReadFile(path); |
| | | }
|
| | |
|
| | | /// <summary>
|
| | | /// 获取自动备份目录下的添加或者编辑的文件
|
| | | /// </summary>
|
| | | /// <returns></returns>
|
| | | public static List<string> GetAutoBackupEditorFile()
|
| | | {
|
| | | string strroot = Common.Config.Instance.FullPath; |
| | | var path = System.IO.Path.Combine(strroot, DirNameResourse.LocalMemoryDirectory, DirNameResourse.AutoBackupDirectory);
|
| | |
|
| | | return GetFileFromDirectory(path);
|
| | | return HdlFileLogic.Current.GetFileFromDirectory(DirNameResourse.AutoBackupDirectory);
|
| | | }
|
| | |
|
| | | /// <summary>
|
| | |
| | | /// <returns></returns>
|
| | | public static List<string> GetAutoBackupDeleteFile()
|
| | | {
|
| | | string strroot = Common.Config.Instance.FullPath; |
| | | var path = System.IO.Path.Combine(strroot, DirNameResourse.LocalMemoryDirectory, DirNameResourse.AutoBackupdeleteDirectory);
|
| | |
|
| | | return GetFileFromDirectory(path);
|
| | | }
|
| | |
|
| | | /// <summary>
|
| | | /// 获取指定文件夹里面的全部文件 |
| | | /// </summary>
|
| | | /// <param name="directory">文件路径(全名)</param>
|
| | | /// <returns></returns>
|
| | | public static List<string> GetFileFromDirectory(string directory) |
| | | { |
| | | if (System.IO.Directory.Exists(directory) == false)
|
| | | {
|
| | | return new List<string>();
|
| | | } |
| | | |
| | | List<string> list = new List<string>(); |
| | | var files = System.IO.Directory.GetFiles(directory); |
| | | foreach (var file in files) |
| | | { |
| | | var f = file.Substring(directory.Length + 1); |
| | | list.Add(f); |
| | | } |
| | | return list; |
| | | return HdlFileLogic.Current.GetFileFromDirectory(DirNameResourse.AutoBackupdeleteDirectory);
|
| | | }
|
| | |
|
| | | #endregion
|
| | |
| | | /// <param name="fileName">文件的名字,不含路径</param>
|
| | | public static void AddOrEditorFile(string fileName)
|
| | | {
|
| | | //根目录
|
| | | string strroot = Common.Config.Instance.FullPath;
|
| | | if (strroot == string.Empty)
|
| | | {
|
| | | return;
|
| | | }
|
| | | fileName = System.IO.Path.GetFileName(fileName);
|
| | | //自动备份目录
|
| | | string strBackPath = System.IO.Path.Combine(strroot, DirNameResourse.LocalMemoryDirectory, DirNameResourse.AutoBackupDirectory);
|
| | |
|
| | |
|
| | | //自动删除备份目录
|
| | | string strdelBackPath = System.IO.Path.Combine(strroot, DirNameResourse.LocalMemoryDirectory, DirNameResourse.AutoBackupdeleteDirectory);
|
| | | //如果删除列表里面有这个东西的话,移除掉
|
| | | string delFile = System.IO.Path.Combine(strdelBackPath, fileName);
|
| | | if (System.IO.File.Exists(delFile) == true)
|
| | | {
|
| | | System.IO.File.Delete(delFile);
|
| | | }
|
| | |
|
| | | string soureFile = System.IO.Path.Combine(strroot, fileName);
|
| | | string newFile = System.IO.Path.Combine(strBackPath, fileName);
|
| | | string strBackPath = DirNameResourse.AutoBackupDirectory;
|
| | | if (System.IO.Directory.Exists(strBackPath) == false)
|
| | | {
|
| | | //预创建个人中心全部的文件夹
|
| | | UserCenterLogic.CreatAllUserCenterDirectory();
|
| | | HdlFileLogic.Current.CreatAllUserCenterDirectory();
|
| | | }
|
| | |
|
| | | //自动删除备份目录
|
| | | string strdelBackPath = DirNameResourse.AutoBackupdeleteDirectory;
|
| | | //如果删除列表里面有这个东西的话,移除掉
|
| | | string delFile = System.IO.Path.Combine(strdelBackPath, fileName);
|
| | | HdlFileLogic.Current.DeleteFile(delFile);
|
| | |
|
| | | string soureFile = System.IO.Path.Combine(Common.Config.Instance.FullPath, fileName);
|
| | | string newFile = System.IO.Path.Combine(strBackPath, fileName);
|
| | |
|
| | | //原原本本的复制文件到指定文件夹
|
| | | CopyFile(soureFile, newFile);
|
| | | HdlFileLogic.Current.CopyFile(soureFile, newFile);
|
| | | }
|
| | |
|
| | | /// <summary>
|
| | |
| | | /// <param name="fileName">文件的名字,不含路径</param>
|
| | | public static void DeleteFile(string fileName)
|
| | | {
|
| | | //根目录
|
| | | string strroot = Common.Config.Instance.FullPath;
|
| | | if (strroot == string.Empty)
|
| | | {
|
| | | return;
|
| | | }
|
| | | fileName = System.IO.Path.GetFileName(fileName);
|
| | | //自动删除备份目录
|
| | | string strBackPath = System.IO.Path.Combine(strroot, DirNameResourse.LocalMemoryDirectory, DirNameResourse.AutoBackupdeleteDirectory);
|
| | |
|
| | | string strBackPath = DirNameResourse.AutoBackupdeleteDirectory;
|
| | | string newFile = System.IO.Path.Combine(strBackPath, fileName);
|
| | |
|
| | | //创建一个空文件
|
| | |
| | | file.Close();
|
| | |
|
| | | //自动备份目录
|
| | | strBackPath = System.IO.Path.Combine(strroot, DirNameResourse.LocalMemoryDirectory, DirNameResourse.AutoBackupDirectory);
|
| | | strBackPath = DirNameResourse.AutoBackupDirectory;
|
| | | //如果备份列表里面有这个东西的话,移除掉
|
| | | string delFile = System.IO.Path.Combine(strBackPath, fileName);
|
| | | if (System.IO.File.Exists(delFile) == true)
|
| | | {
|
| | | System.IO.File.Delete(delFile);
|
| | | }
|
| | |
|
| | | HdlFileLogic.Current.DeleteFile(delFile);
|
| | | }
|
| | |
|
| | | #endregion
|
| | |
| | | public static int SynchronizeDbAutoBackupData()
|
| | | {
|
| | | //判断是否能够同步数据
|
| | | string checkFile = UserCenterLogic.CombinePath(DirNameResourse.LocalMemoryDirectory, DirNameResourse.AutoDownLoadBackupCheckFile);
|
| | | string checkFile = DirNameResourse.AutoDownLoadBackupCheckFile;
|
| | | //如果本地已经拥有了这个文件,则说明不是新手机,不再自动还原
|
| | | if (System.IO.File.Exists(checkFile) == true)
|
| | | {
|
| | |
| | | return -1;
|
| | | }
|
| | | //如果读取到的文件完全没有问题,则清理本地的文件
|
| | | UserCenterLogic.DeleteAllLocationFile(false);
|
| | | HdlFileLogic.Current.DeleteAllLocationFile(false);
|
| | |
|
| | | //没有错误的话,则移动到当前住宅文件夹下面
|
| | | Global.MoveDirectoryFileToHomeDirectory(tempDir, true);
|
| | | HdlFileLogic.Current.MoveDirectoryFileToHomeDirectory(tempDir, true);
|
| | |
|
| | | //创建一个空文件(标识已经完成同步)
|
| | | var file2 = System.IO.File.Create(checkFile);
|
| | |
| | | #region ■ 一般方法___________________________
|
| | |
|
| | | /// <summary>
|
| | | /// 复制文件
|
| | | /// </summary>
|
| | | /// <param name="sourseFile">指定文件(全名)</param>
|
| | | /// <param name="newFile">新文件(全名)</param>
|
| | | private static void CopyFile(string sourseFile, string newFile)
|
| | | {
|
| | | try
|
| | | {
|
| | | if (System.IO.File.Exists(sourseFile) == false)
|
| | | {
|
| | | return;
|
| | | }
|
| | | System.IO.File.Copy(sourseFile, newFile, true);
|
| | | }
|
| | | catch { }
|
| | | }
|
| | |
|
| | | /// <summary>
|
| | | /// 删除全部的自动备份的本地文件(此函数用于读取自动备份的时候使用)
|
| | | /// </summary>
|
| | | public static void DeleteAllAutoBackupFile()
|
| | | {
|
| | | //清空自动备份【文件夹】(编辑,追加)
|
| | | string dirPath = UserCenterLogic.CombinePath(DirNameResourse.LocalMemoryDirectory, DirNameResourse.AutoBackupDirectory);
|
| | | System.IO.Directory.Delete(dirPath, true);
|
| | | System.IO.Directory.CreateDirectory(dirPath);
|
| | | string dirPath = DirNameResourse.AutoBackupDirectory;
|
| | | HdlFileLogic.Current.DeleteDirectory(dirPath);
|
| | | HdlFileLogic.Current.CreateDirectory(dirPath, true);
|
| | |
|
| | | //清空自动备份【文件夹】(删除)
|
| | | dirPath = UserCenterLogic.CombinePath(DirNameResourse.LocalMemoryDirectory, DirNameResourse.AutoBackupdeleteDirectory);
|
| | | System.IO.Directory.Delete(dirPath, true);
|
| | | System.IO.Directory.CreateDirectory(dirPath);
|
| | | dirPath = DirNameResourse.AutoBackupdeleteDirectory;
|
| | | HdlFileLogic.Current.DeleteDirectory(dirPath);
|
| | | HdlFileLogic.Current.CreateDirectory(dirPath, true);
|
| | | }
|
| | |
|
| | | #endregion
|
| | |
| | | public static void SaveBackupNotPrompted(bool notPrompted, int day = -1)
|
| | | {
|
| | | //文件全路径
|
| | | string fullName = UserCenterLogic.CombinePath(DirNameResourse.LocalMemoryDirectory, DirNameResourse.AutoBackupNotPromptedFile);
|
| | | string fullName = DirNameResourse.AutoBackupNotPromptedFile;
|
| | | BackupNotPrompted info = null;
|
| | | if (System.IO.File.Exists(fullName) == true)
|
| | | {
|
| | | var data = Global.ReadFileByDirectory(DirNameResourse.LocalMemoryDirectory, DirNameResourse.AutoBackupNotPromptedFile);
|
| | | var data = HdlFileLogic.Current.ReadFileByteContent(fullName);
|
| | | info = JsonConvert.DeserializeObject<BackupNotPrompted>(System.Text.Encoding.UTF8.GetString(data));
|
| | | }
|
| | | if (info == null)
|
| | |
| | | info.Day = day;
|
| | | }
|
| | | //保存
|
| | | var saveData = JsonConvert.SerializeObject(info);
|
| | | var byteData = System.Text.Encoding.UTF8.GetBytes(saveData);
|
| | | Global.WriteFileToDirectoryByBytes(DirNameResourse.LocalMemoryDirectory, DirNameResourse.AutoBackupNotPromptedFile, byteData);
|
| | | HdlFileLogic.Current.SaveFileContent(fullName, info);
|
| | | }
|
| | |
|
| | | /// <summary>
|
| | |
| | | //暂不支持成员
|
| | | return;
|
| | | }
|
| | | string strroot = Common.Config.Instance.FullPath; |
| | | var path = System.IO.Path.Combine(strroot, DirNameResourse.LocalMemoryDirectory, DirNameResourse.AutoBackupDirectory);
|
| | |
|
| | | List<string> listFile1 = GetFileFromDirectory(path);
|
| | | List<string> listFile1 = HdlFileLogic.Current.GetFileFromDirectory(DirNameResourse.AutoBackupDirectory);
|
| | | List<string> listFile2 = GetAutoBackupDeleteFile();
|
| | |
|
| | | if (listFile1.Count == 0 && listFile2.Count == 0)
|
| | |
| | | }
|
| | |
|
| | | //文件全路径
|
| | | string fullName = UserCenterLogic.CombinePath(DirNameResourse.LocalMemoryDirectory, DirNameResourse.AutoBackupNotPromptedFile);
|
| | | string fullName = DirNameResourse.AutoBackupNotPromptedFile;
|
| | | if (System.IO.File.Exists(fullName) == false)
|
| | | {
|
| | | HdlThreadLogic.Current.RunMain(() =>
|
| | |
| | | return;
|
| | | }
|
| | | BackupNotPrompted info = null;
|
| | | var data = Global.ReadFileByDirectory(DirNameResourse.LocalMemoryDirectory, DirNameResourse.AutoBackupNotPromptedFile);
|
| | | var data = HdlFileLogic.Current.ReadFileByteContent(fullName);
|
| | | info = JsonConvert.DeserializeObject<BackupNotPrompted>(System.Text.Encoding.UTF8.GetString(data));
|
| | | if (info.NotPrompted == true)
|
| | | {
|
| | |
| | | UserCenterResourse.AccountOption.AppCanSignout = false;
|
| | |
|
| | | //首先先创建一个临时文件夹,存在文件则清空
|
| | | string newDir = System.IO.Path.Combine(DirNameResourse.LocalMemoryDirectory, DirNameResourse.DownLoadBackupTempDirectory);
|
| | | Global.CreateEmptyDirectory(newDir, true);
|
| | | string newDir = DirNameResourse.DownLoadBackupTempDirectory;
|
| | | HdlFileLogic.Current.CreateDirectory(newDir, true);
|
| | |
|
| | | //获取这个备份下面有多少个文件
|
| | | List<string> listFile = GetBackFileIDFromDB(BackupClassId, IsGatewayAutoBackup, ZigbeeUniqueId);
|
| | |
| | | return null;
|
| | | }
|
| | | //将输入写入本地的临时文件夹
|
| | | Global.WriteFileToDirectoryByBytes(newDir, fileName, result);
|
| | | HdlFileLogic.Current.SaveTextToFile(System.IO.Path.Combine(newDir, fileName), System.Text.Encoding.UTF8.GetString(result));
|
| | | //设置进度值
|
| | | ProgressFormBar.Current.SetValue(i + 1, listFileCount);
|
| | | }
|
| | |
| | | {
|
| | | //获取本地文件
|
| | | listAllFile = Global.FileListByHomeId();
|
| | | fullDir = UserCenterLogic.CombinePath();
|
| | | fullDir = Common.Config.Instance.FullPath;
|
| | | }
|
| | | else
|
| | | {
|
| | | listAllFile = HdlAutoBackupLogic.GetFileFromDirectory(upPath);
|
| | | listAllFile = HdlFileLogic.Current.GetFileFromDirectory(upPath);
|
| | | fullDir = upPath;
|
| | | }
|
| | | if (listAllFile.Count == 0)
|
| | |
| | |
|
| | | foreach (string fileName in listAllFile)
|
| | | {
|
| | | if (fileName.EndsWith(".png") == true)
|
| | | if (fileName.EndsWith(".png") == true
|
| | | || fileName.EndsWith(".bin") == true)
|
| | | {
|
| | | //图片文件
|
| | | listPicFile.Add(fileName);
|
| | |
| | | var datainfo = new FileInfoData();
|
| | | datainfo.BackupFileName = file;
|
| | | string fullFileName = System.IO.Path.Combine(fullDir, file);
|
| | | datainfo.BackupFileContent = Shared.IO.FileUtils.ReadFile(fullFileName);
|
| | | datainfo.BackupFileContent = HdlFileLogic.Current.ReadFileByteContent(fullFileName);
|
| | |
|
| | | var list = new List<FileInfoData>();
|
| | | list.Add(datainfo);
|
| | |
| | | /// <returns></returns>
|
| | | public bool UpLoadLogBackup()
|
| | | {
|
| | | string upPath = UserCenterLogic.CombinePath(DirNameResourse.LocalMemoryDirectory, DirNameResourse.LogDirectory);
|
| | | if (HdlAutoBackupLogic.GetFileFromDirectory(upPath).Count == 0)
|
| | | string upPath = DirNameResourse.LogDirectory;
|
| | | if (HdlFileLogic.Current.GetFileFromDirectory(upPath).Count == 0)
|
| | | {
|
| | | //没有Log文件
|
| | | return true;
|
| | |
| | | {
|
| | | try
|
| | | {
|
| | | var listAllFile = HdlAutoBackupLogic.GetFileFromDirectory(upPath);
|
| | | var listAllFile = HdlFileLogic.Current.GetFileFromDirectory(upPath);
|
| | | if (listAllFile.Count > 10)
|
| | | {
|
| | | listAllFile.Sort();
|
| | |
| | | });
|
| | |
|
| | | return result;
|
| | | }
|
| | |
|
| | | /// <summary>
|
| | | /// 上传东西到隐匿功能备份
|
| | | /// </summary>
|
| | | /// <param name="fileName"></param>
|
| | | /// <param name="byteData"></param>
|
| | | /// <returns></returns>
|
| | | public bool UpLoadByteDataToOptionBackup(string fileName, byte[] byteData)
|
| | | {
|
| | | ProgressFormBar.Current.Start();
|
| | | ProgressFormBar.Current.SetMsg("正在上传文件");
|
| | |
|
| | | //从云端获取数据
|
| | | var pageData = HdlBackupLogic.Current.GetBackupListNameFromDB(0, null, true);
|
| | | if (pageData == null)
|
| | | {
|
| | | ProgressFormBar.Current.Close();
|
| | | HdlThreadLogic.Current.RunMain(() =>
|
| | | {
|
| | | var contr = new ShowMsgControl(ShowMsgType.Tip, "获取功能备份失败");
|
| | | contr.Show();
|
| | | });
|
| | | return false;
|
| | | }
|
| | | string backId = string.Empty;
|
| | | for (int i = 0; i < pageData.Count; i++)
|
| | | {
|
| | | if (pageData[i].BackupName == DirNameResourse.OptionBackupName)
|
| | | {
|
| | | //获取功能备份的ID
|
| | | backId = pageData[i].Id;
|
| | | break;
|
| | | }
|
| | | }
|
| | | if (backId == string.Empty)
|
| | | {
|
| | | //创建新的备份
|
| | | backId = this.CreatNewBackupNameToDB(DirNameResourse.OptionBackupName);
|
| | | if (backId == null)
|
| | | {
|
| | | ProgressFormBar.Current.Close();
|
| | | HdlThreadLogic.Current.RunMain(() =>
|
| | | {
|
| | | var contr = new ShowMsgControl(ShowMsgType.Tip, "创建功能备份失败");
|
| | | contr.Show();
|
| | | });
|
| | | return false;
|
| | | }
|
| | | }
|
| | | //上传Log文件
|
| | | var datainfo = new FileInfoData();
|
| | | datainfo.BackupFileName = fileName;
|
| | | datainfo.BackupFileContent = byteData;
|
| | |
|
| | | var list = new List<FileInfoData>();
|
| | | list.Add(datainfo);
|
| | |
|
| | | //执行上传
|
| | | bool falge = DoUpLoadInfoToDB(backId, list, 0);
|
| | | //关闭进度条
|
| | | ProgressFormBar.Current.Close();
|
| | |
|
| | | if (falge == false)
|
| | | {
|
| | | HdlThreadLogic.Current.RunMain(() =>
|
| | | {
|
| | | var contr = new ShowMsgControl(ShowMsgType.Tip, "文件上传成功");
|
| | | contr.Show();
|
| | | });
|
| | | return false;
|
| | | }
|
| | | HdlThreadLogic.Current.RunMain(() =>
|
| | | {
|
| | | var contr = new ShowMsgControl(ShowMsgType.Tip, "文件上传成功");
|
| | | contr.Show();
|
| | | });
|
| | |
|
| | | return true;
|
| | | }
|
| | |
|
| | | #endregion
|
| | |
| | | ProgressFormBar.Current.Close();
|
| | |
|
| | | //如果读取到的文件完全没有问题,则清理本地的文件
|
| | | UserCenterLogic.DeleteAllLocationFile(false);
|
| | | HdlFileLogic.Current.DeleteAllLocationFile(false);
|
| | |
|
| | | //没有错误的话,则移动到当前住宅文件夹下面
|
| | | Global.MoveDirectoryFileToHomeDirectory(tempDirectory, true);
|
| | | HdlFileLogic.Current.MoveDirectoryFileToHomeDirectory(tempDirectory, true);
|
| | |
|
| | | //删除全部的自动备份的本地文件(此函数用于读取自动备份的时候使用)
|
| | | HdlAutoBackupLogic.DeleteAllAutoBackupFile();
|
| | |
| | |
|
| | | #endregion
|
| | |
|
| | | #region ■ 子控件的Y轴坐标____________________
|
| | |
|
| | | /// <summary>
|
| | | /// 指定位置类型获取Rowlayout的子控件的Y轴坐标(请确保子控件不大于父容器)
|
| | | /// </summary>
|
| | | /// <param name="fatherCtrHeight">父控件的真实高度</param>
|
| | | /// <param name="ctrHeight">子控件的真实高度</param>
|
| | | /// <param name="alignment">位置对齐方式</param>
|
| | | /// <param name="Space">上下间的空白间距,省略时,取行控件共通变量的值。设置为-1时,不计算空白间距</param>
|
| | | /// <returns></returns>
|
| | | public int GetControlChidrenYaxis(int fatherCtrHeight, int ctrHeight, UViewAlignment alignment, int Space = 0)
|
| | | {
|
| | | if (Space < 0)
|
| | | {
|
| | | //不计算间距值
|
| | | Space = 0;
|
| | | }
|
| | |
|
| | | if (alignment == UViewAlignment.Center)
|
| | | {
|
| | | return fatherCtrHeight / 2 - ctrHeight / 2;
|
| | | }
|
| | | else if (alignment == UViewAlignment.Top)
|
| | | {
|
| | | return (fatherCtrHeight / 2 - Space / 2) / 2 - ctrHeight / 2;
|
| | | }
|
| | | else
|
| | | {
|
| | | int top = fatherCtrHeight / 2 + Space / 2;
|
| | | return top + (fatherCtrHeight - top) / 2 - ctrHeight / 2;
|
| | | }
|
| | | }
|
| | |
|
| | | #endregion
|
| | |
|
| | | #region ■ 计算图片真实大小___________________
|
| | |
|
| | | /// <summary>
|
| | |
| | | }
|
| | |
|
| | | #endregion
|
| | |
|
| | | #region ■ 显示底部弹窗的房间列表_____________
|
| | |
|
| | | /// <summary>
|
| | | /// 显示底部弹窗的房间列表(当还没有房间时,会返回false)
|
| | | /// </summary>
|
| | | /// <param name="RoomKey">默认选择的房间主键</param>
|
| | | /// <param name="titleText">标题信息</param>
|
| | | /// <param name="SelectRoomEvent">确认选择房间的回调函数(房间ID,房间名(会拼上楼层))</param>
|
| | | public bool ShowBottomListRoomView(string RoomKey, string titleText, Action<string, string> SelectRoomEvent)
|
| | | {
|
| | | //楼层列表名字
|
| | | var listFloorName = new List<string>();
|
| | | //楼层列表主键
|
| | | var listFloorKeys = new List<string>();
|
| | | //房间名字
|
| | | var listRoomName = new List<List<string>>();
|
| | | //房间主键
|
| | | var listRoomKeys = new List<List<string>>();
|
| | |
|
| | | //初始化房间列表数据
|
| | | bool result = this.InitRoomListData(ref listFloorName, ref listFloorKeys, ref listRoomName, ref listRoomKeys);
|
| | | if (result == false)
|
| | | {
|
| | | return false;
|
| | | }
|
| | |
|
| | | var room = HdlRoomLogic.Current.GetRoomById(RoomKey);
|
| | | int index1 = room != null ? listFloorKeys.IndexOf(room.FloorId) : 0;
|
| | | if (index1 == -1) { index1 = 0; }
|
| | | int index2 = listRoomKeys[index1].IndexOf(RoomKey);
|
| | | if (index2 == -1) { index2 = 0; }
|
| | |
|
| | | if (listFloorKeys.Count == 0)
|
| | | {
|
| | | //无楼层模式
|
| | | PickerView.Show(listRoomName[0], (value) =>
|
| | | {
|
| | | RoomKey = listRoomKeys[0][value];
|
| | | string roomName = string.Empty;
|
| | | if (RoomKey != string.Empty)
|
| | | {
|
| | | //房间
|
| | | roomName = listRoomName[0][value];
|
| | | }
|
| | | else
|
| | | {
|
| | | roomName = Language.StringByID(R.MyInternationalizationString.uDeviceNotAssignedRoom);
|
| | | }
|
| | | SelectRoomEvent?.Invoke(RoomKey, roomName);
|
| | |
|
| | | }, index2, titleText,
|
| | | Language.StringByID(R.MyInternationalizationString.uFinish),
|
| | | Language.StringByID(R.MyInternationalizationString.uCancel));
|
| | | }
|
| | | else
|
| | | {
|
| | | //有楼层模式
|
| | | PickerView.ShowSecondary(listFloorName, listRoomName, (value1, value2) =>
|
| | | {
|
| | | RoomKey = listRoomKeys[value1][value2];
|
| | | string roomName = string.Empty;
|
| | | if (RoomKey != string.Empty)
|
| | | {
|
| | | //楼层+房间
|
| | | roomName = listFloorName[value1] + " " + listRoomName[value1][value2];
|
| | | }
|
| | | else
|
| | | {
|
| | | roomName = Language.StringByID(R.MyInternationalizationString.uDeviceNotAssignedRoom);
|
| | | }
|
| | | SelectRoomEvent?.Invoke(RoomKey, roomName);
|
| | |
|
| | | }, index1, index2, titleText,
|
| | | Language.StringByID(R.MyInternationalizationString.uFinish),
|
| | | Language.StringByID(R.MyInternationalizationString.uCancel));
|
| | | }
|
| | | return true;
|
| | | }
|
| | |
|
| | | /// <summary>
|
| | | /// 初始化房间列表数据
|
| | | /// </summary>
|
| | | /// <param name="listFloorName">楼层列表名字</param>
|
| | | /// <param name="listFloorKeys">楼层列表主键</param>
|
| | | /// <param name="listRoomName">房间名字</param>
|
| | | /// <param name="listRoomKeys">房间主键</param>
|
| | | private bool InitRoomListData(ref List<string> listFloorName, ref List<string> listFloorKeys, ref List<List<string>> listRoomName, ref List<List<string>> listRoomKeys)
|
| | | {
|
| | | var dicFloor = HdlRoomLogic.Current.GetFloorSortList();
|
| | | if (dicFloor.Count == 0)
|
| | | {
|
| | | //第一位默认添加未分配
|
| | | var listKeys = new List<string>() { "" };
|
| | | var listName = new List<string>() { Language.StringByID(R.MyInternationalizationString.uUndistributed) };
|
| | | //房间名字和主键收集
|
| | | var listRoom = HdlRoomLogic.Current.GetFloorSortRoom(string.Empty, false);
|
| | | foreach (var myRoom in listRoom)
|
| | | {
|
| | | listName.Add(myRoom.Name);
|
| | | listKeys.Add(myRoom.Id);
|
| | | }
|
| | | listRoomName.Add(listName);
|
| | | listRoomKeys.Add(listKeys);
|
| | | }
|
| | | else
|
| | | {
|
| | | //第一位默认添加未分配(未分配放在楼层那个菜单)
|
| | | var listKeys = new List<string>() { "" };
|
| | | var listName = new List<string>() { "" };
|
| | | listRoomName.Add(listName);
|
| | | listRoomKeys.Add(listKeys);
|
| | | listFloorKeys.Add("");
|
| | | listFloorName.Add(Language.StringByID(R.MyInternationalizationString.uUndistributed));
|
| | |
|
| | | foreach (string fKeys in dicFloor.Keys)
|
| | | {
|
| | | var listRoom = HdlRoomLogic.Current.GetFloorSortRoom(fKeys, false);
|
| | | if (listRoom.Count > 0)
|
| | | {
|
| | | //楼层名字和主键收集
|
| | | listFloorKeys.Add(fKeys);
|
| | | listFloorName.Add(dicFloor[fKeys]);
|
| | | //房间名字和主键收集
|
| | | listName = new List<string>();
|
| | | listKeys = new List<string>();
|
| | | foreach (var myRoom in listRoom)
|
| | | {
|
| | | listName.Add(myRoom.Name);
|
| | | listKeys.Add(myRoom.Id);
|
| | | }
|
| | | listRoomName.Add(listName);
|
| | | listRoomKeys.Add(listKeys);
|
| | | }
|
| | | }
|
| | | }
|
| | | //没有建立房间
|
| | | if (listFloorKeys.Count == 0 && listRoomKeys.Count == 0)
|
| | | {
|
| | | return false;
|
| | | }
|
| | | return true;
|
| | | }
|
| | |
|
| | | #endregion
|
| | | }
|
| | | }
|
| | |
| | | ///读取IRACC模块固件版本
|
| | | /// <para>reserve:0-ff</para>
|
| | | /// </summary>
|
| | | public async void UpgradeAsync(CommonDevice device, SendUpgradeData upgradeData)
|
| | | public void UpgradeAsync(CommonDevice device, SendUpgradeData upgradeData)
|
| | | {
|
| | | var Gateway = device.Gateway;
|
| | | if (Gateway == null)
|
| | |
| | | ///读取IRACC模块固件版本
|
| | | /// <para>status:0--成功;1--失败;ff--无效 .</para>
|
| | | /// </summary>
|
| | | public async void SendFinishAsync(CommonDevice device, int status)
|
| | | public void SendFinishAsync(CommonDevice device, int status)
|
| | | {
|
| | | var Gateway = device.Gateway;
|
| | | if (Gateway == null)
|
| | |
| | | /// </summary>
|
| | | /// <param name="panel">干接点对象</param>
|
| | | /// <returns></returns>
|
| | | public async Task<List<CommonDevice.AttributeDataObj>> GetDryContactConfigureInfo(CommonDevice device)
|
| | | public List<CommonDevice.AttributeDataObj> GetDryContactConfigureInfo(CommonDevice device)
|
| | | {
|
| | | //借用它的函数
|
| | | var panel = new Panel();
|
| | | panel.DeviceAddr = device.DeviceAddr;
|
| | | panel.DeviceEpoint = device.DeviceEpoint;
|
| | | panel.CurrentGateWayId = device.CurrentGateWayId;
|
| | |
|
| | | var result = HdlDeviceBindLogic.Current.ReadPanelConfigureInfoAsync(panel);
|
| | | panel = null;
|
| | | var result = HdlDeviceBindLogic.Current.ReadPanelConfigureInfoAsync(device);
|
| | |
|
| | | //共通错误检测
|
| | | string error = HdlCheckLogic.Current.CheckCommonErrorCode(result);
|
| | |
| | | /// </summary>
|
| | | private void SaveDryContactFunctionToLocaltion()
|
| | | {
|
| | | var file = Newtonsoft.Json.JsonConvert.SerializeObject(dicDryContactFunction);
|
| | |
|
| | | var bytes = System.Text.Encoding.UTF8.GetBytes(file);
|
| | | Common.Global.WriteFileByBytesByHomeId(DirNameResourse.DryContactFunctionFile, bytes);
|
| | | HdlFileLogic.Current.SaveFileContent(DirNameResourse.DryContactFunctionFile, dicDryContactFunction);
|
| | | }
|
| | |
|
| | | /// <summary>
|
| | |
| | | /// </summary>
|
| | | private void LoadDryContactFunctionFromLocaltion()
|
| | | {
|
| | | if (Common.Global.IsExistsByHomeId(DirNameResourse.DryContactFunctionFile) == false)
|
| | | this.dicDryContactFunction = new Dictionary<string, DryContactFunctionInfo>();
|
| | |
|
| | | byte[] filebyte = HdlFileLogic.Current.ReadFileByteContent(DirNameResourse.DryContactFunctionFile);
|
| | | if (filebyte == null)
|
| | | {
|
| | | return;
|
| | | }
|
| | |
|
| | | byte[] filebyte = Common.Global.ReadFileByHomeId(DirNameResourse.DryContactFunctionFile);
|
| | | string strvalue = System.Text.Encoding.UTF8.GetString(filebyte);
|
| | | this.dicDryContactFunction = Newtonsoft.Json.JsonConvert.DeserializeObject<Dictionary<string, DryContactFunctionInfo>>(strvalue);
|
| | | }
|
| | |
| | | Config.Instance.Home = HdlResidenceLogic.Current.GetHouseByHouseId(house.Id);
|
| | |
|
| | | //预创建个人中心全部的文件夹
|
| | | UserCenterLogic.CreatAllUserCenterDirectory();
|
| | | HdlFileLogic.Current.CreatAllUserCenterDirectory();
|
| | | }
|
| | |
|
| | | #endregion
|
| | |
| | | }
|
| | | #endregion
|
| | |
|
| | | #region ■ 预创建个人中心全部的文件夹_________
|
| | |
|
| | | /// <summary>
|
| | | /// 预创建个人中心全部的文件夹
|
| | | /// </summary>
|
| | | public void CreatAllUserCenterDirectory()
|
| | | {
|
| | | //本地缓存的根目录
|
| | | this.CreateDirectory(DirNameResourse.LocalMemoryDirectory);
|
| | |
|
| | | //自动备份【文件夹】(编辑,追加)
|
| | | this.CreateDirectory(DirNameResourse.AutoBackupDirectory);
|
| | |
|
| | | //自动备份【文件夹】(删除)
|
| | | this.CreateDirectory(DirNameResourse.AutoBackupdeleteDirectory);
|
| | |
|
| | | //下载备份的时候所使用的临时【文件夹】
|
| | | this.CreateDirectory(DirNameResourse.DownLoadBackupTempDirectory);
|
| | |
|
| | | //保存安防记录的【文件夹】
|
| | | this.CreateDirectory(DirNameResourse.SafeguardAlarmDirectory);
|
| | |
|
| | | //下载分享文件的临时【文件夹】
|
| | | this.CreateDirectory(DirNameResourse.DownLoadShardDirectory);
|
| | |
|
| | | //LOG出力【文件夹】
|
| | | this.CreateDirectory(DirNameResourse.LogDirectory);
|
| | |
|
| | | //用户图片目录路径【文件夹】
|
| | | if (UserCenterResourse.AccountOption.UserPictruePath != string.Empty)
|
| | | {
|
| | | this.CreateDirectory(UserCenterResourse.AccountOption.UserPictruePath);
|
| | | }
|
| | | }
|
| | |
|
| | | #endregion
|
| | |
|
| | | #region ■ 文件保存和读取_____________________
|
| | |
|
| | | /// <summary>
|
| | |
| | | /// <returns></returns> |
| | | private static int GetFirmwareVersionAndSetToMemmory(FirmwareLevelType levelType, GetFirmwareVersionPra pra)
|
| | | {
|
| | | string resultValue = UserCenterLogic.GetResponseDataByRequestHttps("FirmwareMana/DetectionPlatformUploadFirmware", false, pra);
|
| | | var listCheck = new List<string> { "NotCheck" };
|
| | | string resultValue = UserCenterLogic.GetResponseDataByRequestHttps("FirmwareMana/DetectionPlatformUploadFirmware", false, pra, listCheck);
|
| | | if (string.IsNullOrEmpty(resultValue) == true)
|
| | | {
|
| | | return -1;
|
| | |
| | | GatewayResourse.AppOldSelectGatewayId = string.Empty;
|
| | |
|
| | | //从文件中获取上一次选择的网关id
|
| | | byte[] data = Global.ReadFileByDirectory(DirNameResourse.LocalMemoryDirectory, DirNameResourse.AppOldSelectGatewayFile);
|
| | | byte[] data = HdlFileLogic.Current.ReadFileByteContent(DirNameResourse.AppOldSelectGatewayFile);
|
| | | if (data != null)
|
| | | {
|
| | | string strvalue = System.Text.Encoding.UTF8.GetString(data);
|
| | |
| | | }
|
| | |
|
| | | List<string> listBackupGwId = new List<string>();
|
| | | var fileData = Global.ReadFileByDirectory(DirNameResourse.LocalMemoryDirectory, DirNameResourse.BackupGatewayIdFile);
|
| | | var fileData = HdlFileLogic.Current.ReadFileByteContent(DirNameResourse.BackupGatewayIdFile);
|
| | | if (fileData != null)
|
| | | {
|
| | | //新增:虽然概率低,但是确实发生了。如果有网络时,App重新绑定记录的网关失败的话
|
| | |
| | | //删除网关文件
|
| | | this.DeleteGatewayFile(gatewayId);
|
| | | }
|
| | | //LOG输出
|
| | | if (listDelete.Count > 0)
|
| | | //如果网关都没了的话,把场景全部删了
|
| | | if (listDelete.Count > 0 && this.GetAllLocalGateway().Count == 0)
|
| | | {
|
| | | string msg = "本地拥有的网关:";
|
| | | foreach (var gatewayId in this.dicGateway.Keys)
|
| | | {
|
| | | msg += gatewayId + ",";
|
| | | }
|
| | | msg += "\r\n被删除的网关:";
|
| | | foreach (var gatewayId in listDelete)
|
| | | {
|
| | | msg += gatewayId + ",";
|
| | | }
|
| | | msg += "\r\n此时云端返回当前账号所绑定有的网关:";
|
| | | foreach (var gatewayId in result.Keys)
|
| | | {
|
| | | msg += gatewayId + ",";
|
| | | }
|
| | | var bytes = System.Text.Encoding.UTF8.GetBytes(msg);
|
| | | Common.Global.WriteFileByBytesByHomeId("GatewayDeleteLog.txt", bytes);
|
| | | HdlSceneLogic.Current.DeleteAllLocalScene();
|
| | | }
|
| | | } |
| | | |
| | |
| | | //获取控制主人账号的Token
|
| | | bindGateway.LoginAccessToken = UserCenterLogic.GetConnectMainToken(); |
| | | |
| | | var result = UserCenterLogic.GetResultCodeByRequestHttps("App/BindGatewayToHome", true, bindGateway); |
| | | var result = UserCenterLogic.GetResultCodeByRequestHttps("App/BindGatewayToHome", true, bindGateway, new List<string> { "NotCheck" }); |
| | | if (result == "Error")
|
| | | {
|
| | | return -1;
|
| | |
| | | /// </summary> |
| | | /// <param name="zbGateway">网关对象</param> |
| | | /// <param name="gatewayName">网关名</param> |
| | | public async Task<bool> ReName(ZbGateway zbGateway, string gatewayName) |
| | | public bool ReName(ZbGateway zbGateway, string gatewayName) |
| | | {
|
| | | ZbGateway realWay = null;
|
| | | if (this.GetRealGateway(ref realWay, zbGateway) == false)
|
| | | //只取32个byte
|
| | | var bytes = new byte[32];
|
| | | var reamarkGwBytes = System.Text.Encoding.UTF8.GetBytes(gatewayName);
|
| | | System.Array.Copy(reamarkGwBytes, 0, bytes, 0, 32 < reamarkGwBytes.Length ? 32 : reamarkGwBytes.Length);
|
| | | gatewayName = System.Text.Encoding.UTF8.GetString(bytes);
|
| | |
|
| | | var jObject = new Newtonsoft.Json.Linq.JObject { { "Cluster_ID", 0 }, { "Command", 91 } };
|
| | | var data = new Newtonsoft.Json.Linq.JObject { { "GwName", gatewayName } };
|
| | | jObject.Add("Data", data);
|
| | | var result = this.SendJobjectDataToGateway(zbGateway, "GwReName", jObject.ToString(), "GwReName_Respon");
|
| | | if (result.ErrorMsg != null)
|
| | | {
|
| | | //获取网关对象失败
|
| | | string msg = Language.StringByID(R.MyInternationalizationString.uGetGatewayTagartFail); |
| | | this.ShowErrorMsg(msg);
|
| | | this.ShowTipMsg(result.ErrorMsg);
|
| | | return false;
|
| | | }
|
| | |
|
| | | var result = await realWay.GwReNameAsync(gatewayName);
|
| | | //检测网关返回的共通错误状态码
|
| | | string error = HdlCheckLogic.Current.CheckCommonErrorCode(result);
|
| | | if (error != null)
|
| | | {
|
| | | this.ShowErrorMsg(error);
|
| | | return false;
|
| | | }
|
| | |
|
| | | if (result == null)
|
| | | if (result.ErrorMsgDiv == 0)
|
| | | {
|
| | | //网关名称修改失败
|
| | | string msg = Language.StringByID(R.MyInternationalizationString.uGatewayReNameFail);
|
| | | |
| | | this.ShowErrorMsg(msg); |
| | | return false;
|
| | | } |
| | | |
| | | //网关修改失败 |
| | | if (result.gwReNameData == null) |
| | | { |
| | | //网关名称修改失败 |
| | | string msg = Language.StringByID(R.MyInternationalizationString.uGatewayReNameFail);
|
| | | |
| | | this.ShowErrorMsg(msg); |
| | | //网关回复超时 |
| | | msg = UserCenterLogic.CombineGatewayTimeOutMsg(msg, null, "回复超时");
|
| | | this.ShowTipMsg(msg); |
| | | return false; |
| | | }
|
| | |
|
| | |
| | | public void SaveGatewayIdToLocation(string gatewayId)
|
| | | {
|
| | | GatewayResourse.AppOldSelectGatewayId = gatewayId;
|
| | | byte[] data = System.Text.Encoding.UTF8.GetBytes(JsonConvert.SerializeObject(GatewayResourse.AppOldSelectGatewayId));
|
| | | Global.WriteFileToDirectoryByBytes(DirNameResourse.LocalMemoryDirectory, DirNameResourse.AppOldSelectGatewayFile, data);
|
| | | HdlFileLogic.Current.SaveFileContent(DirNameResourse.AppOldSelectGatewayFile, GatewayResourse.AppOldSelectGatewayId);
|
| | | }
|
| | |
|
| | | #endregion |
| | |
| | | /// 获取网关加特效的名称
|
| | | /// </summary>
|
| | | /// <param name="zbGateway"></param>
|
| | | /// <param name="mode"></param>
|
| | | /// <returns></returns>
|
| | | public string GetGatewayName(ZbGateway zbGateway, GetNameMode mode = GetNameMode.SpecialGateway)
|
| | | public string GetGatewayName(ZbGateway zbGateway)
|
| | | {
|
| | | string gwId = zbGateway.GwId;
|
| | | if (this.dicGateway.ContainsKey(gwId) == false)
|
| | |
| | | return name;
|
| | | }
|
| | |
|
| | | if (mode == GetNameMode.SpecialGateway)
|
| | | string keyName = Common.LocalDevice.deviceModelIdName + localWay.LinuxImageType;
|
| | | if (LocalDevice.Current.dicDeviceAllNameID.ContainsKey(keyName) == true)
|
| | | {
|
| | | string keyName = Common.LocalDevice.deviceModelIdName + localWay.LinuxImageType;
|
| | | if (LocalDevice.Current.dicDeviceAllNameID.ContainsKey(keyName) == true)
|
| | | {
|
| | | //没有名称时,则使用R文件里面设置的默认设备名称
|
| | | return Language.StringByID(LocalDevice.Current.dicDeviceAllNameID[keyName] + 20000);
|
| | | }
|
| | | //没有名称时,则使用R文件里面设置的默认设备名称
|
| | | return Language.StringByID(LocalDevice.Current.dicDeviceAllNameID[keyName] + 20000);
|
| | | }
|
| | |
|
| | | return string.Empty;
|
| | |
| | | /// <summary>
|
| | | /// 变更网关房间
|
| | | /// </summary>
|
| | | /// <param name="zbGateway">网关对象</param>
|
| | | /// <param name="gwId">网关Id</param>
|
| | | /// <param name="roomId">房间ID</param>
|
| | | public void ChangedGatewayRoom(ZbGateway zbGateway, string roomId)
|
| | | public void ChangedGatewayRoom(string gwId, string roomId)
|
| | | {
|
| | | var localGateway = this.GetLocalGateway(zbGateway.GwId);
|
| | | var localGateway = this.GetLocalGateway(gwId);
|
| | | if (localGateway != null)
|
| | | {
|
| | | localGateway.RoomId = roomId;
|
| | |
| | | //获取控制主人账号的Token
|
| | | Pra.LoginAccessToken = UserCenterLogic.GetConnectMainToken();
|
| | |
|
| | | List<string> listNotShowError = new List<string>() { "NoExist", "NoBind", "NoRecord" };
|
| | | List<string> listNotShowError = new List<string>() { "NoExist", "NoBind", "NoRecord", "NotCheck" };
|
| | |
|
| | | bool result = UserCenterLogic.GetResultStatuByRequestHttps("App/ReleaseGatewayToHome", true, Pra, listNotShowError);
|
| | | if (result == false)
|
| | |
| | | listBackupGwId.Add(strId);
|
| | |
|
| | | //备份
|
| | | var strData = Newtonsoft.Json.JsonConvert.SerializeObject(listBackupGwId);
|
| | | var byteData = System.Text.Encoding.UTF8.GetBytes(strData);
|
| | | Global.WriteFileToDirectoryByBytes(DirNameResourse.LocalMemoryDirectory, DirNameResourse.BackupGatewayIdFile, byteData);
|
| | | HdlFileLogic.Current.SaveFileContent(DirNameResourse.BackupGatewayIdFile, listBackupGwId);
|
| | | }
|
| | | }
|
| | |
|
| | |
| | | {
|
| | | HdlThreadLogic.Current.RunThread(() =>
|
| | | {
|
| | | var fileData = Global.ReadFileByDirectory(DirNameResourse.LocalMemoryDirectory, DirNameResourse.BackupGatewayIdFile);
|
| | | var fileData = HdlFileLogic.Current.ReadFileByteContent(DirNameResourse.BackupGatewayIdFile);
|
| | | if (fileData == null)
|
| | | {
|
| | | return;
|
| | |
| | | {
|
| | | bindGateway.BindGateways.Clear();
|
| | | bindGateway.BindGateways.Add(gwId);
|
| | | var result = UserCenterLogic.GetResultCodeByRequestHttps("App/BindGatewayToHome", true, bindGateway);
|
| | | var result = UserCenterLogic.GetResultCodeByRequestHttps("App/BindGatewayToHome", true, bindGateway, new List<string> { "NotCheck" });
|
| | | if (result == "Success")
|
| | | {
|
| | | this.listBackupGwId.Remove(gwId);
|
| | |
| | | if (this.listBackupGwId.Count == 0)
|
| | | {
|
| | | //如果没有了内容,则删除文件
|
| | | string file = UserCenterLogic.CombinePath(DirNameResourse.LocalMemoryDirectory, DirNameResourse.BackupGatewayIdFile);
|
| | | string file = DirNameResourse.BackupGatewayIdFile;
|
| | | if (System.IO.File.Exists(file) == true)
|
| | | {
|
| | | System.IO.File.Delete(file);
|
| | |
| | | else
|
| | | {
|
| | | //备份
|
| | | var strData = Newtonsoft.Json.JsonConvert.SerializeObject(listBackupGwId);
|
| | | var byteData = System.Text.Encoding.UTF8.GetBytes(strData);
|
| | | Global.WriteFileToDirectoryByBytes(DirNameResourse.LocalMemoryDirectory, DirNameResourse.BackupGatewayIdFile, byteData);
|
| | | HdlFileLogic.Current.SaveFileContent(DirNameResourse.BackupGatewayIdFile, listBackupGwId);
|
| | | }
|
| | | });
|
| | | }
|
| | |
| | | /// <summary>
|
| | | /// Log出力
|
| | | /// </summary>
|
| | | /// <param name="div">1:普通Log,-1:致命错误Log,2:特殊Log</param>
|
| | | /// <param name="div">1:普通Log,-1:致命错误Log,2,3:特殊Log</param>
|
| | | /// <param name="strLog">Log内容</param>
|
| | | public void WriteLog(int div, string strLog)
|
| | | {
|
| | | lock (objLock)
|
| | | {
|
| | | if (div != -1 && div != 2 && UserCenterResourse.HideOption.DetailedLog == 0)
|
| | | if (div == 1 && UserCenterResourse.HideOption.DetailedLog == 0)
|
| | | {
|
| | | //暂时只记录异常信息
|
| | | return;
|
| | |
| | | try
|
| | | {
|
| | | string fullName = string.Empty;
|
| | | if (div != 2)
|
| | | if (div == 1 || div == -1)
|
| | | {
|
| | | string fileName = this.GetLogFile(div);
|
| | | fullName = UserCenterLogic.CombinePath(DirNameResourse.LocalMemoryDirectory, DirNameResourse.LogDirectory, fileName);
|
| | | fullName = System.IO.Path.Combine(DirNameResourse.LogDirectory, fileName);
|
| | | }
|
| | | else
|
| | | else if (div == 2)
|
| | | {
|
| | | fullName = DirNameResourse.SendAndReceveDataLog;
|
| | | }
|
| | | else if (div == 3)
|
| | | {
|
| | | fullName = DirNameResourse.SocketReceiveDataLog;
|
| | | }
|
| | | strLog = "\r\n[" + DateTime.Now.ToString("yyyyMMdd HH:mm:ss") + "] " + strLog + "\r\n";
|
| | | sw = new System.IO.StreamWriter(fullName, true, Encoding.UTF8);
|
| | | sw.WriteLine(strLog);
|
| | |
| | | Pra.LoginAccessToken = Config.Instance.Token;
|
| | |
|
| | | //编辑住宅
|
| | | bool flage = UserCenterLogic.GetResultStatuByRequestHttps("App/EditHome", false, Pra);
|
| | | bool flage = UserCenterLogic.GetResultStatuByRequestHttps("App/EditHome", false, Pra, new List<string> { "NotCheck" });
|
| | | if (flage == true)
|
| | | {
|
| | | //刷新内存的住宅名
|
| | |
| | | public House GetHouseByHouseId(string houseId)
|
| | | {
|
| | | var path = System.IO.Path.Combine(Shared.IO.FileUtils.RootPath, Config.Instance.Guid, houseId, $"House_{houseId}.json");
|
| | | var file = Shared.IO.FileUtils.ReadFile(path);
|
| | | var file = HdlFileLogic.Current.ReadFileByteContent(path);
|
| | | if (file == null)
|
| | | {
|
| | | return null;
|
| | |
| | | public House GetHouseByFilePath(string filePath)
|
| | | {
|
| | | var path = System.IO.Path.Combine(Shared.IO.FileUtils.RootPath, Config.Instance.Guid, GetHouseIdByFilePath(filePath), filePath);
|
| | | var file = Shared.IO.FileUtils.ReadFile(path);
|
| | | var file = HdlFileLogic.Current.ReadFileByteContent(path);
|
| | | if (file == null)
|
| | | {
|
| | | return null;
|
| | |
| | | if (arryHouse.Length > 0)
|
| | | {
|
| | | //读取文件内容
|
| | | var textValue = UserCenterLogic.LoadFileContent(System.IO.Path.Combine(nowPath, arryHouse[0]));
|
| | | var textValue = HdlFileLogic.Current.ReadFileTextContent(System.IO.Path.Combine(nowPath, arryHouse[0]));
|
| | | if (textValue == null)
|
| | | {
|
| | | continue;
|
| | |
| | | this.dicRooms.Clear();
|
| | | //检测我的喜爱这个房间对象
|
| | | this.CheckLoveRoom();
|
| | | |
| | | foreach (var roomId in Config.Instance.Home.ListRooms)
|
| | |
|
| | | var listFile = Global.FileListByHomeId();
|
| | | foreach (var fileName in listFile)
|
| | | {
|
| | | //从文件里面获取房间对象
|
| | | var room = this.GetRoomByFilePath($"Room_{roomId}.json");
|
| | | if (room != null)
|
| | | if (fileName.StartsWith("Room_") == true)
|
| | | {
|
| | | this.dicRooms[room.Id] = (room);
|
| | | //从文件里面获取房间对象
|
| | | var room = this.GetRoomByFilePath(fileName);
|
| | | if (room != null)
|
| | | {
|
| | | this.dicRooms[room.Id] = (room);
|
| | | }
|
| | | }
|
| | | }
|
| | | //设置当前楼层的ID
|
| | |
| | | /// </summary>
|
| | | public void RefreshAllRoomByLocation()
|
| | | {
|
| | | var homeTemp = Config.Instance.Home;
|
| | | homeTemp.ListRooms.Clear();
|
| | |
|
| | | var listFile = Global.FileListByHomeId();
|
| | |
|
| | | //我的喜爱的房间必须要在第0位才行
|
| | |
| | | if (listFile.Contains(fRoom) == true)
|
| | | {
|
| | | listFile.Remove(fRoom);
|
| | | homeTemp.ListRooms.Add("Favorite");
|
| | | }
|
| | |
|
| | | var listRoomFile = new List<string>();
|
| | |
| | | if (fileName.StartsWith("Room_"))
|
| | | {
|
| | | string roomId = fileName.Replace("Room_", string.Empty).Replace(".json", string.Empty);
|
| | | homeTemp.ListRooms.Add(roomId);
|
| | | listRoomFile.Add(fileName);
|
| | | }
|
| | | }
|
| | |
| | | this.CheckAdminFloorData(listRoomFile);
|
| | | }
|
| | |
|
| | | homeTemp.Save(false);
|
| | | InitAllRoom();
|
| | | this.InitAllRoom();
|
| | | }
|
| | |
|
| | | /// <summary>
|
| | |
| | | {
|
| | | Application.RunOnMainThread(() =>
|
| | | {
|
| | | MainPage.ListRoomViewFrom.Instance?.RefreshListRoom();
|
| | | MainPage.LeftListRoomViewFrom.Instance?.RefreshListRoom();
|
| | | });
|
| | | }
|
| | |
|
| | |
| | | /// <param name="rorefreshRoomViewom">是否刷新房间视图列表界面</param>
|
| | | public void AddRoom(Room room, bool refreshRoomView = true)
|
| | | {
|
| | | if (Global.IsExistsByHomeId(room.FileName) == true
|
| | | || Config.Instance.Home.ListRooms.Contains(room.Id) == true)
|
| | | if (Global.IsExistsByHomeId(room.FileName) == true)
|
| | | {
|
| | | return;
|
| | | }
|
| | | //添加到缓存
|
| | | this.dicRooms[room.Id] = room;
|
| | | //把房间ID添加到住宅
|
| | | Config.Instance.Home.AddRoomId(room.Id);
|
| | | //生成文件
|
| | | room.Save();
|
| | | //备份
|
| | |
| | | /// 删除房间
|
| | | /// </summary>
|
| | | /// <param name="roomId">房间ID</param>
|
| | | /// <param name="refreshLeftView">是否刷新左滑界面(此变量目前是给删除全部房间用的)</param>
|
| | | /// <returns></returns>
|
| | | public void RemoveRoom(string roomId)
|
| | | public void RemoveRoom(string roomId, bool refreshLeftView = true)
|
| | | {
|
| | | //根据房间Id,获取房间对象
|
| | | var room = this.GetRoomById(roomId);
|
| | |
| | | }
|
| | | loveRoom.Save(false);
|
| | | }
|
| | |
|
| | | Config.Instance.Home.RemoveRoomId(roomId);
|
| | | this.dicRooms.Remove(roomId);
|
| | |
|
| | | string roomFilePath = room.FileName;
|
| | |
| | |
|
| | | //根据房间ID,移除指定的真实物理设备的所属房间记录
|
| | | Common.LocalDevice.Current.DeleteRealDeviceByRoomId(roomId);
|
| | | if (refreshLeftView == true)
|
| | | {
|
| | | //HdlAutoBackupLogic.DeleteFile(roomFilePath);
|
| | | //刷新房间视图列表
|
| | | this.RefreshRoomListView();
|
| | | }
|
| | | }
|
| | |
|
| | | //刷新房间视图列表
|
| | | this.RefreshRoomListView();
|
| | | /// <summary>
|
| | | /// 删除全部的房间
|
| | | /// </summary>
|
| | | public void DeleteAllRoom()
|
| | | {
|
| | | var listRoomId = new List<string>();
|
| | | foreach (var room in this.dicRooms.Values)
|
| | | {
|
| | | if (room.IsLove == false)
|
| | | {
|
| | | listRoomId.Add(room.Id);
|
| | | }
|
| | | }
|
| | | foreach (var roomId in listRoomId)
|
| | | {
|
| | | this.RemoveRoom(roomId, false);
|
| | | }
|
| | | }
|
| | |
|
| | | #endregion
|
| | |
| | | public string GetRoomNameByDevice(CommonDevice device)
|
| | | {
|
| | | var room = this.GetRoomByDevice(device);
|
| | | return this.GetFloorRoomName(room);
|
| | | return this.GetRoomName(room);
|
| | | }
|
| | |
|
| | | /// <summary>
|
| | |
| | | /// </summary>
|
| | | /// <returns>房间名</returns>
|
| | | /// <param name="room">房间对象</param>
|
| | | public string GetFloorRoomName(Room room)
|
| | | public string GetRoomName(Room room)
|
| | | {
|
| | | if (room == null)
|
| | | {
|
| | |
| | | {
|
| | | listRoom.Add(room);
|
| | | }
|
| | | return listRoom;
|
| | | return this.SortRoom(listRoom);
|
| | | }
|
| | |
|
| | | /// <summary>
|
| | |
| | | return true;
|
| | | }
|
| | | return false;
|
| | | }
|
| | |
|
| | | /// <summary>
|
| | | /// 获取房间所在区域
|
| | | /// 楼层,房间名
|
| | | /// </summary>
|
| | | /// <returns></returns>
|
| | | public string GetZoneName(Room i_room)
|
| | | {
|
| | | if (string.IsNullOrEmpty(i_room.FloorId))
|
| | | {
|
| | | return i_room.Name;
|
| | | }
|
| | | var floorName = HdlResidenceLogic.Current.GetFloorNameById(i_room.FloorId);
|
| | | if (floorName == null)
|
| | | {
|
| | | return i_room.Name;
|
| | | }
|
| | | return $"{floorName},{i_room.Name}";
|
| | | }
|
| | |
|
| | | #endregion
|
| | |
| | | {
|
| | | i_floorKeys = string.Empty;
|
| | | }
|
| | | Dictionary<string, List<string>> dicAllSort = new Dictionary<string, List<string>>();
|
| | | //读取房间顺序
|
| | | string fullName = UserCenterLogic.CombinePath(DirNameResourse.LocalMemoryDirectory, DirNameResourse.RoomSortFile);
|
| | | var strData = UserCenterLogic.LoadFileContent(fullName);
|
| | | if (strData != null)
|
| | | {
|
| | | dicAllSort = Newtonsoft.Json.JsonConvert.DeserializeObject<Dictionary<string, List<string>>>(strData);
|
| | | }
|
| | |
|
| | | var listRoomSort = new List<string>();
|
| | | if (dicAllSort.ContainsKey(i_floorKeys) == true)
|
| | | {
|
| | | listRoomSort = dicAllSort[i_floorKeys];
|
| | | }
|
| | | else
|
| | | {
|
| | | dicAllSort[i_floorKeys] = listRoomSort;
|
| | | }
|
| | |
|
| | | var dicRoom = new Dictionary<string, Common.Room>();
|
| | | var listRoom = new List<Room>();
|
| | | foreach (var room in this.dicRooms.Values)
|
| | | {
|
| | | if (room.FloorId != i_floorKeys && i_floorKeys != string.Empty)
|
| | | if (room.FloorId != i_floorKeys && i_floorKeys != string.Empty
|
| | | || room.IsLove == true)
|
| | | {
|
| | | //不是同一个楼层
|
| | | //不是同一个楼层,不要我的喜爱
|
| | | continue;
|
| | | }
|
| | | if (room.IsLove == true)
|
| | | {
|
| | | //不要我的喜爱
|
| | | continue;
|
| | | }
|
| | | if (listRoomSort.Contains(room.Id) == false)
|
| | | {
|
| | | //新添加的房间
|
| | | listRoomSort.Add(room.Id);
|
| | | }
|
| | | if (getShard == false && room.IsSharedRoom == true)
|
| | | {
|
| | | //不要分享的房间
|
| | | continue;
|
| | | }
|
| | | dicRoom[room.Id] = room;
|
| | | listRoom.Add(room);
|
| | | }
|
| | |
|
| | | var listSortRoom = new List<Room>();
|
| | | for (int i = 0; i < listRoomSort.Count; i++)
|
| | | {
|
| | | if (dicRoom.ContainsKey(listRoomSort[i]) == true)
|
| | | {
|
| | | listSortRoom.Add(dicRoom[listRoomSort[i]]);
|
| | | }
|
| | | }
|
| | |
|
| | | //保存顺序
|
| | | UserCenterLogic.SaveFileContent(fullName, dicAllSort);
|
| | | return listSortRoom;
|
| | | return this.SortRoom(listRoom);
|
| | | }
|
| | |
|
| | | /// <summary>
|
| | | /// 保存房间的顺序
|
| | | /// 排序房间对象
|
| | | /// </summary>
|
| | | /// <param name="i_floorKeys">楼层主键</param>
|
| | | /// <param name="listSort">房间顺序(房间的主键)</param>
|
| | | public void SaveRoomSort(string i_floorKeys, List<string> listSort)
|
| | | /// <param name="listRoom"></param>
|
| | | /// <returns></returns>
|
| | | public List<Room> SortRoom(List<Room> listRoom)
|
| | | {
|
| | | Dictionary<string, List<string>> dicAllSort = new Dictionary<string, List<string>>();
|
| | | //读取房间顺序
|
| | | string fullName = UserCenterLogic.CombinePath(DirNameResourse.LocalMemoryDirectory, DirNameResourse.RoomSortFile);
|
| | | var strData = UserCenterLogic.LoadFileContent(fullName);
|
| | | if (strData != null)
|
| | | //从一堆文字中,获取这一堆文字里面数字字符串的最长长度
|
| | | var listName = new List<string>();
|
| | | foreach (var room in listRoom)
|
| | | {
|
| | | dicAllSort = Newtonsoft.Json.JsonConvert.DeserializeObject<Dictionary<string, List<string>>>(strData);
|
| | | listName.Add(room.Name);
|
| | | }
|
| | | int numberLength = this.GetNumberMaxLength(listName);
|
| | |
|
| | | //保存顺序
|
| | | dicAllSort[i_floorKeys] = listSort;
|
| | | UserCenterLogic.SaveFileContent(fullName, dicAllSort);
|
| | | dicAllSort.Clear();
|
| | | var listSort = new List<string[]>();
|
| | | foreach (var room in listRoom)
|
| | | {
|
| | | var strArry = new string[2];
|
| | | strArry[0] = room.Id;
|
| | | strArry[1] = string.Empty;
|
| | |
|
| | | string value = string.Empty;
|
| | | foreach (var c in room.Name)
|
| | | {
|
| | | if (char.IsNumber(c) == true)
|
| | | {
|
| | | //数字
|
| | | value += c.ToString();
|
| | | continue;
|
| | | }
|
| | | else if (value != string.Empty)
|
| | | {
|
| | | //如果房间名字带有数字的话,则左边加零,因为这里有个排序的问题
|
| | | strArry[1] += value.PadLeft(numberLength, '0');
|
| | | value = string.Empty;
|
| | | }
|
| | | strArry[1] += c.ToString();
|
| | | }
|
| | | if (value != string.Empty)
|
| | | {
|
| | | //以数字结尾的话
|
| | | strArry[1] += value.PadLeft(numberLength, '0');
|
| | | }
|
| | | listSort.Add(strArry);
|
| | | }
|
| | | //排序
|
| | | listSort.Sort((obj1, obj2) =>
|
| | | {
|
| | | if (obj1[1].CompareTo(obj2[1]) > 0)
|
| | | {
|
| | | return 1;
|
| | | }
|
| | | return -1;
|
| | | });
|
| | | var listSortRoom = new List<Room>();
|
| | | foreach (var strArry in listSort)
|
| | | {
|
| | | var room = this.GetRoomById(strArry[0]);
|
| | | listSortRoom.Add(room);
|
| | | }
|
| | | return listSortRoom;
|
| | | }
|
| | |
|
| | | /// <summary>
|
| | |
| | | /// <returns></returns>
|
| | | public Dictionary<string, string> GetFloorSortList()
|
| | | {
|
| | | //读取楼层顺序
|
| | | var listFloorSort = new List<string>();
|
| | | string fullName = UserCenterLogic.CombinePath(DirNameResourse.LocalMemoryDirectory, DirNameResourse.FloorSortFile);
|
| | | var strData = UserCenterLogic.LoadFileContent(fullName);
|
| | | if (strData != null)
|
| | | //从一堆文字中,获取这一堆文字里面数字字符串的最长长度
|
| | | var listName = new List<string>();
|
| | | foreach (var floorName in Config.Instance.Home.FloorDics.Values)
|
| | | {
|
| | | listFloorSort = Newtonsoft.Json.JsonConvert.DeserializeObject<List<string>>(strData);
|
| | | listName.Add(floorName);
|
| | | }
|
| | | foreach (string keys in Common.Config.Instance.Home.FloorDics.Keys)
|
| | | {
|
| | | if (listFloorSort.Contains(keys) == false)
|
| | | {
|
| | | //新添加的楼层
|
| | | listFloorSort.Add(keys);
|
| | | }
|
| | | }
|
| | | int numberLength = this.GetNumberMaxLength(listName);
|
| | |
|
| | | var listSort = new List<string[]>();
|
| | | foreach (var floorId in Config.Instance.Home.FloorDics.Keys)
|
| | | {
|
| | | var strArry = new string[2];
|
| | | strArry[0] = floorId;
|
| | | strArry[1] = string.Empty;
|
| | |
|
| | | string value = string.Empty;
|
| | | string floorName = Config.Instance.Home.FloorDics[floorId];
|
| | | foreach (var c in floorName)
|
| | | {
|
| | | if (char.IsNumber(c) == true)
|
| | | {
|
| | | //数字
|
| | | value += c.ToString();
|
| | | continue;
|
| | | }
|
| | | else if (value != string.Empty)
|
| | | {
|
| | | //如果房间名字带有数字的话,则左边加零,因为这里有个排序的问题
|
| | | strArry[1] += value.PadLeft(numberLength, '0');
|
| | | value = string.Empty;
|
| | | }
|
| | | strArry[1] += c.ToString();
|
| | | }
|
| | | if (value != string.Empty)
|
| | | {
|
| | | //以数字结尾的话
|
| | | strArry[1] += value.PadLeft(numberLength, '0');
|
| | | }
|
| | | listSort.Add(strArry);
|
| | | }
|
| | | //楼层排序
|
| | | listSort.Sort((obj1, obj2) =>
|
| | | {
|
| | | if (obj1[1].CompareTo(obj2[1]) > 0)
|
| | | {
|
| | | return 1;
|
| | | }
|
| | | return -1;
|
| | | });
|
| | | var dic = new Dictionary<string, string>();
|
| | | for (int i = 0; i < listFloorSort.Count; i++)
|
| | | foreach (var strArry in listSort)
|
| | | {
|
| | | if (Config.Instance.Home.FloorDics.ContainsKey(listFloorSort[i]) == true)
|
| | | {
|
| | | dic[listFloorSort[i]] = Config.Instance.Home.FloorDics[listFloorSort[i]];
|
| | | }
|
| | | dic[strArry[0]] = Config.Instance.Home.FloorDics[strArry[0]];
|
| | | }
|
| | |
|
| | | //保存顺序
|
| | | UserCenterLogic.SaveFileContent(fullName, listFloorSort);
|
| | | return dic;
|
| | | }
|
| | |
|
| | | /// <summary>
|
| | | /// 保存楼层的顺序
|
| | | /// </summary>
|
| | | /// <param name="listSort">楼层的主键</param>
|
| | | public void SaveFloorSort(List<string> listSort)
|
| | | {
|
| | | string fullName = UserCenterLogic.CombinePath(DirNameResourse.LocalMemoryDirectory, DirNameResourse.FloorSortFile);
|
| | | //保存顺序
|
| | | UserCenterLogic.SaveFileContent(fullName, listSort);
|
| | | }
|
| | |
|
| | | #endregion
|
| | |
| | | #region ■ 一般方法___________________________
|
| | |
|
| | | /// <summary>
|
| | | /// 获取房间总数
|
| | | /// </summary>
|
| | | /// <returns></returns>
|
| | | public int GetRoomCount()
|
| | | {
|
| | | return this.dicRooms.Count;
|
| | | }
|
| | |
|
| | | /// <summary>
|
| | | /// 检测我的喜爱这个房间对象
|
| | | /// </summary>
|
| | | private void CheckLoveRoom()
|
| | | {
|
| | | if (Config.Instance.Home.ListRooms.Contains("Favorite") == false)
|
| | | if (this.dicRooms.ContainsKey("Favorite") == true)
|
| | | {
|
| | | return;
|
| | | }
|
| | | //读取本地我的喜爱文件
|
| | | string favoriteFile = System.IO.Path.Combine(Common.Config.Instance.FullPath, "Room_Favorite.json");
|
| | | var fileContent = HdlFileLogic.Current.ReadFileTextContent(favoriteFile);
|
| | | if (fileContent != null)
|
| | | {
|
| | | var love = Newtonsoft.Json.JsonConvert.DeserializeObject<Room>(fileContent);
|
| | | this.dicRooms["Favorite"] = love;
|
| | | }
|
| | | else
|
| | | {
|
| | | //默认添加喜爱的房间--禁止修改房间名
|
| | | var love = new Room { Name = Language.StringByID(R.MyInternationalizationString.Favorite), BackgroundImage = "RoomIcon/0.jpg", Id = "Favorite" };
|
| | | love.Save(false);
|
| | | //添加到house 房间路径列表
|
| | | var currentHome = Config.Instance.Home;
|
| | | currentHome.ListRooms.Insert(0, love.Id);
|
| | | currentHome.Save(false);
|
| | |
|
| | | this.dicRooms["Favorite"] = love;
|
| | | }
|
| | | }
|
| | |
|
| | | /// <summary>
|
| | | /// 从一堆文字中,获取这一堆文字里面数字字符串的最长长度
|
| | | /// </summary>
|
| | | /// <param name="listText"></param>
|
| | | /// <returns></returns>
|
| | | private int GetNumberMaxLength(List<string> listText)
|
| | | {
|
| | | int maxLength = 0;
|
| | | foreach (var text in listText)
|
| | | {
|
| | | string value = string.Empty;
|
| | | foreach (var c in text)
|
| | | {
|
| | | if (char.IsNumber(c) == true)
|
| | | {
|
| | | //数字
|
| | | value += c.ToString();
|
| | | continue;
|
| | | }
|
| | | else if (value != string.Empty)
|
| | | {
|
| | | //判断数字长度
|
| | | if (maxLength <= value.Length)
|
| | | {
|
| | | maxLength = value.Length;
|
| | | }
|
| | | value = string.Empty;
|
| | | }
|
| | | }
|
| | | //判断数字长度
|
| | | if (maxLength <= value.Length)
|
| | | {
|
| | | maxLength = value.Length;
|
| | | }
|
| | | }
|
| | | return maxLength;
|
| | | }
|
| | |
|
| | | #endregion
|
| | | }
|
| | | }
|
| | |
| | |
|
| | | if (this.UserPassword == null)
|
| | | {
|
| | | var data = Global.ReadFileByDirectory(DirNameResourse.LocalMemoryDirectory, DirNameResourse.SafeguardUserPassword);
|
| | | var data = HdlFileLogic.Current.ReadFileByteContent(DirNameResourse.SafeguardUserPassword);
|
| | | if (data != null)
|
| | | {
|
| | | this.UserPassword = System.Text.Encoding.UTF8.GetString(data);
|
| | |
| | | if (result != GarrisonMode.None && result != GarrisonMode.RemoveGarrison)
|
| | | {
|
| | | //保存加密的密码到本地
|
| | | Global.WriteFileToDirectoryByBytes(DirNameResourse.LocalMemoryDirectory, DirNameResourse.SafeguardUserPassword, System.Text.Encoding.UTF8.GetBytes(this.UserPassword));
|
| | | HdlFileLogic.Current.SaveTextToFile(DirNameResourse.SafeguardUserPassword, this.UserPassword);
|
| | | }
|
| | | return result;
|
| | | }
|
| | |
| | | if (result2 != GarrisonMode.None && result2 != GarrisonMode.RemoveGarrison)
|
| | | {
|
| | | //保存加密密码到本地
|
| | | Global.WriteFileToDirectoryByBytes(DirNameResourse.LocalMemoryDirectory, DirNameResourse.SafeguardUserPassword, System.Text.Encoding.UTF8.GetBytes(this.UserPassword));
|
| | | HdlFileLogic.Current.SaveTextToFile(DirNameResourse.SafeguardUserPassword, this.UserPassword);
|
| | | }
|
| | | return result2;
|
| | | }
|
| | |
| | | if (result2 != -1)
|
| | | {
|
| | | //保存到加密密码本地
|
| | | Global.WriteFileToDirectoryByBytes(DirNameResourse.LocalMemoryDirectory, DirNameResourse.SafeguardUserPassword, System.Text.Encoding.UTF8.GetBytes(this.UserPassword));
|
| | | HdlFileLogic.Current.SaveTextToFile(DirNameResourse.SafeguardUserPassword, this.UserPassword);
|
| | | }
|
| | | return result2;
|
| | | }
|
| | |
| | | //超时时间
|
| | | int TimeOut = 0;
|
| | | bool receiptAll = false;
|
| | | bool canReceve = false;
|
| | |
|
| | | var listScene = new List<Scene.GetSceneAllInfo>();
|
| | | Action<string, string> action = (topic, message) =>
|
| | |
| | | var sceneGetAllInfo = Newtonsoft.Json.JsonConvert.DeserializeObject<Scene.GetSceneAllInfo>(jobject["Data"].ToString());
|
| | | listScene.Add(sceneGetAllInfo);
|
| | |
|
| | | //更够接收得到场景
|
| | | canReceve = true;
|
| | | if (sceneGetAllInfo.ScenesNum == sceneGetAllInfo.ScenesSum)
|
| | | {
|
| | | //接收完成
|
| | |
| | | }
|
| | | mainGateway.Actions -= action;
|
| | | action = null;
|
| | | if (receiptAll == false)
|
| | | if (canReceve == false)
|
| | | {
|
| | | //获取场景列表失败,网关回复超时
|
| | | this.ShowTipMsg(Language.StringByID(R.MyInternationalizationString.uGetSceneListFailAndTimeOut));
|
| | | return null;
|
| | | }
|
| | | else if (receiptAll == false)
|
| | | {
|
| | | //网络不稳定,场景列表信息缺损
|
| | | this.ShowTipMsg(Language.StringByID(R.MyInternationalizationString.uNetworkUnStableAndSceneInfoIsNotFull));
|
| | |
| | | }
|
| | |
|
| | | /// <summary>
|
| | | /// 清空本地全部的场景数据
|
| | | /// </summary>
|
| | | public void DeleteAllLocalScene()
|
| | | {
|
| | | var listScene = new List<SceneUI>();
|
| | | foreach (var scene in this.dicScenes.Values)
|
| | | {
|
| | | listScene.Add(scene);
|
| | | }
|
| | | foreach (var scene in listScene)
|
| | | {
|
| | | this.DeleteLocalScene(scene);
|
| | | }
|
| | | }
|
| | |
|
| | | /// <summary>
|
| | | /// 删除场景(这个只移除内存)
|
| | | /// </summary>
|
| | | /// <param name="scene"></param>
|
| | |
| | | #region ■ 获取场景___________________________
|
| | |
|
| | | /// <summary>
|
| | | /// 获取本地全部的场景(包含未分配)
|
| | | /// </summary>
|
| | | /// <returns></returns>
|
| | | public List<SceneUI> GetAllLocalScene()
|
| | | {
|
| | | //房间的场景放在前面
|
| | | var listScene = this.GetAllRoomSceneList();
|
| | | //未分配的场景
|
| | | var listUnalloctScene = this.GetUnalloctedScenes();
|
| | | listScene.AddRange(listUnalloctScene);
|
| | | return listScene;
|
| | | }
|
| | |
|
| | | /// <summary>
|
| | | /// 通过场景id获取场景
|
| | | /// </summary>
|
| | | /// <returns>The scene UIB y scene identifier.</returns>
|
| | |
| | |
|
| | | List<string> listFile = new List<string>();
|
| | | //文件夹
|
| | | string strDir = System.IO.Path.Combine(DirNameResourse.LocalMemoryDirectory, DirNameResourse.DownLoadShardDirectory);
|
| | | string strDir = DirNameResourse.DownLoadShardDirectory;
|
| | |
|
| | | //不允许按系统的返回键
|
| | | Shared.Common.CommonPage.BackKeyCanClick = false;
|
| | |
| | | //文件名字
|
| | | listFile.Add(dataResult.ShareName);
|
| | | //保存到指定文件夹下
|
| | | Global.WriteFileToDirectoryByBytes(strDir, dataResult.ShareName, dataResult.ShareDataBytes);
|
| | | HdlFileLogic.Current.SaveTextToFile(System.IO.Path.Combine(strDir, dataResult.ShareName), System.Text.Encoding.UTF8.GetString(dataResult.ShareDataBytes));
|
| | | //设置进度值
|
| | | ProgressFormBar.Current.SetValue(i + 1, listMarkCount);
|
| | | }
|
| | |
| | | /// <returns></returns>
|
| | | public byte[] GetShardFileContent(string fileName)
|
| | | {
|
| | | string fullName = UserCenterLogic.CombinePath(DirNameResourse.LocalMemoryDirectory, DirNameResourse.DownLoadShardDirectory, fileName);
|
| | | string fullName = System.IO.Path.Combine(DirNameResourse.DownLoadShardDirectory, fileName);
|
| | | if (System.IO.File.Exists(fullName) == false)
|
| | | {
|
| | | return null;
|
| | | }
|
| | | string path = System.IO.Path.Combine(DirNameResourse.LocalMemoryDirectory, DirNameResourse.DownLoadShardDirectory);
|
| | | var varByte = Global.ReadFileByDirectory(path, fileName);
|
| | | string path = System.IO.Path.Combine(DirNameResourse.DownLoadShardDirectory, fileName);
|
| | | var varByte = HdlFileLogic.Current.ReadFileByteContent(path);
|
| | | return varByte;
|
| | | }
|
| | |
|
| | |
| | | /// <returns></returns>
|
| | | public List<string> GetLocalAllShardFile()
|
| | | {
|
| | | string path = UserCenterLogic.CombinePath(DirNameResourse.LocalMemoryDirectory, DirNameResourse.DownLoadShardDirectory);
|
| | | var listFile = HdlAutoBackupLogic.GetFileFromDirectory(path);
|
| | |
|
| | | return listFile;
|
| | | return HdlFileLogic.Current.GetFileFromDirectory(DirNameResourse.DownLoadShardDirectory);
|
| | | }
|
| | |
|
| | | /// <summary>
|
| | |
| | | /// <returns></returns>
|
| | | public bool IsFileExists(string fileName)
|
| | | {
|
| | | string fullName = UserCenterLogic.CombinePath(DirNameResourse.LocalMemoryDirectory, DirNameResourse.DownLoadShardDirectory, fileName);
|
| | | string fullName = System.IO.Path.Combine(DirNameResourse.DownLoadShardDirectory, fileName);
|
| | | if (System.IO.File.Exists(fullName) == false)
|
| | | {
|
| | | return false;
|
| | |
| | | {
|
| | | return;
|
| | | }
|
| | | string oldName = UserCenterLogic.CombinePath(fileName);
|
| | | string newName = UserCenterLogic.CombinePath(DirNameResourse.LocalMemoryDirectory, DirNameResourse.DownLoadShardDirectory, fileName);
|
| | | System.IO.File.Copy(oldName, newName, true);
|
| | | string oldName = System.IO.Path.Combine(Config.Instance.FullPath, fileName);
|
| | | string newName = System.IO.Path.Combine(DirNameResourse.DownLoadShardDirectory, fileName);
|
| | | HdlFileLogic.Current.CopyFile(oldName, newName);
|
| | | }
|
| | |
|
| | | /// <summary>
|
| | |
| | | public void AddShardFile(Common.Room room)
|
| | | {
|
| | | room.IsSharedRoom = true;
|
| | | var data = Newtonsoft.Json.JsonConvert.SerializeObject(room);
|
| | | var byteData = System.Text.Encoding.UTF8.GetBytes(data);
|
| | |
|
| | | string fullName = UserCenterLogic.CombinePath(DirNameResourse.LocalMemoryDirectory, DirNameResourse.DownLoadShardDirectory, room.FileName);
|
| | | string fullName = System.IO.Path.Combine(DirNameResourse.DownLoadShardDirectory, room.FileName);
|
| | | //写入内容
|
| | | Shared.IO.FileUtils.WriteFileByBytes(fullName, byteData);
|
| | | HdlFileLogic.Current.SaveFileContent(fullName, room);
|
| | | }
|
| | |
|
| | | /// <summary>
|
| | |
| | | public void AddShardFile(Common.SceneUI scene)
|
| | | {
|
| | | scene.IsSharedScene = true;
|
| | | var data = Newtonsoft.Json.JsonConvert.SerializeObject(scene);
|
| | | var byteData = System.Text.Encoding.UTF8.GetBytes(data);
|
| | |
|
| | | string fullName = UserCenterLogic.CombinePath(DirNameResourse.LocalMemoryDirectory, DirNameResourse.DownLoadShardDirectory, scene.FileName);
|
| | | string fullName = System.IO.Path.Combine(DirNameResourse.DownLoadShardDirectory, scene.FileName);
|
| | | //写入内容
|
| | | Shared.IO.FileUtils.WriteFileByBytes(fullName, byteData);
|
| | | HdlFileLogic.Current.SaveFileContent(fullName, scene);
|
| | | }
|
| | |
|
| | | /// <summary>
|
| | |
| | | /// <param name="dic">楼层</param>
|
| | | public void AddShardFile(Dictionary<string, string> dic)
|
| | | {
|
| | | var data = Newtonsoft.Json.JsonConvert.SerializeObject(dic);
|
| | | var byteData = System.Text.Encoding.UTF8.GetBytes(data);
|
| | |
|
| | | string fullName = UserCenterLogic.CombinePath(DirNameResourse.LocalMemoryDirectory, DirNameResourse.DownLoadShardDirectory, DirNameResourse.ShardFloorFile);
|
| | | string fullName = System.IO.Path.Combine(DirNameResourse.DownLoadShardDirectory, DirNameResourse.ShardFloorFile);
|
| | | //写入内容
|
| | | Shared.IO.FileUtils.WriteFileByBytes(fullName, byteData);
|
| | | HdlFileLogic.Current.SaveFileContent(fullName, dic);
|
| | | }
|
| | |
|
| | | #endregion
|
| | |
| | | /// <param name="fileName">指定文件名字</param>
|
| | | public void DeleteShardFile(string fileName)
|
| | | {
|
| | | fileName = UserCenterLogic.CombinePath(DirNameResourse.LocalMemoryDirectory, DirNameResourse.DownLoadShardDirectory, fileName);
|
| | | if (System.IO.File.Exists(fileName) == true)
|
| | | {
|
| | | System.IO.File.Delete(fileName);
|
| | | }
|
| | | fileName = System.IO.Path.Combine(DirNameResourse.DownLoadShardDirectory, fileName);
|
| | | HdlFileLogic.Current.DeleteFile(fileName);
|
| | | }
|
| | |
|
| | | /// <summary>
|
| | |
| | | {
|
| | | this.dicShardDeviceFile.Clear();
|
| | | //创建文件夹
|
| | | string strDir = System.IO.Path.Combine(DirNameResourse.LocalMemoryDirectory, DirNameResourse.DownLoadShardDirectory);
|
| | | Global.CreateEmptyDirectory(strDir, true);
|
| | | HdlFileLogic.Current.CreateDirectory(DirNameResourse.DownLoadShardDirectory, true);
|
| | | }
|
| | |
|
| | | #endregion
|
| | |
| | | //生成文件
|
| | | foreach (string fileName in listDbFile)
|
| | | {
|
| | | var oldPath = UserCenterLogic.CombinePath(DirNameResourse.LocalMemoryDirectory, DirNameResourse.DownLoadShardDirectory, fileName);
|
| | | var oldPath = System.IO.Path.Combine(DirNameResourse.DownLoadShardDirectory, fileName);
|
| | | var newPath = System.IO.Path.Combine(Config.Instance.FullPath, fileName);
|
| | | System.IO.File.Copy(oldPath, newPath, true);
|
| | |
|
| | | if (fileName.StartsWith("Room_") == true)
|
| | | {
|
| | | //房间文件特殊处理
|
| | | Config.Instance.Home.AddRoomId(fileName.Replace("Room_", string.Empty).Replace(".json", string.Empty));
|
| | | }
|
| | | HdlFileLogic.Current.CopyFile(oldPath, newPath);
|
| | | }
|
| | | //清空共享文件夹
|
| | | this.ClearShardDirectory();
|
| | |
| | | //删除掉这个房间文件
|
| | | Global.DeleteFilebyHomeId(fileName);
|
| | | dicUpdateTime.Remove(fileName);
|
| | |
|
| | | Config.Instance.Home.RemoveRoomId(nowRoom.Id);
|
| | | }
|
| | | //检测本地场景文件,是否存在已经取消了共享了的
|
| | | else if (fileName.StartsWith("Scene_") == true)
|
| | |
| | | private Dictionary<string, string> GetAllShardFileAgoUpdateTime()
|
| | | {
|
| | | var dicTime = new Dictionary<string, string>();
|
| | | var data = Global.ReadFileByDirectory(DirNameResourse.LocalMemoryDirectory, DirNameResourse.ShardFileUpdateTimeFile);
|
| | | var data = HdlFileLogic.Current.ReadFileByteContent(DirNameResourse.ShardFileUpdateTimeFile);
|
| | | if (data == null)
|
| | | {
|
| | | //目标文件不存在
|
| | |
| | | /// <param name="dicTime"></param>
|
| | | private void SaveAllShardFileAgoUpdateTime(Dictionary<string, string> dicTime)
|
| | | {
|
| | | var data = Newtonsoft.Json.JsonConvert.SerializeObject(dicTime);
|
| | | var byteData = System.Text.Encoding.UTF8.GetBytes(data);
|
| | | Global.WriteFileToDirectoryByBytes(DirNameResourse.LocalMemoryDirectory, DirNameResourse.ShardFileUpdateTimeFile, byteData);
|
| | | HdlFileLogic.Current.SaveFileContent(DirNameResourse.ShardFileUpdateTimeFile, dicTime);
|
| | | }
|
| | |
|
| | | #endregion
|
| | |
| | | /// <returns></returns>
|
| | | private string UpLoadBigBackupFileToDB(MemberShardInfoData memberShardInfo, string fileName)
|
| | | {
|
| | | string fullName = UserCenterLogic.CombinePath(DirNameResourse.LocalMemoryDirectory, DirNameResourse.DownLoadShardDirectory, fileName);
|
| | | string fullName = System.IO.Path.Combine(DirNameResourse.DownLoadShardDirectory, fileName);
|
| | | if (System.IO.File.Exists(fullName) == false)
|
| | | {
|
| | | return null;
|
| | |
| | | }
|
| | | listDeleteFile.Add(device.FilePath);
|
| | | }
|
| | |
|
| | | //再弄场景
|
| | | foreach (var sceneUI in listSceneUI)
|
| | | {
|
| | |
| | | }
|
| | | get
|
| | | {
|
| | | //10秒后允许再次访问
|
| | | if (m_CanAccessHttp == true || (DateTime.Now - oldAccessHttpTime).TotalMilliseconds > 10 * 1000)
|
| | | //8秒后允许再次访问
|
| | | if (m_CanAccessHttp == true || (DateTime.Now - oldAccessHttpTime).TotalMilliseconds > 8 * 1000)
|
| | | {
|
| | | oldAccessHttpTime = DateTime.Now;
|
| | | return true;
|
| | |
| | | /// <summary>
|
| | | /// 监听安卓网络变化
|
| | | /// </summary>
|
| | | /// <param name="value"></param>
|
| | | /// <param name="value">0:没有网络 1:4G 2:wifi</param>
|
| | | private void NetworkStateChanged(int value)
|
| | | {
|
| | | //没有网络
|
| | | if (value == 0)
|
| | | {
|
| | | this.CanAccessHttp = false;
|
| | | //关闭Socket
|
| | | ZigBee.Common.Application.FindGateWaySocket.Stop();
|
| | | }
|
| | | //可以叫4G
|
| | | else if (value == 1)
|
| | | //WIFI或者4G时
|
| | | if (value == 1 || value == 2)
|
| | | {
|
| | | //允许联网
|
| | | this.CanAccessHttp = true;
|
| | | }
|
| | | //WIFI
|
| | | else if (value == 2)
|
| | | {
|
| | | this.CanAccessHttp = true;
|
| | |
|
| | | //检测是否已经完成账号信息初始化
|
| | | if (UserCenterResourse.UserInfo.InitUserInfoSuccess == false
|
| | | && Common.Config.Instance.HomeId != string.Empty)
|
| | | {
|
| | | HdlThreadLogic.Current.RunThread(() =>
|
| | | {
|
| | | ProgressBar.Show();
|
| | | //重新初始化账号信息
|
| | | UserCenterLogic.ReInitUserAccoutInfo();
|
| | | ProgressBar.Close();
|
| | |
|
| | | }, ShowErrorMode.NO);
|
| | | }
|
| | | //重新初始化Socket
|
| | | ZigBee.Common.Application.FindGateWaySocket.Stop();
|
| | | if (value == 2)
|
| | | {
|
| | | ZigBee.Common.Application.FindGateWaySocket.Start();
|
| | | }
|
| | | //断掉本地连接
|
| | | HdlGatewayLogic.Current.ClearAllRealGateway();
|
| | | }
|
| | | }
|
| | |
|
| | |
| | | ShowNotNetMsg(listNotShowError);
|
| | | return false;
|
| | | }
|
| | | //检测是否已经完成账号信息初始化
|
| | | if (UserCenterResourse.UserInfo.InitUserInfoSuccess == false)
|
| | | {
|
| | | //不管结果怎么样,如果调用了这个函数,需要重头获取Token,所以必须返回失败
|
| | | ReInitUserAccoutInfo(listNotShowError);
|
| | | return false;
|
| | | }
|
| | | //获取接口的连接模式
|
| | | var connectMode = GetHttpConnectMode(checkAuthority);
|
| | | //获取从接口那里取到的比特数据
|
| | |
| | | {
|
| | | //当前无法访问网络(当需要重新发送时,跳过这个判断)
|
| | | ShowNotNetMsg(listNotShowError);
|
| | | return "Error";
|
| | | }
|
| | | //检测是否已经完成账号信息初始化
|
| | | if (UserCenterResourse.UserInfo.InitUserInfoSuccess == false)
|
| | | {
|
| | | //不管结果怎么样,如果调用了这个函数,需要重头获取Token,所以必须返回失败
|
| | | ReInitUserAccoutInfo(listNotShowError);
|
| | | return "Error";
|
| | | }
|
| | |
|
| | |
| | | {
|
| | | //当前无法访问网络(当需要重新发送时,跳过这个判断)
|
| | | ShowNotNetMsg(listNotShowError);
|
| | | return null;
|
| | | }
|
| | | //检测是否已经完成账号信息初始化
|
| | | if (UserCenterResourse.UserInfo.InitUserInfoSuccess == false)
|
| | | {
|
| | | //不管结果怎么样,如果调用了这个函数,需要重头获取Token,所以必须返回失败
|
| | | ReInitUserAccoutInfo(listNotShowError);
|
| | | return null;
|
| | | }
|
| | | //获取接口的连接模式
|
| | |
| | | {
|
| | | //当前无法访问网络(当需要重新发送时,跳过这个判断)
|
| | | ShowNotNetMsg(listNotShowError);
|
| | | return null;
|
| | | }
|
| | | //检测是否已经完成账号信息初始化
|
| | | if (UserCenterResourse.UserInfo.InitUserInfoSuccess == false)
|
| | | {
|
| | | //不管结果怎么样,如果调用了这个函数,需要重头获取Token,所以必须返回失败
|
| | | ReInitUserAccoutInfo(listNotShowError);
|
| | | return null;
|
| | | }
|
| | | //获取接口的连接模式
|
| | |
| | | HdlGatewayLogic.Current.SynchronizeDbGateway();
|
| | | //从本地重新加载全部的房间
|
| | | HdlRoomLogic.Current.RefreshAllRoomByLocation();
|
| | | //断开远程Mqtt连接,重新连接
|
| | | HdlThreadLogic.Current.RunThread(async () =>
|
| | | {
|
| | | HdlGatewayLogic.Current.ClearAllRealGateway();
|
| | | await ZigBee.Device.ZbGateway.DisConnectRemoteMqttClient();
|
| | | }, ShowErrorMode.NO);
|
| | | }
|
| | |
|
| | | /// <summary>
|
| | |
| | | Config.Instance.Home.Longitude = Longitude;
|
| | | Config.Instance.Home.Latitude = Latitude;
|
| | | Config.Instance.Home.Save(false);
|
| | | }
|
| | |
|
| | | #endregion
|
| | |
|
| | | #region ■ 删除本地文件_______________________
|
| | |
|
| | | /// <summary>
|
| | | /// 删除本地所有文件
|
| | | /// </summary>
|
| | | /// <param name="all">true:全部删除(用于住宅删除) false:重要的文件不删除</param>
|
| | | public static void DeleteAllLocationFile(bool all = true)
|
| | | {
|
| | | string dPath = Config.Instance.FullPath;
|
| | | if (System.IO.Directory.Exists(dPath) == false)
|
| | | {
|
| | | return;
|
| | | }
|
| | |
|
| | | //然后获取全部的文件
|
| | | List<string> listFile = Global.FileListByHomeId();
|
| | | foreach (string file in listFile)
|
| | | {
|
| | | if (all == false && IsNotDeleteFile(file) == true)
|
| | | {
|
| | | //这是不能删除的文件
|
| | | continue;
|
| | | }
|
| | | //删除文件
|
| | | Global.DeleteFilebyHomeId(file);
|
| | | }
|
| | | //如果是把文件全部删除的话,那么文件夹也一起删除掉
|
| | | if (all == true)
|
| | | {
|
| | | //删除文件夹
|
| | | System.IO.Directory.Delete(dPath, true);
|
| | | }
|
| | | }
|
| | |
|
| | | /// <summary>
|
| | | /// 判断是不是不应该删除的文件
|
| | | /// </summary>
|
| | | /// <param name="fileName"></param>
|
| | | /// <returns></returns>
|
| | | public static bool IsNotDeleteFile(string fileName)
|
| | | {
|
| | | if (fileName == "Config.json")
|
| | | {
|
| | | //不能删除Config文件
|
| | | return true;
|
| | | }
|
| | | else if (fileName.StartsWith("House_") == true)
|
| | | {
|
| | | //不能删除住宅文件
|
| | | return true;
|
| | | }
|
| | | return false;
|
| | | }
|
| | |
|
| | | #endregion
|
| | |
| | | #region ■ 拼接信息___________________________
|
| | |
|
| | | /// <summary>
|
| | | /// 拼接路径(全路径),以住宅ID的文件夹为起点,当没有指定参数时,则返回【住宅ID的文件夹】的全路径
|
| | | /// </summary>
|
| | | /// <param name="listNames">要拼接的路径</param>
|
| | | /// <returns></returns>
|
| | | public static string CombinePath(params object[] listNames)
|
| | | {
|
| | | string rootPath = Config.Instance.FullPath;
|
| | | if (listNames == null || listNames.Length == 0)
|
| | | {
|
| | | return rootPath;
|
| | | }
|
| | | foreach (var file in listNames)
|
| | | {
|
| | | if (file == null)
|
| | | {
|
| | | continue;
|
| | | }
|
| | | rootPath = System.IO.Path.Combine(rootPath, file.ToString());
|
| | | }
|
| | | return rootPath;
|
| | | }
|
| | |
|
| | | /// <summary>
|
| | | /// 拼接网关回复超时的信息
|
| | | /// </summary>
|
| | | /// <param name="errorMsg">错误信息</param>
|
| | |
| | | if (Common.Config.Instance.HomeId != UserCenterResourse.AccountOption.OldHomeStringId
|
| | | || Common.Config.Instance.Account != UserCenterResourse.AccountOption.OldAccountId)
|
| | | {
|
| | | //断开远程Mqtt连接
|
| | | HdlThreadLogic.Current.RunThread(async () =>
|
| | | {
|
| | | await ZigBee.Device.ZbGateway.DisConnectRemoteMqttClient();
|
| | | }, ShowErrorMode.NO);
|
| | |
|
| | | //清空所有成员缓存
|
| | | ClearAllMemberMemory();
|
| | |
|
| | |
| | | var optionInfo = UserCenterResourse.AccountOption.Load();
|
| | | UserCenterResourse.AccountOption = optionInfo;
|
| | | //变更根用户图片目录路径
|
| | | UserCenterResourse.AccountOption.UserPictruePath = System.IO.Path.Combine(Shared.IO.FileUtils.RootPath, Config.Instance.Guid, DirNameResourse.UserPictrueDirectory);
|
| | | UserCenterResourse.AccountOption.UserPictruePath = DirNameResourse.UserPictrueDirectory;
|
| | |
|
| | | //加载住宅配置信息
|
| | | UserCenterResourse.ResidenceOption = UserCenterResourse.ResidenceOption.Load();
|
| | |
| | | //读取隐匿配置
|
| | | HdlBackupLogic.Current.LoadHideOption();
|
| | | }
|
| | |
|
| | | //预创建个人中心全部的文件夹
|
| | | CreatAllUserCenterDirectory();
|
| | | HdlFileLogic.Current.CreatAllUserCenterDirectory();
|
| | |
|
| | | //关闭所有接收
|
| | | HdlGatewayReceiveLogic.Current.RemoveAllEvent();
|
| | |
| | | HdlGatewayLogic.Current.SynchronizeDbGateway();
|
| | | }
|
| | |
|
| | | //断开远程Mqtt连接,重新连接
|
| | | HdlThreadLogic.Current.RunThread(async () =>
|
| | | {
|
| | | HdlGatewayLogic.Current.ClearAllRealGateway();
|
| | | await ZigBee.Device.ZbGateway.DisConnectRemoteMqttClient();
|
| | | }, ShowErrorMode.NO);
|
| | |
|
| | | //刷新APP前一次选择的网关ID(可以反复调用,需要在网关初始化完了之后才能调用)
|
| | | HdlGatewayLogic.Current.RefreshAppOldSelectGatewayId();
|
| | |
|
| | |
| | | //清空所有成员缓存
|
| | | ClearAllMemberMemory();
|
| | | //预创建个人中心全部的文件夹
|
| | | CreatAllUserCenterDirectory();
|
| | | HdlFileLogic.Current.CreatAllUserCenterDirectory();
|
| | | //关闭所有接收
|
| | | HdlGatewayReceiveLogic.Current.RemoveAllEvent();
|
| | | //初始化本地的网关信息
|
| | |
| | | //序列化对象
|
| | | var requestJson = JsonConvert.SerializeObject(pra);
|
| | | //访问接口
|
| | | byte[] byteData = CommonPage.Instance.RequestHttpsZigbeeBytesResultAsync("ZigbeeUsers/GetAccountInfo", Encoding.UTF8.GetBytes(requestJson));
|
| | | byte[] byteData = CommonPage.Instance.RequestHttpsZigbeeBytesResultAsync("ZigbeeUsers/GetAccountInfo", Encoding.UTF8.GetBytes(requestJson), "POST", 4);
|
| | | if (byteData == null)
|
| | | {
|
| | | return -1;
|
| | |
| | | userInfo.AuthorityText = Language.StringByID(R.MyInternationalizationString.uMember);
|
| | | }
|
| | |
|
| | | if (UserCenterResourse.UserInfo.AuthorityNo != userInfo.AuthorityNo)
|
| | | //UserInfo.AuthorityNo==0代表本地还没有生成文件,这个时候不需要处理
|
| | | if (UserCenterResourse.UserInfo.AuthorityNo != userInfo.AuthorityNo
|
| | | && UserCenterResourse.UserInfo.AuthorityNo != 0)
|
| | | {
|
| | | //如果登陆的账号的权限和上一次的不一样,则删除本地这个住宅全部的文件,从头再来
|
| | | string dirPath = CombinePath();
|
| | | string dirPath = Config.Instance.FullPath;
|
| | | if (System.IO.Directory.Exists(dirPath) == true)
|
| | | {
|
| | | try
|
| | | {
|
| | | //同步数据的判断文件(以防万一删除整个文件夹失败的时候,这个文件被删的话,应该没什么大问题)
|
| | | string SynchronizeFile = UserCenterLogic.CombinePath(DirNameResourse.LocalMemoryDirectory, DirNameResourse.AutoDownLoadBackupCheckFile);
|
| | | string SynchronizeFile = DirNameResourse.AutoDownLoadBackupCheckFile;
|
| | | //如果本地已经拥有了这个文件,则说明不是新手机,不再自动还原
|
| | | if (System.IO.File.Exists(SynchronizeFile) == true)
|
| | | {
|
| | | System.IO.File.Delete(SynchronizeFile);
|
| | | }
|
| | | //删除整个文件夹
|
| | | System.IO.Directory.Delete(dirPath, true);
|
| | | HdlFileLogic.Current.DeleteFile(SynchronizeFile);
|
| | | HdlFileLogic.Current.DeleteDirectory(dirPath);
|
| | | }
|
| | | catch { }
|
| | | //创建住宅文件夹
|
| | | Global.CreateHomeDirectory(Config.Instance.HomeId);
|
| | | //预创建个人中心全部的文件夹
|
| | | CreatAllUserCenterDirectory();
|
| | | HdlFileLogic.Current.CreatAllUserCenterDirectory();
|
| | | }
|
| | | }
|
| | | if (string.IsNullOrEmpty(userInfo.UserName) == true)
|
| | |
| | | //密码验证
|
| | | UserCenterResourse.AccountOption.PswAuthentication = UserCenterResourse.UserInfo.StringPwd == null ? string.Empty : UserCenterResourse.UserInfo.StringPwd;
|
| | | UserCenterResourse.UserInfo.StringPwd = null;
|
| | | //保存缓存
|
| | | UserCenterResourse.AccountOption.Save();
|
| | |
|
| | | //初始化管理员控制主人的连接地址(因为这个连接Token是不会改变的,所以只需要初始化一次)
|
| | | var flage = InitAdminConnectMainInfo();
|
| | |
| | | /// <returns></returns>
|
| | | private static UserInformation GetUserInformationFromLocation()
|
| | | {
|
| | | string fileName = CombinePath(DirNameResourse.LocalMemoryDirectory, DirNameResourse.UserInfoFile);
|
| | | var value = LoadFileContent(fileName);
|
| | | var value = HdlFileLogic.Current.ReadFileTextContent(DirNameResourse.UserInfoFile);
|
| | | if (value == null)
|
| | | {
|
| | | return new UserInformation();
|
| | |
| | | /// 重新初始化登陆账号的信息(旨在对应那一瞬间,网络不好,导致误判的情况)
|
| | | /// </summary>
|
| | | /// <returns></returns>
|
| | | private static bool ReInitUserAccoutInfo(List<string> listNotShowError)
|
| | | public static bool ReInitUserAccoutInfo()
|
| | | {
|
| | | //重新初始化账号信息
|
| | | var result = InitUserAccoutInfo(false);
|
| | | //连接不了外网的时候
|
| | | if (result == -1)
|
| | | {
|
| | | if (listNotShowError != null && listNotShowError.Contains("NotCheck") == true)
|
| | | {
|
| | | //有这个标识时,不提示错误
|
| | | return false;
|
| | | }
|
| | | Application.RunOnMainThread(() =>
|
| | | {
|
| | | //当前无网络连接,请确认网络
|
| | | var alert = new ShowMsgControl(ShowMsgType.Tip, Language.StringByID(R.MyInternationalizationString.uNowIsDonotNetworkAndCheckNetwork));
|
| | | alert.Show();
|
| | | });
|
| | | }
|
| | | if (result == 1)
|
| | | {
|
| | | //同步云端的网关id,如果本地拥有云端不存在的id,则表示应该被换绑了,直接删除
|
| | |
| | | /// </summary>
|
| | | private static void SaveUserInformationToLocation()
|
| | | {
|
| | | string fullName = UserCenterLogic.CombinePath(DirNameResourse.LocalMemoryDirectory, DirNameResourse.UserInfoFile);
|
| | | //写入内容
|
| | | SaveFileContent(fullName, UserCenterResourse.UserInfo);
|
| | | HdlFileLogic.Current.SaveFileContent(DirNameResourse.UserInfoFile, UserCenterResourse.UserInfo);
|
| | |
|
| | | //搞一下主人的默认头像
|
| | | string defultFile = IO.FileUtils.GetImageFilePath("Center/Admin.png");
|
| | |
| | |
|
| | | #endregion
|
| | |
|
| | | #region ■ 预创建个人中心全部的文件夹_________
|
| | |
|
| | | /// <summary>
|
| | | /// 预创建个人中心全部的文件夹
|
| | | /// </summary>
|
| | | public static void CreatAllUserCenterDirectory()
|
| | | {
|
| | | //本地缓存的根目录
|
| | | string LocalDirectory = UserCenterLogic.CombinePath(DirNameResourse.LocalMemoryDirectory);
|
| | | Global.CreateEmptyDirectory(LocalDirectory);
|
| | |
|
| | | //自动备份【文件夹】(编辑,追加)
|
| | | string directory = System.IO.Path.Combine(LocalDirectory, DirNameResourse.AutoBackupDirectory);
|
| | | Global.CreateEmptyDirectory(directory);
|
| | |
|
| | | //自动备份【文件夹】(删除)
|
| | | directory = System.IO.Path.Combine(LocalDirectory, DirNameResourse.AutoBackupdeleteDirectory);
|
| | | Global.CreateEmptyDirectory(directory);
|
| | |
|
| | | //下载备份的时候所使用的临时【文件夹】
|
| | | directory = System.IO.Path.Combine(LocalDirectory, DirNameResourse.DownLoadBackupTempDirectory);
|
| | | Global.CreateEmptyDirectory(directory);
|
| | |
|
| | | //保存安防记录的【文件夹】
|
| | | directory = System.IO.Path.Combine(LocalDirectory, DirNameResourse.SafeguardAlarmDirectory);
|
| | | Global.CreateEmptyDirectory(directory);
|
| | |
|
| | | //上传网关备份文件到云端的临时【文件夹】
|
| | | directory = System.IO.Path.Combine(LocalDirectory, DirNameResourse.GatewayBackupDirectory);
|
| | | Global.CreateEmptyDirectory(directory);
|
| | |
|
| | | //下载分享文件的临时【文件夹】
|
| | | directory = System.IO.Path.Combine(LocalDirectory, DirNameResourse.DownLoadShardDirectory);
|
| | | Global.CreateEmptyDirectory(directory);
|
| | |
|
| | | //LOG出力【文件夹】
|
| | | directory = System.IO.Path.Combine(LocalDirectory, DirNameResourse.LogDirectory);
|
| | | Global.CreateEmptyDirectory(directory);
|
| | |
|
| | | //用户图片目录路径【文件夹】
|
| | | if (UserCenterResourse.AccountOption.UserPictruePath != string.Empty && !System.IO.Directory.Exists(UserCenterResourse.AccountOption.UserPictruePath)) |
| | | { |
| | | System.IO.Directory.CreateDirectory(UserCenterResourse.AccountOption.UserPictruePath); |
| | | }
|
| | | }
|
| | |
|
| | | #endregion
|
| | |
|
| | | #region ■ 获取控制主人账号的Token____________
|
| | |
|
| | | /// <summary>
|
| | |
| | | /// <param name="result">同步结果 -1:异常 0:已经同步过,不需要同步 1:正常同步 2:没有自动备份数据</param>
|
| | | private static void ShowGuideForm(int result)
|
| | | {
|
| | | var checkFile = System.IO.Path.Combine(Shared.IO.FileUtils.RootPath, DirNameResourse.GuideFile);
|
| | | var checkFile = DirNameResourse.GuideFile;
|
| | | if (System.IO.File.Exists(checkFile) == true)
|
| | | {
|
| | | //不需要显示
|
| | |
| | | {
|
| | | var utcTime = Convert.ToDateTime(timeText);
|
| | | return TimeZoneInfo.ConvertTimeFromUtc(utcTime, TimeZoneInfo.Local);
|
| | | }
|
| | |
|
| | | #endregion
|
| | |
|
| | | #region ■ 文件保存和读取_____________________
|
| | |
|
| | | /// <summary>
|
| | | /// 文件保存(整天忘记,所以建一个函数来玩玩)
|
| | | /// </summary>
|
| | | /// <param name="fullName">全路径</param>
|
| | | /// <param name="obj">需要序列化的东西</param>
|
| | | public static void SaveFileContent(string fullName, object obj)
|
| | | {
|
| | | var data = JsonConvert.SerializeObject(obj);
|
| | | SaveTexToFile(fullName, data);
|
| | | }
|
| | |
|
| | | /// <summary>
|
| | | /// 文件保存(整天忘记,所以建一个函数来玩玩)
|
| | | /// </summary>
|
| | | /// <param name="fullName">全路径</param>
|
| | | /// <param name="obj">需要序列化的东西</param>
|
| | | public static void SaveTexToFile(string fullName, string textValue)
|
| | | {
|
| | | var byteData = Encoding.UTF8.GetBytes(textValue);
|
| | | //写入内容
|
| | | System.IO.FileStream fileStream = null;
|
| | | try
|
| | | {
|
| | | fileStream = new System.IO.FileStream(fullName, System.IO.FileMode.Create, System.IO.FileAccess.Write);
|
| | | fileStream.Write(byteData, 0, byteData.Length);
|
| | | fileStream.Flush();
|
| | | }
|
| | | catch { }
|
| | | finally
|
| | | {
|
| | | fileStream?.Close();
|
| | | }
|
| | | }
|
| | |
|
| | | /// <summary>
|
| | | /// 读取文件,不限制住宅(文件不存在返回null,整天忘记,所以建一个函数来玩玩)
|
| | | /// </summary>
|
| | | /// <param name="fullName">全路径</param>
|
| | | /// <returns></returns>
|
| | | public static string LoadFileContent(string fullName)
|
| | | {
|
| | | //读取文件
|
| | | var varByte = ReadFileContent(fullName);
|
| | | if (varByte == null)
|
| | | {
|
| | | return null;
|
| | | }
|
| | | return Encoding.UTF8.GetString(varByte);
|
| | | }
|
| | |
|
| | | /// <summary>
|
| | | /// 读取文件,不限制住宅,文件不存在返回null
|
| | | /// </summary>
|
| | | /// <param name="fullName">全路径</param>
|
| | | /// <returns></returns>
|
| | | public static byte[] ReadFileContent(string fullName)
|
| | | {
|
| | | if (System.IO.File.Exists(fullName) == false)
|
| | | {
|
| | | return null;
|
| | | }
|
| | | System.IO.FileStream fileStream = null;
|
| | | try
|
| | | {
|
| | | fileStream = new System.IO.FileStream(fullName, System.IO.FileMode.Open, System.IO.FileAccess.Read);
|
| | | byte[] array = new byte[fileStream.Length];
|
| | | fileStream.Read(array, 0, array.Length);
|
| | | return array;
|
| | | }
|
| | | catch
|
| | | {
|
| | | return null;
|
| | | }
|
| | | finally
|
| | | {
|
| | | fileStream?.Close();
|
| | | }
|
| | | }
|
| | |
|
| | | #endregion
|
| | |
| | | /// <summary>
|
| | | /// 本地缓存的根目录【文件夹】,不需要备份,也不需要上传,只用于当前手机的缓存
|
| | | /// </summary>
|
| | | public const string LocalMemoryDirectory = "43ae770b6035427b21bddd7e6a1eeb88";
|
| | | public static string LocalMemoryDirectory
|
| | | {
|
| | | get { return System.IO.Path.Combine(Common.Config.Instance.FullPath, "43ae770b6035427b21bddd7e6a1eeb88"); }
|
| | | }
|
| | | /// <summary>
|
| | | /// 自动备份【文件夹】(编辑,追加)
|
| | | /// </summary>
|
| | | public const string AutoBackupDirectory = "d560f44a32930569c0328bfe0c7d3beaf6a58bcb2d5f1d3b";
|
| | | public static string AutoBackupDirectory
|
| | | {
|
| | | get { return System.IO.Path.Combine(LocalMemoryDirectory, "d560f44a32930569c0328bfe0c7d3beaf6a58bcb2d5f1d3b"); }
|
| | | }
|
| | | /// <summary>
|
| | | /// 自动备份【文件夹】(删除)
|
| | | /// </summary>
|
| | | public const string AutoBackupdeleteDirectory = "eced1a7b88bb9776ff31c79f6e7a48d69eac74ee0c447d6b";
|
| | | /// <summary>
|
| | | /// 是否自动下载云端的备份数据的【判断文件】
|
| | | /// </summary>
|
| | | public const string AutoDownLoadBackupCheckFile = "93ee2d7241c3d19d7d94317f51a94d7fab1400f8f4f37a5a";
|
| | | public static string AutoBackupdeleteDirectory
|
| | | {
|
| | | get { return System.IO.Path.Combine(LocalMemoryDirectory, "eced1a7b88bb9776ff31c79f6e7a48d69eac74ee0c447d6b"); }
|
| | | }
|
| | | /// <summary>
|
| | | /// 下载备份的时候所使用的临时【文件夹】
|
| | | /// </summary>
|
| | | public const string DownLoadBackupTempDirectory = "2492bc79ce8b87b49beaea261f87d52efc5dd3dfae2c6811be65781d5faccd40";
|
| | | public static string DownLoadBackupTempDirectory
|
| | | {
|
| | | get { return System.IO.Path.Combine(LocalMemoryDirectory, "2492bc79ce8b87b49beaea261f87d52efc5dd3dfae2c6811be65781d5faccd40"); }
|
| | | }
|
| | | /// <summary>
|
| | | /// 保存APP最后选择的网关ID的【文件名字】(不需要备份及上传)
|
| | | /// </summary>
|
| | | public const string AppOldSelectGatewayFile = "1f2d13116b051b76b111b99246bb23f1";
|
| | | public static string AppOldSelectGatewayFile
|
| | | {
|
| | | get { return System.IO.Path.Combine(LocalMemoryDirectory, "1f2d13116b051b76b111b99246bb23f1"); }
|
| | | }
|
| | | /// <summary>
|
| | | /// 保存安防记录的【文件夹】
|
| | | /// </summary>
|
| | | public const string SafeguardAlarmDirectory = "b101c307ddc2fae59a133a31604304560180c5748135de81"; |
| | | public static string SafeguardAlarmDirectory
|
| | | {
|
| | | get { return System.IO.Path.Combine(LocalMemoryDirectory, "b101c307ddc2fae59a133a31604304560180c5748135de81"); }
|
| | | } |
| | | /// <summary>
|
| | | /// 保存门锁记录的【文件夹】
|
| | | /// </summary>
|
| | | public const string DoorLockAlarmDirectory = "4662b1f6eb97dbe44395a2546fd47c273a3def89f56951c6";
|
| | | public static string DoorLockAlarmDirectory
|
| | | {
|
| | | get { return System.IO.Path.Combine(LocalMemoryDirectory, "4662b1f6eb97dbe44395a2546fd47c273a3def89f56951c6"); }
|
| | | }
|
| | | /// <summary>
|
| | | /// 安防用户密码的缓存密码【文件】
|
| | | /// </summary>
|
| | | public const string SafeguardUserPassword = "b101c307ddc2fae587d864275bb8a23478b37ce3bd5c5db1";
|
| | | /// <summary>
|
| | | /// 上传网关备份文件到云端的临时【文件夹】
|
| | | /// </summary>
|
| | | public const string GatewayBackupDirectory = "99a6644e29e7bdcd65d85219312eb4f4cf013d26f4e12925";
|
| | | public static string SafeguardUserPassword
|
| | | {
|
| | | get { return System.IO.Path.Combine(LocalMemoryDirectory, "b101c307ddc2fae587d864275bb8a23478b37ce3bd5c5db1"); }
|
| | | }
|
| | | /// <summary>
|
| | | /// 下载分享文件的临时【文件夹】
|
| | | /// </summary>
|
| | | public const string DownLoadShardDirectory = "98f878a57c59bb6538677bc55187ffab6e8def815981fdbe";
|
| | | public static string DownLoadShardDirectory
|
| | | {
|
| | | get { return System.IO.Path.Combine(LocalMemoryDirectory, "98f878a57c59bb6538677bc55187ffab6e8def815981fdbe"); }
|
| | | }
|
| | | /// <summary>
|
| | | /// 记录分享文件更新时间的【文件】
|
| | | /// </summary>
|
| | | public const string ShardFileUpdateTimeFile = "b4137733cb527d033a3f63d2b32cd6e0f886eef3cee19601";
|
| | | /// <summary>
|
| | | /// 记录自动备份文件更新时间的【文件】
|
| | | /// </summary>
|
| | | public const string AutoBackFileUpdateTimeFile = "9479e724666d970f1a2df4fa67cc456b74b31c4d3fce3b4f8c8eef2f2c0559ec";
|
| | | public static string ShardFileUpdateTimeFile
|
| | | {
|
| | | get { return System.IO.Path.Combine(LocalMemoryDirectory, "b4137733cb527d033a3f63d2b32cd6e0f886eef3cee19601"); }
|
| | | }
|
| | | /// <summary>
|
| | | /// 保存用户个人信息的【文件】
|
| | | /// </summary>
|
| | | public const string UserInfoFile = "c24d43aab01bbe521535c9fae517ffab";
|
| | | public static string UserInfoFile
|
| | | {
|
| | | get { return System.IO.Path.Combine(LocalMemoryDirectory, "c24d43aab01bbe521535c9fae517ffab"); }
|
| | | }
|
| | | /// <summary>
|
| | | /// 保存断网时候,备份网关id用的【文件】
|
| | | /// </summary>
|
| | | public const string BackupGatewayIdFile = "5f7fdfe4258d4cd19a433412468a586834643bed528cdba1";
|
| | | public static string BackupGatewayIdFile
|
| | | {
|
| | | get { return System.IO.Path.Combine(LocalMemoryDirectory, "5f7fdfe4258d4cd19a433412468a586834643bed528cdba1"); }
|
| | | }
|
| | | /// <summary>
|
| | | /// 自动备份不需要再次提醒的【文件名】(不需要备份及上传)
|
| | | /// </summary>
|
| | | public const string AutoBackupNotPromptedFile = "9479e724666d970fb9ae5dff2b739cf1bc8c1a95d63bf182dc8f290cac98592f";
|
| | | public static string AutoBackupNotPromptedFile
|
| | | {
|
| | | get { return System.IO.Path.Combine(LocalMemoryDirectory, "9479e724666d970fb9ae5dff2b739cf1bc8c1a95d63bf182dc8f290cac98592f"); }
|
| | | }
|
| | | /// <summary>
|
| | | /// 干接点私有属性的保存文件
|
| | | /// </summary>
|
| | | public const string DryContactFunctionFile = "10afbada0199511de13edc60259ed03e6ebc817d8a53adce";
|
| | | public static string DryContactFunctionFile
|
| | | {
|
| | | get { return System.IO.Path.Combine(Common.Config.Instance.FullPath, "10afbada0199511de13edc60259ed03e6ebc817d8a53adce"); }
|
| | | }
|
| | | /// <summary>
|
| | | /// 存放用户图片的【文件夹】
|
| | | /// </summary>
|
| | | public const string UserPictrueDirectory = "e3263f227598072fef2a204fb1656cd2";
|
| | | public static string UserPictrueDirectory
|
| | | {
|
| | | get { return System.IO.Path.Combine(Shared.IO.FileUtils.RootPath, Common.Config.Instance.Guid, "e3263f227598072fef2a204fb1656cd2"); }
|
| | | }
|
| | | /// <summary>
|
| | | /// 保存账号配置的【文件】
|
| | | /// </summary>
|
| | | public const string AccountOptionFile = "d33690329dfdf2e5dcce0280893b95a0db47b5be13b46aa0";
|
| | | public static string AccountOptionFile
|
| | | {
|
| | | get { return System.IO.Path.Combine(Shared.IO.FileUtils.RootPath, Common.Config.Instance.Guid, "d33690329dfdf2e5dcce0280893b95a0db47b5be13b46aa0"); }
|
| | | }
|
| | | /// <summary>
|
| | | /// 保存住宅配置的【文件】
|
| | | /// </summary>
|
| | | public const string ResidenceOptionFile = "b79583bed6909a52849eaea268449aee15f29d3bdf8b5ca3";
|
| | | /// <summary>
|
| | | /// 保存楼层顺序的【文件】
|
| | | /// </summary>
|
| | | public const string FloorSortFile = "2b156ce95c29de53578282f4d7228f60";
|
| | | /// <summary>
|
| | | /// 保存房间顺序的【文件】
|
| | | /// </summary>
|
| | | public const string RoomSortFile = "b1b9f1a50064016f62dea3f160703de2";
|
| | | public static string ResidenceOptionFile
|
| | | {
|
| | | get { return System.IO.Path.Combine(LocalMemoryDirectory, "b79583bed6909a52849eaea268449aee15f29d3bdf8b5ca3"); }
|
| | | }
|
| | | /// <summary>
|
| | | /// 保存Log的【文件夹】
|
| | | /// </summary>
|
| | | public const string LogDirectory = "820c65b54b6f3f2a";
|
| | | public static string LogDirectory
|
| | | {
|
| | | get { return System.IO.Path.Combine(LocalMemoryDirectory, "820c65b54b6f3f2a"); }
|
| | | }
|
| | | /// <summary>
|
| | | /// 分享楼层的【文件】
|
| | | /// 是否自动下载云端的备份数据的【判断文件】
|
| | | /// </summary>
|
| | | public const string ShardFloorFile = "5f05f7a6f26c51d1b096dc777f6c02f2";
|
| | | public static string AutoDownLoadBackupCheckFile
|
| | | {
|
| | | get { return System.IO.Path.Combine(LocalMemoryDirectory, "93ee2d7241c3d19d7d94317f51a94d7fab1400f8f4f37a5a"); }
|
| | | }
|
| | | /// <summary>
|
| | | /// 物理设备属于哪个房间的【文件】
|
| | | /// </summary>
|
| | | public const string DeviceRoomIdFile = "020945dd7966a7550090d3c04a04d93cd2278eb4e6aebcf6";
|
| | | public static string DeviceRoomIdFile
|
| | | {
|
| | | get { return System.IO.Path.Combine(Common.Config.Instance.FullPath, "020945dd7966a7550090d3c04a04d93cd2278eb4e6aebcf6"); }
|
| | | }
|
| | | /// <summary>
|
| | | /// 保存意见反馈次数的【文件】
|
| | | /// </summary>
|
| | | public const string SuggestionFile = "f782709778b751ef2b3840f17e407ead";
|
| | | public static string SuggestionFile
|
| | | {
|
| | | get { return System.IO.Path.Combine(Shared.IO.FileUtils.RootPath, Common.Config.Instance.Guid, "f782709778b751ef2b3840f17e407ead"); }
|
| | | }
|
| | | /// <summary>
|
| | | /// 检测引导的【文件】
|
| | | /// </summary>
|
| | | public const string GuideFile = "cad1afb384fb482de753fc37ebe84f9e";
|
| | | public static string GuideFile
|
| | | {
|
| | | get { return System.IO.Path.Combine(Shared.IO.FileUtils.RootPath, "cad1afb384fb482de753fc37ebe84f9e"); }
|
| | | }
|
| | | /// <summary>
|
| | | /// 打开Gbs的判断【文件】(临时)
|
| | | /// 记录发送和接收的数据Log
|
| | | /// </summary>
|
| | | public const string OpenGbsFile = "cd8f75492cb65ef0951442460336db62";
|
| | | public static string SendAndReceveDataLog
|
| | | {
|
| | | get { return System.IO.Path.Combine(Common.Config.Instance.FullPath, LocalMemoryDirectory, "SendAndReceveLog.log"); }
|
| | | }
|
| | | /// <summary>
|
| | | /// 记录SocketReceive数据Log
|
| | | /// </summary>
|
| | | public static string SocketReceiveDataLog
|
| | | {
|
| | | get { return System.IO.Path.Combine(Common.Config.Instance.FullPath, LocalMemoryDirectory, "SocketReceiveDataLog.log"); }
|
| | | }
|
| | | /// <summary>
|
| | | /// 分享楼层的【文件名】
|
| | | /// </summary>
|
| | | public const string ShardFloorFile = "5f05f7a6f26c51d1b096dc777f6c02f2";
|
| | |
|
| | | /// <summary>
|
| | | /// 记录自动备份上传日期的【文件】,不加密
|
| | | /// </summary>
|
| | | public const string UpLoadAutoBackDayFile = "UpLoadAutoBackDayFile";
|
| | | //------------------------以下为辅助文件------------------------
|
| | | /// <summary>
|
| | | /// 显示功能菜单的【标识文件】,不加密
|
| | | /// </summary>
|
| | |
| | | /// 功能备份的名字 这个东西不加密
|
| | | /// </summary>
|
| | | public const string OptionBackupName = "##Option##";
|
| | | /// <summary>
|
| | | /// 记录发送和接收的数据Log
|
| | | /// </summary>
|
| | | public static string SendAndReceveDataLog
|
| | | {
|
| | | get { return System.IO.Path.Combine(Common.Config.Instance.FullPath, LocalMemoryDirectory, "SendAndReceveLog.log"); }
|
| | | }
|
| | | }
|
| | | }
|
| | |
| | | listText.Add(Language.StringByID(R.MyInternationalizationString.uReverseDirection));//反向
|
| | |
|
| | | var form = new BottomItemSelectForm();
|
| | | form.AddForm(Language.StringByID(R.MyInternationalizationString.uDirectionSelect), listText, nowSelectNo);
|
| | | form.AddForm(Language.StringByID(R.MyInternationalizationString.uDirectionSelect), listText, null, nowSelectNo);
|
| | | form.FinishSelectEvent += (index) =>
|
| | | {
|
| | | //变更方向
|
| | |
| | | listText.Add(Language.StringByID(R.MyInternationalizationString.uReverseDirection));//反向
|
| | |
|
| | | var form = new BottomItemSelectForm();
|
| | | form.AddForm(Language.StringByID(R.MyInternationalizationString.uDirectionSelect), listText, nowSelectNo);
|
| | | form.AddForm(Language.StringByID(R.MyInternationalizationString.uDirectionSelect), listText, null, nowSelectNo);
|
| | | form.FinishSelectEvent += (index) =>
|
| | | {
|
| | | //变更方向
|
| | |
| | | this.SetDoorTime();
|
| | | //新入网的设备,清空掉它的房间
|
| | | this.ClearDeviceFromRoom();
|
| | | //添加设备的时候,关闭左划菜单的未分配界面
|
| | | MainPage.LeftListRoomViewFrom.Instance?.CloseUnallocatedRoomForm();
|
| | | }
|
| | |
|
| | | /// <summary>
|
| | |
| | | //这里先去获取它的干接点类型
|
| | | this.ShowProgressBar();
|
| | | //获取第七回路的配置信息
|
| | | listRelayInfo7 = await HdlDevicePanelLogic.Current.GetDryContactConfigureInfo(nowSelectDevice);
|
| | | listRelayInfo7 = HdlDevicePanelLogic.Current.GetDryContactConfigureInfo(nowSelectDevice);
|
| | | if (listRelayInfo7 == null)
|
| | | {
|
| | | //关闭进度条
|
| | |
| | | var title = Language.StringByID(R.MyInternationalizationString.uSelectDryContactFunction);
|
| | |
|
| | | var form = new BottomItemSelectForm();
|
| | | form.AddForm(title, listText, nowSelectNo);
|
| | | form.AddForm(title, listText, null, nowSelectNo);
|
| | | form.FinishSelectEvent += (selectNo) =>
|
| | | {
|
| | | if (selectNo == nowSelectNo)
|
| | |
| | | rowMac.AddBottomLine(); |
| | | |
| | | //制造商
|
| | | string strProtuct = listDevice[0].DriveCode > 0 ? "HDL" : listDevice[0].ManufacturerName;
|
| | | string strProtuct = listDevice[0].ManufacturerName;
|
| | | if (listDevice[0].DriveCode > 0 || Common.LocalDevice.Current.IsHdlDevice(listDevice[0]) == true)
|
| | | {
|
| | | strProtuct = "广州河东科技有限公司";
|
| | | }
|
| | | var rowProtuct = new FrameRowControl(listView.rowSpace / 2);
|
| | | rowProtuct.UseClickStatu = false; |
| | | listView.AddChidren(rowProtuct); |
| | | rowProtuct.AddLeftCaption(Language.StringByID(R.MyInternationalizationString.uManufacturerName), 400); |
| | | rowProtuct.AddLeftCaption(Language.StringByID(R.MyInternationalizationString.uManufacturerName), 600); |
| | | rowProtuct.AddMostRightView(strProtuct, 600); |
| | | |
| | | listView.AdjustRealHeight(Application.GetRealHeight(23)); |
| | |
| | |
|
| | | var form = new BottomItemSelectForm();
|
| | | form.CancelCallEvent = false;//允许取消
|
| | | form.AddForm(title, listText, nowSelectNo);
|
| | | form.AddForm(title, listText, null, nowSelectNo);
|
| | | form.FinishSelectEvent += (selectNo) =>
|
| | | {
|
| | | if (selectNo == nowSelectNo)
|
| | |
| | |
|
| | | var form = new BottomItemSelectForm();
|
| | | form.CancelCallEvent = false;//允许取消
|
| | | form.AddForm(title, listText, nowSelectNo);
|
| | | form.AddForm(title, listText, null, nowSelectNo);
|
| | | form.FinishSelectEvent += (selectNo) =>
|
| | | {
|
| | | if (selectNo == nowSelectNo)
|
| | |
| | |
|
| | | var form = new BottomItemSelectForm();
|
| | | form.CancelCallEvent = false;//允许取消
|
| | | form.AddForm(title, listText, nowSelectNo);
|
| | | form.AddForm(title, listText, null, nowSelectNo);
|
| | | form.FinishSelectEvent += (selectNo) =>
|
| | | {
|
| | | if (selectNo == nowSelectNo)
|
| | |
| | | row1.ButtonClickEvent += (sender, e) =>
|
| | | {
|
| | | var form = new BottomItemSelectForm();
|
| | | form.AddForm(btnCaption1.Text, listSelect, this.pirConfigure.mode == 0 ? 1 : 0);
|
| | | form.AddForm(btnCaption1.Text, listSelect, null, this.pirConfigure.mode == 0 ? 1 : 0);
|
| | | form.FinishSelectEvent += (value) =>
|
| | | {
|
| | | this.isDataChanged = true;
|
| | |
| | | row2.ButtonClickEvent += (sender, e) =>
|
| | | {
|
| | | var form = new BottomItemSelectForm();
|
| | | form.AddForm(btnCaption2.Text, listSelect, this.pirConfigure.type);
|
| | | form.AddForm(btnCaption2.Text, listSelect, null, this.pirConfigure.type);
|
| | | form.FinishSelectEvent += (value) =>
|
| | | {
|
| | | this.isDataChanged = true;
|
| | |
| | | rowBeloneArea.SelectRoomEvent += (roomKeys) =>
|
| | | {
|
| | | //变更网关房间
|
| | | HdlGatewayLogic.Current.ChangedGatewayRoom(this.zbGateway, roomKeys);
|
| | | HdlGatewayLogic.Current.ChangedGatewayRoom(this.zbGateway.GwId, roomKeys);
|
| | | };
|
| | |
|
| | | //所属住宅
|
| | |
| | | /// 设置网关名字
|
| | | /// </summary>
|
| | | /// <param name="gatewayName">网关名称</param>
|
| | | private async void SetGatewayName(string gatewayName, bool closeForm)
|
| | | private void SetGatewayName(string gatewayName, bool closeForm)
|
| | | {
|
| | | //修改网关名
|
| | | var result = await HdlGatewayLogic.Current.ReName(zbGateway, gatewayName);
|
| | | var result = HdlGatewayLogic.Current.ReName(zbGateway, gatewayName);
|
| | | //网关修改失败
|
| | | if (result == false)
|
| | | {
|
| | |
| | | rowBeloneArea.SelectRoomEvent += (roomKeys) =>
|
| | | {
|
| | | //变更网关房间
|
| | | HdlGatewayLogic.Current.ChangedGatewayRoom(this.zbGateway, roomKeys);
|
| | | HdlGatewayLogic.Current.ChangedGatewayRoom(this.zbGateway.GwId, roomKeys);
|
| | | };
|
| | |
|
| | | //完成初始化桌布
|
| | |
| | | /// </summary>
|
| | | /// <param name="gatewayName">网关名称</param>
|
| | | /// <param name="closeForm">关闭界面</param>
|
| | | private async void SetGatewayName(string gatewayName, bool closeForm)
|
| | | private void SetGatewayName(string gatewayName, bool closeForm)
|
| | | {
|
| | | //打开进度条
|
| | | this.ShowProgressBar();
|
| | | //修改本地网关名
|
| | | var result = await HdlGatewayLogic.Current.ReName(zbGateway, gatewayName);
|
| | | var result = HdlGatewayLogic.Current.ReName(zbGateway, gatewayName);
|
| | | //关闭进度条
|
| | | this.CloseProgressBar();
|
| | |
|
| | |
| | | //底线
|
| | | frameRow.frameTable.AddBottomLine();
|
| | | }
|
| | | frameRow.frameTable.ButtonClickEvent += (sender, e) =>
|
| | | {
|
| | | var form = new GatewayProductInfoForm();
|
| | | form.AddForm(gateway);
|
| | | };
|
| | |
|
| | | if (dicZbGatewayDiv[gwid] == 2)
|
| | | {
|
| | | //换绑
|
| | | var btnBind = new NormalViewControl(Application.GetRealWidth(184), frameRow.Height, false);
|
| | | btnBind.BackgroundColor = 0xfffb744a;
|
| | | btnBind.TextAlignment = TextAlignment.Center;
|
| | | btnBind.TextColor = UserCenterColor.Current.White;
|
| | | btnBind.TextSize = 12;
|
| | | btnBind.TextID = R.MyInternationalizationString.uReBindAgain;
|
| | | frameRow.AddRightView(btnBind);
|
| | | btnBind.ButtonClickEvent += (sender, e) =>
|
| | | //需重新绑定
|
| | | frameRow.frameTable.AddMostRightView(Language.StringByID(R.MyInternationalizationString.uNeedToRebind), 300);
|
| | | }
|
| | |
|
| | | frameRow.frameTable.ButtonClickEvent += (sender, e) =>
|
| | | {
|
| | | if (dicZbGatewayDiv[gwid] == 2)
|
| | | {
|
| | | //确认绑定旧网关?
|
| | | string msg = Language.StringByID(R.MyInternationalizationString.uRebindGatewayMsg);
|
| | |
| | | var form = new GatewayRebindForm();
|
| | | form.AddForm(gateway, dicZbGatewayDiv);
|
| | | });
|
| | | };
|
| | | }
|
| | | }
|
| | | else
|
| | | {
|
| | | var form = new GatewayProductInfoForm();
|
| | | form.AddForm(gateway);
|
| | | }
|
| | | };
|
| | |
|
| | | //定位
|
| | | var btnPosition = frameRow.AddEditorControl(false);
|
| | | btnPosition.TextID = R.MyInternationalizationString.uFixedPosition;
|
| | |
| | | /// </summary>
|
| | | public virtual void ShowFrom()
|
| | | {
|
| | | Phone.MainPage.ListRoomViewFrom.Instance.CanClick = false;
|
| | | Phone.MainPage.LeftListRoomViewFrom.Instance.CanClick = false;
|
| | |
|
| | | UserView.UserPage.Instance.AddChidren(this);
|
| | | this.BackgroundColor = Common.ZigbeeColor.Current.GXCGrayBackgroundColor;
|
| | |
| | | var btnKnwon = this.AddIKnwonButton();
|
| | | btnKnwon.ButtonClickEvent += (sender, e) =>
|
| | | {
|
| | | Phone.MainPage.ListRoomViewFrom.Instance.CanClick = true;
|
| | | Phone.MainPage.LeftListRoomViewFrom.Instance.CanClick = true;
|
| | | this.RemoveFromParent();
|
| | | };
|
| | | }
|
| | |
| | | #region ■ 一般方法___________________________
|
| | |
|
| | | /// <summary>
|
| | | /// 把本地所有文件移动到自动备份文件夹
|
| | | /// </summary>
|
| | | private void CopyLocationAllFileToAutoBackDirectory()
|
| | | {
|
| | | List<string> listAllFile = Shared.Common.Global.FileListByHomeId();
|
| | |
|
| | | string strroot = Common.Config.Instance.FullPath;
|
| | | string autoPath = System.IO.Path.Combine(strroot, DirNameResourse.LocalMemoryDirectory, DirNameResourse.AutoBackupDirectory);
|
| | | foreach (string file in listAllFile)
|
| | | {
|
| | | //判断是否是应该上传的文件
|
| | | if (HdlBackupLogic.Current.IsNotUpLoadFile(file) == true)
|
| | | {
|
| | | continue;
|
| | | }
|
| | | string sourseName = System.IO.Path.Combine(strroot, file);
|
| | | string newName = System.IO.Path.Combine(autoPath, file);
|
| | | System.IO.File.Copy(sourseName, newName, true);
|
| | | }
|
| | | }
|
| | |
|
| | | /// <summary>
|
| | | /// 检测备考名称
|
| | | /// </summary>
|
| | | /// <param name="backName"></param>
|
| | |
| | | row1.ButtonClickEvent += (sender, e) =>
|
| | | {
|
| | | var form = new HideOptionFileListForm();
|
| | | form.AddForm(UserCenterLogic.CombinePath());
|
| | | form.AddForm(Common.Config.Instance.FullPath);
|
| | | };
|
| | |
|
| | | //查看全部文件
|
| | |
| | |
|
| | | private void AddRowControl(VerticalListControl listView, string directory, string directoryValue, bool addLine)
|
| | | {
|
| | | string myPath = UserCenterLogic.CombinePath(DirNameResourse.LocalMemoryDirectory, directoryValue);
|
| | | if (directoryValue == DirNameResourse.LocalMemoryDirectory)
|
| | | string localDir = DirNameResourse.LocalMemoryDirectory;
|
| | | string myPath = System.IO.Path.Combine(localDir, directoryValue);
|
| | | if (localDir.EndsWith(directoryValue) == true)
|
| | | {
|
| | | myPath = UserCenterLogic.CombinePath(DirNameResourse.LocalMemoryDirectory);
|
| | | myPath = localDir;
|
| | | }
|
| | | if (System.IO.Directory.Exists(myPath) == false)
|
| | | {
|
| | |
| | | {
|
| | | this.ClearBodyFrame();
|
| | |
|
| | | var listAllFile = HdlAutoBackupLogic.GetFileFromDirectory(directory);
|
| | | var listAllFile = HdlFileLogic.Current.GetFileFromDirectory(directory);
|
| | | listAllFile.Sort();
|
| | |
|
| | | var listView = new VerticalListControl(23);
|
| | |
| | | }
|
| | | });
|
| | | };
|
| | | if (directory == UserCenterLogic.CombinePath())
|
| | | if (directory == Common.Config.Instance.FullPath)
|
| | | {
|
| | | btnButon.CanClick = false;
|
| | | }
|
| | |
| | | }
|
| | | row1.frameTable.AddRightArrow();
|
| | |
|
| | | var btnUpLoad = row1.AddEditorControl();
|
| | | btnUpLoad.Text = "上传";
|
| | | btnUpLoad.ButtonClickEvent += (sender, e) =>
|
| | | {
|
| | | this.ShowMassage(ShowMsgType.Confirm, "是否上传该文件(测试)?", () =>
|
| | | {
|
| | | HdlThreadLogic.Current.RunThread(() =>
|
| | | {
|
| | | string tagrtFile = System.IO.Path.Combine(directory, fileName);
|
| | | HdlBackupLogic.Current.UpLoadByteDataToOptionBackup(fileName, HdlFileLogic.Current.ReadFileByteContent(tagrtFile));
|
| | | });
|
| | | });
|
| | | };
|
| | |
|
| | | var btnDelete = row1.AddDeleteControl();
|
| | | btnDelete.ButtonClickEvent += (sender, e) =>
|
| | | {
|
| | | this.ShowMassage(ShowMsgType.Confirm, "是否清除该缓存文件", () =>
|
| | | {
|
| | | var myFile = UserCenterLogic.CombinePath(directory, fileName);
|
| | | var myFile = System.IO.Path.Combine(Common.Config.Instance.FullPath, directory, fileName);
|
| | | try
|
| | | {
|
| | | System.IO.File.Delete(myFile);
|
| | |
| | | row1.frameTable.ButtonClickEvent += (sender, e) =>
|
| | | {
|
| | | var form = new HideOptionFileContentForm();
|
| | | form.AddForm(UserCenterLogic.CombinePath(directory, fileName));
|
| | | form.AddForm(System.IO.Path.Combine(Common.Config.Instance.FullPath, directory, fileName));
|
| | | };
|
| | | }
|
| | |
|
| | |
| | | this.AddNormalRowControl("Socket链接", 400, ZigBee.Common.Application.FindGateWaySocket.busSocket.Connected == true ? "true" : "false", 400);
|
| | | }
|
| | |
|
| | | int count = HdlGatewayLogic.Current.GetAllLocalGateway().Count;
|
| | | int count = ZbGateway.GateWayList.Count;
|
| | | var row1 = new FrameRowControl(listView.rowSpace / 2);
|
| | | listView.AddChidren(row1);
|
| | | row1.UseClickStatu = false;
|
| | | row1.AddLeftCaption("本地网关", 400);
|
| | | if (count > 0)
|
| | | {
|
| | | row1.UseClickStatu = true;
|
| | | row1.AddRightArrow();
|
| | | row1.ButtonClickEvent += (sender, e) =>
|
| | | {
|
| | | var form = new HideOptionGatewayListForm();
|
| | | form.AddForm(1);
|
| | | };
|
| | | }
|
| | | row1.AddMostRightView(count + "个", 400);
|
| | | row1.AddBottomLine();
|
| | |
|
| | | count = ZigBee.Device.ZbGateway.GateWayList.Count;
|
| | | row1 = new FrameRowControl(listView.rowSpace / 2);
|
| | | listView.AddChidren(row1);
|
| | | row1.UseClickStatu = false;
|
| | | row1.AddLeftCaption("缓存中的网关", 400);
|
| | | row1.AddLeftCaption("广播到的网关", 400);
|
| | | if (count > 0)
|
| | | {
|
| | | row1.UseClickStatu = true;
|
| | |
| | | }
|
| | | else
|
| | | {
|
| | | UserCenterResourse.HideOption.WriteSendAndReceveDataToFile = 0;
|
| | | btnSwitchLog.IsSelected = false;
|
| | | var txtvalue = HdlFileLogic.Current.ReadFileTextContent(DirNameResourse.SendAndReceveDataLog);
|
| | | if (txtvalue != null)
|
| | |
| | | form.SetTextContent(txtvalue);
|
| | | }
|
| | | }
|
| | | };
|
| | |
|
| | | row1 = new FrameRowControl(listView.rowSpace / 2);
|
| | | listView.AddChidren(row1);
|
| | | row1.AddLeftCaption("SocketReceive", 600);
|
| | | row1.AddBottomLine();
|
| | | var btnSocketReceiveLog = row1.AddMostRightSwitchIcon();
|
| | | btnSocketReceiveLog.ButtonClickEvent += (sender, e) =>
|
| | | {
|
| | | if (btnSocketReceiveLog.IsSelected == false)
|
| | | {
|
| | | this.ShowMassage(ShowMsgType.Confirm, "是否打开记录SocketReceive的记录?", () =>
|
| | | {
|
| | | btnSocketReceiveLog.IsSelected = true;
|
| | | HdlFileLogic.Current.DeleteFile(DirNameResourse.SocketReceiveDataLog);
|
| | | UserCenterResourse.HideOption.WriteSocketReceiveDataToFile = 1;
|
| | | });
|
| | | }
|
| | | else
|
| | | {
|
| | | UserCenterResourse.HideOption.WriteSocketReceiveDataToFile = 0;
|
| | | btnSocketReceiveLog.IsSelected = false;
|
| | | var txtvalue = HdlFileLogic.Current.ReadFileTextContent(DirNameResourse.SocketReceiveDataLog);
|
| | | if (txtvalue != null)
|
| | | {
|
| | | var form = new HideOptionFileContentForm();
|
| | | form.AddForm(string.Empty);
|
| | |
|
| | | form.SetTextContent(txtvalue);
|
| | | }
|
| | | }
|
| | | };
|
| | |
|
| | | row1 = new FrameRowControl(listView.rowSpace / 2);
|
| | | listView.AddChidren(row1);
|
| | | row1.AddLeftCaption("重新初始化Socket", 600);
|
| | | row1.AddRightArrow();
|
| | | row1.AddBottomLine();
|
| | | row1.ButtonClickEvent += (sender, e) =>
|
| | | {
|
| | | this.ShowMassage(ShowMsgType.Confirm, "是否重新初始化Socket对象?", () =>
|
| | | {
|
| | | ZigBee.Common.Application.FindGateWaySocket.Stop();
|
| | | ZigBee.Common.Application.FindGateWaySocket.Start();
|
| | | this.ShowMassage(ShowMsgType.Tip, "初始化完成");
|
| | | });
|
| | | };
|
| | |
|
| | | row1 = new FrameRowControl(listView.rowSpace / 2);
|
| | |
| | | /// </summary>
|
| | | public override void CloseFormBefore()
|
| | | {
|
| | | Shared.Phone.UserCenter.UserCenterResourse.DicReceiveGatewayTest = null;
|
| | | UserCenterResourse.DicReceiveGatewayTest = null;
|
| | | UserCenterResourse.HideOption.CheckCanReceiveGateway = 0;
|
| | | UserCenterResourse.HideOption.WriteSendAndReceveDataToFile = 1;
|
| | |
|
| | | UserCenterResourse.HideOption.WriteSendAndReceveDataToFile = 0;
|
| | | UserCenterResourse.HideOption.WriteSocketReceiveDataToFile = 0;
|
| | |
|
| | | base.CloseFormBefore();
|
| | | }
|
| | |
| | | }
|
| | | listDirectory.Sort();
|
| | |
|
| | | listAllFile = HdlAutoBackupLogic.GetFileFromDirectory(directory.TrimEnd('/'));
|
| | | listAllFile = HdlFileLogic.Current.GetFileFromDirectory(directory.TrimEnd('/'));
|
| | | listAllFile.Sort();
|
| | | }
|
| | |
|
| | |
| | | }
|
| | | row1.frameTable.AddRightArrow();
|
| | |
|
| | | var btnUpLoad = row1.AddEditorControl();
|
| | | btnUpLoad.Text = "上传";
|
| | | btnUpLoad.ButtonClickEvent += (sender, e) =>
|
| | | {
|
| | | this.ShowMassage(ShowMsgType.Confirm, "是否上传该文件(测试)?", () =>
|
| | | {
|
| | | HdlThreadLogic.Current.RunThread(() =>
|
| | | {
|
| | | string tagrtFile = System.IO.Path.Combine(directory, fileName);
|
| | | HdlBackupLogic.Current.UpLoadByteDataToOptionBackup(fileName, HdlFileLogic.Current.ReadFileByteContent(tagrtFile));
|
| | | });
|
| | | });
|
| | | };
|
| | |
|
| | | var btnDelete = row1.AddDeleteControl();
|
| | | btnDelete.ButtonClickEvent += (sender, e) =>
|
| | | {
|
| | |
| | | return;
|
| | | }
|
| | | pra.Account = dicMemberAccount[keys];
|
| | | var result = UserCenterLogic.GetByteResponseDataByRequestHttps("ZigbeeUsers/GetSubAccountInfo", false, pra);
|
| | | var result = UserCenterLogic.GetByteResponseDataByRequestHttps("ZigbeeUsers/GetSubAccountInfo", false, pra, new List<string> { "NotCheck" });
|
| | | if (result == null)
|
| | | {
|
| | | continue;
|
| | |
| | | {
|
| | | var pra = new AccountInfoPra();
|
| | | pra.Account = memberInfo.Account;
|
| | | var result = UserCenterLogic.GetByteResponseDataByRequestHttps("ZigbeeUsers/GetSubAccountInfo", false, pra);
|
| | | var result = UserCenterLogic.GetByteResponseDataByRequestHttps("ZigbeeUsers/GetSubAccountInfo", false, pra, new List<string> { "NotCheck" });
|
| | | if (result == null)
|
| | | {
|
| | | return;
|
| | |
| | | if (changedFloor == false)
|
| | | {
|
| | | //刷新左滑的房间列表界面的指定房间的信息
|
| | | MainPage.ListRoomViewFrom.Instance.RefreshRoomInfo(this.editorRoom);
|
| | | MainPage.LeftListRoomViewFrom.Instance.RefreshRoomInfo(this.editorRoom);
|
| | | }
|
| | | else
|
| | | {
|
| | | //刷新左滑的房间列表界面的房间列表信息
|
| | | MainPage.ListRoomViewFrom.Instance.RefreshListRoom();
|
| | | MainPage.LeftListRoomViewFrom.Instance.RefreshListRoom();
|
| | | }
|
| | |
|
| | | //算了,这里如果按下保存,则主页需要重新刷新
|
| | |
| | | /// 楼层的主键
|
| | | /// </summary>
|
| | | private string floorKeys = string.Empty;
|
| | | /// <summary>
|
| | | /// 房间顺序
|
| | | /// </summary>
|
| | | private List<string> listRoomSort = new List<string>();
|
| | |
|
| | | #endregion
|
| | |
|
| | |
| | | {
|
| | | //获取楼层的房间
|
| | | var listRoom = HdlRoomLogic.Current.GetFloorSortRoom(this.floorKeys);
|
| | | this.listRoomSort.Clear();
|
| | | for (int i = 0; i < listRoom.Count; i++)
|
| | | {
|
| | | this.listRoomSort.Add(listRoom[i].Id);
|
| | | }
|
| | |
|
| | | this.listView.RemoveAll();
|
| | | listView.Height = bodyFrameLayout.Height + Application.GetRealHeight(6);
|
| | |
| | | //调整高度
|
| | | frameRow.RemoveFromParent();
|
| | | listView.AdjustRealHeight(Application.GetRealHeight(23));
|
| | | //保存顺序
|
| | | this.listRoomSort.Remove(room.Id);
|
| | | HdlRoomLogic.Current.SaveRoomSort(floorKeys, this.listRoomSort);
|
| | | });
|
| | | };
|
| | | }
|
| | |
| | | /// <param name="ResidenceName"></param>
|
| | | /// <param name="info"></param>
|
| | | /// <returns></returns>
|
| | | private async void EditorResidenceName(string ResidenceName, Common.ResponseEntity.ResidenceObj info, NormalViewControl btnHome)
|
| | | private void EditorResidenceName(string ResidenceName, Common.ResponseEntity.ResidenceObj info, NormalViewControl btnHome)
|
| | | {
|
| | | //检测能否保存住宅
|
| | | if (this.CheckIsCanSaveResidence(info.Id, ResidenceName, true) == false)
|
| | |
| | | Pra.LoginAccessToken = Config.Instance.Token;
|
| | |
|
| | | //编辑住宅
|
| | | bool flage = UserCenterLogic.GetResultStatuByRequestHttps("App/EditHome", false, Pra);
|
| | | bool flage = UserCenterLogic.GetResultStatuByRequestHttps("App/EditHome", false, Pra, new List<string> { "NotCheck" });
|
| | | //关闭进度条
|
| | | this.CloseProgressBar();
|
| | |
|
| | |
| | | /// </summary>
|
| | | private VerticalFrameControl listBackContr = null;
|
| | | /// <summary>
|
| | | /// 楼层顺序
|
| | | /// </summary>
|
| | | private List<string> listFloorSort = new List<string>();
|
| | | /// <summary>
|
| | | /// 房间顺序
|
| | | /// </summary>
|
| | | private List<string> listRoomSort = new List<string>();
|
| | | /// <summary>
|
| | | /// 当前APP的住宅模式 0:还没有设置有模式 1:楼层模式 2:没有楼层模式
|
| | | /// </summary>
|
| | | private int AppResidenceMode = 0;
|
| | |
| | | {
|
| | | //获取楼层
|
| | | var dicFloor = HdlRoomLogic.Current.GetFloorSortList();
|
| | | this.listFloorSort.Clear();
|
| | | foreach (string keys in dicFloor.Keys)
|
| | | {
|
| | | listFloorSort.Add(keys);
|
| | | }
|
| | |
|
| | | if (Common.Config.Instance.Home.FloorDics.Count == 0)
|
| | | if (dicFloor.Count == 0)
|
| | | {
|
| | | return;
|
| | | }
|
| | | HdlThreadLogic.Current.RunMainInThread(() =>
|
| | | {
|
| | | int count = listFloorSort.Count - 1;
|
| | | for (int i = 0; i < listFloorSort.Count; i++)
|
| | | int count = dicFloor.Count;
|
| | | foreach (var keys in dicFloor.Keys)
|
| | | {
|
| | | string keys = listFloorSort[i];
|
| | | this.AddFloorRow(keys, dicFloor[keys], i != count);
|
| | | count--;
|
| | | this.AddFloorRow(keys, dicFloor[keys], count != 0);
|
| | | }
|
| | | //调整控件高度
|
| | | this.AdjustContrlTableHeight();
|
| | |
| | | HdlRoomLogic.Current.RemoveRoom(roomId);
|
| | | }
|
| | | Common.Config.Instance.Home.Save();
|
| | | //保存顺序
|
| | | listFloorSort.Remove(keys);
|
| | | HdlRoomLogic.Current.SaveFloorSort(listFloorSort);
|
| | |
|
| | | if (Common.Config.Instance.Home.FloorDics.Count == 0)
|
| | | {
|
| | |
| | | {
|
| | | //获取楼层的房间
|
| | | var listRoom = HdlRoomLogic.Current.GetFloorSortRoom(string.Empty);
|
| | | this.listRoomSort.Clear();
|
| | | for (int i = 0; i < listRoom.Count; i++)
|
| | | {
|
| | | this.listRoomSort.Add(listRoom[i].Id);
|
| | | }
|
| | |
|
| | | for (int i = 0; i < listRoom.Count; i++)
|
| | | {
|
| | | //添加房间行
|
| | |
| | | //如果是分享的房间,不能编辑和修改
|
| | | return;
|
| | | }
|
| | |
|
| | | //编辑
|
| | | var btnEditor = frameRow.AddEditorControl();
|
| | | btnEditor.ButtonClickEvent += (sender, e) =>
|
| | |
| | | this.ShowMassage(ShowMsgType.Confirm, Language.StringByID(R.MyInternationalizationString.uDeleteRoomMsg), () =>
|
| | | {
|
| | | HdlRoomLogic.Current.RemoveRoom(room.Id);
|
| | | //保存顺序
|
| | | this.listRoomSort.Remove(room.Id);
|
| | | HdlRoomLogic.Current.SaveRoomSort(string.Empty, this.listRoomSort);
|
| | |
|
| | | var listAllRoom = HdlRoomLogic.Current.GetAllListRooms();
|
| | | if (listAllRoom.Count <= 1)
|
| | |
| | | {
|
| | | continue;
|
| | | }
|
| | | var sceneUi = Newtonsoft.Json.JsonConvert.DeserializeObject<Common.SceneUI>(System.Text.Encoding.UTF8.GetString(byteData));
|
| | | listScene.Add(sceneUi);
|
| | | try
|
| | | {
|
| | | var sceneUi = Newtonsoft.Json.JsonConvert.DeserializeObject<Common.SceneUI>(System.Text.Encoding.UTF8.GetString(byteData));
|
| | | listScene.Add(sceneUi);
|
| | | }
|
| | | catch { }
|
| | | }
|
| | | if (listScene.Count == 0)
|
| | | {
|
| | |
| | | }
|
| | | //从分享文件中序列化回来
|
| | | var deviceData = HdlShardLogic.Current.GetShardFileContent(deviceFile);
|
| | | var device = ZigBee.Device.CommonDevice.CommonDeviceByByteString(strArry[1], System.Text.Encoding.UTF8.GetString(deviceData));
|
| | | if (device != null)
|
| | | try
|
| | | {
|
| | | listDevice.Add(device);
|
| | | var device = ZigBee.Device.CommonDevice.CommonDeviceByByteString(strArry[1], System.Text.Encoding.UTF8.GetString(deviceData));
|
| | | if (device != null)
|
| | | {
|
| | | listDevice.Add(device);
|
| | | }
|
| | | }
|
| | | catch { }
|
| | | }
|
| | | }
|
| | | return listDevice;
|
| | |
| | | continue;
|
| | | }
|
| | | var device = Newtonsoft.Json.JsonConvert.DeserializeObject<CommonDevice>(System.Text.Encoding.UTF8.GetString(byteData));
|
| | | device.Type = (DeviceType)device.DeviceID;
|
| | | listDevice.Add(device);
|
| | | }
|
| | | //获取全部场景
|
| | |
| | | this.UploadSuggestion(txtInput.Text, txtEmail.Text);
|
| | | };
|
| | |
|
| | |
|
| | | var strFile = System.IO.Path.Combine(Shared.IO.FileUtils.RootPath, Common.Config.Instance.Guid, DirNameResourse.SuggestionFile);
|
| | | if (System.IO.File.Exists(strFile) == false)
|
| | | {
|
| | | return;
|
| | | }
|
| | | var data = UserCenterLogic.LoadFileContent(strFile);
|
| | | var data = HdlFileLogic.Current.ReadFileTextContent(DirNameResourse.SuggestionFile);
|
| | | if (data != null)
|
| | | {
|
| | | var strNowData = DateTime.Now.ToString("yyyyMMdd");
|
| | |
| | | {
|
| | | //保存次数
|
| | | this.suggestionCount--;
|
| | | var strFile = System.IO.Path.Combine(Shared.IO.FileUtils.RootPath, Common.Config.Instance.Guid, DirNameResourse.SuggestionFile);
|
| | | var byteData = System.Text.Encoding.UTF8.GetBytes(this.suggestionCount + DateTime.Now.ToString("yyyyMMdd"));
|
| | | //写入内容
|
| | | Shared.IO.FileUtils.WriteFileByBytes(strFile, byteData);
|
| | | HdlFileLogic.Current.SaveTextToFile(DirNameResourse.SuggestionFile, this.suggestionCount + DateTime.Now.ToString("yyyyMMdd"));
|
| | |
|
| | | HdlThreadLogic.Current.RunMain(() =>
|
| | | {
|
| | |
| | | BackgroundColor = Shared.Common.ZigbeeColor.Current.MainColor; |
| | | Shared.Application.LocationAction += (lon, lat) => |
| | | { |
| | | //上报经纬度 |
| | | Login.AccountLogic.Instance.ReceiveAppLatAndLon(lon.ToString(), lat.ToString()); |
| | | }; |
| | | }
|
| | |
| | | { |
| | | return; |
| | | } |
| | | isInited = true; |
| | | isInited = true;
|
| | |
|
| | | //初始化Socket
|
| | | FindGateWaySocket.Start(); |
| | | |
| | | new System.Threading.Thread(async () => |
| | | { |
| | |
| | | |
| | | var broadcastIpAddress = new Shared.Net.NetWiFi().BroadcastIpAddress;
|
| | |
|
| | |
|
| | | if (Shared.Application.IsWifi)
|
| | | {
|
| | | if (0 < gateWayList.Count)
|
| | |
| | | FindGateWaySocket.BeginSend(new System.Net.IPEndPoint(broadcastIpAddress, 7624), broadBytes); |
| | | } |
| | | } |
| | | catch
|
| | | { |
| | | //关闭Socket,下次发送会自动连接
|
| | | FindGateWaySocket.Stop();
|
| | | } |
| | | catch{} |
| | | System.Threading.Thread.Sleep(500); |
| | | } |
| | | }) |
| | |
| | | var bytes = new byte[1024]; |
| | | |
| | | var len = FindGateWaySocket.busSocket.Receive(bytes, bytes.Length, System.Net.Sockets.SocketFlags.None); |
| | | |
| | | if (bytes[43] == 0xA2) |
| | | { |
| | | //广播回复网关的基本信息处理 |
| | |
| | | }
|
| | | } |
| | | } |
| | | else |
| | | {
|
| | | //调试用
|
| | | if (Shared.Phone.UserCenter.UserCenterResourse.HideOption.WriteSocketReceiveDataToFile == 1)
|
| | | {
|
| | | var data33 = Encoding.UTF8.GetString(bytes).Replace("�)", string.Empty).TrimStart('\0').TrimEnd('\0');
|
| | | Shared.Phone.UserCenter.HdlLogLogic.Current.WriteLog(3, data33);
|
| | | } |
| | | } |
| | | } |
| | | catch |
| | | { |
| | | //关闭Socket,下次发送会自动连接 |
| | | FindGateWaySocket.Stop(); |
| | | } |
| | | catch{} |
| | | } |
| | | #endregion |
| | | } |
| | |
| | | { |
| | | try |
| | | { |
| | | Start(7624); |
| | | busSocket.BeginSendTo(bytes, 0, bytes.Length, SocketFlags.None, iPEndPoint, new AsyncCallback(asyncEndSend), null); |
| | | if (IsRunning)
|
| | | {
|
| | | busSocket.BeginSendTo(bytes, 0, bytes.Length, SocketFlags.None, iPEndPoint, new AsyncCallback(asyncEndSend), null);
|
| | | } |
| | | |
| | | } |
| | | catch { } |
| | | catch (Exception ex) |
| | | {
|
| | | //调试用
|
| | | if (Shared.Phone.UserCenter.UserCenterResourse.HideOption.WriteSocketReceiveDataToFile == 1)
|
| | | {
|
| | | Shared.Phone.UserCenter.HdlLogLogic.Current.WriteLog(3, "发送异常(BeginSendTo)\r\n" + ex.Message);
|
| | | }
|
| | | } |
| | | } |
| | | |
| | | /// <summary> |
| | |
| | | { |
| | | int bytesSent = busSocket.EndSendTo(iar); |
| | | } |
| | | catch { } |
| | | catch(Exception ex) |
| | | {
|
| | | //调试用
|
| | | if (Shared.Phone.UserCenter.UserCenterResourse.HideOption.WriteSocketReceiveDataToFile == 1)
|
| | | {
|
| | | Shared.Phone.UserCenter.HdlLogLogic.Current.WriteLog(3, "异步发送结束异常(asyncEndSend)\r\n" + ex.Message);
|
| | | } |
| | | } |
| | | } |
| | | } |
| | | } |
| | |
| | | System.IO.Directory.CreateDirectory(path); |
| | | } |
| | | } |
| | | |
| | | /// <summary> |
| | | /// 在当前住宅文件夹下创建一个空的文件夹(tz) |
| | | /// </summary> |
| | | /// <param name="directoryName">需要创建的文件夹名字</param> |
| | | /// <param name="clear">如果文件夹存在,是否需要清空文件夹</param> |
| | | public static void CreateEmptyDirectory(string directoryName, bool clear = false) |
| | | { |
| | | string creatName = Config.Instance.FullPath; |
| | | creatName = System.IO.Path.Combine(creatName, directoryName); |
| | | if (!System.IO.Directory.Exists(creatName)) |
| | | { |
| | | System.IO.Directory.CreateDirectory(creatName); |
| | | } |
| | | else if (clear == true) |
| | | { |
| | | //如果存在,则清空全部文件 |
| | | var files = System.IO.Directory.GetFiles(creatName); |
| | | foreach (var file in files) |
| | | { |
| | | System.IO.File.Delete(file); |
| | | } |
| | | } |
| | | } |
| | | |
| | | /// <summary> |
| | | /// 将信息写入指定的文件夹里(根目录为当前住宅的文件夹)(tz) |
| | | /// </summary> |
| | | /// <param name="directoryName">指定的文件夹路径</param> |
| | | /// <param name="fileName">文件名</param> |
| | | /// <param name="bytes">内容</param> |
| | | public static void WriteFileToDirectoryByBytes(string directoryName, string fileName, byte[] bytes) |
| | | { |
| | | //先去创建它吧 |
| | | Global.CreateEmptyDirectory(directoryName); |
| | | |
| | | //拼接路径 |
| | | string fullName = Config.Instance.FullPath; |
| | | fullName = System.IO.Path.Combine(fullName, directoryName); |
| | | fullName = System.IO.Path.Combine(fullName, fileName); |
| | | //写入内容 |
| | | Shared.IO.FileUtils.WriteFileByBytes(fullName, bytes); |
| | | } |
| | | |
| | | /// <summary> |
| | | /// 读取指定的文件夹里的指定的文件(根目录为当前住宅的文件夹)(tz) |
| | | /// </summary> |
| | | /// <param name="directoryName">指定的文件夹路径</param> |
| | | /// <param name="fileName">文件名</param> |
| | | public static byte[] ReadFileByDirectory(string directoryName, string fileName) |
| | | { |
| | | //拼接路径 |
| | | string fullName = Config.Instance.FullPath; |
| | | fullName = System.IO.Path.Combine(fullName, directoryName); |
| | | fullName = System.IO.Path.Combine(fullName, fileName); |
| | | if (System.IO.File.Exists(fullName) == false) |
| | | { |
| | | return null; |
| | | } |
| | | return Shared.IO.FileUtils.ReadFile(fullName); |
| | | } |
| | | |
| | | /// <summary> |
| | | /// 移动文件(tz) |
| | | /// </summary> |
| | | /// <param name="oldFile">需要移动的文件(FullName)</param> |
| | | /// <param name="newFile">要移动到的位置(FullName)</param> |
| | | public static void MoveFileToDirectory(string oldFile, string newFile) |
| | | { |
| | | //先删除 |
| | | if (System.IO.File.Exists(newFile) == true) |
| | | { |
| | | System.IO.File.Delete(newFile); |
| | | } |
| | | System.IO.File.Move(oldFile, newFile); |
| | | } |
| | | |
| | | /// <summary> |
| | | /// 将指定文件夹里面的全部文件移动到当前住宅的文件夹内(tz) |
| | | /// </summary> |
| | | /// <param name="directory"></param> |
| | | /// <param name="deleteDirectory">处理完之后,是否把文件夹删除</param> |
| | | public static void MoveDirectoryFileToHomeDirectory(string directory, bool deleteDirectory = false) |
| | | { |
| | | string rootPath = Config.Instance.FullPath; |
| | | string fulldirectory = System.IO.Path.Combine(rootPath, directory); |
| | | |
| | | if (System.IO.Directory.Exists(fulldirectory) == false) |
| | | { |
| | | return; |
| | | } |
| | | |
| | | var files = System.IO.Directory.GetFiles(fulldirectory); |
| | | var listFile = new List<string>(); |
| | | foreach (var file in files) |
| | | { |
| | | var f = file.Substring(fulldirectory.Length + 1); |
| | | listFile.Add(f); |
| | | } |
| | | |
| | | foreach (var file in listFile) |
| | | { |
| | | string oldFile = System.IO.Path.Combine(fulldirectory, file); |
| | | string newFile = System.IO.Path.Combine(rootPath, file); |
| | | //移动文件 |
| | | Global.MoveFileToDirectory(oldFile, newFile); |
| | | } |
| | | if (deleteDirectory == true) |
| | | { |
| | | System.IO.Directory.Delete(fulldirectory); |
| | | } |
| | | } |
| | | } |
| | | } |
| | | |
| | |
| | | MainAccountId = Config.Instance.Home.MainUserDistributedMark,
|
| | | SharedHid = Config.Instance.Home.Id
|
| | | };
|
| | | var resultData = Shared.Phone.UserCenter.UserCenterLogic.GetByteResponseDataByRequestHttps("App/GetSharedHomeApiControl", false, pra);
|
| | | var resultData = Shared.Phone.UserCenter.UserCenterLogic.GetByteResponseDataByRequestHttps("App/GetSharedHomeApiControl", false, pra, new List<string> { "NotCheck" });
|
| | | if (resultData == null)
|
| | | {
|
| | | return;
|
| | |
| | | /// </summary> |
| | | public long GwVersionDate = 0; |
| | | /// <summary> |
| | | ///Linux网关类型 |
| | | ///Linux网关类型(也叫网关镜像类型) |
| | | /// </summary> |
| | | public int LinuxImageType = -1; |
| | | /// <summary> |
| | |
| | | /// </summary> |
| | | public int CoordinatorFirmwareVersion = -1; |
| | | /// <summary> |
| | | /// 协调器镜像ID(也叫网关镜像类型) |
| | | /// 协调器镜像ID |
| | | /// </summary> |
| | | public int CoordinatorImageId = -1; |
| | | /// <summary> |
| | |
| | | /// 设置设备功能类型失败
|
| | | /// </summary> |
| | | public const int uSetDeviceFunctionTypeFail = 16134;
|
| | |
|
| | | /// <summary>
|
| | | /// 获取场景列表失败,网关回复超时
|
| | | /// </summary> |
| | | public const int uGetSceneListFailAndTimeOut = 16135;
|
| | | /// <summary>
|
| | | /// 需重新绑定
|
| | | /// </summary> |
| | | public const int uNeedToRebind = 16136;
|
| | |
|
| | |
|
| | |
|
| | |
| | | <Compile Include="$(MSBuildThisFileDirectory)Phone\Device\CommonForm\RoomView.cs" />
|
| | | <Compile Include="$(MSBuildThisFileDirectory)Phone\Device\CommonForm\SceneCategoryView.cs" />
|
| | | <Compile Include="$(MSBuildThisFileDirectory)Phone\Device\CommonForm\SelectTime.cs" />
|
| | | <Compile Include="$(MSBuildThisFileDirectory)Phone\Device\CommonForm\SelectZone.cs" />
|
| | | <Compile Include="$(MSBuildThisFileDirectory)Phone\Device\CommonForm\TopFrameLayout.cs" />
|
| | | <Compile Include="$(MSBuildThisFileDirectory)Phone\Device\Logic\AddLogicPage.cs" />
|
| | | <Compile Include="$(MSBuildThisFileDirectory)Phone\Device\Logic\AddScenePage.cs" />
|
| | |
| | | <Compile Include="$(MSBuildThisFileDirectory)Common\ResponseEntity\UserLoginRes.cs" />
|
| | | <Compile Include="$(MSBuildThisFileDirectory)Common\SendDataToServer.cs" />
|
| | | <Compile Include="$(MSBuildThisFileDirectory)Common\Room.cs" />
|
| | | <Compile Include="$(MSBuildThisFileDirectory)Phone\MainPage\ListRoomViewFrom.cs" />
|
| | | <Compile Include="$(MSBuildThisFileDirectory)Phone\MainPage\LeftListRoomViewFrom.cs" />
|
| | | <Compile Include="$(MSBuildThisFileDirectory)Phone\UserCenter\Residence\SelectLocalRoomImageForm.cs" />
|
| | | <Compile Include="$(MSBuildThisFileDirectory)Phone\UserCenter\CommonBase\Controls\CompoundControls\ProgressBar.cs" />
|
| | | <Compile Include="$(MSBuildThisFileDirectory)Phone\UserCenter\CommonBase\Controls\CompoundControls\SearchEditText.cs" />
|