public InventoryItem(NancyContext context, InventoryItemDto item)
            : base(context.Request.Url.ToString(), new [] { "item", "detail" })
        {
            Properties = new Dictionary <string, object>
            {
                { "Name", item.Name },
                { "Quantity", item.Quantity }
            };

            Links = new LinksFactory(context)
                    .With(new GetInventoryLink(), WithLink <GetInventoryLink> .Property(x => x.Title = "Back to inventory"))
                    .Build();

            Actions = new ActionsFactory(context)
                      .With(new AddInventoryItemQuantityAction(item.Id, item.Version),
                            WithAction <AddInventoryItemQuantityAction>
                            .Field(x => x.Version)
                            .Having(x => x.Type = "hidden"))
                      .With(new RemoveInventoryItemQuantityAction(item.Id, item.Version),
                            WithAction <RemoveInventoryItemQuantityAction>
                            .Field(x => x.Version)
                            .Having(x => x.Type = "hidden"))
                      .With(new RenameInventoryItemAction(item.Id, item.Version, item.Name),
                            WithAction <RenameInventoryItemAction>
                            .Field(x => x.Version)
                            .Having(x => x.Type = "hidden"))
                      .Build();
        }
        public void CreateTest()
        {
            var ser           = new XActionWriter();
            var actionFactory = new ActionsFactory();
            var vals          = Enum.GetValues(typeof(ActionCode));

            foreach (ActionCode type in vals)
            {
                if ((byte)type <= 0x80)
                {
                    var action = actionFactory.Create(type);
                    try {
                        var res          = ser.Serialize(action);
                        var actualName   = res.Name.LocalName;
                        var expectedName = type.ToString();
                        if (type == ActionCode.End)
                        {
                            expectedName = "EndAction";
                        }
                        if (actualName != expectedName)
                        {
                            Console.WriteLine("Warning: Incosistent naming, Action type: {0}, Class: {1}", type,
                                              actualName);
                        }
                    } catch (Exception) {
                        Assert.Fail("Couldnt serialize: {0}", type);
                    }
                }
            }
        }
        public void AddActionClicked(object sender, RoutedEventArgs e)
        {
            Act selectedAct;

            if (IsLegacyPlatform)
            {
                if (AvailableActions.CurrentItem == null)
                {
                    Reporter.ToUser(eUserMsgKey.AskToSelectAction);
                    return;
                }

                selectedAct = AvailableActions.CurrentItem as Act;
                SetActionDetails(selectedAct);
            }
            else
            {
                if (DefaultAction == null)
                {
                    Reporter.ToUser(eUserMsgKey.AskToSelectAction);
                    return;
                }

                DefaultAction.Description = string.Format("{0} : {1} - {2}", (DefaultAction as ActUIElement).ElementAction, mElementInfo.ElementTypeEnum.ToString(), mElementInfo.ElementName);
                selectedAct = DefaultAction;
            }

            ActionsFactory.AddActionsHandler(selectedAct, mContext);
        }
        private void listActions_ItemDropped(object sender, EventArgs e)
        {
            object droppedItem = ((DragInfo)sender).Data as object;

            if (droppedItem != null)
            {
                int mouseIndex     = -1;
                int lastAddedIndex = -1;
                Act actDroppedOn   = DragDrop2.GetRepositoryItemHit(ListView) as Act;

                if (actDroppedOn != null)
                {
                    mouseIndex = ListView.DataSourceList.IndexOf(actDroppedOn);
                }

                lastAddedIndex = ActionsFactory.AddActionsHandler(droppedItem, mContext, mouseIndex);

                if (lastAddedIndex > mouseIndex)
                {
                    ListView.xListView.SelectedItems.Clear();
                    for (int itemIndex = mouseIndex; itemIndex < lastAddedIndex; itemIndex++)
                    {
                        RepositoryItemBase repoBaseItem = ListView.DataSourceList[itemIndex] as RepositoryItemBase;
                        if (repoBaseItem != null)
                        {
                            ListView.xListView.SelectedItems.Add(repoBaseItem);
                        }
                    }
                }
            }
        }
 private void AddAction()
 {
     if (ActionsTabs.SelectedContent != null && ((ucGrid)ActionsTabs.SelectedContent).CurrentItem != null)
     {
         Act selectedAction = ((ucGrid)ActionsTabs.SelectedContent).CurrentItem as Act;
         ActionsFactory.AddActionsHandler(selectedAction, mContext);
     }
 }
Beispiel #6
0
        public Root(NancyContext context) : base(context.Request.Url.ToString(), "root")
        {
            Links = new LinksFactory(context).With(new GetUsers()).Build();

            Actions = new ActionsFactory(context)
                      .With(new DeleteLogout())
                      .Build();
        }
 protected UnauthorisedResponse(NancyContext context, IList <string> @class) : base(context.Request.Url.ToString(), @class)
 {
     Actions = new ActionsFactory(context)
               .With(new PostLogin(), WithAction <PostLogin> .Field(x => x.Password).Having(x => x.Type = "password"))
               .With(new PostRegister(),
                     WithAction <PostRegister> .Field(x => x.Password).Having(x => x.Type        = "password"),
                     WithAction <PostRegister> .Field(x => x.ConfirmPassword).Having(x => x.Type = "password"))
               .With(new PostResetPassword())
               .Build();
 }
Beispiel #8
0
        private void AddActionListView(object sender, RoutedEventArgs e)
        {
            List <RepositoryItemBase> list = new List <RepositoryItemBase>();
            List <object>             SelectedItemsList = mListView.List.SelectedItems.Cast <object>().ToList();

            foreach (Act act in SelectedItemsList)
            {
                list.Add(act);
                ActionsFactory.AddActionsHandler(act, mContext);
            }
        }
        private void AddActionButton_Click(object sender, RoutedEventArgs e)
        {
            if (mActions.CurrentItem == null)
            {
                Reporter.ToUser(eUserMsgKey.AskToSelectAction);
                return;
            }

            Act selectedAct = mActions.CurrentItem as Act;

            SetActionDetails(selectedAct);
            ActionsFactory.AddActionsHandler(selectedAct, mContext);
        }
Beispiel #10
0
 private void AddFromPOMNavPage(object sender, RoutedEventArgs e)
 {
     if (xMainElementsGrid.Grid.SelectedItems != null && xMainElementsGrid.Grid.SelectedItems.Count > 0)
     {
         foreach (ElementInfo elemInfo in xMainElementsGrid.Grid.SelectedItems)
         {
             ActionsFactory.AddActionsHandler(elemInfo, mContext);
         }
     }
     else
     {
         Reporter.ToUser(eUserMsgKey.NoItemWasSelected);
     }
 }
        public InventoryCollectionItem(NancyContext context, InventoryListItemDto item)
            : base($"{context.Request.Url.SiteBase}{context.Request.Url.BasePath}{context.Request.Url.Path}/{item.Id}", "inventory-item")
        {
            Properties = new Dictionary <string, object> {
                { "Name", item.Name }
            };
            Links = new LinksFactory(context).With(new GetInventoryItemLink(item.Id)).Build();

            Actions = new ActionsFactory(context)
                      .With(new RemoveInventoryItemAction(item.Id, item.Version),
                            WithAction <RemoveInventoryItemAction> .Field(x => x.Version)
                            .Having(x => x.Type = "hidden"))
                      .Build();
        }
Beispiel #12
0
 private void AddFromPOMNavPage(object sender, RoutedEventArgs e)
 {
     if (mListView.List.SelectedItems != null && mListView.List.SelectedItems.Count > 0)
     {
         foreach (ElementInfo selectedItem in mListView.List.SelectedItems)
         {
             ActionsFactory.AddActionsHandler(selectedItem, mContext);
         }
     }
     else
     {
         Reporter.ToUser(eUserMsgKey.NoItemWasSelected);
     }
 }
        public UsersCollectionItem(NancyContext context, Domain.User user)
            : base(string.Format("{0}{1}{2}/{3}", context.Request.Url.SiteBase, context.Request.Url.BasePath, context.Request.Url.Path, user.Id), "user")
        {
            Properties = new Dictionary <string, object>
            {
                { "Username", user.Username },
                { "Created On", user.CreatedOn.ToShortDateString() }
            };

            Links   = new LinksFactory(context).With(new GetUser(user.Id)).Build();
            Actions = new ActionsFactory(context).With(new DeleteUser {
                Id = user.Id
            }).Build();
        }
Beispiel #14
0
        public void WriteOneByteActionsTest()
        {
            var vals    = Enum.GetValues(typeof(ActionCode));
            var factory = new ActionsFactory();

            foreach (ActionCode type in vals)
            {
                if ((byte)type < 0x80)
                {
                    var action  = factory.Create(type);
                    var xAction = XAction.ToXml(action);
                    Assert.AreEqual(xAction.Name.LocalName, XActionNames.FromActionCode(type));
                }
            }
        }
Beispiel #15
0
        public User(NancyContext context, Domain.User user) : base(context.Request.Url.ToString(), "user")
        {
            Properties = new Dictionary <string, object>
            {
                { "Username", user.Username },
                { "Claims", string.Join(", ", user.Claims.Select(x => x.ToString()).ToList()) }
            };

            Links = new LinksFactory(context).With(new GetUsers(), WithLink <GetUsers> .Property(x => x.Title = "Back to all users")).Build();

            Actions = new ActionsFactory(context).With(new PutClaims(user),
                                                       WithAction <PutClaims> .Field(x => x.Claims)
                                                       .Having(x => x.Type    = "select")
                                                       .Having(x => x.Options = GetClaimsOptions())).Build();
        }
Beispiel #16
0
        public InventoryCollection(NancyContext context, ICollection <InventoryListItemDto> items)
            : base(context.Request.Url.ToString(), new[] { "inventory", "collection" })
        {
            int pageNumber   = context.Request.Query.PageNumber;
            int pageSize     = context.Request.Query.PageSize;
            int totalEntries = items.Count;

            var booksPage = items.Skip(pageNumber * pageSize).Take(pageSize);

            Properties = new Dictionary <string, object> {
                { "Page Details", PagedProperties.GetPageDetails(pageNumber, pageSize, totalEntries) }
            };
            Entities = new List <Entity>(booksPage.Select(x => new InventoryCollectionItem(context, x)));
            Links    = new LinksFactory(context).WithPage <GetInventoryLink>(pageNumber, pageSize, totalEntries).Build();
            Actions  = new ActionsFactory(context).With(new AddInventoryItemAction()).Build();
        }
Beispiel #17
0
        public void AllActionsBuildTest()
        {
            var factory = new ActionsFactory();
            var vals    = Enum.GetValues(typeof(ActionCode));

            foreach (ActionCode type in vals)
            {
                var action = factory.Create(type);
                Assert.IsNotNull(action);
                if (action.GetType().Name != "Action" + type.ToString())
                {
                    Console.WriteLine("Warning: Incosistent naming, Action code: {0}, Class: {1}", type, action.GetType().Name);
                }
                var actualType = action.ActionCode;
                Assert.AreEqual(type, actualType);
            }
        }
Beispiel #18
0
        private static void Main( string[] args )
        {
            NetcoLogger.LoggerFactory = new NLogLoggerFactory();

            try
            {
                var actions = new ActionsFactory().CreateCommandsToExecute();
                PrintActionsToExecute( actions );
                ExecuteActionsWithConfirmation( actions );
            }
            catch( Exception exc )
            {
                NetcoLogger.GetLogger( typeof( Program ) ).Error( exc, "Global exception" );
            }
            Console.WriteLine( "Press ENTER to exit" );
            Console.ReadLine();
        }
Beispiel #19
0
        private static void Main(string[] args)
        {
            NetcoLogger.LoggerFactory = new NLogLoggerFactory();

            try
            {
                var actions = new ActionsFactory().CreateCommandsToExecute();
                PrintActionsToExecute(actions);
                ExecuteActionsWithConfirmation(actions);
            }
            catch (Exception exc)
            {
                NetcoLogger.GetLogger(typeof(Program)).Error(exc, "Global exception");
            }
            Console.WriteLine("Press ENTER to exit");
            Console.ReadLine();
        }
 private void AddMultipleActions(object sender, RoutedEventArgs e)
 {
     if (ActionsTabs.SelectedContent != null)
     {
         ucGrid actionsGrid = ((ucGrid)ActionsTabs.SelectedContent);
         if (actionsGrid.Grid.SelectedItems != null && actionsGrid.Grid.SelectedItems.Count > 0)
         {
             foreach (Act selectedAct in actionsGrid.Grid.SelectedItems)
             {
                 ActionsFactory.AddActionsHandler(selectedAct, mContext);
             }
         }
         else
         {
             Reporter.ToUser(eUserMsgKey.NoItemWasSelected);
         }
     }
 }
Beispiel #21
0
        private void DroppedItemHandler(object droppedItem, int mouseIndex)
        {
            int lastAddedIndex = -1;

            lastAddedIndex = ActionsFactory.AddActionsHandler(droppedItem, mContext, mouseIndex);

            if (lastAddedIndex > mouseIndex)
            {
                ListView.xListView.SelectedItems.Clear();
                for (int itemIndex = mouseIndex; itemIndex < lastAddedIndex; itemIndex++)
                {
                    RepositoryItemBase repoBaseItem = ListView.DataSourceList[itemIndex] as RepositoryItemBase;
                    if (repoBaseItem != null)
                    {
                        ListView.xListView.SelectedItems.Add(repoBaseItem);
                    }
                }
            }
        }
Beispiel #22
0
 private void AddFromRepository(object sender, RoutedEventArgs e)
 {
     if (mListView.List.SelectedItems != null && mListView.List.SelectedItems.Count > 0)
     {
         if (mContext.BusinessFlow == null)
         {
             return;
         }
         List <Act> list = new List <Act>();
         foreach (Act selectedItem in mListView.List.SelectedItems)
         {
             ActionsFactory.AddActionsHandler(selectedItem, mContext);
         }
     }
     else
     {
         Reporter.ToUser(eUserMsgKey.NoItemWasSelected);
     }
 }
Beispiel #23
0
        private void AddFromRepository(object sender, RoutedEventArgs e)
        {
            if (mContext.BusinessFlow == null)
            {
                return;
            }

            if (xActionsGrid.Grid.SelectedItems != null && xActionsGrid.Grid.SelectedItems.Count > 0)
            {
                foreach (Act selectedItem in xActionsGrid.Grid.SelectedItems)
                {
                    ActionsFactory.AddActionsHandler(selectedItem, mContext);
                    //mContext.BusinessFlow.AddAct((Act)selectedItem.CreateInstance(true));
                }
            }
            else
            {
                Reporter.ToUser(eUserMsgKey.NoItemWasSelected);
            }
        }
Beispiel #24
0
        public void WriteOneByteActionsTest()
        {
            var vals    = Enum.GetValues(typeof(ActionCode));
            var factory = new ActionsFactory();

            foreach (ActionCode type in vals)
            {
                if ((byte)type < 0x80)
                {
                    var action       = factory.Create(type);
                    var mem          = new MemoryStream();
                    var writer       = new SwfStreamWriter(mem);
                    var actionWriter = new ActionWriter(writer);
                    actionWriter.WriteAction(action);
                    var buffer = mem.ToArray();
                    Assert.AreEqual(1, buffer.Length);
                    Assert.AreEqual((byte)type, buffer[0]);
                }
            }
        }
Beispiel #25
0
 private void AddFromRepository(object sender, RoutedEventArgs e)
 {
     if (mInTreeModeView == false)
     {
         if (xActivitiesRepositoryGrid.Grid.SelectedItems != null && xActivitiesRepositoryGrid.Grid.SelectedItems.Count > 0)
         {
             if (mContext.BusinessFlow != null)
             {
                 List <Activity> list = new List <Activity>();
                 foreach (Activity selectedItem in xActivitiesRepositoryGrid.Grid.SelectedItems)
                 {
                     list.Add(selectedItem);
                 }
                 ActionsFactory.AddActivitiesFromSRHandler(list, mContext.BusinessFlow);
             }
         }
         else
         {
             Reporter.ToUser(eUserMsgKey.NoItemWasSelected);
         }
     }
 }
        /// <summary>
        /// Paste the Copied or Cut Items
        /// </summary>
        /// <param name="containerControl">The UI control which paste is done on (DataGrid/TreeView/ListView)</param>
        /// <param name="propertiesToSet">List of properties PropertyName-Value to set in reflection to they paste item</param>
        public static void PasteItems(IClipboardOperations containerControl, List <Tuple <string, object> > propertiesToSet = null, int currentIndex = -1, Context context = null)
        {
            bool IsValidActionPlatform = true;

            ((Control)containerControl).Dispatcher.Invoke(() =>
            {
                try
                {
                    if (CopiedorCutItems.Count > 0)
                    {
                        Reporter.ToStatus(eStatusMsgKey.PasteProcess, null, string.Format("Performing paste operation for {0} items...", CopiedorCutItems.Count));

                        if (CutSourceList != null)
                        {
                            //CUT
                            //first remove from cut source
                            foreach (RepositoryItemBase item in CopiedorCutItems)
                            {
                                //clear from source
                                CutSourceList.Remove(item);
                                if (currentIndex > 0)
                                {
                                    currentIndex--;
                                }
                                //set needed properties if any
                                SetProperties(item, propertiesToSet);
                                if (!containerControl.GetSourceItemsAsIList().Contains(item))//Not cut & paste on same grid
                                {
                                    //set unique name
                                    GingerCoreNET.GeneralLib.General.SetUniqueNameToRepoItem(containerControl.GetSourceItemsAsList(), item);
                                }
                                //check action platform before copy
                                if (!ActionsFactory.IsValidActionPlatformForActivity(item, context))
                                {
                                    IsValidActionPlatform = false;
                                    continue;
                                }
                                //paste on target and select
                                containerControl.SetSelectedIndex(AddItemAfterCurrent(containerControl, item, currentIndex));
                                //Trigger event for changing sub classes fields
                                containerControl.OnPasteItemEvent(PasteItemEventArgs.ePasteType.PasteCutedItem, item);
                            }

                            //clear so will be past only once
                            CutSourceList = null;
                            CopiedorCutItems.Clear();
                        }
                        else
                        {
                            //COPY
                            //paste on target
                            foreach (RepositoryItemBase item in CopiedorCutItems)
                            {
                                RepositoryItemBase copiedItem = item.CreateCopy();
                                //set unique name
                                GingerCoreNET.GeneralLib.General.SetUniqueNameToRepoItem(containerControl.GetSourceItemsAsList(), copiedItem, "_Copy");
                                //set needed properties if any
                                SetProperties(copiedItem, propertiesToSet);

                                //check action platform before copy
                                if (!ActionsFactory.IsValidActionPlatformForActivity(copiedItem, context))
                                {
                                    IsValidActionPlatform = false;
                                    continue;
                                }
                                //add and select
                                containerControl.SetSelectedIndex(AddItemAfterCurrent(containerControl, copiedItem, currentIndex));
                                //Trigger event for changing sub classes fields
                                containerControl.OnPasteItemEvent(PasteItemEventArgs.ePasteType.PasteCopiedItem, copiedItem);
                            }
                        }
                    }
                    else
                    {
                        Reporter.ToStatus(eStatusMsgKey.PasteProcess, null, "No items found to paste");
                    }
                    if (!IsValidActionPlatform)
                    {
                        Reporter.ToUser(eUserMsgKey.MissingTargetApplication, "Unable to copy actions with different platform.");
                    }
                }
                catch (Exception ex)
                {
                    Reporter.ToUser(eUserMsgKey.StaticWarnMessage, "Operation Failed, make sure the copied/cut items type and destination type is matching." + System.Environment.NewLine + System.Environment.NewLine + "Error: " + ex.Message);
                    //CutSourceList = null;
                    //CopiedorCutItems.Clear();
                }
                finally
                {
                    Reporter.HideStatusMessage();
                }
            });
        }
Beispiel #27
0
 public string Command(string xmlFormatCommand)
 {
     return(ActionsFactory.Handle(xmlFormatCommand).ToString(SaveOptions.None));
 }
Beispiel #28
0
        public BaseAction Run(State state)
        {
            var firstAlly = state?.Allies?.FirstOrDefault();

            return(ActionsFactory.Rest(firstAlly?.Id ?? Guid.Empty));
        }