Exemplo n.º 1
0
 public void SetState(BaseEntityState <Player> state)
 {
     foreach (Player player in players)
     {
         player.ChangeState(state);
     }
 }
Exemplo n.º 2
0
 public void ChangeState(BaseEntityState <entity_type> newState)
 {
     // ステート保存
     previousState = currentState;
     // 終了関数
     if (currentState != null)
     {
         currentState.Exit(owner);
     }
     // ステート切り替え
     currentState = newState;
     // 開始関数
     currentState.Enter(owner);
 }
Exemplo n.º 3
0
    public void ChangeState(BaseEntityState <SceneMain> newState)
    {
        // ステートチェンジ
        stateMachine.ChangeState(newState);

        // ステート同期用メッセージ
        char[]        newStateName = newState.GetType().FullName.ToCharArray();
        SyncStateInfo info;

        info.cStateName = new char[128];
        for (int i = 0; i < newStateName.Length; i++)
        {
            info.cStateName[i] = newStateName[i];
        }

        MessageManager.Dispatch(playerManager.GetMyPlayerID(), MessageType.SyncState, info);
    }
Exemplo n.º 4
0
        public void CreateNotice(IUnitOfWork unitOfWork, BaseObject obj, BaseEntityState state)
        {
            var notifications = new List<Notification>();

            CreateNoticeEx(unitOfWork, obj, state, notifications);

            if (!notifications.Any()) return;

            _notificationService.UpdateCollection(unitOfWork, notifications);

            if (_emailSettingsService.EnableEmail)
            {
                //TODO: [scheduler]
                //BackgroundJob.Schedule<ManagerNotification>(
                //    x => x.SendNoticesToMail(notifications.Select(z => z.ID), Hostname),
                //    TimeSpan.FromMinutes(_emailSettingsService.SendDelay));
            }
        }
Exemplo n.º 5
0
 public bool isInState(BaseEntityState <entity_type> st)
 {
     return(currentState.GetType() == st.GetType());
 }
Exemplo n.º 6
0
 public BaseEntityStateMachine(entity_type owner)
 {
     this.owner   = owner;
     currentState = previousState = globalState = null;
 }
Exemplo n.º 7
0
 public void ChangeState(BaseEntityState <Player> newState)
 {
     stateMachine.ChangeState(newState);
 }
Exemplo n.º 8
0
 private void CreateNoticeEx(IUnitOfWork unitOfWork, BaseObject obj, BaseEntityState state, ICollection<Notification> updateCollection)
 {
     if (obj is Task)
     {
         CreateTaskNotice(unitOfWork, obj, state, updateCollection);
     }
     else if (obj is UserPromotion)
     {
         CreatePromotionNotice(obj, state, updateCollection);
     }
     else if (obj is SupportQA)
     {
         CreateSupportQANotice(obj, state, updateCollection);
     }
 }
Exemplo n.º 9
0
        private void CreateTaskNotice(IUnitOfWork unitOfWork, BaseObject obj, BaseEntityState state, ICollection<Notification> updateCollection)
        {
            var task = unitOfWork.GetRepository<Task>().Find(obj.ID);

            var assignedFrom = unitOfWork.GetRepository<User>().Find(task.AssignedFromID);

            var linkBaseObject = new LinkBaseObject()
            {
                ID = task.ID,
                FullName = typeof(Task).FullName,
                Assembly = typeof(Task).Assembly.FullName,
                Mnemonic = "Task"
            };

            string typeName = linkBaseObject.FullName;

            Notification notification = null;

            switch (state)
            {
                case BaseEntityState.Added:
                    if (task.AssignedToID != null && task.AssignedFromID != null)
                    {
                        linkBaseObject.Mnemonic = "InTask";

                        notification = new Notification()
                        {
                            sys_name = "Added",
                            Date = DateTime.Now,
                            UserID = task.AssignedToID,
                            UserEmail = task.AssignedTo.Email,
                            Entity = linkBaseObject,
                            Title = String.Format("Новое напоминание от {0}", assignedFrom.FullName),
                            Description = task.Title.TruncateAtWord(100)
                        };

                        updateCollection.Add(notification);
                    }

                    break;

                case BaseEntityState.Modified:
                    if (task.AssignedToID != null && task.AssignedFromID != null)
                    {
                        foreach (var notice in _notificationService.GetAll(unitOfWork, null).Where(x => x.Entity.ID == task.ID && x.Entity.FullName == typeName))
                        {
                            notice.Status = NotificationStatus.Viewed;
                            updateCollection.Add(notice);
                        }

                        string sys_name = null;
                        string title = null;
                        string description = null;

                        int? userID = null;
                        string userEmail = null;

                        switch (task.Status)
                        {
                            case TaskStatus.InProcess:
                                if (task.TaskChangeHistory != null)
                                {
                                    var itemHistory = task.TaskChangeHistory.LastOrDefault(x => x.Status != TaskStatus.InProcess);

                                    if (itemHistory != null)
                                    {
                                        userID = task.AssignedToID;
                                        if (userID == AppContext.SecurityUser.ID) break;

                                        userEmail = task.AssignedTo.Email;
                                        linkBaseObject.Mnemonic = "InTask";
                                        description = task.Title.TruncateAtWord(100);

                                        if (itemHistory.Status == TaskStatus.Refinement)
                                        {
                                            sys_name = "Refinement->InProcess";
                                            title = String.Format("{0} ответил(а)", assignedFrom.FullName);
                                        }
                                        else
                                        {
                                            sys_name = "NotRelevant->InProcess";
                                            title = String.Format("Новое напоминание от {0}", assignedFrom.FullName);
                                        }
                                    }
                                }

                                break;

                            case TaskStatus.New:
                                if (task.TaskChangeHistory != null)
                                {
                                    var itemHistory = task.TaskChangeHistory.LastOrDefault(x => x.Status != TaskStatus.InProcess);

                                    if (itemHistory != null)
                                    {
                                        userID = task.AssignedToID;

                                        if (userID == AppContext.SecurityUser.ID) break;

                                        userEmail = task.AssignedTo.Email;
                                        sys_name = "->New";
                                        linkBaseObject.Mnemonic = "InTask";
                                        title = String.Format("Новое напоминание от {0}", assignedFrom.FullName);
                                        description = task.Title.TruncateAtWord(100);
                                    }
                                }

                                break;

                            case TaskStatus.Refinement:
                                userID = task.AssignedFromID;
                                if (userID == AppContext.SecurityUser.ID) break;

                                userEmail = assignedFrom.Email;
                                sys_name = "Refinement";
                                linkBaseObject.Mnemonic = "OutTask";
                                title = String.Format("{0} задал(а) вопрос", task.AssignedTo.FullName);
                                description = task.LastComment.TruncateAtWord(100);

                                break;

                            case TaskStatus.Revise:
                                userID = task.AssignedFromID;
                                if (userID == AppContext.SecurityUser.ID) break;

                                userEmail = assignedFrom.Email;
                                sys_name = "Revise";
                                linkBaseObject.Mnemonic = "OutTask";
                                title = String.Format("{0} просит проверить", task.AssignedTo.FullName);
                                description = task.Title.TruncateAtWord(100);

                                break;

                            case TaskStatus.Rework:
                                userID = task.AssignedToID;
                                if (userID == AppContext.SecurityUser.ID) break;

                                userEmail = task.AssignedTo.Email;
                                sys_name = "Rework";
                                linkBaseObject.Mnemonic = "InTask";
                                title = String.Format("{0} просит уточнить", assignedFrom.FullName);
                                description = task.LastComment.TruncateAtWord(100);

                                break;

                            case TaskStatus.NotRelevant:

                                break;
                        }

                        if (sys_name != null)
                        {
                            if (!_notificationService.GetAll(unitOfWork)
                                .Any(x => x.UserID == userID && x.Entity.ID == task.ID && x.Entity.FullName == typeName &&
                                          x.sys_name == sys_name && x.Status == NotificationStatus.New))
                            {
                                linkBaseObject.Mnemonic = "InTask";

                                notification = new Notification()
                                {
                                    sys_name = sys_name,
                                    Date = DateTime.Now,
                                    UserID = userID,
                                    UserEmail = userEmail,
                                    Entity = linkBaseObject,
                                    Title = title,
                                    Description = description
                                };

                                updateCollection.Add(notification);
                            }
                        }
                    }

                    break;
            }
        }
Exemplo n.º 10
0
        private void CreateSupportQANotice(BaseObject obj, BaseEntityState state, ICollection<Notification> updateCollection)
        {
            var supportQa = obj as SupportQA;

            if (supportQa != null && String.IsNullOrEmpty(supportQa.SenderEmail)) return ;

            var linkBaseObject = new LinkBaseObject()
            {
                ID = supportQa.ID,
                FullName = typeof(SupportQA).FullName,
                Assembly = typeof(SupportQA).Assembly.FullName,
                Mnemonic = "SupportQA"
            };

            var notification = new Notification()
            {
                sys_name = "Updated",
                Date = DateTime.Now,
                UserID = supportQa.SenderID,
                UserEmail = supportQa.Sender.Email,
                Entity = linkBaseObject,
                Title = String.Format("Обратная связь"),
                Description = supportQa.AnswerMessage
            };

            updateCollection.Add(notification);
        }
Exemplo n.º 11
0
        private void CreatePromotionNotice(BaseObject obj, BaseEntityState state, ICollection<Notification> updateCollection)
        {
            var promotion = obj as UserPromotion;

            if (promotion != null && String.IsNullOrEmpty(promotion.User.Email)) return;

            var linkBaseObject = new LinkBaseObject()
            {
                ID = promotion.ID,
                FullName = typeof(UserPromotion).FullName,
                Assembly = typeof(UserPromotion).Assembly.FullName,
                Mnemonic = "UserPromotion"
            };

            var notification = new Notification()
            {
                sys_name = "Updated",
                Date = DateTime.Now,
                UserID = promotion.UserID,
                UserEmail = promotion.User.Email,
                Entity = linkBaseObject,
                Title = String.Format("Заявка {0}", promotion.State.GetDescription().ToLower()),
                Description = String.Format("Ваша заявка на изменение типа учетной записи пользователя на \"{0}\" была {1}.",
                                            promotion.RequestedType.GetDescription(), promotion.State.GetDescription().ToLower())
            };

            updateCollection.Add(notification);
        }
Exemplo n.º 12
0
 public void SetState(BaseEntityState <Player> state, int no)
 {
     players[no].ChangeState(state);
 }