Exemplo n.º 1
0
        public void MeasureEmptyMustNotCrash()
        {
            var g = new BoxGroup(LayoutTestStyle.Create());

            g.Measure(Size.Auto);

            g.DesiredSize.Should().Be(new Size());
        }
Exemplo n.º 2
0
        public void ArrangeEmptyMustNotCrash()
        {
            var g = new BoxGroup(LayoutTestStyle.Create());

            g.Arrange(new Rectangle(10, 20, 400, 300));

            g.DesiredSize.Should().Be(new Size());
            g.LayoutRect.Should().Be(new Rectangle(10, 20, 0, 0));
        }
Exemplo n.º 3
0
        protected async Task CreateGroupsFromFile(string path,
                                                  bool save = false, string overrideSavePath = "", string overrideSaveFileFormat = "", bool json = false)
        {
            var boxClient = base.ConfigureBoxClient(oneCallAsUserId: this._asUser.Value(), oneCallWithToken: base._oneUseToken.Value());

            if (!string.IsNullOrEmpty(path))
            {
                path = GeneralUtilities.TranslatePath(path);
            }
            try
            {
                var             groupRequests = base.ReadFile <BoxGroupRequest, BoxGroupRequestMap>(path);
                List <BoxGroup> saveCreated   = new List <BoxGroup>();

                foreach (var groupRequest in groupRequests)
                {
                    BoxGroup createdGroup = null;
                    try
                    {
                        createdGroup = await boxClient.GroupsManager.CreateAsync(groupRequest);
                    }
                    catch (Exception e)
                    {
                        Reporter.WriteError("Couldn't create group...");
                        Reporter.WriteError(e.Message);
                    }
                    if (createdGroup != null)
                    {
                        this.PrintGroup(createdGroup, json);
                        if (save || !string.IsNullOrEmpty(overrideSavePath) || base._settings.GetAutoSaveSetting())
                        {
                            saveCreated.Add(createdGroup);
                        }
                    }
                }
                if (save || !string.IsNullOrEmpty(overrideSavePath) || base._settings.GetAutoSaveSetting())
                {
                    var fileFormat = base._settings.GetBoxReportsFileFormatSetting();
                    if (!string.IsNullOrEmpty(overrideSaveFileFormat))
                    {
                        fileFormat = overrideSaveFileFormat;
                    }
                    var savePath = base._settings.GetBoxReportsFolderPath();
                    if (!string.IsNullOrEmpty(overrideSavePath))
                    {
                        savePath = overrideSavePath;
                    }
                    var fileName = $"{base._names.CommandNames.Groups}-{base._names.SubCommandNames.Create}-{DateTime.Now.ToString(GeneralUtilities.GetDateFormatString())}";
                    base.WriteListResultsToReport <BoxGroup, BoxGroupMap>(saveCreated, fileName, savePath, fileFormat);
                }
            }
            catch (Exception e)
            {
                Reporter.WriteError(e.Message);
            }
        }
Exemplo n.º 4
0
        IWidget SetupUi()
        {
            var styleSystem = uiManager.UIStyle;

            var mapX = new TextField(styleSystem);

            mapX.Anchor = AnchoredRect.CreateCentered(100);
            mapX.Content.Document.DocumentModified += (_, _) => navModel.MapXText = mapX.Text;

            var mapY = new TextField(styleSystem);

            mapY.Anchor = AnchoredRect.CreateCentered(100);
            mapY.Content.Document.DocumentModified += (_, _) => navModel.MapYText = mapY.Text;

            var button = new Button(styleSystem, "Go!");

            button.ActionPerformed   += (_, _) => navModel.TryNavigate(GameRendering);
            navModel.PropertyChanged += (_, _) => button.Enabled = navModel.Valid;

            var rotateLeftButton = new Button(styleSystem, "Left");

            rotateLeftButton.ActionPerformed         +=
                (_, _) => GameRendering.RotationSteps = (GameRendering.RotationSteps + 1) % 4;

            var rotateRightButton = new Button(styleSystem, "Right");

            rotateRightButton.ActionPerformed        +=
                (_, _) => GameRendering.RotationSteps = (GameRendering.RotationSteps - 1) % 4;

            var hbox = new BoxGroup(styleSystem, Orientation.Horizontal, 5);

            hbox.Anchor = AnchoredRect.CreateBottomLeftAnchored();
            hbox.AddStyleClass("opaque-root");
            hbox.Add(new Label(styleSystem, "Move to: X: "));
            hbox.Add(mapX);
            hbox.Add(new Label(styleSystem, "Y: "));
            hbox.Add(mapY);
            hbox.Add(button);
            hbox.Add(rotateLeftButton);
            hbox.Add(rotateRightButton);

            group = new Group(styleSystem);
            group.Add(hbox);
            group.Focusable     = true;
            group.MouseDragged += OnMouseDragged;
            group.MouseDown    += OnMouseDragStarted;
            group.MouseUp      += OnMouseDragFinished;
            group.KeyReleased  += Root_KeyReleased;
            group.MouseMoved   += OnMouseMoved;
            group.Focused       = true;
            group.Anchor        = AnchoredRect.Full;
            return(group);
        }
Exemplo n.º 5
0
 protected virtual void PrintGroup(BoxGroup g, bool json)
 {
     if (json)
     {
         base.OutputJson(g);
         return;
     }
     else
     {
         this.PrintGroup(g);
     }
 }
Exemplo n.º 6
0
        public void MeasureVertical()
        {
            var g = new BoxGroup(LayoutTestStyle.Create());

            g.Spacing = 5;
            g.Add(LayoutTestWidget.FixedSize(200, 100));
            g.Add(LayoutTestWidget.FixedSize(150, 50));

            g.Measure(Size.Auto);

            g.DesiredSize.Should().Be(new Size(200, 155));
            g[0].DesiredSize.Should().Be(new Size(200, 100));
            g[1].DesiredSize.Should().Be(new Size(150, 50));
        }
Exemplo n.º 7
0
        public void ArrangeVerticalWithAnchor()
        {
            var g = new BoxGroup(LayoutTestStyle.Create());

            g.Spacing = 5;
            g.Add(LayoutTestWidget.FixedSize(200, 100).WithAnchorRect(AnchoredRect.Full));
            g.Add(LayoutTestWidget.FixedSize(150, 50).WithAnchorRect(AnchoredRect.Full));

            g.Arrange(new Rectangle(10, 20, 400, 300));

            g.LayoutRect.Should().Be(new Rectangle(10, 20, 400, 155));
            g[0].LayoutRect.Should().Be(new Rectangle(10, 20, 400, 100));
            g[1].LayoutRect.Should().Be(new Rectangle(10, 125, 400, 50));
        }
Exemplo n.º 8
0
        public void ArrangeHorizontal()
        {
            var g = new BoxGroup(LayoutTestStyle.Create());

            g.Spacing     = 5;
            g.Orientation = Orientation.Horizontal;
            g.Add(LayoutTestWidget.FixedSize(200, 100).WithAnchorRect(AnchoredRect.CreateTopLeftAnchored(0, 0)));
            g.Add(LayoutTestWidget.FixedSize(150, 50).WithAnchorRect(AnchoredRect.CreateTopLeftAnchored(0, 0)));

            g.Arrange(new Rectangle(10, 20, 400, 300));

            g.LayoutRect.Should().Be(new Rectangle(10, 20, 355, 300));
            g[0].LayoutRect.Should().Be(new Rectangle(10, 20, 200, 100));
            g[1].LayoutRect.Should().Be(new Rectangle(215, 20, 150, 50));
        }
Exemplo n.º 9
0
        public void MeasureHorizontal()
        {
            var g = new BoxGroup(LayoutTestStyle.Create());

            g.Spacing     = 5;
            g.Orientation = Orientation.Horizontal;
            g.Add(LayoutTestWidget.FixedSize(200, 100));
            g.Add(LayoutTestWidget.FixedSize(150, 50));

            g.Measure(Size.Auto);

            g.DesiredSize.Should().Be(new Size(355, 100));
            g[0].DesiredSize.Should().Be(new Size(200, 100));
            g[1].DesiredSize.Should().Be(new Size(150, 50));
        }
Exemplo n.º 10
0
        public void ValidateWidgetEvents()
        {
            var      style   = LayoutTestStyle.Create();
            BoxGroup backend = new BoxGroup(style);
            var      label   = new Label(style);

            var d = Substitute.For <EventHandler <ContainerEventArgs> >();

            backend.ChildrenChanged += d;

            backend.Add(label);
            d.Received().Invoke(backend, new ContainerEventArgs(0, null, null, label, false));

            backend.Should().BeEquivalentTo(new[] { label });
        }
Exemplo n.º 11
0
        public void BindToMappingTest()
        {
            // Note: T
            var style   = LayoutTestStyle.Create();
            var backend = new BoxGroup(style);

            var sourceList = new ObservableCollection <WidgetAndConstraint <bool> >();

            sourceList.ToBinding().BindTo(backend);

            var widget = new Label(style);

            sourceList.Add(new WidgetAndConstraint <bool>(widget));
            backend[0].ShouldBeSameObjectReference(widget);
        }
Exemplo n.º 12
0
        public static void updateBoxGroup(string oldGroupName, string newGroupName)
        {
            var data        = BoxFileData.STATIC_Shortcuts.Where(o => o.Key.Key == BoxFileData.getUniqueKey(oldGroupName)).FirstOrDefault();
            var oldBoxGroup = data.Key;
            var newBoxGroup = new BoxGroup()
            {
                Key = BoxFileData.getUniqueKey(newGroupName), Name = newGroupName
            };
            var newBoxFileItems = data.Value;

            BoxFileData.STATIC_Shortcuts.Remove(oldBoxGroup);
            BoxFileData.STATIC_Shortcuts.Add(newBoxGroup, newBoxFileItems);

            BoxFileData.SaveShortcut();
        }
Exemplo n.º 13
0
        /// <summary>
        /// Create the hitbox group of the given index.
        /// </summary>
        /// <param name="index">The index of the hitbox group.</param>
        public void CreateHitboxGroup(int index)
        {
            // Group was already created.
            if (hitboxGroups.ContainsKey(index))
            {
                return;
            }

            // Variables.
            BoxGroup      currentGroup    = combatManager.CurrentAttack.attackDefinition.boxGroups[index];
            List <Hitbox> groupHitboxList = new List <Hitbox>(currentGroup.boxes.Count);

            // Keep track of what the hitbox ID has hit.
            if (!hurtablesHit.ContainsKey(currentGroup.ID))
            {
                hurtablesHit.Add(currentGroup.ID, new List <IHurtable>());
                hurtablesHit[currentGroup.ID].Add(combatManager);
            }

            // Loop through all the hitboxes in the group.
            for (int i = 0; i < currentGroup.boxes.Count; i++)
            {
                // Instantiate the hitbox with the correct position and rotation.
                BoxDefinition hitboxDefinition = currentGroup.boxes[i];
                Vector3       pos = controller.GetVisualBasedDirection(Vector3.forward) * hitboxDefinition.offset.z
                                    + controller.GetVisualBasedDirection(Vector3.right) * hitboxDefinition.offset.x
                                    + controller.GetVisualBasedDirection(Vector3.up) * hitboxDefinition.offset.y;

                Hitbox hitbox = InstantiateHitbox(controller.transform.position + pos,
                                                  Quaternion.Euler(controller.transform.eulerAngles + hitboxDefinition.rotation));

                // Attach the hitbox if neccessary.
                if (currentGroup.attachToEntity)
                {
                    hitbox.transform.SetParent(controller.transform, true);
                }

                hitbox.Initialize(controller.gameObject, controller.visual.transform, currentGroup.boxes[i].shape,
                                  currentGroup.hitboxHitInfo, hurtablesHit[currentGroup.ID]);
                int cID        = currentGroup.ID;
                int groupIndex = index;
                hitbox.OnHurt += (hurtable, hitInfo) => { OnHitboxHurt(hurtable, hitInfo, cID, groupIndex); };
                hitbox.Activate();
                groupHitboxList.Add(hitbox);
            }
            // Add the hitbox group to our list.
            hitboxGroups.Add(index, groupHitboxList);
        }
Exemplo n.º 14
0
        public RadioButtonSet(IUIStyle style, IEnumerable <T> items = null) : base(style)
        {
            selectionChangedSupport = new EventSupport <ListSelectionEventArgs>();
            InternalContent         = new BoxGroup(UIStyle)
            {
                Orientation = Orientation.Horizontal
            };
            Renderer = DefaultRenderFunction;

            DataItems = new ObservableCollection <T>();
            if (items != null)
            {
                DataItems.AddRange(items);
            }
            DataItems.CollectionChanged += OnItemsChanged;
        }
        public async Task UpdateGroup_ExtraFields_ValidGroup()
        {
            IBoxRequest boxRequest = null;

            Handler.Setup(h => h.ExecuteAsync <BoxGroup>(It.IsAny <IBoxRequest>()))
            .Returns(() => Task.FromResult <IBoxResponse <BoxGroup> >(new BoxResponse <BoxGroup>()
            {
                Status        = ResponseStatus.Success,
                ContentString = @"{
                        ""type"": ""group"",
                        ""id"": ""159322"",
                        ""description"": ""A group from Okta"",
                        ""external_sync_identifier"": ""foo"",
                        ""provenance"": ""Okta"",
                        ""invitability_level"": ""admins_only"",
                        ""member_viewability_level"": ""admins_only""
                    }"
            }))
            .Callback <IBoxRequest>(r => boxRequest = r);

            BoxGroupRequest request = new BoxGroupRequest()
            {
                Description            = "A group from Okta",
                ExternalSyncIdentifier = "foo",
                Provenance             = "Okta",
                InvitabilityLevel      = "admins_only",
                MemberViewabilityLevel = "admins_only"
            };

            var fields = new string[]
            {
                BoxGroup.FieldDescription,
                BoxGroup.FieldExternalSyncIdentifier,
                BoxGroup.FieldProvenance,
                BoxGroup.FieldInvitabilityLevel,
                BoxGroup.FieldMemberViewabilityLevel
            };

            BoxGroup group = await _groupsManager.UpdateAsync("123", request, fields : fields);

            Assert.AreEqual("{\"description\":\"A group from Okta\",\"provenance\":\"Okta\",\"external_sync_identifier\":\"foo\",\"invitability_level\":\"admins_only\",\"member_viewability_level\":\"admins_only\"}", boxRequest.Payload);
            Assert.AreEqual("A group from Okta", group.Description);
            Assert.AreEqual("foo", group.ExternalSyncIdentifier);
            Assert.AreEqual("Okta", group.Provenance);
            Assert.AreEqual("admins_only", group.InvitabilityLevel);
            Assert.AreEqual("admins_only", group.MemberViewabilityLevel);
        }
Exemplo n.º 16
0
        public void ArrangeHorizontalExpanded()
        {
            var g = new BoxGroup(LayoutTestStyle.Create());

            g.Spacing     = 5;
            g.Orientation = Orientation.Horizontal;
            g.Add(LayoutTestWidget.FixedSize(200, 100).WithAnchorRect(AnchoredRect.Full));
            g.Add(LayoutTestWidget.FixedSize(150, 50).WithAnchorRect(AnchoredRect.Full), true);
            g.Add(LayoutTestWidget.FixedSize(150, 50).WithAnchorRect(AnchoredRect.Full));

            g.Arrange(new Rectangle(10, 20, 800, 500));

            g.LayoutRect.Should().Be(new Rectangle(10, 20, 800, 500));
            g[0].LayoutRect.Should().Be(new Rectangle(10, 20, 200, 500));
            g[1].LayoutRect.Should().Be(new Rectangle(215, 20, 440, 500));
            g[2].LayoutRect.Should().Be(new Rectangle(660, 20, 150, 500));
        }
Exemplo n.º 17
0
        public async Task GetGroup_ValidResponse_ValidGroup()
        {
            Handler.Setup(h => h.ExecuteAsync <BoxGroup>(It.IsAny <IBoxRequest>()))
            .Returns(() => Task.FromResult <IBoxResponse <BoxGroup> >(new BoxResponse <BoxGroup>()
            {
                Status        = ResponseStatus.Success,
                ContentString = @"{""type"": ""group"", ""id"": ""26477"", ""name"": ""adfasdf"", ""created_at"": ""2011-02-15T14:07:22-08:00"", ""modified_at"": ""2011-10-05T19:04:40-07:00""}"
            }));

            BoxGroup group = await _groupsManager.GetGroupAsync("222");

            Assert.AreEqual("26477", group.Id, "Wrong Id");
            Assert.AreEqual("group", group.Type, "Wrong type");
            Assert.AreEqual("adfasdf", group.Name, "Wrong name");
            Assert.AreEqual(DateTime.Parse("2011-02-15T14:07:22-08:00"), group.CreatedAt, "Wrong created at");
            Assert.AreEqual(DateTime.Parse("2011-10-05T19:04:40-07:00"), group.ModifiedAt, "Wrong modified at");
        }
Exemplo n.º 18
0
        public void ArrangeVerticalExpanded()
        {
            var g = new BoxGroup(LayoutTestStyle.Create());

            g.Spacing = 5;
            g.Add(LayoutTestWidget.FixedSize(200, 100));
            g.Add(LayoutTestWidget.FixedSize(150, 50), true);
            g.Add(LayoutTestWidget.FixedSize(150, 50), true);
            g.Add(LayoutTestWidget.FixedSize(150, 50));

            g.Arrange(new Rectangle(10, 20, 400, 1300));

            g.LayoutRect.Should().Be(new Rectangle(10, 20, 400, 1300));
            g[0].LayoutRect.Should().Be(new Rectangle(10, 20, 400, 100));
            g[1].LayoutRect.Should().Be(new Rectangle(10, 125, 400, 567));
            g[2].LayoutRect.Should().Be(new Rectangle(10, 697, 400, 568));
            g[3].LayoutRect.Should().Be(new Rectangle(10, 1270, 400, 50));
        }
        /// <summary>
        /// Create the hitbox group of the given index.
        /// </summary>
        /// <param name="index">The index of the hitbox group.</param>
        public virtual void CreateHitboxGroup(int index)
        {
            // Group was already created.
            if (hitboxGroups.ContainsKey(index))
            {
                return;
            }

            // Variables.
            BoxGroup          currentGroup    = combatManager.CurrentAttack.attackDefinition.boxGroups[index];
            List <HitboxBase> groupHitboxList = new List <HitboxBase>(currentGroup.boxes.Count);

            // Keep track of what the hitbox ID has hit.
            if (!hurtablesHit.ContainsKey(currentGroup.ID))
            {
                hurtablesHit.Add(currentGroup.ID, new List <IHurtable>());
                hurtablesHit[currentGroup.ID].Add(combatManager);
            }

            // Loop through all the hitboxes in the group.
            for (int i = 0; i < currentGroup.boxes.Count; i++)
            {
                // Instantiate the hitbox with the correct position and rotation.
                BoxDefinitionBase hitboxDefinition = currentGroup.boxes[i];
                HitboxBase        hitbox           = InstantiateHitbox(hitboxDefinition);

                // Attach the hitbox if neccessary.
                if (currentGroup.attachToEntity)
                {
                    hitbox.transform.SetParent(manager.transform, true);
                }

                hitbox.Initialize(manager.gameObject, manager.visual.transform, manager.CombatManager.GetTeam(),
                                  currentGroup.boxes[i].shape, currentGroup.hitboxHitInfo, hitboxDefinition, hurtablesHit[currentGroup.ID]);
                int cID        = currentGroup.ID;
                int groupIndex = index;
                hitbox.OnHurt += (hurtable, hitInfo) => { OnHitboxHurt(hurtable, hitInfo, cID, groupIndex); };
                hitbox.Activate();
                groupHitboxList.Add(hitbox);
            }
            // Add the hitbox group to our list.
            hitboxGroups.Add(index, groupHitboxList);
        }
Exemplo n.º 20
0
        public void ArrangeHugeAnchored()
        {
            var g = new BoxGroup(LayoutTestStyle.Create());

            g.Spacing     = 5;
            g.Orientation = Orientation.Horizontal;
            g.Add(LayoutTestWidget.FixedSize(2000, 1000).WithAnchorRect(AnchoredRect.CreateCentered(500, 500)));
            g.Add(LayoutTestWidget.FixedSize(150, 50).WithAnchorRect(AnchoredRect.CreateFull(10)));

            g.Arrange(new Rectangle(10, 20, 400, 300));

            g.DesiredSize.Should().Be(new Size(675, 500)); // 500 + 150 + 20 (from full-anchor) + 5
            g[0].DesiredSize.Should().Be(new Size(2000, 1000));
            g[1].DesiredSize.Should().Be(new Size(150, 50));

            g.LayoutRect.Should().Be(new Rectangle(10, 20, 675, 300));
            g[0].LayoutRect.Should().Be(new Rectangle(10, -80, 500, 500));
            g[1].LayoutRect.Should().Be(new Rectangle(525, 30, 150, 280));
        }
Exemplo n.º 21
0
        public void BindTo_Conflicts_with_widget_changes()
        {
            // Note: T
            var style   = LayoutTestStyle.Create();
            var backend = new BoxGroup(style);

            var sourceList = new ObservableCollection <WidgetAndConstraint <bool> >();

            sourceList.ToBinding().BindTo(backend);
            try
            {
                backend.Add(new Label(style));
                throw new AssertionException("Expected to raise exception.");
            }
            catch (InvalidOperationException)
            {
                // ok
            }
        }
Exemplo n.º 22
0
        public void BindTo_Fails_When_Widget_not_empty()
        {
            // Note: T
            var style   = LayoutTestStyle.Create();
            var backend = new BoxGroup(style)
            {
                new Label(style)
            };

            try
            {
                var sourceList = new ObservableCollection <WidgetAndConstraint <bool> >();
                sourceList.ToBinding().BindTo(backend);
                throw new AssertionException("Expected to raise exception.");
            }
            catch (InvalidOperationException)
            {
                // ok
            }
        }
Exemplo n.º 23
0
        public void CreateBinding()
        {
            var      style   = LayoutTestStyle.Create();
            BoxGroup backend = new BoxGroup(style);
            var      label   = new Label(style);

            var binding = backend.ToBinding();

            using (var monitoredBinding = binding.Monitor <INotifyCollectionChanged>())
            {
                backend.Add(label);
                monitoredBinding.Should().RaiseCollectionChange(
                    binding,
                    new NotifyCollectionChangedEventArgs(NotifyCollectionChangedAction.Add,
                                                         BindingAssertions.AsList(new WidgetAndConstraint <bool>(label)),
                                                         0));

                backend.WidgetsWithConstraints.Should().BeEquivalentTo(new WidgetAndConstraint <bool>(label));
                binding.Should().BeEquivalentTo(new WidgetAndConstraint <bool>(label));
            }
        }
Exemplo n.º 24
0
        public async Task CreateGroup_ValidResponse_NewGroup()
        {
            Handler.Setup(h => h.ExecuteAsync <BoxGroup>(It.IsAny <BoxRequest>()))
            .Returns(() => Task.FromResult <IBoxResponse <BoxGroup> >(new BoxResponse <BoxGroup>()
            {
                Status        = ResponseStatus.Success,
                ContentString = @"{ ""type"": ""group"", ""id"": ""159322"", ""name"": ""TestGroup2"", ""created_at"": ""2013-11-12T15:19:47-08:00"", ""modified_at"": ""2013-11-12T15:19:47-08:00"" }"
            }));

            BoxGroupRequest request = new BoxGroupRequest()
            {
                Name = "NewGroup"
            };

            BoxGroup group = await _groupsManager.CreateAsync(request);

            Assert.AreEqual <string>("TestGroup2", group.Name, "Wrong group name");
            Assert.AreEqual <string>("159322", group.Id, "Wrong id");
            Assert.AreEqual(DateTime.Parse("2013-11-12T15:19:47-08:00"), group.ModifiedAt, "Wrong modified at");
            Assert.AreEqual(DateTime.Parse("2013-11-12T15:19:47-08:00"), group.CreatedAt, "Wrong created at");
        }
Exemplo n.º 25
0
        private void btnCommence_Click(object sender, EventArgs e)
        {
            DateTime DSelected = Convert.ToDateTime(dtpPriorDate.Value.ToShortDateString());

            using (var context = new TTI2Entities())
            {
                //================================================================================
                // 1st Step is to clear down all the TLCSV_stockOnHand Records
                //========================================================================

                // Display the ProgressBar control.
                pBar1.Visible = true;
                // Set Minimum to 1
                pBar1.Minimum = 1;
                // Set the initial value of ProgessBar
                pBar1.Value = 1;
                // Set the Step property to a value of 1 to represent PPS Record processed
                pBar1.Step = 1;
                //===========================================================================

                textBox1.Text = "Commencing Customer Services Clear Down";
                this.Refresh();


                //==============================================================================
                // 1st Step - We have a situation whereby a box has been sold
                // We need to ensure that it is removed
                //====================================================
                var BoxSold = (from SOH in context.TLCSV_StockOnHand
                               where SOH.TLSOH_Sold && SOH.TLSOH_SoldDate <= DSelected
                               select SOH).GroupBy(x => x.TLSOH_POOrderDetail_FK).ToList();

                pBar1.Maximum = BoxSold.Count();
                foreach (var BoxGroup in BoxSold)
                {
                    var PODPrimaryKey = BoxGroup.FirstOrDefault().TLSOH_POOrderDetail_FK;
                    var POPrimaryKey  = BoxGroup.FirstOrDefault().TLSOH_POOrder_FK;

                    var BoxedQty = BoxGroup.Sum(x => (int?)x.TLSOH_BoxedQty) ?? 0;

                    var PODetail = context.TLCSV_PuchaseOrderDetail.Find(PODPrimaryKey);
                    if (PODetail != null && !PODetail.TLCUSTO_Closed)
                    {
                        if (BoxedQty < PODetail.TLCUSTO_Qty)
                        {
                            continue;
                        }

                        context.TLCSV_PurchaseOrder.Where(x => x.TLCSVPO_Pk == POPrimaryKey).Delete();
                        context.TLCSV_PuchaseOrderDetail.Where(x => x.TLCUSTO_Pk == PODPrimaryKey).Delete();

                        context.TLCSV_OrderAllocated.Where(x => x.TLORDA_POOrder_FK == POPrimaryKey).Delete();
                    }

                    context.TLCSV_StockOnHand.Where(x => x.TLSOH_POOrderDetail_FK == PODPrimaryKey).Delete();
                    context.TLCSV_RePackTransactions.Where(x => x.REPACT_PurchaseOrderDetail_FK == PODPrimaryKey).Delete();
                    context.TLCSV_RePackConfig.Where(x => x.PORConfig_PONumber_Fk == PODPrimaryKey).Delete();
                    context.TLCSV_MergePODetail.Where(x => x.TLMerge_PoDetail_FK == PODPrimaryKey).Delete();

                    context.TLCSV_OrderAllocated.Where(x => x.TLORDA_POOrder_FK == POPrimaryKey).Delete();

                    Expression <Func <TLCMT_CompletedWork, bool> >      CWPredicate       = PredicateBuilder.New <TLCMT_CompletedWork>();
                    Expression <Func <TLCSV_Movement, bool> >           MovePredicate     = PredicateBuilder.New <TLCSV_Movement>();
                    Expression <Func <TLCSV_BoxSplit, bool> >           BoxSplitPredicate = PredicateBuilder.New <TLCSV_BoxSplit>();
                    Expression <Func <TLCSV_WhseTransferDetail, bool> > WhseTransfer      = PredicateBuilder.New <TLCSV_WhseTransferDetail>();

                    foreach (var Box in BoxGroup)
                    {
                        CWPredicate       = CWPredicate.Or(x => x.TLCMTWC_Pk == Box.TLSOH_CMT_FK);
                        BoxSplitPredicate = BoxSplitPredicate.Or(x => x.TLCMTBS_BoxNo == Box.TLSOH_BoxNumber);
                        MovePredicate     = MovePredicate.Or(s => s.TLMV_BoxNumber == Box.TLSOH_BoxNumber);
                        WhseTransfer      = WhseTransfer.Or(x => x.TLCSVWHTD_TLSOH_Fk == Box.TLSOH_Pk);
                    }

                    context.TLCMT_CompletedWork.Where(CWPredicate).Update(x => new TLCMT_CompletedWork()
                    {
                        TLCMTWC_MarkedForDeletion = true
                    });
                    context.TLCSV_BoxSplit.Where(BoxSplitPredicate).Delete();
                    context.TLCSV_Movement.Where(MovePredicate).Delete();
                    context.TLCSV_WhseTransferDetail.Where(WhseTransfer).Delete();

                    pBar1.PerformStep();
                }

                //
                //====================================================================

                var WhseTransfers = context.TLCSV_WhseTransfer.ToList();

                foreach (var Transfer in WhseTransfers)
                {
                    var Trns = context.TLCSV_WhseTransferDetail.Where(x => x.TLCSVWHTD_WhseTranfer_FK == Transfer.TLCSVWHT_Pk).FirstOrDefault();
                    if (Trns != null)
                    {
                        continue;
                    }

                    context.TLCSV_WhseTransfer.Where(x => x.TLCSVWHT_Pk == Transfer.TLCSVWHT_Pk).Delete();
                }


                //=====================================================================
                // End of Customer Service Clear Down
                //=======================================================


                /*
                 * //================================================================
                 * // 2nd Step is to clear down the CMT Recrds
                 * //========================================================================
                 * pBar1.Visible = true;
                 * // Display the ProgressBar control.
                 * pBar1.Visible = true;
                 * // Set Minimum to 1
                 * pBar1.Minimum = 1;
                 * // Set the initial value of ProgessBar
                 * pBar1.Value = 1;
                 * // Set the Step property to a value of 1 to represent PPS Record processed
                 * pBar1.Step = 1;
                 *
                 * textBox1.Text = "Commencing with CMT ClearDown";
                 *
                 * var MarkDeletedGrouped = context.TLCMT_CompletedWork.Where(x => x.TLCMTWC_MarkedForDeletion && x.TLCMTWC_Despatched).GroupBy(x => x.TLCMTWC_LineIssue_FK);
                 * pBar1.Maximum = MarkDeletedGrouped.Count();
                 *
                 * foreach (var Grp in MarkDeletedGrouped)
                 * {
                 *  int NoRecords = Grp.Count();
                 *  int NoMarked = Grp.Where(x => x.TLCMTWC_MarkedForDeletion).Count();
                 *  if (NoRecords == NoMarked)
                 *  {
                 *      var LineIssue_Pk = Grp.FirstOrDefault().TLCMTWC_LineIssue_FK;
                 *      var LineIssueCS_Pk = Grp.FirstOrDefault().TLCMTWC_CutSheet_FK;
                 *
                 *      // Remove records from NonCompliance
                 *      //=======================================================
                 *      context.TLCMT_NonCompliance.Where(x => x.CMTNCD_CutSheet_Fk == LineIssueCS_Pk).Delete();
                 *
                 *      // Remove Records from AuditMeasure
                 *      //===========================================================
                 *      context.TLCMT_AuditMeasureRecorded.Where(x => x.TLBFAR_CutSheet_FK == LineIssueCS_Pk).Delete();
                 *
                 *      // Remove Record from Production Faults
                 *      //==========================================================
                 *      context.TLCMT_ProductionFaults.Where(x => x.TLCMTPF_PanelIssue_FK == LineIssueCS_Pk).Delete();
                 *
                 *
                 *      // Remove the records from the main completed work analysis
                 *      //===========================================================
                 *      context.TLCMT_CompletedWork.Where(x => x.TLCMTWC_MarkedForDeletion).Delete();
                 *
                 *
                 *      // Only Mark the Header record ready for deletion if all child records
                 *      //==============================================================
                 *      if (context.TLCMT_CompletedWork.Where(x => x.TLCMTWC_CutSheet_FK == LineIssueCS_Pk).Count() == 0)
                 *      {
                 *          //Mark for Deletion the main  record
                 *          //=================================================
                 *          var LI = context.TLCMT_LineIssue.Find(LineIssue_Pk);
                 *          if (LI != null)
                 *              LI.TLCMTLI_MarkedForDeltion = true;
                 *      }
                 *  }
                 *  pBar1.PerformStep();
                 * }
                 * try
                 * {
                 *  context.SaveChanges();
                 * }
                 * catch (Exception ex)
                 * {
                 *
                 * }
                 *
                 * //========================================================================
                 * // 3rd Step Clear down the Cutting Information
                 * //========================================================================
                 * pBar1.Visible = true;
                 * // Display the ProgressBar control.
                 * pBar1.Visible = true;
                 * // Set Minimum to 1
                 * pBar1.Minimum = 1;
                 * // Set the initial value of ProgessBar
                 * pBar1.Value = 1;
                 * // Set the Step property to a value of 1 to represent PPS Record processed
                 * pBar1.Step = 1;
                 * textBox1.Text = "Commencing with Cutting ClearDown";
                 *
                 * var MarkedForDel = context.TLCMT_LineIssue.Where(x => x.TLCMTLI_MarkedForDeltion).ToList();
                 * pBar1.Maximum = MarkedForDel.Count;
                 *
                 * foreach (var Marked in MarkedForDel)
                 * {
                 *  // 1st Step find the CutSheet
                 *  var CutSheet = context.TLCUT_CutSheet.Find(Marked.TLCMTLI_CutSheet_FK);
                 *  if (CutSheet != null)
                 *  {
                 *      // Delete from TLCut Trims
                 *      //========================================
                 *      context.TLCUT_TrimsOnCut.Where(x => x.TLCUTTOC_CutSheet_FK == CutSheet.TLCutSH_Pk).Delete();
                 *
                 *      var CutSheetReceipt = context.TLCUT_CutSheetReceipt.Where(x => x.TLCUTSHR_CustSheet_FK == CutSheet.TLCutSH_Pk).FirstOrDefault();
                 *      if (CutSheetReceipt != null)
                 *      {
                 *          // Delete from TLCut Receipt boxes
                 *          //=======================================
                 *          context.TLCUT_CutSheetReceiptBoxes.Where(x => x.TLCUTSHB_CutSheet_FK == CutSheetReceipt.TLCUTSHR_Pk).Delete();
                 *
                 *          // Delete from TLCut Expected Units
                 *          //=======================================
                 *          context.TLCUT_ExpectedUnits.Where(x => x.TLCUTE_CutSheet_FK == CutSheetReceipt.TLCUTSHR_Pk).Delete();
                 *
                 *          // Delete from TLCut QC Berrie
                 *          //=======================================
                 *          context.TLCUT_QCBerrie.Where(x => x.TLQCFB_CutSheetReceipt_FK == CutSheetReceipt.TLCUTSHR_Pk).Delete();
                 *
                 *          var CutSheetReceiptDetail = context.TLCUT_CutSheetReceiptDetail.Where(x => x.TLCUTSHRD_CutSheet_FK == CutSheetReceipt.TLCUTSHR_Pk).FirstOrDefault();
                 *          if (CutSheetReceiptDetail != null)
                 *          {
                 *              // QaA Results
                 *              //===========================================
                 *              context.TLCUT_QAResults.Where(x => x.TLCUTQA_Bundle_FK == CutSheetReceiptDetail.TLCUTSHRD_Pk).Delete();
                 *          }
                 *
                 *
                 *          // Remove Receipt Detail Records
                 *          //=============================================
                 *          context.TLCUT_CutSheetReceiptDetail.Where(x => x.TLCUTSHRD_CutSheet_FK == CutSheetReceipt.TLCUTSHR_Pk).Delete();
                 *
                 *          // Need to remove the Panel Issue Records in Panel Issue
                 *          //======================================================
                 *          context.TLCMT_PanelIssueDetail.Where(x => x.CMTPID_CutSheet_FK == CutSheetReceipt.TLCUTSHR_Pk).Delete();
                 *
                 *          //Remove Receipt Master
                 *          //===================================================
                 *          context.TLCUT_CutSheetReceipt.Remove(CutSheetReceipt);
                 *
                 *      }
                 *
                 *      context.TLCUT_CutSheetDetail.Where(x => x.TLCutSHD_CutSheet_FK == CutSheet.TLCutSH_Pk).Delete();
                 *      CutSheet.TLCUTSH_MarkedForDeletion = true;
                 *
                 *      pBar1.PerformStep();
                 *
                 * }
                 *
                 *
                 *
                 * //Remove all CMT Line Issues
                 * //==========================================================================
                 * context.TLCMT_LineIssue.Where(x => x.TLCMTLI_MarkedForDeltion).Delete();
                 *
                 * var PanelIssues = context.TLCMT_PanelIssue.ToList();
                 * foreach (var PanelIssue in PanelIssues)
                 * {
                 *      if (context.TLCMT_PanelIssueDetail.Where(x => x.CMTPID_PI_FK == PanelIssue.CMTPI_Pk).Count() == 0)
                 *      {
                 *          var PI = context.TLCMT_PanelIssue.Find(PanelIssue.CMTPI_Pk);
                 *          if (PI != null)
                 *              context.TLCMT_PanelIssue.Remove(PI);
                 *      }
                 *
                 * }
                 *
                 * try
                 * {
                 *   context.SaveChanges();
                 * }
                 * catch (Exception ex)
                 * {
                 *
                 * }
                 *
                 * //=============================================================================
                 * // 4th step Clear Down DyeHouse
                 * //========================================================================
                 *  IList<TLDYE_DyeOrder> DOOrder = null;
                 *  pBar1.Visible = true;
                 *  // Display the ProgressBar control.
                 *  pBar1.Visible = true;
                 *  // Set Minimum to 1
                 *  pBar1.Minimum = 1;
                 *  // Set the initial value of ProgessBar
                 *  pBar1.Value = 1;
                 *  // Set the Step property to a value of 1 to represent PPS Record processed
                 *  pBar1.Step = 1;
                 *
                 *  textBox1.Text = "Commencing with DyeHouse ClearDown";
                 *
                 *  var CSMarked = context.TLCUT_CutSheet.Where(x => x.TLCUTSH_MarkedForDeletion).ToList();
                 *  pBar1.Maximum = CSMarked.Count;
                 *
                 *  foreach (var CSMark in CSMarked)
                 *  {
                 *      bool BatchDelete = true;
                 *
                 *      //=======================================
                 *      // 1st find Dye Batch
                 *      //=================================================
                 *      var DyeBatch = context.TLDYE_DyeBatch.Find(CSMark.TLCutSH_DyeBatch_FK);
                 *      if (DyeBatch != null)
                 *      {
                 *          // Now find the details
                 *          //===============================
                 *          var DyeBatchDetails = context.TLDYE_DyeBatchDetails.Where(x => x.DYEBD_DyeBatch_FK == DyeBatch.DYEB_Pk).ToList();
                 *          var Cnt = DyeBatchDetails.Count();
                 *          if (Cnt != 0)
                 *          {
                 *              var ToCSheet = DyeBatchDetails.Where(x => x.DYEBO_CutSheet).Count();
                 *              if (Cnt == ToCSheet)
                 *              {
                 *                  // All the pieces in this DyeBatch have been used and therefore be deleted
                 *                  //=========================================================================
                 *                  context.TLDYE_DyeBatchDetails.Where(x => x.DYEBD_DyeBatch_FK == DyeBatch.DYEB_Pk).Delete();
                 *              }
                 *              else
                 *              {
                 *                  //We only delete those pieces that have been sent to cutting
                 *                  //==========================================================
                 *                  BatchDelete = false;
                 *                  context.TLDYE_DyeBatchDetails.Where(x => x.DYEBD_DyeBatch_FK == DyeBatch.DYEB_Pk && x.DYEBO_CutSheet).Delete();
                 *
                 *              }
                 *          }
                 *
                 *          if (BatchDelete)
                 *          {
                 *              var index = DOOrder.Where(x => x.TLDYO_Pk == DyeBatch.DYEB_DyeOrder_FK).FirstOrDefault();
                 *              if (index == null)
                 *              {
                 *                  var Do = context.TLDYE_DyeOrder.Find(DyeBatch.DYEB_DyeOrder_FK);
                 *                  if (Do == null)
                 *                      DOOrder.Add(Do);
                 *              }
                 *              context.TLDYE_DyeBatch.Remove(DyeBatch);
                 *          }
                 *      }
                 *
                 *      // Now Delete from the Cut Sheet file
                 *      //=======================================================
                 *      var CS = context.TLCUT_CutSheet.Find(CSMark.TLCutSH_Pk);
                 *      if (CS != null && BatchDelete)
                 *      {
                 *          //Before we do all the measurements and non-compliance
                 *          //=====================================================
                 *          context.TLDYE_DyeTransactions.RemoveRange(context.TLDYE_DyeTransactions.Where(x => x.TLDYET_Batch_FK == DyeBatch.DYEB_Pk));
                 *
                 *          context.TLDYE_NonCompliance.RemoveRange(context.TLDYE_NonCompliance.Where(x => x.TLDYE_NcrBatchNo_FK == DyeBatch.DYEB_Pk));
                 *          context.TLDYE_NonComplianceAnalysis.RemoveRange(context.TLDYE_NonComplianceAnalysis.Where(x => x.TLDYEDC_BatchNo == DyeBatch.DYEB_Pk));
                 *          context.TLDYE_NonComplianceDetail.RemoveRange(context.TLDYE_NonComplianceDetail.Where(x => x.DYENCRD_BatchNo_Fk == DyeBatch.DYEB_Pk));
                 *          context.TLDYE_NonComplianceConsDetail.RemoveRange(context.TLDYE_NonComplianceConsDetail.Where(x => x.DYENCCON_BatchNo_FK == DyeBatch.DYEB_Pk));
                 *
                 *          context.TLDye_QualityException.RemoveRange(context.TLDye_QualityException.Where(x => x.TLDyeIns_DyeBatch_Fk == DyeBatch.DYEB_Pk));
                 *
                 *          context.TLCUT_CutSheet.Remove(CS);
                 *      }
                 *
                 *  }
                 *
                 *  //======================================
                 *  // we need Delete Dye Orders of DyeBatches Deleted but only if there are no DyeBatch attached
                 *  //====================================================
                 *  foreach (var Do in DOOrder)
                 *  {
                 *      var Cnt = context.TLDYE_DyeBatch.Where(x => x.DYEB_DyeOrder_FK == Do.TLDYO_Pk).Count();
                 *      if (Cnt == 0)
                 *      {
                 *          var DyeO = context.TLDYE_DyeOrder.Find(Do.TLDYO_Pk);
                 *          if (DyeO != null)
                 *          {
                 *              context.TLDYE_DyeOrderDetails.Where(x => x.TLDYOD_DyeOrder_Fk == Do.TLDYO_Pk).Delete();
                 *              context.TLDYE_DyeOrder.Remove(DyeO);
                 *          }
                 *      }
                 *  }
                 *
                 *  try
                 *  {
                 *      context.SaveChanges();
                 *  }
                 *  catch (Exception ex)
                 *  {
                 *
                 *  }
                 *  // 5th step Clear Knitting - We achieve this by looping throu DOrder
                 *  // Have decided to leave Bought in Fabric for the moment
                 *  //========================================================================
                 *  pBar1.Visible = true;
                 *  // Display the ProgressBar control.
                 *  pBar1.Visible = true;
                 *  // Set Minimum to 1
                 *  pBar1.Minimum = 1;
                 *  // Set the initial value of ProgessBar
                 *  pBar1.Value = 1;
                 *  // Set the Step property to a value of 1 to represent PPS Record processed
                 *  pBar1.Step = 1;
                 *
                 *  textBox1.Text = "Commencing with Knitting ClearDown";
                 *
                 *  var KoOrders = context.TLKNI_Order.Where(x => x.KnitO_Closed && x.KnitO_ClosedDate <= DSelected).ToList();
                 *  foreach (var KoOrder in KoOrders)
                 *  {
                 *      var GProd = context.TLKNI_GreigeProduction.Where(x => x.GreigeP_KnitO_Fk == KoOrder.KnitO_Pk && !x.GreigeP_BoughtIn).ToList();
                 *      int NoDyed = GProd.Where(x => x.GreigeP_Dye).Count();
                 *      if (NoDyed == GProd.Count)
                 *      {
                 *          // We only want to delete batches where all the Production has been sent to dyeing
                 *          //================================================================================
                 *          // But before we do that
                 *          //==============================================
                 *          var YarnAllocs = context.TLKNI_YarnAllocTransctions.Where(x => x.TLKYT_KnitOrder_FK == KoOrder.KnitO_Pk).ToList();
                 *          foreach (var YarnAlloc in YarnAllocs)
                 *          {
                 *              var Pallet = context.TLKNI_YarnOrderPallets.Find(YarnAlloc.TLKYT_YOP_FK);
                 *              if (Pallet != null && Pallet.TLKNIOP_PalletAllocated)
                 *              {
                 *                  context.TLKNI_YarnOrderPallets.Remove(Pallet);
                 *              }
                 *          }
                 *
                 *          context.TLKNI_GreigeProduction.Where(x => x.GreigeP_KnitO_Fk == KoOrder.KnitO_Pk).Delete();
                 *
                 *          var Ko = context.TLKNI_Order.Find(KoOrder.KnitO_Pk);
                 *          if (Ko != null)
                 *          {
                 *              context.TLKNI_Order.Remove(Ko);
                 *          }
                 *      }
                 *
                 *      context.TLKNI_GreigeTransactions.Where(x => x.GreigeT_KOrder_FK == KoOrder.KnitO_Pk).Delete();
                 *  }
                 *
                 *  //3rd Party
                 *  //=========================================================
                 *  var YarnTS = context.TLKNI_YarnTransaction.Where(x => x.KnitY_TransactionDate <= DSelected).ToList();
                 *  foreach (var YarnT in YarnTS)
                 *  {
                 *      context.TLKNI_YarnTransactionDetails.Where(x => x.KnitYD_KnitY_FK == YarnT.KnitY_Pk).Delete();
                 *
                 *  }
                 *  context.TLKNI_GreigeCommissionTransctions.Where(x => x.GreigeCom_Transdate <= DSelected).Delete();
                 * }
                 *
                 * // 6th step Clear Spinning
                 * //========================================================================
                 *
                 * pBar1.Visible = true;
                 * // Display the ProgressBar control.
                 * pBar1.Visible = true;
                 * // Set Minimum to 1
                 * pBar1.Minimum = 1;
                 * // Set the initial value of ProgessBar
                 * pBar1.Value = 1;
                 * // Set the Step property to a value of 1 to represent PPS Record processed
                 * pBar1.Step = 1;
                 * textBox1.Text = "Commencing with Spinning ClearDown";
                 *
                 * // 6th step 1st Step cotton received transactions
                 * //======================================================================
                 *
                 * var CottonTrans = context.TLSPN_CottonTransactions.Where(x => x.cotrx_TransDate <= DSelected).ToList();
                 *
                 * foreach (var CottonTran in CottonTrans)
                 * {
                 *  context.TLSPN_CottonReceivedBales.Where(x => x.CotBales_LotNo == CottonTran.cotrx_LotNo).Delete();
                 *  context.TLSPN_YarnOrderLayDown.Where(x => x.YarnLD_LotNo == CottonTran.cotrx_LotNo).Delete();
                 *
                 *  var CT = context.TLSPN_CottonTransactions.Find(CottonTran.cotrx_pk);
                 *  if (CT != null)
                 *      context.TLSPN_CottonTransactions.Remove(CT);
                 * }
                 *
                 * var YarnOrders = context.TLSPN_YarnOrder.Where(x => x.Yarno_Closed && x.YarnO_DelDate <= DSelected).ToList();
                 * foreach (var YarnOrder in YarnOrders)
                 * {
                 *  context.TLSPN_YarnOrderPallets.RemoveRange(context.TLSPN_YarnOrderPallets.Where(x => x.YarnOP_YarnOrder_FK == YarnOrder.YarnO_Pk));
                 *  context.TLSPN_YarnTransactions.RemoveRange(context.TLSPN_YarnTransactions.Where(x => x.YarnTrx_YarnOrder_FK == YarnOrder.YarnO_Pk));
                 *
                 *  var YO = context.TLSPN_YarnOrder.Find(YarnOrder.YarnO_Pk);
                 *  if (YO != null)
                 *      context.TLSPN_YarnOrder.Remove(YO);
                 * }
                 * */
            }
        }
Exemplo n.º 26
0
        public void BoxDefaultOrientationIsVertical()
        {
            var g = new BoxGroup(LayoutTestStyle.Create());

            g.Orientation.Should().Be(Orientation.Vertical);
        }
Exemplo n.º 27
0
 public MoveGroup(BoxId boxId, BoxGroup boxGroup, int initialMoveNumber)
 {
     BoxId             = boxId;
     BoxGroup          = boxGroup;
     InitialMoveNumber = initialMoveNumber;
 }
Exemplo n.º 28
0
 // Start is called before the first frame update
 private void Start()
 {
     _gameManager = FindObjectOfType <GameManager>();
     _boxGroup    = FindObjectOfType <BoxGroup>();
 }
Exemplo n.º 29
0
 protected virtual void PrintGroup(BoxGroup g)
 {
     Reporter.WriteInformation($"ID: {g.Id}");
     Reporter.WriteInformation($"Name: {g.Name}");
 }