Ejemplo n.º 1
0
        public override void InitWorkManager()
        {
            var organizerManager = new OrganizerManager();

            IocUnity.RegisterInstance <IWorkManager>(typeof(OrganizerManager).Name, organizerManager);
            DicWorkManagers.Add(typeof(OrganizerManager).Name, (IWorkManager)organizerManager);

            var leagueManager = new LeagueManager();

            IocUnity.RegisterInstance <IWorkManager>(typeof(LeagueManager).Name, leagueManager);
            DicWorkManagers.Add(typeof(LeagueManager).Name, (IWorkManager)leagueManager);

            var teamManager = new TeamManager();

            IocUnity.RegisterInstance <IWorkManager>(typeof(TeamManager).Name, teamManager);
            DicWorkManagers.Add(typeof(TeamManager).Name, (IWorkManager)teamManager);

            var playerManager = new PlayerManager();

            IocUnity.RegisterInstance <IWorkManager>(typeof(PlayerManager).Name, playerManager);
            DicWorkManagers.Add(typeof(PlayerManager).Name, (IWorkManager)playerManager);

            //  起始任务添加到OrganizerManager中
            var indexUrl = "gismo.php?&html=1&id=1828&language=zh&clientid=4&child=1&ismenu=1&childnodeid=1819";
            var param    = new OrganizerParam()
            {
                HandleType = (int)RBHandleType.Organizer, IndexUrl = indexUrl
            };

            organizerManager.AddOrUpdateParam(param);
        }
        public static bool Organizing()
        {
            OrganizerManager manager = OrganizerManager.GetInstance();

            bool organizing = manager.Items.Any(o => o.IsRunning());

            return(organizing);
        }
Ejemplo n.º 3
0
        static void Main()
        {
            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);

            MainForm         mainForm = new MainForm();
            EditForm         editForm = new EditForm();
            MessageService   message  = new MessageService();
            OrganizerManager manager  = new OrganizerManager();

            Presenter presenter = new Presenter(mainForm, editForm, manager, message);

            Application.Run(mainForm);
        }
        public static void Organizer(string name)
        {
            OrganizerManager manager = OrganizerManager.GetInstance();

            OrganizerEntry agent = manager.Items.FirstOrDefault(oa => oa.Name.ToLower().Equals(name.ToLower()));

            if (agent == null)
            {
                UOC.SystemMessage(string.Format(Strings.Organizer___0___not_found___, name));
                return;
            }

            agent.Action.Invoke(agent);
        }
Ejemplo n.º 5
0
        public static void SetOrganizerContainers(string entryName, object sourceContainer = null,
                                                  object destinationContainer = null)
        {
            int sourceSerial      = AliasCommands.ResolveSerial(sourceContainer, false);
            int destinationSerial = AliasCommands.ResolveSerial(destinationContainer, false);

            OrganizerManager manager = OrganizerManager.GetInstance();

            OrganizerEntry entry = manager.Items.FirstOrDefault(e => e.Name.ToLower().Equals(entryName.ToLower()));

            if (entry == null)
            {
                UOC.SystemMessage(Strings.Invalid_organizer_agent_name___, true);
                return;
            }

            entry.SourceContainer      = sourceSerial;
            entry.DestinationContainer = destinationSerial;

            UOC.SystemMessage(Strings.Organizer_containers_set___, true);
        }
Ejemplo n.º 6
0
        public static void Organizer(string name, object sourceContainer = null, object destinationContainer = null)
        {
            OrganizerManager manager = OrganizerManager.GetInstance();

            OrganizerEntry entry = manager.Items.FirstOrDefault(oa => oa.Name.ToLower().Equals(name.ToLower()));

            if (entry == null)
            {
                UOC.SystemMessage(string.Format(Strings.Organizer___0___not_found___, name));
                return;
            }

            if (sourceContainer != null && destinationContainer != null)
            {
                int sourceContainerSerial     = AliasCommands.ResolveSerial(sourceContainer);
                int destinatinContainerSerial = AliasCommands.ResolveSerial(destinationContainer);

                manager.Organize(entry, sourceContainerSerial, destinatinContainerSerial).Wait();
            }
            else
            {
                manager.Organize(entry).Wait();
            }
        }
Ejemplo n.º 7
0
        public void WillOrganizeLimitAmount()
        {
            AppDomain appDomain = AppDomain.CreateDomain("WillOrganizeLimitAmount",
                                                         AppDomain.CurrentDomain.Evidence,
                                                         AppDomain.CurrentDomain.SetupInformation);

            appDomain.DoCallBack(() =>
            {
                Dictionary <int, int> serialAmount = new Dictionary <int, int>();

                void OnInternalPacketSentEvent(byte[] data, int length)
                {
                    if (data[0] == 0x07)
                    {
                        int serial = (data[1] << 24) | (data[2] << 16) | (data[3] << 8) | data[4];
                        int amount = (data[5] << 8) | data[6];

                        if (serialAmount.ContainsKey(serial))
                        {
                            serialAmount.Remove(serial);
                        }

                        serialAmount.Add(serial, amount);
                    }

                    if (data[0] == 0x08)
                    {
                        int serial          = (data[1] << 24) | (data[2] << 16) | (data[3] << 8) | data[4];
                        int containerSerial = (data[11] << 24) | (data[12] << 16) | (data[13] << 8) | data[14];

                        Item sourceItem    = Engine.Items.GetItem(serial);
                        Item containerItem = Engine.Items.GetItem(containerSerial);

                        if (serialAmount.ContainsKey(serial))
                        {
                            sourceItem.Count = serialAmount[serial];
                        }

                        containerItem.Container.Add(sourceItem);
                    }
                }

                Engine.InternalPacketSentEvent += OnInternalPacketSentEvent;

                OrganizerEntry entry = new OrganizerEntry();

                entry.Items.Add(new OrganizerItem {
                    ID = 0xff, Item = "Shmoo", Amount = 10
                });

                Item sourceContainer = new Item(0x40000004)
                {
                    Container = new ItemCollection(0x40000004)
                };
                sourceContainer.Container.Add(
                    new Item(0x40000005, 0x40000004)
                {
                    ID = 0xff, Count = 5, Owner = 0x40000004
                });
                sourceContainer.Container.Add(
                    new Item(0x40000006, 0x40000004)
                {
                    ID = 0xff, Count = 100, Owner = 0x40000004
                });

                Engine.Items.Add(sourceContainer);

                Item destinationContainer = new Item(0x40000007)
                {
                    Container = new ItemCollection(0x40000007)
                };

                Engine.Items.Add(destinationContainer);

                entry.SourceContainer      = sourceContainer.Serial;
                entry.DestinationContainer = destinationContainer.Serial;

                Engine.PacketWaitEntries = new PacketWaitEntries();

                OrganizerManager.GetInstance().Organize(entry).Wait();

                Item[] destinationItems = destinationContainer.Container.GetItems();

                Assert.AreEqual(entry.Items[0].Amount,
                                destinationItems.Sum(i => i.ID == entry.Items[0].ID ? i.Count : 0));

                Engine.InternalPacketSentEvent -= OnInternalPacketSentEvent;
                Engine.Items.Clear();
                Engine.PacketWaitEntries = null;
            });
        }
Ejemplo n.º 8
0
        public OrganizerTabViewModel() : base(Strings.Organizer)
        {
            _manager = OrganizerManager.GetInstance();

            _manager.Items = Items;
        }
Ejemplo n.º 9
0
        public void WillOrganizeAnyHue()
        {
            Engine.Items.Clear();

            Item container = new Item(0x40000000)
            {
                Container = new ItemCollection(0x40000000)
            };

            container.Container.Add(new Item(0x40000001)
            {
                ID = 0xf06, Hue = 1000
            });
            container.Container.Add(new Item(0x40000002)
            {
                ID = 0xf06, Hue = 1161
            });
            Engine.Items.Add(container);

            Engine.PacketWaitEntries = new PacketWaitEntries();

            OrganizerManager manager = OrganizerManager.GetInstance();

            OrganizerEntry entry = new OrganizerEntry();

            entry.Items.Add(new OrganizerItem {
                ID = 0xf06, Hue = -1, Amount = -1, Item = "Test"
            });

            AutoResetEvent are = new AutoResetEvent(false);

            void OnInternalPacketSentEvent(byte[] data, int length)
            {
                if (data[0] == 0x06)
                {
                    int serial = (data[1] << 24) | (data[2] << 16) | (data[3] << 8) | data[4];

                    PacketWriter writer = new PacketWriter();
                    writer.Write(0x3C);
                    writer.Seek(19, SeekOrigin.Begin);
                    writer.Write(serial);

                    Engine.SendPacketToClient(writer);
                }

                if (data[0] == 0x07)
                {
                    are.Set();
                }
            }

            Engine.InternalPacketSentEvent += OnInternalPacketSentEvent;

            Task.Run(() => manager.Organize(entry, container.Serial, container.Serial)).Wait();

            bool result = are.WaitOne(4000);

            Assert.IsTrue(result);

            manager.Items.Clear();
            Engine.InternalPacketSentEvent -= OnInternalPacketSentEvent;
            Engine.PacketWaitEntries        = null;
            Engine.Items.Clear();
        }