예제 #1
0
 //Used for late bound
 protected void RegisterEvent(string entityLogicalName, EventOperation eventOperation, ExecutionStage executionStage, Action <LocalPluginContext> action)
 => RegisteredEvents.Add(
     new Tuple <int, string, string, Action <LocalPluginContext> >(
         (int)executionStage,
         eventOperation.ToString(),
         entityLogicalName,
         action));
예제 #2
0
        private void BroadcastMessage(EventOperation operation, Guid clientId, string message)
        {
            ThreadPool.QueueUserWorkItem(
                delegate
            {
                lock (clients)
                {
                    List <Guid> disconnectedClientGuids = new List <Guid>();

                    foreach (KeyValuePair <Guid, INotificationServiceCallBack> client in clients)
                    {
                        try
                        {
                            client.Value.HandleMessage(operation);
                        }
                        catch (Exception)
                        {
                            disconnectedClientGuids.Add(client.Key);
                        }
                    }


                    foreach (Guid clientGuid in disconnectedClientGuids)
                    {
                        clients.Remove(clientGuid);
                    }
                }
            });
        }
예제 #3
0
 // Метод-обработчик события KeyPress для textBox1, возникающее когда элемент управления находится в фокусе и пользователь нажимает и отпускает клавишу
 private void textBoxKeyPress(object sender, KeyPressEventArgs e)
 {
     keyPressEventArgs.KeyChar = e.KeyChar;
     eventArgs = new KeyPressEventArgs(keyPressEventArgs.KeyChar);
     ((TextBox)senderDeleteX).Text = ((TextBox)senderDelete).Text;
     EventBoolM.Invoke(senderDeleteX, eventArgs);
     if (keyDelete == true)
     {
         EventDelete.Invoke(senderDelete, keyPressEventArgs);
         keyDelete = false;
         e.KeyChar = '\0';
     }
     if (keyBackspace == true)
     {
         EventBackspace.Invoke(senderDelete, keyPressEventArgs);
         keyBackspace = false;
         return;
     }
     if (((TextBox)senderDeleteX).Text == "\0\0\0")
     {
         ((TextBox)senderDelete).Text = "0";
     }
     EventSigns.Invoke(sender, e);
     EventOperation.Invoke(sender, e);
     EventKeyPress.Invoke(sender, e);
     EventKeyPressKey.Invoke(sender, e);
     keyPressEventArgs = e;
 }
예제 #4
0
 public void LocallyHandleMessageArrived(EventOperation op, int userID)
 {
     if (AlterationsEvents != null)
     {
         AlterationsEvents(op, userID);
     }
 }
예제 #5
0
 public void HandleMessage(EventOperation operation)
 {
     if (UserNotifiedEvent != null)
     {
         UserNotifiedEvent(operation);
     }
 }
예제 #6
0
 protected void RegisterEventOnAllEntities(EventOperation eventOperation, ExecutionStage executionStage, Action <LocalPluginContext> action)
 => RegisteredEvents.Add(
     new Tuple <int, string, string, Action <LocalPluginContext> >(
         (int)executionStage,
         eventOperation.ToString(),
         null,
         action));
예제 #7
0
 protected void RegisterEvent <T>(EventOperation eventOperation, ExecutionStage executionStage, Action <LocalPluginContext> action) where T : Entity
 => RegisteredEvents.Add(
     new Tuple <int, string, string, Action <LocalPluginContext> >(
         (int)executionStage,
         eventOperation.ToString(),
         Activator.CreateInstance <T>().LogicalName,
         action));
예제 #8
0
 public EntityModifiedMessage(Guid identityId, Guid entityId, ModuleType moduleType, string entityType, EventOperation operationType)
 {
     EntityId      = entityId;
     IdentityId    = identityId;
     EntityType    = entityType;
     ModuleType    = moduleType;
     OperationType = operationType;
 }
예제 #9
0
 /// <summary>
 /// 向恢复管理器中写入日志内容
 /// </summary>
 /// <param name="logId">日志编号,同一个日志可以写多份内容,可以根据这些内容执行恢复操作</param>
 /// <param name="name">内容名称</param>
 /// <param name="content">内容</param>
 private static void WriteAndFlush(Guid logId, EventOperation operation, DTObject content)
 {
     DataContext.NewScope(() =>
     {
         var log = GetLog(logId);
         Write(log, operation, content);
     }, true);
 }
예제 #10
0
 public PluginStepConfig(EventOperation eventOperation, ExecutionStage executionStage)
 {
     this.LogicalName    = Activator.CreateInstance <T>().LogicalName;
     this.EventOperation = eventOperation.ToString();
     this.ExecutionStage = (int)executionStage;
     this.Deployment     = (int)Plugins.Deployment.ServerOnly;
     this.ExecutionMode  = (int)Plugins.ExecutionMode.Synchronous;
     this.ExecutionOrder = 1;
 }
예제 #11
0
 public EventLogEntry(Guid id, EventOperation operation, string contentCode, int orderIndex, bool isReversed)
     : base(id)
 {
     this.Operation   = operation;
     this.ContentCode = contentCode;
     this.OrderIndex  = orderIndex;
     this.IsReversed  = isReversed;
     this.OnConstructed();
 }
        public async Task <IActionResult> JoinEvent([FromRoute] Guid eventId)
        {
            try
            {
                Guid userId = User.GetUserId();

                var eventOperation = await _eventOperationRepo.First(eo => eo.UserId == userId && eo.EventId == eventId);

                if (eventOperation != null)
                {
                    return(BadRequest("Etkinliğe daha önce katıldınız."));
                }
                else
                {
                    var entity = new EventOperation()
                    {
                        Id      = new Guid(),
                        UserId  = userId,
                        EventId = eventId
                    };

                    var response = await _eventOperationRepo.Add(entity);

                    if (response)
                    {
                        try
                        {
                            await _gameHelper.Point(userId, GameType.AttendEvent);
                        }
                        catch { }

                        var @event = await _eventRepo.First(e => e.Id == eventId);

                        if (@event != null)
                        {
                            Guid receiverId = @event.UserId;
                            if (!receiverId.Equals(userId))
                            {
                                await _notificationHelper.SendEventAttendNotification(userId, receiverId, @event.Id);
                            }
                        }

                        return(Ok("Etkinliğe katıldınız."));
                    }
                    else
                    {
                        return(BadRequest("Etkinliğe katılamadınız."));
                    }
                }
            }
            catch (Exception ex)
            {
                _logHelper.Log("EventOperationsController", 500, "JoinEvent", ex.Message);
                return(null);
            }
        }
예제 #13
0
 public EventLogEntry(EventLog log, EventOperation operation, string contentCode, int orderIndex)
     : base(Guid.NewGuid())
 {
     this.Log         = log;
     this.Operation   = operation;
     this.ContentCode = contentCode;
     this.OrderIndex  = orderIndex;
     this.IsReversed  = false;
     this.OnConstructed();
 }
예제 #14
0
 /// <summary>
 /// Trigger all plugin steps which match the given parameters.
 /// </summary>
 /// <param name="operation"></param>
 /// <param name="stage"></param>
 /// <param name="entity"></param>
 /// <param name="preImage"></param>
 /// <param name="postImage"></param>
 /// <param name="pluginContext"></param>
 /// <param name="core"></param>
 public void Trigger(EventOperation operation, ExecutionStage stage,
                     object entity, Entity preImage, Entity postImage, PluginContext pluginContext, Core core)
 {
     //Parallel.ForEach(asynchronousWorkflows, (x => ExecuteIfMatch(x, operation, stage, entity,
     //        preImage, postImage, pluginContext, crm)));
     synchronousWorkflows.ForEach((x => ExecuteIfMatch(x, operation, stage, entity,
                                                       preImage, postImage, pluginContext, core)));
     asynchronousWorkflows.ForEach(x => ExecuteIfMatch(x, operation, stage, entity,
                                                       preImage, postImage, pluginContext, core));
 }
예제 #15
0
 public PluginStepConfig(string entityLogicalName, EventOperation eventOperation, ExecutionStage executionStage)
 {
     this._LogicalName    = entityLogicalName;
     this._EventOperation = eventOperation.ToString();
     this._ExecutionStage = (int)executionStage;
     this._Deployment     = (int)Deployment.ServerOnly;
     this._ExecutionMode  = (int)ExecutionMode.Synchronous;
     this._ExecutionOrder = 1;
     this._UserContext    = Guid.Empty;
 }
예제 #16
0
 public PluginStepConfig(EventOperation eventOperation, ExecutionStage executionStage)
 {
     this._LogicalName    = Activator.CreateInstance <T>().LogicalName;
     this._EventOperation = eventOperation.ToString();
     this._ExecutionStage = (int)executionStage;
     this._Deployment     = (int)Deployment.ServerOnly;
     this._ExecutionMode  = (int)ExecutionMode.Synchronous;
     this._ExecutionOrder = 1;
     this._UserContext    = Guid.Empty;
 }
예제 #17
0
 /// <summary>
 /// Trigger all plugin steps which match the given parameters.
 /// </summary>
 /// <param name="operation"></param>
 /// <param name="stage"></param>
 /// <param name="entity"></param>
 /// <param name="preImage"></param>
 /// <param name="postImage"></param>
 /// <param name="pluginContext"></param>
 /// <param name="core"></param>
 public void Trigger(EventOperation operation, ExecutionStage stage,
                     object entity, Entity preImage, Entity postImage, PluginContext pluginContext, Core core)
 {
     if (!disableRegisteredPlugins && registeredPlugins.ContainsKey(operation) && registeredPlugins[operation].ContainsKey(stage))
     {
         registeredPlugins[operation][stage].ForEach(p => p.ExecuteIfMatch(entity, preImage, postImage, pluginContext, core));
     }
     if (temporaryPlugins.ContainsKey(operation) && temporaryPlugins[operation].ContainsKey(stage))
     {
         temporaryPlugins[operation][stage].ForEach(p => p.ExecuteIfMatch(entity, preImage, postImage, pluginContext, core));
     }
 }
예제 #18
0
 public void AddTrigger(EventOperation operation, ExecutionStage stage, PluginTrigger trigger, Dictionary <EventOperation, Dictionary <ExecutionStage, List <PluginTrigger> > > register)
 {
     if (!register.ContainsKey(operation))
     {
         register.Add(operation, new Dictionary <ExecutionStage, List <PluginTrigger> >());
     }
     if (!register[operation].ContainsKey(stage))
     {
         register[operation].Add(stage, new List <PluginTrigger>());
     }
     register[operation][stage].Add(trigger);
 }
예제 #19
0
        private static void Write(EventLog log, EventOperation operation, DTObject content)
        {
            //写入日志条目
            var index       = log.EntryCount;
            var contentCode = content.IsEmpty() ? "{}" : content.GetCode();
            var entry       = new EventLogEntry(log, operation, contentCode, index);
            var repository  = Repository.Create <IEventLogEntryRepository>();

            repository.Add(entry);

            log.EntryCount++;
            UpdateLog(log);
        }
예제 #20
0
 //Post operation - Trigger Sync and Async in that order
 public void TriggerSync(EventOperation operation, ExecutionStage stage,
                         object entity, Entity preImage, Entity postImage, PluginContext pluginContext, Core core)
 {
     if (!disableRegisteredPlugins && registeredPlugins.ContainsKey(operation) && registeredPlugins[operation].ContainsKey(stage))
     {
         registeredPlugins[operation][stage].Where(p => p.GetExecutionMode() == ExecutionMode.Synchronous)
         .OrderBy(p => p.GetExecutionOrder()).ToList().ForEach(p => p.ExecuteIfMatch(entity, preImage, postImage, pluginContext, core));
     }
     if (temporaryPlugins.ContainsKey(operation) && temporaryPlugins[operation].ContainsKey(stage))
     {
         temporaryPlugins[operation][stage].Where(p => p.GetExecutionMode() == ExecutionMode.Synchronous)
         .OrderBy(p => p.GetExecutionOrder()).ToList().ForEach(p => p.ExecuteIfMatch(entity, preImage, postImage, pluginContext, core));
     }
 }
예제 #21
0
        public void TriggerSystem(EventOperation operation, ExecutionStage stage,
                                  object entity, Entity preImage, Entity postImage, PluginContext pluginContext, Core core)
        {
            if (!this.registeredSystemPlugins.ContainsKey(operation))
            {
                return;
            }
            if (!this.registeredSystemPlugins[operation].ContainsKey(stage))
            {
                return;
            }

            registeredSystemPlugins[operation][stage].ForEach(p => p.ExecuteIfMatch(entity, preImage, postImage, pluginContext, core));
        }
 protected void UserNotified_Handler(EventOperation operation)
 {
     /*
      * LoadWorkers();
      * if (workersDropDownList.SelectedIndex >= 0)
      * {
      *  int selectedWorkerID = workersList[workersDropDownList.SelectedIndex].id;
      *  LoadWorkerTickets(selectedWorkerID);
      *  UpdateQuestionsListBox(selectedWorkerID);
      * }
      * //ClientScript.RegisterStartupScript(GetType(), "hwa", "reload();", true);
      * warningLabel.Text = "call back";
      */
 }
예제 #23
0
 private void UserNotified_Handler(EventOperation op)
 {
     if (op == EventOperation.NEW_TICKET_ADDED || op == EventOperation.UPDATE_UNASSIGNED)
     {
         UI_UpdateUnassignedTickets();
     }
     if (op == EventOperation.QUESTION_ANSWERED)
     {
         for (int i = 0; i < openWindows.Count; i++)
         {
             openWindows[i].UI_UpdateQuestionTables();
         }
         UI_UpdateAssignedTickets();
     }
 }
예제 #24
0
        protected PluginStepConfig RegisterPluginStep(string logicalName, EventOperation eventOperation, ExecutionStage executionStage, Action <LocalPluginContext> action)
        {
            PluginStepConfig stepConfig = new PluginStepConfig(logicalName, eventOperation, executionStage);

            this.PluginStepConfigs.Add((IPluginStepConfig)stepConfig);

            this.RegisteredEvents.Add(
                new Tuple <int, string, string, Action <LocalPluginContext> >(
                    stepConfig._ExecutionStage,
                    stepConfig._EventOperation,
                    stepConfig._LogicalName,
                    new Action <LocalPluginContext>(action)));

            return(stepConfig);
        }
예제 #25
0
 public void StageAsync(EventOperation operation, ExecutionStage stage,
                        object entity, Entity preImage, Entity postImage, PluginContext pluginContext, Core core)
 {
     if (!disableRegisteredPlugins && registeredPlugins.ContainsKey(operation) && registeredPlugins[operation].ContainsKey(stage))
     {
         var asyncExecutors = registeredPlugins[operation][stage].Where(p => p.GetExecutionMode() == ExecutionMode.Asynchronous)
                              .OrderBy(p => p.GetExecutionOrder()).ToList().Select(p => p.ToPluginExecution(entity, preImage, postImage, pluginContext, core));
         asyncExecutors.ToList().ForEach(x => pendingAsyncPlugins.Enqueue(x));
     }
     if (temporaryPlugins.ContainsKey(operation) && temporaryPlugins[operation].ContainsKey(stage))
     {
         var asyncExecutors = temporaryPlugins[operation][stage].Where(p => p.GetExecutionMode() == ExecutionMode.Asynchronous)
                              .OrderBy(p => p.GetExecutionOrder()).ToList().Select(p => p.ToPluginExecution(entity, preImage, postImage, pluginContext, core));
         asyncExecutors.ToList().ForEach(x => pendingAsyncPlugins.Enqueue(x));
     }
 }
        private static EntityModifiedMessage BuildMessage <TEntity>(Guid actingIdentityId, TEntity entity, ModuleType moduleType, DataEntryAggregateType aggregateType,
                                                                    EventOperation operation)
            where TEntity : CallForServiceCaseReceived
        {
            switch (aggregateType)
            {
            case DataEntryAggregateType.Report:
                return(new ReportCFSCaseReceivedModified(actingIdentityId, entity.Id, moduleType, entity.GetType().Name, operation));

            case DataEntryAggregateType.Summary:
                return(new SummaryCFSCaseReceivedModified(actingIdentityId, entity.Id, moduleType, entity.GetType().Name, operation));

            default:
                throw new ArgumentOutOfRangeException("aggregateType");
            }
        }
예제 #27
0
        private static EntityModifiedMessage BuildMessage <TEntity>(Guid actingIdentityId, TEntity entity, ModuleType moduleType, DataEntryAggregateType aggregateType,
                                                                    EventOperation operation)
            where TEntity : PublicSafetyEntity, IVehicle
        {
            switch (aggregateType)
            {
            case DataEntryAggregateType.Report:
                return(new ReportVehicleModified(actingIdentityId, entity.Id, moduleType, entity.GetType().Name, operation));

            case DataEntryAggregateType.Summary:
                return(new SummaryVehicleModified(actingIdentityId, entity.Id, moduleType, entity.GetType().Name, operation));

            default:
                throw new ArgumentOutOfRangeException("aggregateType");
            }
        }
예제 #28
0
        protected PluginStepConfig <T> RegisterPluginStep <T>(
            EventOperation eventOperation, ExecutionStage executionStage, Action <LocalPluginContext> action)
            where T : Entity
        {
            PluginStepConfig <T> stepConfig = new PluginStepConfig <T>(eventOperation, executionStage);

            this.PluginStepConfigs.Add((IPluginStepConfig)stepConfig);

            this.RegisteredEvents.Add(
                new Tuple <int, string, string, Action <LocalPluginContext> >(
                    stepConfig.ExecutionStage,
                    stepConfig.EventOperation,
                    stepConfig.LogicalName,
                    new Action <LocalPluginContext>(action)));

            return(stepConfig);
        }
예제 #29
0
            public PluginTrigger(EventOperation operation, ExecutionStage stage,
                                 Action <MockupServiceProviderAndFactory> pluginExecute, Tuple <StepConfig, ExtendedStepConfig,
                                                                                                IEnumerable <ImageTuple> > stepConfig, Dictionary <string, EntityMetadata> metadata)
            {
                this.pluginExecute = pluginExecute;
                this.entityName    = stepConfig.Item1.Item4;
                this.operation     = operation;
                this.stage         = stage;
                this.mode          = (ExecutionMode)stepConfig.Item2.Item2;
                this.order         = stepConfig.Item2.Item4;
                this.images        = stepConfig.Item3;
                this.metadata      = metadata;

                var attrs = stepConfig.Item2.Item5 ?? "";

                this.attributes = String.IsNullOrWhiteSpace(attrs) ? new HashSet <string>() : new HashSet <string>(attrs.Split(','));
            }
        public void DoAlterations(EventOperation op, int userID)
        {
            switch (op)
            {
            case EventOperation.QUOTA_CHANGED:
                UI_UpdateQuotaValue(userService.GetCurrentQuote());
                UI_UpdateSellOrdersTable(userService.GetUserSellOrdersList(user.id));
                UI_UpdateBuyOrdersTable(userService.GetUserBuyOrdersList(user.id));
                UI_UpdateTransacionsTable(userService.GetMyTransactions(user.id));
                break;

            case EventOperation.TRANSACTION:
                if (userID == user.id)
                {
                    UI_UpdateSellOrdersTable(userService.GetUserSellOrdersList(user.id));
                    UI_UpdateBuyOrdersTable(userService.GetUserBuyOrdersList(user.id));
                    UI_UpdateTransacionsTable(userService.GetMyTransactions(user.id));
                    UI_UpdateTotalDiginotesNumber(userService.GetDiginotesNumber(user.id));
                    UI_UpdateMyDigicoinsTable(userService.GetMyDiginotesIDList(user.id));
                    UI_UpdateBalance(userService.GetUserBalance(user.id));
                }
                break;

            case EventOperation.UNSUSPEND:
                UI_UpdateSellOrdersTable(userService.GetUserSellOrdersList(user.id));
                UI_UpdateBuyOrdersTable(userService.GetUserBuyOrdersList(user.id));
                UI_UpdateTransacionsTable(userService.GetMyTransactions(user.id));
                break;

            case EventOperation.UPDATE_ALL:
                UI_UpdateBalance(userService.GetUserBalance(user.id));
                UI_UpdateTotalDiginotesNumber(userService.GetDiginotesNumber(user.id));
                UI_UpdateQuotaValue(userService.GetCurrentQuote());

                UI_UpdateTransacionsTable(userService.GetMyTransactions(user.id));
                UI_UpdateMyDigicoinsTable(userService.GetMyDiginotesIDList(user.id));
                UI_UpdateSellOrdersTable(userService.GetUserSellOrdersList(user.id));
                UI_UpdateBuyOrdersTable(userService.GetUserBuyOrdersList(user.id));
                break;

            default:
                Console.WriteLine("Error");
                break;
            }
        }
예제 #31
0
파일: Program.cs 프로젝트: devel0/Lib0
        public void Test3()
        {
            IEventOperation op = new EventOperation();

            op.Fire();

            op.Event += (a, b) =>
            {
            };

            Assert.True(op.FireCount == 1);
            Assert.True(op.HandledCount == 0);
        }
예제 #32
0
파일: Program.cs 프로젝트: devel0/Lib0
        public void Test4()
        {
            IEventOperation op = new EventOperation(EventOperationBehaviorTypes.RemindPastEvents);

            op.Fire();

            Assert.True(op.FireCount == 1);
            Assert.True(op.HandledCount == 0);

            op.Event += (a, b) =>
            {
            };

            Assert.True(op.FireCount == 1);
            Assert.True(op.HandledCount == 1);
        }
예제 #33
0
파일: Program.cs 프로젝트: devel0/Lib0
        public void Test1()
        {
            IEventOperation<MyEventArgs> op = new EventOperation<MyEventArgs>();

            op.Event += (a, b) =>
            {
                Assert.True(b.Type == EventTypes.EventA);
            };

            op.Fire(null, new MyEventArgs(EventTypes.EventA));

            Assert.True(op.FireCount == 1);
            Assert.True(op.HandledCount == 1);
        }
예제 #34
0
파일: Program.cs 프로젝트: devel0/Lib0
        public void Test5()
        {
            IEventOperation op = new EventOperation(EventOperationBehaviorTypes.RemindPastEvents);

            var listener1HitCount = 0;
            var listener2HitCount = 0;

            {
                op.Fire(); // event fired ( no handlers yet connected )
                Assert.True(op.FireCount == 1 && op.HandledCount == 0);

                op.Event += (a, b) => // listener1 connects and receive 1 event
                {
                    ++listener1HitCount;
                };
                Assert.True(op.FireCount == 1 && op.HandledCount == 1);
            }

            {
                op.Fire(); // event fired ( listener1 will receive its 2-th event )
                Assert.True(op.FireCount == 2 && op.HandledCount == 2);

                op.Event += (a, b) => // listener2 connected and receive 2 events
                {
                    ++listener2HitCount;
                };
            }

            Assert.True(listener1HitCount == 2 && listener2HitCount == 2);
            Assert.True(op.FireCount == 2 && op.HandledCount == listener1HitCount + listener2HitCount);
        }