Exemple #1
0
        public override void ExecuteCommand(SmartSession session, StringRequestInfo requestInfo)
        {
            if (requestInfo.Parameters != null && requestInfo.Parameters.Length == 2)
            {
                var sesssionList = session.AppServer.GetAllSessions();
                if (sesssionList != null)
                {
                    SmartSession oldSession = sesssionList.FirstOrDefault(s => requestInfo.Parameters[0].Equals(s.user));
                    if (oldSession != null)
                    {
                        oldSession.Send("login other computer,you kick off!");
                        oldSession.Close();
                    }
                }

                //不去数据库查询了
                session.user      = requestInfo.Parameters[0];
                session.IsLogin   = true;
                session.LoginTime = DateTime.Now;

                session.Send("Login Success");

                { //登陆获取离线消息--好友列表
                    SmartDataManager.SendLogin(session.user, c =>
                    {
                        session.Send($"{c.FromId}给你发消息:{c.Message} {c.Id}");
                    });
                }
            }
            else//能进入这个方法,说明已经是Check
            {
                session.Send("Wrong Parameter");
            }
        }
        private void AddActionCommand(SmartEvent obj)
        {
            int?sourceId = _container.Resolve <ISmartTypeListProvider>().Get(SmartType.SmartSource, data =>
            {
                if (data.IsOnlyTarget)
                {
                    return(false);
                }

                return(data.UsableWithEventTypes == null || data.UsableWithEventTypes.Contains(script.SourceType));
            }
                                                                             );

            if (!sourceId.HasValue)
            {
                return;
            }

            int?actionId = _container.Resolve <ISmartTypeListProvider>().Get(SmartType.SmartAction, data =>
            {
                return(data.UsableWithEventTypes == null || data.UsableWithEventTypes.Contains(script.SourceType));
            });

            if (!actionId.HasValue)
            {
                return;
            }

            var actionData = SmartDataManager.GetInstance().GetRawData(SmartType.SmartAction, actionId.Value);

            SmartTarget target = null;

            if (actionData.UsesTarget)
            {
                int?targetId = _container.Resolve <ISmartTypeListProvider>().Get(SmartType.SmartTarget, data =>
                {
                    return((data.UsableWithEventTypes == null || data.UsableWithEventTypes.Contains(script.SourceType)) &&
                           actionData.Targets.Intersect(data.Types).Any());
                });

                if (!targetId.HasValue)
                {
                    return;
                }

                target = _container.Resolve <ISmartFactory>().TargetFactory(targetId.Value);
            }
            else
            {
                target = _container.Resolve <ISmartFactory>().TargetFactory(0);
            }


            SmartSource source = _container.Resolve <ISmartFactory>().SourceFactory(sourceId.Value);

            SmartAction ev = _container.Resolve <ISmartFactory>().ActionFactory(actionId.Value, source, target);

            EditActionCommand(ev);
            obj.Actions.Add(ev);
        }
        public void Initialize()
        {
            _container.RegisterType <ISolutionItemProvider, SmartScriptCreatureProvider>("Creature Script");
            _container.RegisterType <ISolutionItemProvider, SmartScriptGameobjectProvider>("Gameobject Script");
            _container.RegisterType <ISolutionItemProvider, SmartScriptQuestProvider>("Quest Script");
            _container.RegisterType <ISolutionItemProvider, SmartScriptAuraProvider>("Aura Script");
            _container.RegisterType <ISolutionItemProvider, SmartScriptSpellProvider>("Spell Script");
            _container.RegisterType <ISolutionItemProvider, SmartScriptTimedActionListProvider>("Timed action list Script");

            _container.Resolve <ISolutionEditorManager>().Register <SmartScriptSolutionItem>(item =>
            {
                var view         = new SmartScriptEditorView();
                var solutionItem = item as SmartScriptSolutionItem;
                var vm           = new SmartScriptEditorViewModel(solutionItem, _container, _container.Resolve <IHistoryManager>());
                view.DataContext = vm;

                DocumentEditor editor = new DocumentEditor();
                editor.Title          = solutionItem.Name;
                editor.Content        = view;
                editor.Undo           = vm.UndoCommand;
                editor.Redo           = vm.RedoCommand;
                editor.Save           = vm.SaveCommand;

                return(editor);
            });

            SmartDataLoader.Load(SmartDataManager.GetInstance(), new SmartDataFileLoader());
        }
Exemple #4
0
 public override void ExecuteCommand(SmartSession session, StringRequestInfo requestInfo)
 {
     //ToId  Message
     if (requestInfo.Parameters != null && requestInfo.Parameters.Length == 1)
     {
         string modelId = requestInfo.Parameters[0];     //确认时  把消息ID发回去
         Console.WriteLine($"用户{session.user} 已确认 收到 消息{modelId}");
         SmartDataManager.Remove(session.user, modelId); //改状态或者删除
     }
     else
     {
         session.Send("Wrong Parameter");
     }
 }
Exemple #5
0
        public override void ExecuteCommand(SmartSession session, StringRequestInfo requestInfo)
        {
            //ToId  Message
            if (requestInfo.Parameters != null && requestInfo.Parameters.Length == 2)
            {
                string toId    = requestInfo.Parameters[0];
                string message = requestInfo.Parameters[1];

                SmartSession toSession = session.AppServer.GetAllSessions().FirstOrDefault(s => toId.Equals(s.user));
                //用户在线
                string modelId = Guid.NewGuid().ToString();
                if (toSession != null)
                {
                    toSession.Send($"{session.user}给你发消息:{message} {modelId}");
                    //只能保证把数据发出去了,但是不保证目标一定收到
                    //需要客户端回发确认!
                    SmartDataManager.Add(toId, new SmartModel()
                    {
                        FromId     = session.user,
                        ToId       = toSession.user,
                        Message    = message,
                        Id         = modelId,
                        State      = 1,//待确认
                        CreateTime = DateTime.Now
                    });
                }
                else
                {
                    SmartDataManager.Add(toId, new SmartModel()
                    {
                        FromId     = session.user,
                        ToId       = toId,
                        Message    = message,
                        Id         = modelId,
                        State      = 0,//未发送
                        CreateTime = DateTime.Now
                    });
                    Console.WriteLine($"{toId}不在线,消息暂时没能送达!");
                }
            }
            else
            {
                session.Send("Wrong Parameter");
            }
        }
Exemple #6
0
        public SmartSelectViewModel(string file, SmartType type, Func <SmartGenericJsonData, bool> predicate, IUnityContainer container)
        {
            _predicate = predicate;
            _container = container;
            string group = null;

            foreach (string line in File.ReadLines("SmartData/" + file))
            {
                if (line.IndexOf(" ", StringComparison.Ordinal) == 0)
                {
                    if (!SmartDataManager.GetInstance().Contains(type, line.Trim()))
                    {
                        continue;
                    }

                    SmartItem i    = new SmartItem();
                    var       data = SmartDataManager.GetInstance().GetDataByName(type, line.Trim());

                    i.Group      = group;
                    i.Name       = data.NameReadable;
                    i.Id         = data.Id;
                    i.Help       = data.Help;
                    i.Deprecated = data.Deprecated;
                    i.Data       = data;

                    _allItems.Add(i);
                }
                else
                {
                    group = line;
                }
            }

            _items        = new CollectionViewSource();
            _items.Source = _allItems;
            _items.GroupDescriptions.Add(new PropertyGroupDescription("Group"));
            _items.Filter += ItemsOnFilter;

            if (_items.View.MoveCurrentToFirst())
            {
                SelectedItem = _items.View.CurrentItem as SmartItem;
            }
        }
        public void OnInitialized(IContainerProvider containerProvider)
        {
            containerProvider.Resolve <ISolutionEditorManager>().Register <SmartScriptSolutionItem>(item =>
            {
                var view         = new SmartScriptEditorView();
                var solutionItem = item as SmartScriptSolutionItem;
                var vm           = new SmartScriptEditorViewModel(solutionItem, containerProvider.Resolve <IHistoryManager>(), containerProvider.Resolve <IDatabaseProvider>(), containerProvider.Resolve <IEventAggregator>(), containerProvider.Resolve <ISmartFactory>(), containerProvider.Resolve <IItemFromListProvider>(), containerProvider.Resolve <SmartTypeListProvider>(), containerProvider.Resolve <ISolutionItemNameRegistry>());
                view.DataContext = vm;

                DocumentEditor editor = new DocumentEditor();
                editor.Title          = containerProvider.Resolve <ISolutionItemNameRegistry>().GetName(solutionItem);
                editor.Content        = view;
                editor.Undo           = vm.UndoCommand;
                editor.Redo           = vm.RedoCommand;
                editor.Save           = vm.SaveCommand;
                editor.History        = vm.History;
                editor.CanClose       = true;

                return(editor);
            });

            SmartDataLoader.Load(SmartDataManager.GetInstance(), new SmartDataFileLoader());
        }
Exemple #8
0
        private void AddActionCommand(SmartEvent obj)
        {
            int?sourceId = smartTypeListProvider.Get(SmartType.SmartSource, data =>
            {
                if (data.IsOnlyTarget)
                {
                    return(false);
                }

                return(data.UsableWithEventTypes == null || data.UsableWithEventTypes.Contains(script.SourceType));
            }
                                                     );

            if (!sourceId.HasValue)
            {
                return;
            }

            int?actionId = smartTypeListProvider.Get(SmartType.SmartAction, data =>
            {
                return((data.UsableWithEventTypes == null || data.UsableWithEventTypes.Contains(script.SourceType)) &&
                       (!data.ImplicitSource || sourceId.Value <= 1 /* @todo: remove this const: this is none or self */));
            });

            if (!actionId.HasValue)
            {
                return;
            }

            var actionData = SmartDataManager.GetInstance().GetRawData(SmartType.SmartAction, actionId.Value);

            SmartTarget target = null;

            if (actionData.UsesTarget && !actionData.TargetIsSource)
            {
                int?targetId = smartTypeListProvider.Get(SmartType.SmartTarget, data =>
                {
                    return((data.UsableWithEventTypes == null || data.UsableWithEventTypes.Contains(script.SourceType)) &&
                           (actionData.Targets == null || actionData.Targets.Intersect(data.Types).Any()));
                });

                if (!targetId.HasValue)
                {
                    return;
                }

                target = smartFactory.TargetFactory(targetId.Value);
            }
            else if (actionData.TargetIsSource)
            {
                target   = smartFactory.TargetFactory(sourceId.Value);
                sourceId = 0;
            }
            else
            {
                target = smartFactory.TargetFactory(0);
            }

            if (actionData.ImplicitSource)
            {
                sourceId = 0;
            }

            SmartSource source = smartFactory.SourceFactory(sourceId.Value);

            SmartAction ev = smartFactory.ActionFactory(actionId.Value, source, target);

            EditActionCommand(ev);
            obj.Actions.Add(ev);
        }
Exemple #9
0
 public void OnInitialized(IContainerProvider containerProvider)
 {
     SmartDataLoader.Load(SmartDataManager.GetInstance(), new SmartDataFileLoader());
 }