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();
            }
        }
Esempio n. 2
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();
        }