public static void ExecuteApps(AppEvent appEvent, object eventObject) { logger.Log(LogLevel.Debug, "ExecuteApps called for event [{0}]", appEvent); IList<App> apps = null; switch(appEvent) { case AppEvent.CommentSaved: case AppEvent.CommentSaving: apps = AppStore.Instance.GetAppList(AppScope.Comment); break; case AppEvent.ImageUploaded: apps = AppStore.Instance.GetAppList(AppScope.Image); break; } if (apps != null) { ExecuteApp(apps, appEvent, eventObject); } }
private void DispatchEvent(AppEvent evt, object eventData = null) { if (!_eventListeners.ContainsKey(evt)) return; foreach (var action in _eventListeners[evt].ToArray()) { action(eventData); } }
public void On(AppEvent evt, EventHandler listener) { if (!_eventListeners.ContainsKey(evt)) { _eventListeners[evt] = new HashSet<EventHandler>(); } _eventListeners[evt].Add(listener); }
public static void Execute(AbstractApp app, AppEvent appEvent, object eventObject) { if (app == null) { throw new ArgumentNullException("app"); } if (appEvent == AppEvent.None) { logger.Log(LogLevel.Info, "Ignoring execution on {0} as event is none", app); return; } Comment comment; FormEntry formEntry; logger.Log(LogLevel.Info, "Executing [{0}] for event - [{1}]", app, appEvent); switch (appEvent) { case AppEvent.CommentSaved: comment = eventObject as Comment; app.CommentSaved(comment); break; case AppEvent.CommentSaving: comment = eventObject as Comment; app.CommentSaving(comment); break; case AppEvent.CommentSpammed: comment = eventObject as Comment; app.CommentSpamed(comment); break; case AppEvent.FormEntrySaving: formEntry = eventObject as FormEntry; app.FormEntrySaving(formEntry); break; case AppEvent.FormEntrySaved: formEntry = eventObject as FormEntry; app.FormEntrySaved(formEntry); break; case AppEvent.ImageUploaded: app.ImageUploaded(eventObject as string); break; } logger.Log(LogLevel.Info, "Execution [{0}] for event - [{1}] done", app, appEvent); }
/// <summary> /// 调用 <see cref="CQ_GroupManagerChange"/> 方法 /// </summary> /// <param name="appEvent">目标事件信息</param> /// <param name="subType">事件类型</param> /// <param name="sendTime">发送时间</param> /// <param name="fromGroup">来源群</param> /// <param name="beingOperateQQ">被操作QQ</param> /// <exception cref="ObjectDisposedException">当前对象已经被释放</exception> /// <exception cref="MissingMethodException">尝试访问未公开的函数</exception> /// <returns>返回函数处理结果</returns> public HandleType InvokeCQGroupManagerChange(AppEvent appEvent, GroupManagerChangeType subType, int sendTime, long fromGroup, long beingOperateQQ) { if (appEvent is null) { throw new ArgumentNullException(nameof(appEvent)); } if (appEvent.Type != AppEventType.GroupManagerChange) { throw new ArgumentException($"函数信息不是 {AppEventType.GroupManagerChange} 类型", nameof(appEvent)); } return((HandleType)this.GetFunction <CQ_GroupManagerChange> (appEvent.Function) ((int)subType, sendTime, fromGroup, beingOperateQQ)); }
/// <summary> /// 调用 <see cref="CQ_GroupBanSpeak"/> 方法 /// </summary> /// <param name="appEvent">目标事件信息</param> /// <param name="subType">事件类型</param> /// <param name="sendTime">发送时间</param> /// <param name="fromGroup">来源群</param> /// <param name="fromQQ">来源QQ</param> /// <param name="beingOperateQQ">被操作QQ</param> /// <param name="duration">禁言时间</param> /// <exception cref="ObjectDisposedException">当前对象已经被释放</exception> /// <exception cref="MissingMethodException">尝试访问未公开的函数</exception> /// <returns>返回函数处理结果</returns> public HandleType InvokeCQGroupBanSpeak(AppEvent appEvent, GroupBanSpeakType subType, int sendTime, long fromGroup, long fromQQ, long beingOperateQQ, long duration) { if (appEvent is null) { throw new ArgumentNullException(nameof(appEvent)); } if (appEvent.Type != AppEventType.GroupMemberBanSpeak) { throw new ArgumentException($"函数信息不是 {AppEventType.GroupMemberBanSpeak} 类型", nameof(appEvent)); } return((HandleType)this.GetFunction <CQ_GroupBanSpeak> (appEvent.Function) ((int)subType, sendTime, fromGroup, fromQQ, beingOperateQQ, duration)); }
/// <summary> /// 调用 <see cref="CQ_FriendAdd"/> 方法 /// </summary> /// <param name="appEvent">目标事件信息</param> /// <param name="subType">事件类型</param> /// <param name="sendTime">发送时间</param> /// <param name="fromQQ">来源QQ</param> /// <exception cref="ObjectDisposedException">当前对象已经被释放</exception> /// <exception cref="MissingMethodException">尝试访问未公开的函数</exception> /// <returns>返回函数处理结果</returns> public HandleType InvokeCQFriendAdd(AppEvent appEvent, FriendAddType subType, int sendTime, long fromQQ) { if (appEvent is null) { throw new ArgumentNullException(nameof(appEvent)); } if (appEvent.Type != AppEventType.FriendAdd) { throw new ArgumentException($"函数信息不是 {AppEventType.FriendAdd} 类型", nameof(appEvent)); } return((HandleType)this.GetFunction <CQ_FriendAdd> (appEvent.Function) ((int)subType, sendTime, fromQQ)); }
public override void Handle(AppEvent message) { base.Handle(message); if(message.Type.Equals(Constants.RifleRemovedMessage)) { SelectedRifle = Rifles.FirstOrDefault(); SelectedCartridge = SelectedRifle.Cartridge; } if (message.Type.Equals(Constants.CartridgeRemovedMessage)) { SelectedCartridge = SelectedRifle.Cartridge; } }
private async Task UpdateAppAsync(AppEvent @event, EnvelopeHeaders headers, Action <MongoAppEntity> updater) { await Collection.UpdateAsync(@event, headers, a => { updater(a); a.ContributorIds = a.Contributors.Keys.ToList(); }); foreach (var subscriber in subscribers) { subscriber(@event.AppId); } }
public AppEvent UpdateResource(Resource entity, ClaimsPrincipal principal) { string username = principal.FindFirstValue(AppClaimType.UserName); var ev = new AppEvent { Data = null, Description = $"User {username} updated resource id: {entity.Id}", Type = Data.Constants.AppEventType.UpdateResource, UserId = principal.Identity.Name }; PrepareCreate(ev); return(context.AppEvent.Add(ev).Entity); }
public AppEvent DeleteDefectType(DefectType entity, ClaimsPrincipal principal) { string username = principal.FindFirstValue(AppClaimType.UserName); var ev = new AppEvent { Data = null, Description = $"User {username} deleted defect type id: {entity.Id}", Type = Data.Constants.AppEventType.DeleteDefectType, UserId = principal.Identity.Name }; PrepareCreate(ev); return(context.AppEvent.Add(ev).Entity); }
public AppEvent CreateProductionLine(ProductionLine entity, ClaimsPrincipal principal) { string username = principal.FindFirstValue(AppClaimType.UserName); var ev = new AppEvent { Data = null, Description = $"User {username} created a production line with code {entity.Code}, id: {entity.Id}", Type = Data.Constants.AppEventType.CreateProductionLine, UserId = principal.Identity.Name }; PrepareCreate(ev); return(context.AppEvent.Add(ev).Entity); }
public AppEvent ChangeProductionLineStatus(ProductionLine entity, ClaimsPrincipal principal) { string username = principal.FindFirstValue(AppClaimType.UserName); var ev = new AppEvent { Data = null, Description = $"User {username} changed production line disabled status: {entity.Disabled} - id: {entity.Id}", Type = Data.Constants.AppEventType.ChangeProductionLineStatus, UserId = principal.Identity.Name }; PrepareCreate(ev); return(context.AppEvent.Add(ev).Entity); }
public async Task PublishAsync(AppEvent appEvent, CancellationToken cancellationToken) { await Task.Run(() => { try { return(_mediator.PublishAsync(appEvent, cancellationToken)); } catch (Exception ex) { var eventingEx = new EventingException(appEvent, ex); _exceptionHandler.Handle(eventingEx); return(Task.FromException(ex)); } }); }
/// <summary> /// 单个资源下载完成 /// 将文件写入本地 /// 如果有压缩或者加密,可以在这里进行解析 /// </summary> /// <param name="s"></param> /// <param name="o"></param> /// <param name="arg3"></param> private void SingleAssetComplete(string s, object o, object arg3) { byte[] bytes = (byte[])o; AssetBundleVersionItem downloadItem = (AssetBundleVersionItem)arg3; string localItemPath = GetFileLocalPath(downloadItem); // 写入到本地 App.Make <IFileDiskSystem>().CreateFile(localItemPath, bytes); if (downloadItem.AssetPathType == AssetPathType.gameLoad) { // 广播,通知临时资源使用中心来替换临时资源(一般为模型,音效,UI等) AppEvent.BroadCastEvent(string.Format("{0}_{1}", AssetBundleDefine.ABDownloadSuccess, localItemPath)); } }
private string CreateEventName(AppEvent appEvent) { var eventName = typeNameRegistry.GetName(appEvent.GetType()); if (appEvent is SchemaEvent schemaEvent) { if (eventName.StartsWith(ContentPrefix, StringComparison.Ordinal)) { eventName = eventName.Substring(ContentPrefix.Length); } return($"{schemaEvent.SchemaId.Name.ToPascalCase()}{eventName}"); } return(eventName); }
public string GetName(AppEvent @event) { foreach (var handler in ruleTriggerHandlers.Values) { if (handler.Handles(@event)) { var name = handler.GetName(@event); if (!string.IsNullOrWhiteSpace(name)) { return(name); } } } return(@event.GetType().Name); }
/// <summary> /// Fills the default values for the properties. /// </summary> /// <param name="appEvent">The event to populate data with.</param> private void FillDefaults(AppEvent appEvent) { if (appEvent.ApiKey == null) { appEvent.ApiKey = apiKey; } if (appEvent.ContextAppVersion == null) { appEvent.ContextAppVersion = contextAppVersion; } if (appEvent.ContextEnvName == null) { appEvent.ContextEnvName = this.contextEnvName; } if (appEvent.ContextEnvVersion == null) { appEvent.ContextEnvVersion = this.contextEnvVersion; } if (appEvent.ContextEnvHostname == null) { appEvent.ContextEnvHostname = this.contextEnvHostname; } if (appEvent.ContextAppOS == null) { appEvent.ContextAppOS = this.contextAppOS; appEvent.ContextAppOSVersion = this.contextAppOSVersion; } if (appEvent.ContextDataCenter == null) { appEvent.ContextDataCenter = contextDataCenter; } if (appEvent.ContextDataCenterRegion == null) { appEvent.ContextDataCenterRegion = contextDataCenterRegion; } if (!appEvent.EventTime.HasValue) { appEvent.EventTime = (long)(DateTime.Now - DT_EPOCH).TotalMilliseconds; } }
private async Task EnqueueJobAsync(string payload, IWebhookEntity webhook, AppEvent contentEvent, string eventName, Instant now) { var signature = $"{payload}{webhook.SharedSecret}".Sha256Base64(); var job = new WebhookJob { Id = Guid.NewGuid(), AppId = contentEvent.AppId.Id, RequestUrl = webhook.Url, RequestBody = payload, RequestSignature = signature, EventName = eventName, Expires = now.Plus(ExpirationTime), WebhookId = webhook.Id }; await webhookEventRepository.EnqueueAsync(job, now); }
private static void AddAppEventContent(IHtmlOutput outer, AppEvent e) { if (!outer.Items.ContainsKey(e)) { return; } outer.Append(".on"); outer.Append(e.ToString()); outer.Append("(function (view) {"); outer.Append("\r\n"); foreach (var item in outer.Items[e] as List <string> ) { outer.Append(item); outer.Append("\r\n"); } outer.Append("})"); }
public override void calculate_signals_impl(Object sender, MarketDataEventArgs args) { AppEvent appEvent = eventManager.storeEventQueue[stgName].Take(); var watch = Stopwatch.StartNew(); if (appEvent.Type.Equals(AppEventType.TickerPrice)) { AppTickPriceEvent tickPriceEvent = (AppTickPriceEvent)appEvent; updateTick(tickPriceEvent); } else if (appEvent.Type.Equals(AppEventType.DailyReset)) { stgDailyReset(); return; } else { return; } if (!MDManager.isDataReady()) { return; } if (!dataIsReady) { log.Info("Data is Ready."); } dataIsReady = true; Series <DateTime, MarketDataElement> seriesSelected = MDManager.getTimeBarSeries(); cacluateRanges(); calculateCurrentMax(seriesSelected); checkStgExitOrderCompleted(seriesSelected); checkStgEnterOrderCompleted(seriesSelected); exitTradeStrategy(seriesSelected); dayEndCloseTrade(seriesSelected); enterTradeStrategy(seriesSelected); watch.Stop(); double ticks = watch.ElapsedTicks; log.Info("[Strategy] calculate_signals_impl running for = " + watch.ElapsedTicks * 1000000 / Stopwatch.Frequency + " micro second"); }
/// <summary> /// 添加事件脚本 /// </summary> /// <param name="source"></param> /// <param name="e"></param> /// <param name="script"></param> public static void AddEvent(this IHtmlOutput source, AppEvent e, Element.Script script) { if (script == null) { return; } if (!script.HasContent()) { return; } InitEventContent(source); if (!source.Items.ContainsKey(e)) { source.Items.Add(e, new List <string>()); } var list = source.Items[e] as List <string>; script.SetListFromContent(list); }
/// <summary> /// 调用 <see cref="CQ_AppDisable"/> 方法 /// </summary> /// <param name="appEvent">目标事件信息</param> /// <exception cref="ObjectDisposedException">当前对象已经被释放</exception> /// <exception cref="MissingMethodException">尝试访问未公开的函数</exception> /// <returns>操作成功返回 0</returns> public int InvokeCQAppDisable(AppEvent appEvent) { if (appEvent is null) { throw new ArgumentNullException(nameof(appEvent)); } if (appEvent.Type != AppEventType.CQAppDisable) { throw new ArgumentException($"函数信息不是 {AppEventType.CQAppDisable} 类型", nameof(appEvent)); } int recode = this.GetFunction <CQ_AppDisable> (appEvent.Function) (); if (recode == 0) { this.IsEnable = false; } return(recode); }
public IDictionary <string, object> GetAppEventDynamic( AppEvent row, AppEventQueryProjection projection, AppEventQueryOptions options) { var obj = new Dictionary <string, object>(); foreach (var f in projection.GetFieldsArr()) { switch (f) { case AppEventQueryProjection.INFO: { var entity = row; obj["id"] = entity.Id; var time = entity.CreatedTime .ToDefaultTimeZone(); var timeStr = time.ToString(options.date_format); obj["created_time"] = new { display = timeStr, iso = $"{time.ToUniversalTime():s}Z" }; obj["description"] = entity.Description; obj["type"] = entity.Type; obj["user_id"] = entity.UserId; } break; case AppEventQueryProjection.USER: { var entity = row.User; obj["user"] = new { id = entity.Id, username = entity.UserName, full_name = entity.FullName, }; } break; } } return(obj); }
public override void calculate_signals_impl(Object sender, MarketDataEventArgs args) { try { AppEvent appEvent = eventManager.storeEventQueue[stgName].Take(); var watch = Stopwatch.StartNew(); if (appEvent.Type.Equals(AppEventType.TickerPrice)) { AppTickPriceEvent tickPriceEvent = (AppTickPriceEvent)appEvent; updateTick(tickPriceEvent); } else { return; } //updateTick(tick); if (!MDManager.isDataReady()) { return; } if (!dataIsReady) { log.Info("Data is Ready."); } dataIsReady = true; series1 = MDManager.getTimeBarSeries(); checkStgEnterOrderCompleted(series1); checkStgExitOrderCompleted(series1); cutLossTrade(series1); exitTradeStrategy(series1); enterTradeStrategy(series1); // log.Info("[Strategy] day end close running for = " + watch.ElapsedMilliseconds + " millsecond"); watch.Stop(); double ticks = watch.ElapsedTicks; log.Info("[Strategy] calculate_signals_impl running for = " + watch.ElapsedTicks * 1000000 / Stopwatch.Frequency + " micro second"); } catch (InvalidOperationException e) { return; } }
void Start() { if (GameManager.Instance.CursorActive) { AppEvent.InvokeMouseCursorEnable(false); } CrosshairStartPosition = new Vector2(Screen.width / 2f, Screen.height / 2f); // set horizontal offset HorizontalOffset = (Screen.width * CrosshairHorizontalPercentage) / 2f; MinHorizontalDeltaConstrain = -(Screen.width / 2f) + HorizontalOffset; MaxHorizontalDeltaConstrain = (Screen.width / 2f) - HorizontalOffset; // set vertical offset VerticalOffset = (Screen.height * CrosshairVerticalPercentage) / 2f; MinVerticalDeltaConstrain = -(Screen.height / 2f) + VerticalOffset; MaxVerticalDeltaConstrain = (Screen.height / 2f) - VerticalOffset; }
public void Eventlistener <T>(object sender, AppEvent <T> e) { string key = sender.ToString(); if (key == Mediator.DANGNHAP_THANH_CONG) { var nhanvien = e.value as NhanVienModel; MANHANVIEN = nhanvien.MaCV; txtUserInfo.Text = "Nhân viên: " + nhanvien.TenNhanVien; LoadBaoCaoView(); LoadSanPhamView(); LoadHoaDonBanView(); LoadHoaDonNhapView(); } if (key == Mediator.DANGNHAP_KHONG_THANH_CONG) { Application.Exit(); } }
public void AddEventListener <T>(object sender, AppEvent <T> e) { var key = sender.ToString(); if (key == Mediator.NHAN_VIEN_CALL_CONG_VIEC_GET_MA) { if (e != null) { if (e.value != null) { var m = e.value as CongViecModel; if (m != null) { nhanVienView.SetTxtMaCv(m.MaCV); app.Resolve <IBaseController <CongViecModel> >().HideForm(); } } } } }
public override void calculate_signals_impl(Object sender, MarketDataEventArgs args) { AppEvent appEvent = eventManager.storeEventQueue[stgName].Take(); if (appEvent.Type.Equals(AppEventType.TickerPrice)) { AppTickPriceEvent tickPriceEvent = (AppTickPriceEvent)appEvent; updateTick(tickPriceEvent); } else if (appEvent.Type.Equals(AppEventType.DailyReset)) { stgDailyReset(); return; } else { return; } if (!MDManager.isDataReady()) { return; } if (!dataIsReady) { log.Info("Data is Ready."); } dataIsReady = true; Series <DateTime, MarketDataElement> seriesSelected = MDManager.getTimeBarSeries(); calculateExtreme(seriesSelected); cancelInvalidSignalOrder(); cacluateRanges(); calculateCurrentMax(seriesSelected); checkStgExitOrderCompleted(seriesSelected); checkStgEnterOrderCompleted(seriesSelected); exitTradeStrategy(seriesSelected); dayEndCloseTrade(seriesSelected); enterTradeStrategy(seriesSelected); }
public List <AppEvent> getEvents(string user_id) { var dbcon = new SqlConnection(ConfigurationManager.ConnectionStrings["userdata"].ToString()); var dbcommand = new SqlCommand("select * from app_events where user_id = @user_id", dbcon); dbcommand.Parameters.AddWithValue("@user_id", SqlDbType.UniqueIdentifier).Value = user_id; dbcon.Open(); var reader = dbcommand.ExecuteReader(); var model = new List <AppEvent>(); while (reader.Read()) { var appEvent = new AppEvent(); appEvent.user_id = reader["user_id"].ToString(); appEvent.event_date = reader["event_date"].ToString(); appEvent.event_type = reader["event_type"].ToString(); model.Add(appEvent); } dbcon.Close(); return(model); }
public ActionResult Save(AppEventFormViewModel model, string comment, HttpPostedFileBase image1) { var userIdToPass = User.Identity.GetUserId(); var user = _context.Users.FirstOrDefault(u => u.Id == userIdToPass); AppUser appUserToPass = _context.AppUsers.SingleOrDefault(c => c.Id == user.AppUserId); AppEvent _event = model.AppEvent; Guid str_guid = Guid.NewGuid(); string idToGive = str_guid.ToString(); _event.Findid = idToGive; _event.AppUser = appUserToPass; _event.AppUserId = appUserToPass.Id; if (_event.Id == 0) { _context.Events.Add(_event); _context.SaveChanges(); var _eventToAddImgWith = _context.Events.SingleOrDefault(x => x.Findid == idToGive); AddImgWithEvent(image1, comment, _eventToAddImgWith.Id); } else { var eventInDb = _context.Events.Single(m => m.Id == _event.Id); eventInDb.Name = _event.Name; eventInDb.Description = _event.Description; eventInDb.StatusId = _event.StatusId; eventInDb.CategoryId = _event.CategoryId; //eventInDb.Status = _event.Status; eventInDb.CityId = _event.CityId; eventInDb.Street = _event.Street; eventInDb.HouseNumber = _event.HouseNumber; } _context.SaveChanges(); return(RedirectToAction("Index", "AppEvents")); }
private void ListenNetEvents() { while (Running) { AppEvent appEvent = AppNetChannel.TakeFromNet(); Target target = appEvent.Target; Action action = appEvent.Action; Subject subject = appEvent.Subject; object data = appEvent.Data; if (appEvent.GetType() == typeof(ClientAppEvent)) { Client client = ((ClientAppEvent)appEvent).Client; if (subject == Subject.Desktop) { if (action == Action.Fetched) { string path = Directory.GetCurrentDirectory() + Path.DirectorySeparatorChar + client.PcName; if (!Directory.Exists(path)) { Directory.CreateDirectory(path); } File.WriteAllBytes(path + Path.DirectorySeparatorChar + "screenshot.png", (byte[])data); appEvent.Data = path; } } } AppUiChannel.SubmitToUi(appEvent); } }
/// <summary> /// 添加事件脚本 /// </summary> /// <param name="source"></param> /// <param name="e"></param> /// <param name="script"></param> public static void AddEvent(this IHtmlOutput source, AppEvent e, string script) { if (string.IsNullOrWhiteSpace(script)) { return; } InitEventContent(source); if (!source.Items.ContainsKey(e)) { source.Items.Add(e, new List <string>()); } var list = source.Items[e] as List <string>; if (script.Last() == ';') { list.Add(script); } else { list.Add(string.Format("{0};", script)); } }
public JsonResult SaveEvent(AppEvent evt) { bool status = false; using (var db = new DatabaseModel()) { if (evt.EndAt != null && evt.StartAt.TimeOfDay == new TimeSpan(0, 0, 0) && evt.EndAt.Value.TimeOfDay == new TimeSpan(0, 0, 0)) { evt.IsFullDay = true; } else { evt.IsFullDay = false; } if (evt.EventID > 0) { var exist = db.AppEvents.Where(a => a.EventID.Equals(evt.EventID)).FirstOrDefault(); if (exist != null) { exist.Title = evt.Title; exist.Description = evt.Description; exist.StartAt = evt.StartAt; exist.EndAt = evt.EndAt; exist.IsFullDay = evt.IsFullDay; } } else { db.AppEvents.Add(evt); } db.SaveChanges(); status = true; } return(new JsonResult { Data = new { status = status } }); }
public void Off(AppEvent evt, EventHandler listener) { _eventListeners[evt].Remove(listener); }
private static void ExecuteApp(IList<App> apps, AppEvent appEvent, object eventObject) { logger.Log(LogLevel.Debug, "ExecuteApp called for event [{0}] - eventObject [{1}]", appEvent, eventObject); if (apps != null && apps.Count > 0) { foreach (App app in apps) { logger.Log(LogLevel.Debug, "Executing app [{0}] for [{1}]", app, eventObject); AbstractApp abstractApp = AppEngine.GetDefinedApp(app); if (abstractApp != null) { long executionId = AppEngine.RecordAppExecutionStart(app); bool success = false; string error = string.Empty; try { AppExecutor.Execute(abstractApp, appEvent, eventObject); } catch (Exception exception) { error = exception.Message; logger.Log(LogLevel.Warn, "Error executing app [{0}] - Exception : {1}", app, exception); } finally { AppEngine.RecordAppExecutionEnd(executionId, success, error); } } } } }