protected virtual byte[] ExecuteCurrentService() { if ((Services == null) || (Services.Count == 0)) { throw new InvalidOperationException("La lista de servicios PSEM no puede estar nula o vacía."); } byte[] request = null; try { if (serviceIndex < Services.Count) { if (serviceIndex == 0) { OnServicesExecutionStarted(); } request = CurrentService.SendRequest(); OnServiceExecutionStarted(CurrentService); } else { OnServicesExecutionCompleted(); StartCloseSession(); } } catch (Exception ex) { logger.Error(ex, nameof(ExecuteCurrentService), new object[] { nameof(serviceIndex), serviceIndex }); } return(request); }
/// <summary> /// 设置通知特征对象。 /// </summary> /// <returns></returns> public async Task GetCurrentNotifyCharacteristic() { Guid guid = new Guid(NotifyCharacteristicGuid); CurrentService.GetCharacteristicsForUuidAsync(guid).Completed = async(asyncInfo, asyncStatus) => { if (asyncStatus == AsyncStatus.Completed) { GattCharacteristicsResult result = asyncInfo.GetResults(); if (result.Characteristics.Count > 0) { CurrentNotifyCharacteristic = result.Characteristics[CHARACTERISTIC_INDEX]; CurrentNotifyCharacteristic.ProtectionLevel = GattProtectionLevel.Plain; CurrentNotifyCharacteristic.ValueChanged += Characteristic_ValueChanged; await EnableNotifications(CurrentNotifyCharacteristic); } else { //没有发现通知特征对象,自动重试中 await GetCurrentNotifyCharacteristic(); } } }; }
/// <summary> /// 设置写特征对象。 /// </summary> /// <returns></returns> public async Task GetCurrentWriteCharacteristic() { string msg = ""; Guid guid = new Guid(WriteCharacteristicGuid); CurrentService.GetCharacteristicsForUuidAsync(guid).Completed = async(asyncInfo, asyncStatus) => { if (asyncStatus == AsyncStatus.Completed) { GattCharacteristicsResult result = asyncInfo.GetResults(); msg = "特征对象=" + CurrentDevice.ConnectionStatus; ValueChanged(MsgType.NotifyTxt, msg); if (result.Characteristics.Count > 0) { CurrentWriteCharacteristic = result.Characteristics[CHARACTERISTIC_INDEX]; } else { msg = "没有发现特征对象Write,自动重试中"; ValueChanged(MsgType.NotifyTxt, msg); await GetCurrentWriteCharacteristic(); } } }; }
/// <summary> /// 提交按钮点击事件 - 添加记录 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void SubmitCurrent_Click(object sender, EventArgs e) { try { Current current = GetAddingCurrent(); bool isOk = CurrentService.AddCurrent(current); if (isOk) { Int64 currentId = GetCurrentId(current); if (!AddTopicJoin(currentId)) { PromptInfo.Text = "添加话题参与失败"; return; } else { Response.Redirect(URL_CURRENT_DETAIL + currentId); // 跳转到动态详情页 return; } } } catch (Exception ex) { PromptInfo.Text = ex.Message; } }
/// <summary> /// 显示用户发布的动态 /// </summary> protected void DisplayCurrentList() { try { Int64 userId = GetUserId(); if (userId == -1) { Response.Redirect("/layout/SignIn.aspx"); return; } DataTable data = CurrentService.GetCurrentByUserId(userId); if (data != null) { ListCurrent.DataSource = data; ListCurrent.DataBind(); } } catch (Exception ex) { PromptInfo.Text = ex.Message; } }
/// <summary> /// 设置通知特征对象。 /// </summary> /// <returns></returns> public async Task GetCurrentNotifyCharacteristic() { string msg = ""; Guid guid = new Guid(NotifyCharacteristicGuid); CurrentService.GetCharacteristicsForUuidAsync(guid).Completed = async(asyncInfo, asyncStatus) => { if (asyncStatus == AsyncStatus.Completed) { GattCharacteristicsResult result = asyncInfo.GetResults(); msg = "特征对象=" + CurrentDevice.ConnectionStatus; ValueChanged(MsgType.NotifyTxt, msg); if (result.Characteristics.Count > 0) { CurrentNotifyCharacteristic = result.Characteristics[CHARACTERISTIC_INDEX]; CurrentNotifyCharacteristic.ProtectionLevel = GattProtectionLevel.Plain; CurrentNotifyCharacteristic.ValueChanged += Characteristic_ValueChanged; await EnableNotifications(CurrentNotifyCharacteristic); } else { msg = "没有发现特征对象,自动重试中"; ValueChanged(MsgType.NotifyTxt, msg); await GetCurrentNotifyCharacteristic(); } } }; }
public void OnNext(Profile value) { Log.Log("Profile Found: "); Log.Log(value); if (value.Configurations.TryGetValue("keyboard", out var keyboardValue)) { CurrentService.ChangeKeyboardColor(new CompanyColor(keyboardValue)); } if (value.Configurations.TryGetValue("mouse", out var mouseValue)) { if ((mouseValue as String).Length > 6) { mouseValue = (mouseValue as String).Substring(2); } CurrentService.ChangeMouseColor(new CompanyColor(mouseValue)); } if (value.Configurations.TryGetValue("headset", out var headsetValue)) { CurrentService.ChangeHeadsetColor(new CompanyColor(headsetValue)); } if (value.Configurations.TryGetValue("headsetStand", out var headStandValue)) { CurrentService.ChangeHeadsetStandColor(new CompanyColor(headStandValue)); } if (value.Configurations.TryGetValue("mousepad", out var mouseMatValue)) { CurrentService.ChangeMousematColor(new CompanyColor(mouseMatValue)); } Thread.Sleep(10000); }
public ActionResult Index() { var entities = CurrentService.GetAllEntities().OrderByDescending(m => m.Id).ToList(); var model = ModelHelper <CargoInfo, CargoInfoViewModel> .EntitiesToModels(entities); return(View(model)); }
/// <summary> /// 获取服务。 /// </summary> /// <param name="prn"></param> /// <param name="time"></param> /// <returns></returns> public TProduct Get(SatelliteNumber prn, Time time) { if (CurrentService != null) { var result = CurrentService.Get(prn, time); if (result == null) { //重新选择服务。 log.Warn(this.Name + " " + prn + " 在 " + time + " 获取 " + typeof(TProduct).Name + " 失败!"); if (IsSwitchWhenEphemerisNull) { log.Info(typeof(TProduct).Name + " " + this.Name + "尝试重新选择服务"); return(LoopGetAndSetCurrentService(prn, time)); } } return(result); } if (NulledServices.Contains(time.GetGpsWeekAndDay())) { return(default(TProduct)); } TProduct rst = LoopGetAndSetCurrentService(prn, time); return(rst); }
/// <summary>Used to start the TVCore functionality, setup the user experience</summary> /// <returns>An awaitable task</returns> public static async Task Start() { if (State != TvCoreState.None) { throw new ApplicationException("TvCore already initializing or initialized..."); } ChangeState(TvCoreState.Starting); // Ask the service to give us the channel and guide data var(channels, guide) = await CurrentService.Process(); Channels = channels; Guide = guide; // Build the zero index map to the actual channel numbers ChannelIndexList = Channels.Select(x => x.Index).ToList(); // Put all the logos needed to be loaded into a queue so we can load them in another thread _imageCacheQueue = new Queue <Tuple <uint, string> >(Channels.Select(chan => new Tuple <uint, string>(chan.Index, chan.Logo?.ToString())).ToList()); // Threads... ThreadPool.QueueUserWorkItem(async x => await DownloadChannelImages()); // We are now considered ready to be running ChangeState(TvCoreState.Running); // Start the timer _coreTimer.AutoReset = true; _coreTimer.Elapsed += CoreTimerOnElapsed; _coreTimer.Start(); }
public ActionResult Delete(UserInfo model) { var returnMessageModel = CurrentService.Delete(model.Id); return(Redirect(Url.Action("Index"))); //return Json(returnMessageModel); }
public ActionResult Edit(T model) { var returnMessageModel = CurrentService.Edit(model); return(Redirect(Url.Action("Index"))); //return Json(returnMessageModel); }
public virtual ActionResult Create(T model) { var returnMessageModel = CurrentService.Add(model); return(Redirect(Url.Action("Index"))); //return Json(returnMessageModel); }
public virtual async void Save() { await CurrentService.ExecuteAsync(CurrentObject); await OnSavedChange?.Invoke(); Close(); }
public ActionResult Edit(int id) { //ViewBag.UserPrivilegesId = new SelectList(_db.CategoryInfo, "Id", "CategoryName", 1); var entity = CurrentService.GetEntityById(id); var model = ModelHelper <CategoryInfo, CategoryInfoViewModel> .EntityToModel(entity); return(View(model)); }
public virtual async void Delete() { await CurrentService.Delete(CurrentObject); await OnSavedChange?.Invoke(); Close(); }
public ActionResult Delete(int id) { //ViewBag.UserPrivilegesId = new SelectList(_db.ProjectInfo, "Id", "ProjectName", 1); var entity = CurrentService.GetEntityById(id); var model = ModelHelper <CargoInfo, CargoInfoViewModel> .EntityToModel(entity); return(View(model)); }
public ActionResult Create(SupplyCategoryInfoViewModel model) { SupplyInfoService.get return(View()); var returnMessageModel = CurrentService.Add(model); return(Redirect(Url.Action("Index"))); //return base.Create(model); }
/// <summary> /// 主动断开连接 /// </summary> /// <returns></returns> public void Dispose() { CurrentDeviceMAC = null; CurrentService?.Dispose(); CurrentDevice?.Dispose(); CurrentDevice = null; CurrentService = null; CurrentWriteCharacteristic = null; CurrentNotifyCharacteristic = null; ValueChanged(MsgType.NotifyTxt, "主动断开连接"); }
protected override void OnMouseWheel(MouseWheelEventArgs e) { base.OnMouseWheel(e); Preferences.IsExpanded = true; ToleranceSlider.Value += e.Delta * .05; if (CurrentService != null) { CurrentService.Update(); } }
public void ContinueService() { try { if (CurrentService != null) { CurrentService.Continue(); } } catch (Exception ex) { } }
public void PauseService() { try { if (CurrentService != null) { CurrentService.Pause(); } } catch (Exception ex) { } }
public void StartService() { try { if (CurrentService != null) { CurrentService.Start(); } } catch (Exception ex) { } }
/// <summary> /// 通过 ID 获取对应动态 /// </summary> /// <returns>数据表或 null</returns> protected DataTable GetDataOfCurrent() { Int64 currentId = GetCurrentId(); if (currentId >= 0) { return(CurrentService.GetCurrentById(currentId)); } else { return(null); } }
public InitializeViewModel( IRegionManager rm, CurrentService currentService, ArchiveService archiveService, CurrentHolder currentHolder, ArchiveHolder archiveHolder) : base(rm) { _currentService = currentService; _archiveService = archiveService; _currentHolder = currentHolder; _archiveHolder = archiveHolder; LoadedCommand = new DelegateCommand(async() => await LoadedAsync()); }
static void Main(string[] args) { CurrentService CurSvc = new CurrentService(); ServiceController[] ComSvc, DevSvc; ComSvc = ServiceController.GetServices(); DevSvc = ServiceController.GetDevices(); int CSc = 0, DSc = 0, CSl = ComSvc.Length, DSl = DevSvc.Length, MinNumOfSvc = (CSl > DSl) ? DSl : CSl; while (CSc < CSl && DSc < DSl) { if (String.Compare(ComSvc[CSc].ServiceName, DevSvc[DSc].ServiceName, true) > 0) { CurSvc.ServiceName = DevSvc[DSc].ServiceName; CurSvc.DisplayName = DevSvc[DSc].DisplayName; CurSvc.Status = DevSvc[DSc].Status.ToString(); DSc++; } else { CurSvc.ServiceName = ComSvc[CSc].ServiceName; CurSvc.DisplayName = ComSvc[CSc].DisplayName; CurSvc.Status = ComSvc[CSc].Status.ToString(); CSc++; } Console.Write(CurSvc.ServiceName); Console.Write('\t'); Console.Write(CurSvc.DisplayName); Console.Write('\t'); Console.WriteLine(CurSvc.Status); } if (DSc == DSl) { while (++CSc < CSl) { Console.Write(ComSvc[CSc].ServiceName); Console.Write('\t'); Console.Write(ComSvc[CSc].DisplayName); Console.Write('\t'); Console.WriteLine(ComSvc[CSc].Status.ToString()); } } else { while (++DSc < DSl) { Console.Write(DevSvc[DSc].ServiceName); Console.Write('\t'); Console.Write(DevSvc[DSc].DisplayName); Console.Write('\t'); Console.WriteLine(DevSvc[DSc].Status.ToString()); } } }
/// <summary> /// 获取刚添加的动态 ID /// </summary> /// <param name="current">实体对象</param> /// <returns>动态ID, -1 表示获取失败</returns> protected Int64 GetCurrentId(Current current) { Int64 currentId = 0; try { currentId = CurrentService.GetAddingCurrentId(current); } catch (Exception ex) { currentId = -1; PromptInfo.Text = ex.Message; } return(currentId); }
/// <summary> /// 主动断开连接 /// </summary> /// <returns></returns> public void Dispose() { CurrentDeviceMAC = null; if (CurrentService != null) { CurrentService.Dispose(); } if (CurrentDevice != null) { CurrentDevice.Dispose(); } CurrentDevice = null; CurrentService = null; CurrentWriteCharacteristic = null; CurrentNotifyCharacteristic = null; }
/// <summary> /// 根据话题 ID 获取动态 /// </summary> /// <returns>数据表或 null</returns> protected DataTable GetDataOfCurrrent() { DataTable data = null; Int64 topicId = GetTopicId(); if (topicId > 0) { data = CurrentService.GetCurrentByTopicId(topicId); } else { throw new Exception("传递 URL 参数错误,话题 ID 格式不正确, 获取动态数据失败 -> GetDataOfCurrrent()"); } return(data); }
/// <summary> /// 显示前 5 条热门动态 /// </summary> protected void DisplayHotCurrent() { try { DataTable data = CurrentService.GetHotCurrent(); if (data != null) { LvHotCurrent.DataSource = data; LvHotCurrent.DataBind(); } } catch (Exception ex) { PromptInfo.Text = ex.Message; } }