| | |
| | | using HDL_ON.UI.CSS; |
| | | using HDL_ON.Entity; |
| | | using HDL_ON.DriverLayer; |
| | | using HDL_ON.DAL.Server; |
| | | |
| | | namespace HDL_ON.UI |
| | | { |
| | |
| | | /// </summary> |
| | | private Dictionary<string, string> dicText = new Dictionary<string, string>(); |
| | | |
| | | |
| | | |
| | | #endregion |
| | | |
| | | #region ■ 初始化_____________________________ |
| | |
| | | this.RefreshFormStatu(); |
| | | //读取设备状态 |
| | | Control.Ins.SendReadCommand(device); |
| | | |
| | | // 获取临时密码 |
| | | GetTempPwd(); |
| | | } |
| | | |
| | | /// <summary> |
| | | /// 获取临时密码 |
| | | /// </summary> |
| | | private void GetTempPwd() |
| | | { |
| | | return; |
| | | new System.Threading.Thread(() => |
| | | { |
| | | try |
| | | { |
| | | var pack = Common.ApiUtlis.Ins.HttpRequest.GetDoorTempPassword(device.deviceId); |
| | | if (pack != null) |
| | | { |
| | | Application.RunOnMainThread(() => |
| | | { |
| | | if (pack.Code == StateCode.SUCCESS) |
| | | { |
| | | var tempPasswrodObj = Newtonsoft.Json.JsonConvert.DeserializeObject<List<DoorTempPassword>>(pack.Data.ToString()); |
| | | if (tempPasswrodObj.Count > 0) |
| | | { |
| | | doorLockData.TempPassword = tempPasswrodObj[0].pwd; |
| | | doorLockData.StartTimeTick = tempPasswrodObj[0].beginTime; |
| | | doorLockData.EndTimeTick = tempPasswrodObj[0].endTime; |
| | | doorLockData.PwdId = tempPasswrodObj[0].pwdId; |
| | | this.InitTempPasswordControl(); |
| | | } |
| | | } |
| | | }); |
| | | } |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | | MainPage.Log($"获取临时密码异常:{ex.Message}"); |
| | | } |
| | | }) |
| | | { IsBackground = true }.Start(); |
| | | |
| | | } |
| | | |
| | | /// <summary> |
| | |
| | | frameTempPsw.Visible = false; |
| | | FrameWhiteCentet1.AddChidren(frameTempPsw); |
| | | |
| | | ////声音 |
| | | //this.btnVoice = new IconViewControl(24); |
| | | //btnVoice.UnSelectedImagePath = "FunctionIcon/DoorLock/Voice.png"; |
| | | //btnVoice.X = Application.GetRealWidth(23); |
| | | //btnVoice.Y = Application.GetRealHeight(410); |
| | | //FrameWhiteCentet1.AddChidren(btnVoice); |
| | | |
| | | //声音 |
| | | this.btnVoice = new IconViewControl(24); |
| | | btnVoice.UnSelectedImagePath = "FunctionIcon/DoorLock/Voice.png"; |
| | | btnVoice.X = Application.GetRealWidth(23); |
| | | btnVoice.Y = Application.GetRealHeight(410); |
| | | FrameWhiteCentet1.AddChidren(btnVoice); |
| | | |
| | | ////声音的滑动条 |
| | | //this.seekBarVoiceControl = new SeekBarImageControl(215); |
| | | //seekBarVoiceControl.Gravity = Gravity.CenterHorizontal; |
| | | //FrameWhiteCentet1.AddChidren(seekBarVoiceControl); |
| | | //seekBarVoiceControl.Y = btnVoice.Y - (seekBarVoiceControl.Height - btnVoice.Height) / 2; |
| | | ////绑定PageLayout控件 |
| | | //seekBarVoiceControl.BindPageLayout(); |
| | | //声音的滑动条 |
| | | this.seekBarVoiceControl = new SeekBarImageControl(215); |
| | | seekBarVoiceControl.Gravity = Gravity.CenterHorizontal; |
| | | FrameWhiteCentet1.AddChidren(seekBarVoiceControl); |
| | | seekBarVoiceControl.Y = btnVoice.Y - (seekBarVoiceControl.Height - btnVoice.Height) / 2; |
| | | //绑定PageLayout控件 |
| | | seekBarVoiceControl.BindPageLayout(); |
| | | |
| | | ////声音百分比 |
| | | //this.btnVoicePersent = new NormalViewControl(Application.GetRealWidth(50), btnVoice.Height, false); |
| | | //btnVoicePersent.X = seekBarVoiceControl.Right + Application.GetRealWidth(8) - seekBarVoiceControl.SeekBarPadding; |
| | | //btnVoicePersent.Y = btnVoice.Y; |
| | | //btnVoicePersent.TextColor = CSS_Color.PromptingColor1; |
| | | //btnVoicePersent.TextSize = CSS_FontSize.PromptFontSize_FirstLevel; |
| | | //btnVoicePersent.Text = "100%"; |
| | | //FrameWhiteCentet1.AddChidren(btnVoicePersent); |
| | | //声音百分比 |
| | | this.btnVoicePersent = new NormalViewControl(Application.GetRealWidth(50), btnVoice.Height, false); |
| | | btnVoicePersent.X = seekBarVoiceControl.Right + Application.GetRealWidth(8) - seekBarVoiceControl.SeekBarPadding; |
| | | btnVoicePersent.Y = btnVoice.Y; |
| | | btnVoicePersent.TextColor = CSS_Color.PromptingColor1; |
| | | btnVoicePersent.TextSize = CSS_FontSize.PromptFontSize_FirstLevel; |
| | | btnVoicePersent.Text = "100%"; |
| | | FrameWhiteCentet1.AddChidren(btnVoicePersent); |
| | | |
| | | //seekBarVoiceControl.ProgressChangedEvent += (div, value) => |
| | | //{ |
| | | // btnVoicePersent.Text = value + "%"; |
| | | // if (div == 1) |
| | | // { |
| | | // } |
| | | //}; |
| | | seekBarVoiceControl.ProgressChangedEvent += (div, value) => |
| | | { |
| | | btnVoicePersent.Text = value + "%"; |
| | | //if (div == 1) |
| | | //{ |
| | | //} |
| | | }; |
| | | seekBarVoiceControl.OnStopTrackingTouchEvent = (sender, e) => { |
| | | var dic = new Dictionary<string, string>(); |
| | | dic.Add("door_volume", e.ToString()); |
| | | Control.Ins.SendWriteCommand(this.device, dic); |
| | | }; |
| | | |
| | | //初始化开锁菜单(一键开锁,临时密码开锁) |
| | | this.InitUnLockMenuControl(); |
| | |
| | | private void InitUnLockMenuControl() |
| | | { |
| | | //如果是成员,则只有一键开锁 |
| | | if (true)// DB_ResidenceData.Instance.CurrentRegion.isOtherShare == true) |
| | | if ( DB_ResidenceData.Instance.CurrentRegion.isOtherShare == true) |
| | | { |
| | | //一键开锁 |
| | | var btnOneKey = new NormalViewControl(100, 25, true); |
| | |
| | | this.frameTempPsw.AddChidren(btnDelete); |
| | | btnDelete.ButtonClickEvent += (sender, e) => |
| | | { |
| | | //清除当前临时密码? |
| | | HdlMessageLogic.Current.ShowMassage(ShowMsgType.Confirm, Language.StringByID(StringId.ClearTempPsswordMsg), () => |
| | | if (Convert.ToInt64(this.doorLockData.EndTimeTick) < DateTime.Now.Ticks) |
| | | { |
| | | //清空临时密码 |
| | | this.doorLockData.TempPassword = string.Empty; |
| | | this.doorLockData.StatrtTime = string.Empty; |
| | | this.doorLockData.EndTime = string.Empty; |
| | | //重新初始化临时密码控件 |
| | | this.InitTempPasswordControl(); |
| | | }); |
| | | DelTempPwd(); |
| | | } |
| | | else |
| | | { |
| | | //清除当前临时密码? |
| | | HdlMessageLogic.Current.ShowMassage(ShowMsgType.Confirm, Language.StringByID(StringId.ClearTempPsswordMsg), () => |
| | | { |
| | | DelTempPwd(); |
| | | }); |
| | | } |
| | | }; |
| | | |
| | | //复制临时密码图标 |
| | | var btnCopy = new IconViewControl(28); |
| | | btnCopy.UnSelectedImagePath = "FunctionIcon/DoorLock/Shard.png"; |
| | | btnCopy.X = this.frameTempPsw.Width - btnCopy.IconSize - btnDelete.X; |
| | | btnCopy.Y = btnDelete.Y; |
| | | this.frameTempPsw.AddChidren(btnCopy); |
| | | btnCopy.ButtonClickEvent += (sender, e) => |
| | | { |
| | | //临时密码已经复制 |
| | | HdlCommonLogic.Current.SetTextToShearPlate(this.doorLockData.TempPassword, Language.StringByID(StringId.TempPsswordHasBeenCopy)); |
| | | }; |
| | | ////复制临时密码图标 |
| | | //var btnCopy = new IconViewControl(28); |
| | | //btnCopy.UnSelectedImagePath = "FunctionIcon/DoorLock/Shard.png"; |
| | | //btnCopy.X = this.frameTempPsw.Width - btnCopy.IconSize - btnDelete.X; |
| | | //btnCopy.Y = btnDelete.Y; |
| | | //this.frameTempPsw.AddChidren(btnCopy); |
| | | //btnCopy.ButtonClickEvent += (sender, e) => |
| | | //{ |
| | | // //临时密码已经复制 |
| | | // HdlCommonLogic.Current.SetTextToShearPlate(this.doorLockData.TempPassword, Language.StringByID(StringId.TempPsswordHasBeenCopy)); |
| | | //}; |
| | | |
| | | //生效时间 |
| | | var frameEffective = this.CreatEffectiveTimeControl(this.frameTempPsw, Language.StringByID(StringId.EffectiveTime), this.doorLockData.StatrtTime); |
| | | var frameEffective = this.CreatEffectiveTimeControl(this.frameTempPsw, Language.StringByID(StringId.EffectiveTime), this.doorLockData.StartTime); |
| | | frameEffective.X = Application.GetRealWidth(24); |
| | | frameEffective.Y = Application.GetRealHeight(180); |
| | | |
| | |
| | | btnLine.TextSize = CSS_FontSize.PromptFontSize_FirstLevel; |
| | | this.frameTempPsw.AddChidren(btnLine); |
| | | } |
| | | } |
| | | /// <summary> |
| | | /// 删除临时密码 |
| | | /// </summary> |
| | | private void DelTempPwd() |
| | | { |
| | | var waitPage = new Loading(); |
| | | this.AddChidren(waitPage); |
| | | waitPage.Start(""); |
| | | new System.Threading.Thread(() => |
| | | { |
| | | try |
| | | { |
| | | var pack = Common.ApiUtlis.Ins.HttpRequest.DelDoorTempPassword(device.deviceId, doorLockData.PwdId); |
| | | if (pack != null) |
| | | { |
| | | Application.RunOnMainThread(() => |
| | | { |
| | | if (pack.Code == StateCode.SUCCESS) |
| | | { |
| | | //清空临时密码 |
| | | this.doorLockData.TempPassword = string.Empty; |
| | | this.doorLockData.StartTimeTick = string.Empty; |
| | | this.doorLockData.EndTimeTick = string.Empty; |
| | | this.doorLockData.PwdId = string.Empty; |
| | | //重新初始化临时密码控件 |
| | | this.InitTempPasswordControl(); |
| | | } |
| | | else |
| | | { |
| | | IMessageCommon.Current.ShowErrorInfoAlter(pack.Code); |
| | | } |
| | | }); |
| | | } |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | | MainPage.Log($"删除门锁临时密码异常: {ex.Message}"); |
| | | } |
| | | finally |
| | | { |
| | | Application.RunOnMainThread(() => |
| | | { |
| | | try |
| | | { |
| | | waitPage.Hide(); |
| | | waitPage.RemoveFromParent(); |
| | | waitPage = null; |
| | | } |
| | | catch { } |
| | | }); |
| | | } |
| | | }) |
| | | { IsBackground = true }.Start(); |
| | | |
| | | } |
| | | |
| | | /// <summary> |
| | |
| | | |
| | | //生效时间 |
| | | var effectiveTime = Language.StringByID(StringId.EffectiveTime); |
| | | contr.AddRowMenu(effectiveTime, startTime.ToString("yyyy.MM.dd HH:mm"), (btnView, btnValue) => |
| | | contr.AddRowMenu(effectiveTime + ": " + startTime.ToString("yyyy.MM.dd HH:mm"),"", (btnView, btnValue) => |
| | | { |
| | | //关掉界面,然后重新调起来 |
| | | contr.Close(); |
| | | |
| | | var form = new DoorLockSelectTimePage(); |
| | | form.TimeCheck = true; |
| | | form.AddForm(startTime); |
| | | form.SelectFinshEvent += (selectTime) => |
| | | { |
| | |
| | | |
| | | //失效时间 |
| | | var failTime = Language.StringByID(StringId.FailureTime); |
| | | contr.AddRowMenu(failTime, endTime.ToString("yyyy.MM.dd HH:mm"), (btnView, btnValue) => |
| | | contr.AddRowMenu(failTime+": "+ endTime.ToString("yyyy.MM.dd HH:mm"),"", (btnView, btnValue) => |
| | | { |
| | | //关掉界面,然后重新调起来 |
| | | contr.Close(); |
| | | |
| | | var form = new DoorLockSelectTimePage(); |
| | | form.TimeCheck = true; |
| | | form.AddForm(endTime); |
| | | form.SelectFinshEvent += (selectTime) => |
| | | { |
| | |
| | | //关掉界面 |
| | | contr.Close(); |
| | | |
| | | //生成临时密码 |
| | | this.doorLockData.TempPassword = "987654"; |
| | | this.doorLockData.StatrtTime = startTime.ToString("yyyy.MM.dd HH:mm"); |
| | | this.doorLockData.EndTime = endTime.ToString("yyyy.MM.dd HH:mm"); |
| | | //重新初始化临时密码控件 |
| | | this.InitTempPasswordControl(); |
| | | new System.Threading.Thread(() => |
| | | { |
| | | var pack = Common.ApiUtlis.Ins.HttpRequest.CreateDoorTempPassword(device.deviceId, |
| | | Utlis.DateTimeToUnix(startTime).ToString(), Utlis.DateTimeToUnix(endTime).ToString()); |
| | | if (pack != null) |
| | | { |
| | | if (pack.Code == StateCode.SUCCESS) |
| | | { |
| | | // 获取临时密码 |
| | | GetTempPwd(); |
| | | } |
| | | else |
| | | { |
| | | Application.RunOnMainThread(() => { |
| | | IMessageCommon.Current.ShowErrorInfoAlter(pack.Code); |
| | | }); |
| | | } |
| | | } |
| | | }) |
| | | { IsBackground = true }.Start(); |
| | | ////生成临时密码 |
| | | //this.doorLockData.TempPassword = "987654"; |
| | | //this.doorLockData.StatrtTime = startTime.ToString("yyyy.MM.dd HH:mm"); |
| | | //this.doorLockData.EndTime = endTime.ToString("yyyy.MM.dd HH:mm"); |
| | | ////重新初始化临时密码控件 |
| | | //this.InitTempPasswordControl(); |
| | | } |
| | | }; |
| | | |
| | |
| | | } |
| | | } |
| | | //音量 |
| | | else if (data.key == "volume") |
| | | else if (data.key == "door_volume") |
| | | { |
| | | var value = data.state; |
| | | if (value != string.Empty) |
| | |
| | | /// <summary> |
| | | /// 临时密码生效时间(2020.03.17 13:27) |
| | | /// </summary> |
| | | public string StatrtTime = string.Empty; |
| | | public string StartTime { |
| | | get |
| | | { |
| | | try |
| | | { |
| | | if(string.IsNullOrEmpty(StartTimeTick)) |
| | | { |
| | | return string.Empty; |
| | | } |
| | | return Utlis.UnixToDateTime(Convert.ToInt64(StartTimeTick)).ToString("yyyy.MM.dd HH:mm"); |
| | | }catch(Exception ex) |
| | | { |
| | | MainPage.Log($"临时密码生效时间转换异常: {ex.Message}"); |
| | | return string.Empty; |
| | | } |
| | | } |
| | | } |
| | | public string StartTimeTick = string.Empty; |
| | | /// <summary> |
| | | /// 临时密码失效时间(2020.03.17 13:27) |
| | | /// </summary> |
| | | public string EndTime = string.Empty; |
| | | public string EndTime { |
| | | get |
| | | { |
| | | try |
| | | { |
| | | if (string.IsNullOrEmpty(EndTimeTick)) |
| | | { |
| | | return string.Empty; |
| | | } |
| | | return Utlis.UnixToDateTime(Convert.ToInt64(EndTimeTick)).ToString("yyyy.MM.dd HH:mm"); |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | | MainPage.Log($"临时密码生效时间转换异常: {ex.Message}"); |
| | | return string.Empty; |
| | | } |
| | | } |
| | | } |
| | | public string EndTimeTick = string.Empty; |
| | | /// <summary> |
| | | /// 临时密码id |
| | | /// </summary> |
| | | public string PwdId = string.Empty; |
| | | } |
| | | |
| | | /// <summary> |
| | | /// 门锁临时密码 |
| | | /// </summary> |
| | | private class DoorTempPassword |
| | | { |
| | | public string pwdId = string.Empty; |
| | | public string pwd = string.Empty; |
| | | public string beginTime = string.Empty; |
| | | public string endTime = string.Empty; |
| | | } |
| | | #endregion |
| | | } |
| | | } |