Exemplo n.º 1
0
    private GameObject GetItemPrefab(ActionItemType type)
    {
        switch (type)
        {
        case ActionItemType.Coin:
            return(CoinPrefab);

        case ActionItemType.TreasureChest:
            return(FullTreasureChestPrefab);

        case ActionItemType.EmptyChest:
            return(EmptyTreasureChestPrefab);

        case ActionItemType.MimicChest:
            return(MimicTreasureChestPrefab);

        case ActionItemType.SpikeTrap:
            return(SpiketrapPrefab);

        case ActionItemType.Bottle:
            return(FlaskPrefab);

        case ActionItemType.TestTube:
            return(TesttubePrefab);

        default:
            return(CoinPrefab);
        }
    }
Exemplo n.º 2
0
        /// <summary>
        /// Adds an Action item to the Action controller.
        /// </summary>
        /// <param name="number">Number of the Action item.</param>
        /// <param name="alias">Alias of the Action item.</param>
        /// <param name="idXML">IdXML of the Action item.</param>
        /// <param name="agents">List of agents that can access to the Action item.</param>
        /// <param name="className">Class name of the Action item.</param>
        /// <param name="iuName">Interaction unit name of the Action item.</param>
        /// <param name="navigationalFilteringIdentity">Navigational filtering identifier.</param>
        /// <param name="actionItemType">Type of the actiom item.</param>
        /// <param name="objectActionEnabled">If the Object-Action feature is enabled or not.</param>
        /// <param name="multiSelectionSupported">If multiselection is supported or not.</param>
        /// <param name="attributesListForFormulas">List of attributes needed for evaluating the enabling/disabling formulas.</param>
        /// <returns>ActionItemController.</returns>
        /// <returns></returns>
        public ActionItemController Add(
            int number,
            string alias,
            string idXML,
            string[] agents,
            string classIUName,
            string iuName,
            string navigationalFilteringIdentity,
            ActionItemType actionItemType,
            bool objectActionEnabled,
            bool multiSelectionSupported,
            List <KeyValuePair <string, string[]> > attributesListForFormulas)
        {
            // Check the attributes for enabled formulas depending on the connected agent.
            List <string> lAttributesForFormulas = new List <string>();

            if (attributesListForFormulas != null && Logic.Agent.IsActiveFacet(agents))
            {
                foreach (KeyValuePair <string, string[]> lKeyPair in attributesListForFormulas)
                {
                    // Check the connected agent visibility.
                    if (Logic.Agent.IsActiveFacet(lKeyPair.Key))
                    {
                        foreach (string lAttribute in lKeyPair.Value)
                        {
                            // Avoid adding repeated elements.
                            if (!lAttributesForFormulas.Contains(lAttribute))
                            {
                                lAttributesForFormulas.Add(lAttribute);
                            }
                        }
                    }
                }
            }

            // Set the 'AnyActionItemEnabledByCondition' flag to true.
            if ((lAttributesForFormulas != null) && (lAttributesForFormulas.Count > 0))
            {
                AnyActionItemEnabledByCondition = true;
            }

            List <string>        lAgents     = new List <string>(agents);
            ActionItemController lActionItem = new ActionItemController(number, alias, idXML, lAgents, classIUName, iuName, navigationalFilteringIdentity, actionItemType, objectActionEnabled, multiSelectionSupported, lAttributesForFormulas, this);

            mActionItems.Add(number, lActionItem);

            lActionItem.RefreshRequired            += new EventHandler <RefreshRequiredEventArgs>(HandleActionItemRefreshRequired);
            lActionItem.SelectNextPreviousInstance += new EventHandler <SelectNextPreviousInstanceEventArgs>(HandleActionItemSelectNextPreviousInstance);
            lActionItem.BeforeExecute             += new EventHandler <CheckForPendingChangesEventArgs>(HandleActionItemBeforeActionItemExecution);
            lActionItem.SelectedInstancesRequired += new EventHandler <SelectedInstancesRequiredEventArgs>(HandleActionItemSelectedInstancesRequired);
            lActionItem.ContextRequired           += new EventHandler <ContextRequiredEventArgs>(HandleActionItemContextRequired);
            lActionItem.LaunchingScenario         += new EventHandler <LaunchingScenarioEventArgs>(HandleActionItemLaunchingScenario);

            return(lActionItem);
        }
        /// <summary>
        /// Initializes a new instance of the 'ActionItemController' class.
        /// </summary>
        /// <param name="number">Number of the Action item.</param>
        /// <param name="alias">Alias of the Action item.</param>
        /// <param name="idXML">IdXML of the Action item.</param>
        /// <param name="agents">List of agents that can acces to the Action item.</param>
        /// <param name="classIUName">Class name of the Action item.</param>
        /// <param name="iuName">Interaction unit name of the Action item.</param>
        /// <param name="navigationalFilteringIdentity">Navigational filtering identifier.</param>
        /// <param name="actionType">Type of the action item.</param>
        /// <param name="objectActionEnabled">Boolean value indicating whether the Object-Action feature is enabled or not.</param>
        /// <param name="multiSelectionSupported">If multiselection is supported or not.</param>
        /// <param name="attributesListForFormulas">List of attributes needed for evaluating the enabling/disabling formulas.</param>
        /// <param name="parent">Parent controller.</param>
        public ActionItemController(
            int number,
            string alias,
            string idXML,
            List <string> agents,
            string classIUName,
            string iuName,
            string navigationalFilteringIdentity,
            ActionItemType actionType,
            bool objectActionEnabled,
            bool multiSelectionSupported,
            List <string> attributesListForFormulas,
            ActionController parent)
            : base(parent)
        {
            mNumber     = number;
            mAlias      = alias;
            mIdXML      = idXML;
            mAgents     = agents;
            ClassIUName = classIUName;
            IUName      = iuName;
            NavigationalFilteringIdentity = navigationalFilteringIdentity;
            ActionItemType          = actionType;
            ObjectActionEnabled     = objectActionEnabled;
            MultiSelectionSupported = multiSelectionSupported;

            // Build the attributes for enabling/disabling formulas (comma-sepatated string).
            if (attributesListForFormulas != null)
            {
                StringBuilder lAttributes = new StringBuilder();
                foreach (string lItem in attributesListForFormulas)
                {
                    lAttributes.Append(lItem);
                    lAttributes.Append(',');
                }
                // Remove the last comma.
                if (lAttributes.Length > 0)
                {
                    lAttributes.Length--;
                }

                ActionItemAttributesForFormulas = lAttributes.ToString();
            }
        }
Exemplo n.º 4
0
        public List <ActionItem> GetByPersonId(int Id)
        {
            List <ActionItem> who = null;

            _prov.ExecuteCmd("dbo.ActionItem_SearchByPersonId",
                             inputParamMapper : delegate(SqlParameterCollection parameter)
            {
                parameter.AddWithValue("@PersonId", Id);
            },
                             singleRecordMapper : delegate(IDataReader rdr, short set)
            {
                switch (set)
                {
                case 0:
                    ActionItem e            = new ActionItem();
                    int ord                 = 0;
                    e.Id                    = rdr.GetSafeInt32(ord++);
                    e.UserId                = rdr.GetSafeInt32(ord++);
                    e.AssignedDate          = rdr.GetSafeUtcDateTime(ord++);
                    e.DueDate               = rdr.GetSafeUtcDateTime(ord++);
                    e.Description           = rdr.GetSafeString(ord++);
                    ActionItemType ait      = new ActionItemType();
                    e.ActionItemType        = ait;
                    e.ActionItemType.Id     = rdr.GetSafeInt32(ord++);
                    e.Name                  = rdr.GetSafeString(ord++);
                    Status ais              = new Status();
                    e.ActionItemStatus      = ais;
                    e.ActionItemStatus.Id   = rdr.GetSafeInt32(ord++);
                    e.ActionItemType.Name   = rdr.GetSafeString(ord++);
                    e.ActionItemStatus.Name = rdr.GetSafeString(ord++);
                    e.IsOverDue             = rdr.GetSafeInt32(ord++);
                    if (who == null)
                    {
                        who = new List <ActionItem>();
                    }
                    who.Add(e);
                    break;
                }
            }
                             );
            return(who);
        }
Exemplo n.º 5
0
 /// <summary>
 /// Removes a specific item
 /// </summary>
 /// <param name="itemType"> The type of the item </param>
 /// <param name="itemId"> The id of the item </param>
 /// <param name="result"> Description of the result </param>
 /// <returns> The result </returns>
 public bool RemoveItem(ActionItemType itemType, short itemId, out ActionbarOperationResult result)
 {
     result = ActionbarOperationResult.Success;
     // rules check
     if (!CanRemove)
     {
         result = ActionbarOperationResult.NotAllowed;
         return(false);
     }
     // actionbar is empty
     if (IsEmpty)
     {
         result = ActionbarOperationResult.ItemNotFound;
         return(false);
     }
     // searching for the item
     for (var i = 0; i < this.Size; i++)
     {
         // if the slot is empty skip it
         var slot = slots[i];
         if (slot.IsEmpty)
         {
             continue;
         }
         // matching the item id and the type
         var item = slot.Item;
         if (item.Type != itemType || item.ItemId != itemId)
         {
             continue;
         }
         // remove the item
         this.slots[i].IsEmpty = true;
         this.FilledSlots--;
         return(true);
     }
     // this should not happen
     result = ActionbarOperationResult.Fail;
     return(false);
 }
Exemplo n.º 6
0
        public bool ChangeApprovalStatus(int itemId, ActionItemType itemType, ApprovalStatus newStatus)
        {
            try
            {
                if (itemType == ActionItemType.Song)
                {
                    var song = this.context.Songs.Find(itemId);
                    if (song != null)
                    {
                        song.ApprovalStatus = newStatus;
                        this.context.SaveChanges();
                        return(true);
                    }

                    return(false);
                }

                if (itemType == ActionItemType.Album)
                {
                    var album = this.context.Albums.Find(itemId);
                    if (album != null)
                    {
                        album.ApprovalStatus = newStatus;
                        this.context.SaveChanges();
                        return(true);
                    }

                    return(false);
                }
            }
            catch
            {
                return(false);
            }

            return(false);
        }
Exemplo n.º 7
0
        private static ActionItem MapActionItem(IDataReader rdr)
        {
            ActionItem e   = new ActionItem();
            int        ord = 0;

            e.Id           = rdr.GetSafeInt32(ord++);
            e.UserId       = rdr.GetSafeInt32(ord++);
            e.AssignedDate = rdr.GetSafeUtcDateTime(ord++);
            e.DueDate      = rdr.GetSafeUtcDateTime(ord++);
            e.Description  = rdr.GetSafeString(ord++);
            ActionItemType ait = new ActionItemType();

            e.ActionItemType    = ait;
            e.ActionItemType.Id = rdr.GetSafeInt32(ord++);
            e.Name = rdr.GetSafeString(ord++);
            Status ais = new Status();

            e.ActionItemStatus      = ais;
            e.ActionItemStatus.Id   = rdr.GetSafeInt32(ord++);
            e.ActionItemType.Name   = rdr.GetSafeString(ord++);
            e.ActionItemStatus.Name = rdr.GetSafeString(ord++);
            e.IsOverDue             = rdr.GetSafeInt32(ord++);
            return(e);
        }
Exemplo n.º 8
0
 /// <summary>
 /// Adds a(n) <see cref="ActionItem"/> at a specific slot.
 /// </summary>
 /// <param name="itemType"> The type of the item </param>
 /// <param name="itemId"> The id of the item </param>
 /// <param name="slot"> The slot to add to </param>
 /// <param name="result"> Description of the result </param>
 /// <returns> The result </returns>
 public bool AddItemAt(ActionItemType itemType, short itemId, int slot, out ActionbarOperationResult result)
 {
     result = ActionbarOperationResult.Success;
     // rules check
     if (!CanAdd)
     {
         result = ActionbarOperationResult.NotAllowed;
         return(false);
     }
     // range check
     if (slot < 0 || slot >= this.Size)
     {
         result = ActionbarOperationResult.Fail;
         return(false);
     }
     // add the item at that slot
     this.slots[slot] = new Slot {
         Item = new ActionItem {
             Type = itemType, ItemId = itemId
         }, IsEmpty = false
     };
     this.FilledSlots++;
     return(true);
 }
Exemplo n.º 9
0
 /// <summary>
 /// Adds a(n) <see cref="ActionItem"/> to the next empty slot.
 /// </summary>
 /// <param name="itemType"> The type of the item </param>
 /// <param name="itemId"> The id of the item </param>
 /// <param name="result"> Description of the result </param>
 /// <returns> The result </returns>
 public bool AddItem(ActionItemType itemType, short itemId, out ActionbarOperationResult result)
 {
     result = ActionbarOperationResult.Success;
     // rules check
     if (!CanAdd)
     {
         result = ActionbarOperationResult.NotAllowed;
         return(false);
     }
     // if the actionbar is full just return
     if (IsFull)
     {
         result = ActionbarOperationResult.ActionbarFull;
         return(false);
     }
     // try to find an empty slot
     for (var i = 0; i < this.Size; i++)
     {
         // if the slot isnt empty skip
         if (!slots[i].IsEmpty)
         {
             continue;
         }
         // add the item at an empty slot
         this.slots[i] = new Slot {
             Item = new ActionItem {
                 Type = itemType, ItemId = itemId
             }, IsEmpty = false
         };
         this.FilledSlots++;
         return(true);
     }
     // this should not happen
     result = ActionbarOperationResult.Fail;
     return(false);
 }
Exemplo n.º 10
0
        /// <summary>
        /// Initializes a new instance of the 'ActionItemController' class.
        /// </summary>
        /// <param name="number">Number of the Action item.</param>
        /// <param name="alias">Alias of the Action item.</param>
        /// <param name="idXML">IdXML of the Action item.</param>
        /// <param name="agents">List of agents that can acces to the Action item.</param>
        /// <param name="classIUName">Class name of the Action item.</param>
        /// <param name="iuName">Interaction unit name of the Action item.</param>
        /// <param name="navigationalFilteringIdentity">Navigational filtering identifier.</param>
        /// <param name="actionType">Type of the action item.</param>
        /// <param name="objectActionEnabled">Boolean value indicating whether the Object-Action feature is enabled or not.</param>
        /// <param name="multiSelectionSupported">If multiselection is supported or not.</param>
        /// <param name="attributesListForFormulas">List of attributes needed for evaluating the enabling/disabling formulas.</param>
        /// <param name="parent">Parent controller.</param>
        public ActionItemController(
			int number,
			string alias,
			string idXML,
			List<string> agents,
			string classIUName,
			string iuName,
			string navigationalFilteringIdentity,
			ActionItemType actionType,
			bool objectActionEnabled,
			bool multiSelectionSupported,
			List<string> attributesListForFormulas,
			ActionController parent)
            : base(parent)
        {
            mNumber = number;
            mAlias = alias;
            mIdXML = idXML;
            mAgents = agents;
            ClassIUName = classIUName;
            IUName = iuName;
            NavigationalFilteringIdentity = navigationalFilteringIdentity;
            ActionItemType = actionType;
            ObjectActionEnabled = objectActionEnabled;
            MultiSelectionSupported = multiSelectionSupported;

            // Build the attributes for enabling/disabling formulas (comma-sepatated string).
            if (attributesListForFormulas != null)
            {
                StringBuilder lAttributes = new StringBuilder();
                foreach (string lItem in attributesListForFormulas)
                {
                    lAttributes.Append(lItem);
                    lAttributes.Append(',');
                }
                // Remove the last comma.
                if (lAttributes.Length > 0)
                {
                    lAttributes.Length--;
                }

                ActionItemAttributesForFormulas = lAttributes.ToString();
            }
        }
Exemplo n.º 11
0
        /// <summary>
        /// Adds an Action item to the Action controller.
        /// </summary>
        /// <param name="number">Number of the Action item.</param>
        /// <param name="alias">Alias of the Action item.</param>
        /// <param name="idXML">IdXML of the Action item.</param>
        /// <param name="agents">List of agents that can access to the Action item.</param>
        /// <param name="className">Class name of the Action item.</param>
        /// <param name="iuName">Interaction unit name of the Action item.</param>
        /// <param name="navigationalFilteringIdentity">Navigational filtering identifier.</param>
        /// <param name="actionItemType">Type of the actiom item.</param>
        /// <param name="objectActionEnabled">If the Object-Action feature is enabled or not.</param>
        /// <param name="multiSelectionSupported">If multiselection is supported or not.</param>
        /// <param name="attributesListForFormulas">List of attributes needed for evaluating the enabling/disabling formulas.</param>
        /// <returns>ActionItemController.</returns>
        /// <returns></returns>
        public ActionItemController Add(
			int number,
			string alias,
			string idXML,
			string[] agents,
			string classIUName,
			string iuName,
			string navigationalFilteringIdentity,
			ActionItemType actionItemType,
			bool objectActionEnabled,
			bool multiSelectionSupported,
			List<KeyValuePair<string, string[]>> attributesListForFormulas)
        {
            // Check the attributes for enabled formulas depending on the connected agent.
            List<string> lAttributesForFormulas = new List<string>();
            if (attributesListForFormulas != null && Logic.Agent.IsActiveFacet(agents))
            {
                foreach (KeyValuePair<string, string[]> lKeyPair in attributesListForFormulas)
                {
                    // Check the connected agent visibility.
                    if (Logic.Agent.IsActiveFacet(lKeyPair.Key))
                    {
                        foreach (string lAttribute in lKeyPair.Value)
                        {
                            // Avoid adding repeated elements.
                            if (!lAttributesForFormulas.Contains(lAttribute))
                            {
                                lAttributesForFormulas.Add(lAttribute);
                            }
                        }
                    }
                }
            }

            // Set the 'AnyActionItemEnabledByCondition' flag to true.
            if ((lAttributesForFormulas != null) && (lAttributesForFormulas.Count > 0))
            {
                AnyActionItemEnabledByCondition = true;
            }

            List<string> lAgents = new List<string>(agents);
            ActionItemController lActionItem = new ActionItemController(number, alias, idXML, lAgents, classIUName, iuName, navigationalFilteringIdentity, actionItemType, objectActionEnabled, multiSelectionSupported, lAttributesForFormulas, this);
            mActionItems.Add(number, lActionItem);

            lActionItem.RefreshRequired += new EventHandler<RefreshRequiredEventArgs>(HandleActionItemRefreshRequired);
            lActionItem.SelectNextPreviousInstance += new EventHandler<SelectNextPreviousInstanceEventArgs>(HandleActionItemSelectNextPreviousInstance);
            lActionItem.BeforeExecute += new EventHandler<CheckForPendingChangesEventArgs>(HandleActionItemBeforeActionItemExecution);
            lActionItem.SelectedInstancesRequired += new EventHandler<SelectedInstancesRequiredEventArgs>(HandleActionItemSelectedInstancesRequired);
            lActionItem.ContextRequired += new EventHandler<ContextRequiredEventArgs>(HandleActionItemContextRequired);
            lActionItem.LaunchingScenario += new EventHandler<LaunchingScenarioEventArgs>(HandleActionItemLaunchingScenario);

            return lActionItem;
        }
Exemplo n.º 12
0
        private async Task <int> CreateWorkItemFromTicketAsync(SqlConnection cn, IFreshdeskClient client, Ticket ticket, int objectId, ActionItemType objectType)
        {
            int?appId = (objectType == ActionItemType.Application) ?
                        objectId :
                        (objectId == -1) ?
                        CurrentOrgUser.CurrentAppId :
                        await GetAppFromProjectIdAsync(cn, objectId);

            int?projectId = (objectType == ActionItemType.Project) ? objectId : default(int?);

            if (projectId == -1 && ticket.CompanyId.HasValue)
            {
                var company = await client.GetCompanyAsync(ticket.CompanyId.Value);

                projectId = await CreateNewProjectAsync(cn, CurrentOrgUser.CurrentAppId.Value, company);
            }

            if (projectId == -1)
            {
                projectId = null;
            }

            var workItem = new Ginseng.Models.WorkItem()
            {
                OrganizationId = OrgId,
                ApplicationId  = appId,
                TeamId         = CurrentOrgUser.CurrentTeamId.Value,
                ProjectId      = projectId,
                Title          = $"FD: {ticket.Subject} (ticket # {ticket.Id})",
                HtmlBody       = ticket.Description + $"<hr/><p>Created from Freshdesk <a href=\"{CurrentOrg.FreshdeskUrl}/a/tickets/{ticket.Id}\">ticket {ticket.Id}</a></p>"
            };
            await workItem.SetNumberAsync(cn);

            await workItem.SaveHtmlAsync(Data, cn);

            await Data.TrySaveAsync(workItem);

            // this will make it "work on next" if it has no priority already
            var wip =
                await cn.FindWhereAsync <WorkItemPriority>(new { WorkItemId = workItem.Id }) ??
                new WorkItemPriority()
            {
                WorkItemId = workItem.Id, Value = 1
            };

            await Data.TrySaveAsync(wip);

            return(workItem.Number);
        }
Exemplo n.º 13
0
        public async Task <IActionResult> OnPostDoActionAsync(int ticketId, int objectId, int teamId, ActionItemType objectType)
        {
            var client = await _freshdeskClientFactory.CreateClientForOrganizationAsync(OrgId);

            var ticket = await client.GetTicketAsync(ticketId, withConversations : true);

            await FreshdeskCache.InitializeAsync(OrgName);

            using (var cn = Data.GetConnection())
            {
                if (objectId == 0)
                {
                    await IgnoreTicketInner(ticketId, teamId, cn);
                }
                else
                {
                    int number = await CreateWorkItemFromTicketAsync(cn, client, ticket, objectId, objectType);

                    var wit = new WorkItemTicket()
                    {
                        TicketId       = ticketId,
                        WorkItemNumber = number,
                        OrganizationId = OrgId,
                        TicketStatus   = ticket.Status,
                        TicketType     = WebhookRequestToWebhookConverter.TicketTypeFromString(ticket.Type),
                        CompanyId      = ticket.CompanyId,
                        CompanyName    = GetCompanyName(ticket.CompanyId ?? 0),
                        ContactId      = ticket.RequesterId,
                        ContactName    = GetContactName(ticket.RequesterId),
                        Subject        = ticket.Subject
                    };

                    await client.UpdateTicketWorkItemAsync(ticketId, number.ToString());

                    await Data.TrySaveAsync(cn, wit);
                }
            }

            return(Redirect($"Tickets/Index"));
        }
Exemplo n.º 14
0
        /// <summary>
        /// Removes a specific item
        /// </summary>
        /// <param name="itemType"> The type of the item </param>
        /// <param name="itemId"> The id of the item </param>
        /// <returns> The result </returns>
        public bool RemoveItem(ActionItemType itemType, short itemId)
        {
            ActionbarOperationResult result;

            return(this.RemoveItem(itemType, itemId, out result));
        }
Exemplo n.º 15
0
        /// <summary>
        /// Adds a(n) <see cref="ActionItem"/> at a specific slot.
        /// </summary>
        /// <param name="itemType"> The type of the item </param>
        /// <param name="itemId"> The id of the item </param>
        /// <param name="slot"> The slot to add to </param>
        /// <returns> The result </returns>
        public bool AddItemAt(ActionItemType itemType, short itemId, int slot)
        {
            ActionbarOperationResult result;

            return(this.AddItemAt(itemType, itemId, slot, out result));
        }