| | |
| | | { |
| | | #region 本地变量 |
| | | /// <summary> |
| | | /// 是否常开模式[当数据获取失败,返回空] |
| | | /// 更新“逻辑常开”界面的回调 |
| | | /// </summary> |
| | | public static bool? IsDoorLockNormallyMode = new bool?(); |
| | | public static Action<bool> LogicAction = null; |
| | | /// <summary> |
| | | /// 常开模式时间 |
| | | /// 更新当前门锁涉及的状态【主要用于门锁操作常开模式的回调】 |
| | | /// </summary> |
| | | public static Action<string, bool> UpdateCurrentDoorlockAction = null; |
| | | /// <summary> |
| | | /// 网关(门锁)所在的时间 |
| | | /// </summary> |
| | | public static DateTime DoorlockZoneTime = DateTime.Now; |
| | | /// <summary> |
| | | /// 所有门锁中的常开模式值[用于推送查询,提示门锁失效) |
| | | /// keys:门锁mac+epoint value:是否常开模式 |
| | | /// ture:常开; false:关闭 |
| | | /// </summary> |
| | | public static Dictionary<string, bool?> DoorLockNormallyMode = new Dictionary<string, bool?> { }; |
| | | /// <summary> |
| | | /// 常开模式执行时间 |
| | | /// </summary> |
| | | public static int NormallyOpenModeInvalidTime = 12; |
| | | /// <summary> |
| | |
| | | /// 失效效日期“秒” |
| | | /// </summary> |
| | | public static int InValidDateSecond = 0; |
| | | #endregion |
| | | |
| | | /// <summary> |
| | | /// 获取当前门锁的常开模式 |
| | | /// 门锁操作类型 |
| | | /// </summary> |
| | | /// <param name="doorLock:当前门锁"></param> |
| | | /// <returns></returns> |
| | | public enum DoorLockMessType |
| | | { |
| | | /// <summary> |
| | | /// app操作 |
| | | /// </summary> |
| | | AppOperate = 0, |
| | | /// <summary> |
| | | /// 通过门锁操作设备上报 |
| | | /// </summary> |
| | | DeviceReport = 1, |
| | | /// <summary> |
| | | /// 通过服务器推送 |
| | | /// </summary> |
| | | ServicePush = 2, |
| | | } |
| | | #endregion |
| | | |
| | | #region 常开模式 API |
| | | /// <summary> |
| | | /// 获取当前门锁的常开模式 |
| | | /// </summary> |
| | | /// <param name="doorLock:当前门锁"></param> |
| | | /// <returns>null:没有回复 ; true:门锁常开;false:门锁常关</returns> |
| | | public static async System.Threading.Tasks.Task<bool?> GetNormallyOpenMode(ZigBee.Device.DoorLock doorLock) |
| | | { |
| | | bool? IsDoorLockNormallyMode = null; |
| | | var result = await doorLock.ReadNormallyOpenModeFuncAsync(); |
| | | //共通错误检测 |
| | | string error = HdlCheckLogic.Current.CheckCommonErrorCode(result); |
| | |
| | | { |
| | | IsDoorLockNormallyMode = false; |
| | | } |
| | | |
| | | return IsDoorLockNormallyMode; |
| | | } |
| | | |
| | | /// <summary> |
| | | /// 门锁是否支持常开[这里暂时只有S-One门锁支持,H06C不支持, 后期通过能力值支持] |
| | | /// </summary> |
| | | /// <param name="doorLock:当前门锁"></param> |
| | | /// <returns></returns> |
| | | /// <param name="doorLock:当前门锁"></param> |
| | | /// <returns>true:支持常开;false: 不支持常开</returns> |
| | | public static bool CanNormallyOpen(ZigBee.Device.DoorLock doorLock) |
| | | { |
| | | var listDevice = new List<CommonDevice> { }; |
| | |
| | | } |
| | | |
| | | /// <summary> |
| | | /// 设置本地门锁的常开模式值 |
| | | /// </summary> |
| | | public static void NormallyOpenModeValue(ZigBee.Device.DoorLock doorLock, bool value) |
| | | { |
| | | doorLock.IsDoorLockNormallyMode = value; |
| | | if (DoorLockCommonInfo.DoorLockNormallyMode.ContainsKey(doorLock.DeviceAddr + doorLock.DeviceEpoint)) |
| | | { |
| | | DoorLockCommonInfo.DoorLockNormallyMode[doorLock.DeviceAddr + doorLock.DeviceEpoint] = value; |
| | | } |
| | | else |
| | | { |
| | | DoorLockCommonInfo.DoorLockNormallyMode.Add(doorLock.DeviceAddr + doorLock.DeviceEpoint, value); |
| | | } |
| | | } |
| | | |
| | | /// <summary> |
| | | /// 常开模式失效处理【弹窗】 |
| | | /// </summary> |
| | | /// <param name="doorLock">当前门锁</param> |
| | | /// <param name="doorLockMessType">导致门锁失效的操作类型</param> |
| | | /// <param name="haveLogic">网关中是否存在逻辑常开模式</param> |
| | | /// <param name="action">回调处理更新内容</param> |
| | | /// <param name="type">1:确认常开模式已经开启;0:常开模式失效提示</param> |
| | | public static async void NomallyOpenModeInvalidDialog(ZigBee.Device.DoorLock doorLock, DoorLockMessType doorLockMessType, bool haveLogic, Action<bool> action = null, int type = 0) |
| | | { |
| | | //常开模式只能主人操作 |
| | | if (UserCenterResourse.UserInfo.AuthorityNo != 1) |
| | | { |
| | | Application.RunOnMainThread(() => |
| | | { |
| | | string msg0 = Language.StringByID(R.MyInternationalizationString.OnlyMasterOperate); |
| | | ShowTipMsg(msg0); |
| | | }); |
| | | return; |
| | | } |
| | | |
| | | //常开模式将被取消弹窗 |
| | | string msg = Language.StringByID(R.MyInternationalizationString.NomallyModeIsCanceled).Replace("{0}", "\r\n"); |
| | | var confirm = Language.StringByID(R.MyInternationalizationString.SureCancel); |
| | | var alert = new ShowDoorLockMsgControl(ShowDoorLockMsgControl.DoorLockMsgType.NomallyOpenMode, msg, confirm); |
| | | |
| | | if (haveLogic) |
| | | { |
| | | //有逻辑设置的弹窗 |
| | | alert = new ShowDoorLockMsgControl(ShowDoorLockMsgControl.DoorLockMsgType.CancelNomallyOpenModeWithLogic, msg, confirm); |
| | | } |
| | | alert.Show(); |
| | | |
| | | alert.MsgControlClickEvent += async () => |
| | | { |
| | | if (doorLockMessType == DoorLockMessType.DeviceReport || doorLockMessType == DoorLockMessType.ServicePush) |
| | | { |
| | | //上报“常开模式”已被取消,app默认了“常开模式”被取消 |
| | | DoorLockCommonInfo.NormallyOpenModeValue(doorLock, false); |
| | | if (LogicAction != null) |
| | | { |
| | | LogicAction(false); |
| | | } |
| | | if (haveLogic) |
| | | { |
| | | //此处删除温居城的常开模式特殊逻辑 |
| | | var resTemp1 = await Shared.Phone.Device.Logic.SkipView.DelAllLogic(doorLock); |
| | | } |
| | | } |
| | | else |
| | | { |
| | | //保持常开 |
| | | NormallyOpenModeValue(doorLock, true); |
| | | } |
| | | action?.Invoke(doorLock.IsDoorLockNormallyMode); |
| | | action = null; |
| | | }; |
| | | |
| | | alert.CancelClickEvent += async () => |
| | | { |
| | | if (doorLockMessType == DoorLockMessType.DeviceReport || doorLockMessType == DoorLockMessType.ServicePush) |
| | | { |
| | | //上报“常开模式”已被取消 |
| | | Application.RunOnMainThread(() => { CommonPage.Loading.Start(""); }); |
| | | |
| | | //app重新开启“常开模式” |
| | | var result = await doorLock.SetNormallyOpenModeFuncAsync(true); |
| | | if (result == null || result.defaultControlResponseData == null) |
| | | { |
| | | Application.RunOnMainThread(() => |
| | | { |
| | | string msg0 = Language.StringByID(R.MyInternationalizationString.GwResponseOvertime); |
| | | ShowTipMsg(msg0); |
| | | NormallyOpenModeValue(doorLock, false); |
| | | CommonPage.Loading.Hide(); |
| | | }); |
| | | action?.Invoke(doorLock.IsDoorLockNormallyMode); |
| | | action = null; |
| | | if (LogicAction != null) |
| | | { |
| | | LogicAction(false); |
| | | } |
| | | return; |
| | | } |
| | | if (result.defaultControlResponseData.status != 0) |
| | | { |
| | | Application.RunOnMainThread(() => |
| | | { |
| | | string msg1 = Language.StringByID(R.MyInternationalizationString.OpenNormallyOpenModeFailed); |
| | | ShowTipMsg(msg1); |
| | | NormallyOpenModeValue(doorLock, false); |
| | | CommonPage.Loading.Hide(); |
| | | }); |
| | | |
| | | action?.Invoke(doorLock.IsDoorLockNormallyMode); |
| | | action = null; |
| | | if (LogicAction != null) |
| | | { |
| | | LogicAction(false); |
| | | } |
| | | return; |
| | | } |
| | | else |
| | | { |
| | | Application.RunOnMainThread(() => |
| | | { |
| | | string msg0 = Language.StringByID(R.MyInternationalizationString.OpenNormallyOpenModeSuccess); |
| | | ShowTipMsg(msg0); |
| | | NormallyOpenModeValue(doorLock, true); |
| | | CommonPage.Loading.Hide(); |
| | | if (LogicAction != null) |
| | | { |
| | | LogicAction(true); |
| | | } |
| | | }); |
| | | } |
| | | } |
| | | else |
| | | { |
| | | //app操作不取消“常开模式” |
| | | DoorLockCommonInfo.NormallyOpenModeValue(doorLock, true); |
| | | } |
| | | action?.Invoke(doorLock.IsDoorLockNormallyMode); |
| | | action = null; |
| | | }; |
| | | |
| | | alert.ConfirmClickEvent += async () => |
| | | { |
| | | if (doorLockMessType == DoorLockMessType.DeviceReport || doorLockMessType == DoorLockMessType.ServicePush) |
| | | { |
| | | NormallyOpenModeValue(doorLock, false); |
| | | if (LogicAction != null) |
| | | { |
| | | LogicAction(false); |
| | | } |
| | | if (haveLogic) |
| | | { |
| | | //此处删除温居城的常开模式特殊逻辑 |
| | | var resTemp1 = await Shared.Phone.Device.Logic.SkipView.DelAllLogic(doorLock); |
| | | } |
| | | } |
| | | else |
| | | { |
| | | //app操作取消“常开模式” |
| | | Application.RunOnMainThread(() => { CommonPage.Loading.Start(""); }); |
| | | var result = await doorLock.SetNormallyOpenModeFuncAsync(false); |
| | | if (result == null || result.defaultControlResponseData == null) |
| | | { |
| | | Application.RunOnMainThread(() => |
| | | { |
| | | ShowTipMsg(Language.StringByID(R.MyInternationalizationString.GwResponseOvertime)); |
| | | CommonPage.Loading.Hide(); |
| | | }); |
| | | action?.Invoke(doorLock.IsDoorLockNormallyMode); |
| | | action = null; |
| | | if (LogicAction != null) |
| | | { |
| | | LogicAction(false); |
| | | } |
| | | return; |
| | | } |
| | | if (result.defaultControlResponseData.status != 0) |
| | | { |
| | | Application.RunOnMainThread(() => |
| | | { |
| | | string msg1 = Language.StringByID(R.MyInternationalizationString.CloseNormallyOpenModeFailed); |
| | | ShowTipMsg(msg1); |
| | | CommonPage.Loading.Hide(); |
| | | }); |
| | | action?.Invoke(doorLock.IsDoorLockNormallyMode); |
| | | action = null; |
| | | if (LogicAction != null) |
| | | { |
| | | LogicAction(false); |
| | | } |
| | | return; |
| | | } |
| | | else |
| | | { |
| | | //添加App开启常开模式的历史记录 |
| | | HdlDeviceDoorLockLogic.Current.AddDoorHistoryLog(doorLock, 9002, string.Empty); |
| | | //app确认取消“常开模式”成功 |
| | | NormallyOpenModeValue(doorLock, false); |
| | | //删除设置常开模式创建的逻辑 |
| | | if (haveLogic) |
| | | { |
| | | //此处删除温居城的常开模式特殊逻辑 |
| | | var resTemp1 = await Shared.Phone.Device.Logic.SkipView.DelAllLogic(doorLock); |
| | | } |
| | | Application.RunOnMainThread(() => |
| | | { |
| | | string msg2 = Language.StringByID(R.MyInternationalizationString.CloseNormallyOpenModeSuccess); |
| | | ShowTipMsg(msg2); |
| | | CommonPage.Loading.Hide(); |
| | | }); |
| | | if (LogicAction != null) |
| | | { |
| | | LogicAction(false); |
| | | } |
| | | } |
| | | } |
| | | action?.Invoke(doorLock.IsDoorLockNormallyMode); |
| | | action = null; |
| | | }; |
| | | } |
| | | |
| | | /// <summary>
|
| | | /// 删除常开模式
|
| | | /// </summary>
|
| | | /// <param name="doorLock">当前门锁</param>
|
| | | /// <param name="action">回调处理更新内容</param>
|
| | | /// <returns></returns>
|
| | | public static async System.Threading.Tasks.Task<bool> DelNormallyOpenMode(ZigBee.Device.DoorLock doorLock, Action action = null)
|
| | | {
|
| | | //app操作取消“常开模式” |
| | | var result = await doorLock.SetNormallyOpenModeFuncAsync(false);
|
| | | if (result == null || result.defaultControlResponseData == null || result.defaultControlResponseData.status != 0)
|
| | | {
|
| | | action?.Invoke();
|
| | | return false;
|
| | | }
|
| | |
|
| | | if (result.defaultControlResponseData.status == 0)
|
| | | {
|
| | | //app确认取消“常开模式”成功 |
| | | NormallyOpenModeValue(doorLock, false);
|
| | | action?.Invoke();
|
| | | return true;
|
| | | }
|
| | | return false;
|
| | | }
|
| | |
|
| | | /// <summary>
|
| | | /// 设置常开模式
|
| | | /// </summary>
|
| | | /// <param name="doorLock">当前门锁</param>
|
| | | /// <param name="action">回调处理更新内容</param>
|
| | | /// <returns></returns>
|
| | | public static async System.Threading.Tasks.Task<bool> SetNormallyOpenModeFuncAsync(ZigBee.Device.DoorLock doorLock)
|
| | | {
|
| | | //app设置“常开模式”失败 |
| | | var result = await doorLock.SetNormallyOpenModeFuncAsync(true);
|
| | | if (result == null || result.defaultControlResponseData == null || result.defaultControlResponseData.status != 0)
|
| | | {
|
| | | return false;
|
| | | }
|
| | |
|
| | | if (result.defaultControlResponseData.status == 0)
|
| | | {
|
| | | //app设置“常开模式”成功 |
| | | NormallyOpenModeValue(doorLock, false);
|
| | | return true;
|
| | | }
|
| | | return false;
|
| | | } |
| | | |
| | | /// <summary> |
| | | /// 启动常开模式【弹窗】 |
| | | /// </summary> |
| | | /// <param name="doorLock">当前门锁</param> |
| | | /// <param name="action">回调处理更新内容</param> |
| | | public static async void NomallyOpenModeStartDialog(ZigBee.Device.DoorLock doorLock, Action action) |
| | | { |
| | | //常开模式只能主人操作ZigBee.Device.DoorLock doorLock |
| | | if (UserCenterResourse.UserInfo.AuthorityNo != 1) |
| | | { |
| | | Application.RunOnMainThread(() => |
| | | { |
| | | string msg0 = Language.StringByID(R.MyInternationalizationString.OnlyMasterOperate); |
| | | ShowTipMsg(msg0); |
| | | }); |
| | | return; |
| | | } |
| | | |
| | | //设置常开模式后,您的门锁将始终处于打开状态,确认开启? |
| | | string msg = Language.StringByID(R.MyInternationalizationString.SetDoorLockNomallyOpen).Replace("{0}", "\r\n"); |
| | | var confirm = Language.StringByID(R.MyInternationalizationString.Confrim); |
| | | var alert = new ShowDoorLockMsgControl(ShowDoorLockMsgControl.DoorLockMsgType.Confirm, msg, confirm); |
| | | alert.Show(); |
| | | |
| | | alert.ConfirmClickEvent += async () => |
| | | { |
| | | NomallyOpenModeInvalidTimeDialog(doorLock, action); |
| | | }; |
| | | } |
| | | |
| | | /// <summary> |
| | | /// 常开模式失效时间处理【弹窗】 |
| | | /// </summary> |
| | | public static async void NomallyOpenModeInvalidTimeDialog(ZigBee.Device.DoorLock doorLock, Action action) |
| | | { |
| | | //失效设置 |
| | | string msgTimeInValidSetting = Language.StringByID(R.MyInternationalizationString.DoorLockOpenAllTheTime); |
| | | var timeConfrim = Language.StringByID(R.MyInternationalizationString.Confrim); |
| | | var alertTimeInValidSetting = new ShowDoorLockMsgControl(ShowDoorLockMsgControl.DoorLockMsgType.InValid, msgTimeInValidSetting, timeConfrim); |
| | | alertTimeInValidSetting.Show(); |
| | | |
| | | alertTimeInValidSetting.InvalidTimeAction += async (obj) => |
| | | { |
| | | //常开模式失效时间设置成功 |
| | | var temp = int.Parse(obj); |
| | | DoorLockCommonInfo.NormallyOpenModeInvalidTime = temp; |
| | | |
| | | Application.RunOnMainThread(() => { CommonPage.Loading.Start(""); }); |
| | | var result = await doorLock.SetNormallyOpenModeFuncAsync(true); |
| | | if (result == null || result.defaultControlResponseData == null) |
| | | { |
| | | Application.RunOnMainThread(() => |
| | | { |
| | | string msg0 = Language.StringByID(R.MyInternationalizationString.GwResponseOvertime); |
| | | ShowTipMsg(msg0); |
| | | CommonPage.Loading.Hide(); |
| | | }); |
| | | return; |
| | | } |
| | | if (result.defaultControlResponseData.status != 0) |
| | | { |
| | | Application.RunOnMainThread(() => |
| | | { |
| | | string msg1 = Language.StringByID(R.MyInternationalizationString.OpenNormallyOpenModeFailed); |
| | | ShowTipMsg(msg1); |
| | | CommonPage.Loading.Hide(); |
| | | }); |
| | | return; |
| | | } |
| | | else |
| | | { |
| | | //添加App开启常开模式的历史记录 |
| | | HdlDeviceDoorLockLogic.Current.AddDoorHistoryLog(doorLock, 9001, string.Empty); |
| | | DoorLockCommonInfo.NormallyOpenModeValue(doorLock, true); |
| | | action?.Invoke(); |
| | | Application.RunOnMainThread(() => |
| | | { |
| | | CommonPage.Loading.Hide(); |
| | | }); |
| | | } |
| | | |
| | | //温居城方法??? |
| | | //此处是否要创建常开模式的特殊逻辑 |
| | | }; |
| | | } |
| | | #endregion |
| | | |
| | | #region 音量 |
| | | /// <summary> |
| | | /// 门锁是否支持音量[这里暂时只有S-One门锁支持,H06C不支持,后期通过能力值支持] |
| | | /// </summary> |
| | | /// <param name="doorLock:当前门锁"></param> |
| | | /// <returns></returns> |
| | | /// <param name="doorLock:当前门锁"></param> |
| | | /// <returns></returns> |
| | | public static bool CanVolume(ZigBee.Device.DoorLock doorLock) |
| | | { |
| | | var listDevice = new List<CommonDevice> { }; |
| | |
| | | return false; |
| | | } |
| | | |
| | | #region 从云端获取的方法 |
| | | #endregion |
| | | |
| | | #region 从云端获取的方法 |
| | | /// <summary> |
| | | /// 获取当前账户门锁操作权限(是否被冻结) |
| | | /// </summary> |
| | |
| | | var SubAccounListTemp = await ZigBee.Device.DoorLock.GetSubAccountByDistributedMark(); |
| | | var SubAccounListDictionary = new Dictionary<string, Shared.Phone.UserCenter.MemberInfoRes> { }; |
| | | |
| | | foreach (var member in SubAccounListTemp) |
| | | { |
| | | //判断一个账户绑定了邮箱的情况 |
| | | if (SubAccounListDictionary.ContainsKey(member.DistributedMark) == true |
| | | || member.Account == UserCenterResourse.UserInfo.Phone |
| | | || member.Account == UserCenterResourse.UserInfo.Email) |
| | | { |
| | | //如果是它自己的话,不显示,账户和绑定的邮箱只显示其中之一 |
| | | continue; |
| | | if (SubAccounListTemp != null)
|
| | | {
|
| | | foreach (var member in SubAccounListTemp)
|
| | | {
|
| | | //判断一个账户绑定了邮箱的情况
|
| | | if (SubAccounListDictionary.ContainsKey(member.DistributedMark) == true
|
| | | || member.Account == UserCenterResourse.UserInfo.Phone
|
| | | || member.Account == UserCenterResourse.UserInfo.Email)
|
| | | {
|
| | | //如果是它自己的话,不显示,账户和绑定的邮箱只显示其中之一
|
| | | continue;
|
| | | }
|
| | | //去掉子账户中普通成员,留下拥有管理员权限的成员
|
| | | //(因为分配账户给普通成员,普通成员在app中不能进入设备管理那里,所以没发查看主人分配对账户)
|
| | | if (member.AccountType != 1)
|
| | | {
|
| | | continue;
|
| | | }
|
| | |
|
| | | SubAccounListDictionary.Add(member.DistributedMark, member);
|
| | | } |
| | | //去掉子账户中普通成员,留下拥有管理员权限的成员 |
| | | //(因为分配账户给普通成员,普通成员在app中不能进入设备管理那里,所以没发查看主人分配对账户) |
| | | if (member.AccountType != 1) |
| | | { |
| | | continue; |
| | | } |
| | | |
| | | SubAccounListDictionary.Add(member.DistributedMark, member); |
| | | } |
| | | |
| | | foreach (var addMemberID in SubAccounListDictionary.Keys) |
| | | { |
| | | SubAccounList.Add(SubAccounListDictionary[addMemberID]); |
| | |
| | | } |
| | | |
| | | |
| | | //2、读取云端门锁信息 |
| | | //2、读取云端门锁信息 |
| | | var getDoorLockInfoAllList = new List<ZigBee.Device.DoorLock.CloudDoorLockObj> { }; |
| | | var getDoorLockInfoList = await Shared.Phone.UserCenter.DoorLock.DoorLockCommonInfo.GetDoorLockAllAccountInfolist(doorLock); |
| | | if (getDoorLockInfoList != null) |
| | |
| | | |
| | | /// <summary> |
| | | /// 将系统时间转换成UNIX时间戳(精确到秒) |
| | | /// </summary> |
| | | /// <param name="dateTime">北京时间</param> |
| | | /// <param name="accurateToMilliseconds">精确到毫秒,否到秒</param> |
| | | /// </summary> |
| | | /// <param name="dateTime"></param> |
| | | /// <returns>返回一个长整数时间戳</returns> |
| | | public static string GetUnixTimeStamp(DateTime dateTime) |
| | | { |
| | | DateTime dtStart = TimeZone.CurrentTimeZone.ToLocalTime(new DateTime(1970, 1, 1)); |
| | | //DateTime dtNow = DateTime.Parse(DateTime.Now.ToString()); |
| | | TimeSpan toNow = dateTime.Subtract(dtStart); |
| | | string timeStamp = toNow.Ticks.ToString(); |
| | | timeStamp = timeStamp.Substring(0, timeStamp.Length - 7); |
| | | return timeStamp; |
| | | } |
| | | |
| | | /// <summary> |
| | | /// 获取时区的时间 |
| | | /// </summary> |
| | | /// <returns></returns> |
| | | public static DateTime GetDoorLockZoneTime() |
| | | { |
| | | //通过经度获取时区 |
| | | var gwZone = int.Parse(CaculateTimeZone(Common.Config.Instance.Home.Longitude)); |
| | | //将本地时间转换成世界时 |
| | | var utc = DateTime.Now.AddHours(-gwZone); |
| | | //世界时转换成时间戳 |
| | | var utcUnix = GetUnixTimeStamp(utc); |
| | | //时区的时间戳 |
| | | var zoneUnix = int.Parse(utcUnix) + gwZone * 3600; |
| | | var zoneDateTime = GetLocalTime(zoneUnix); |
| | | DoorlockZoneTime = zoneDateTime; |
| | | return zoneDateTime; |
| | | } |
| | | |
| | | /// <summary> |
| | | /// 获取时区 |
| | | /// </summary> |
| | | /// <param name="currentLon">currentLon:"+"为东区,“-”为西区</param> |
| | | /// <returns></returns> |
| | | public static String CaculateTimeZone(double currentLon) |
| | | { |
| | | int timeZone; |
| | | int shangValue = (int)(currentLon / 15); |
| | | double yushuValue = Math.Abs(currentLon % 15); |
| | | if (yushuValue <= 7.5) |
| | | { |
| | | timeZone = shangValue; |
| | | } |
| | | else |
| | | { |
| | | timeZone = shangValue + (currentLon > 0 ? 1 : -1); |
| | | } |
| | | return timeZone >= 0 ? "+" + Math.Abs(timeZone) : "-" + Math.Abs(timeZone); |
| | | |
| | | } |
| | | |
| | | /// <summary> |
| | |
| | | |
| | | #endregion |
| | | |
| | | #region 一般方法 |
| | | #region 一般方法 |
| | | /// <summary> |
| | | /// 显示错误信息窗口 |
| | | /// </summary> |
| | | /// <param name="msg"></param> |
| | | private void ShowErrorMsg(string msg) |
| | | private static void ShowErrorMsg(string msg) |
| | | { |
| | | Application.RunOnMainThread(() => |
| | | { |
| | |
| | | /// 显示Tip信息窗口 |
| | | /// </summary> |
| | | /// <param name="msg"></param> |
| | | private void ShowTipMsg(string msg) |
| | | private static void ShowTipMsg(string msg) |
| | | { |
| | | Application.RunOnMainThread(() => |
| | | { |
| | |
| | | }); |
| | | } |
| | | |
| | | #endregion |
| | | #endregion |
| | | } |
| | | } |