Ejemplo n.º 1
0
        /// <summary>
        /// Handles the Click event of the lbConfigure control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="EventArgs"/> instance containing the event data.</param>
        protected void lbConfigure_Click(object sender, EventArgs e)
        {
            SelectedAttributes = new List <int>();
            AttributeList.ForEach(a => SelectedAttributes.Add(a));

            ddlCategories.Items.Clear();

            int    attributeEntityTypeId = EntityTypeCache.Read("Rock.Model.Attribute").Id;
            string personEntityTypeId    = EntityTypeCache.Read("Rock.Model.Person").Id.ToString();

            foreach (var category in new CategoryService().Queryable()
                     .Where(c =>
                            c.EntityTypeId == attributeEntityTypeId &&
                            c.EntityTypeQualifierColumn == "EntityTypeId" &&
                            c.EntityTypeQualifierValue == personEntityTypeId))
            {
                if (category.IsAuthorized("View", CurrentPerson))
                {
                    ListItem li = new ListItem(category.Name, category.Id.ToString());
                    ddlCategories.Items.Add(li);
                }
            }

            BindAttributeSelection(ddlCategories.SelectedValueAsId() ?? 0);

            ShowDialog("KEYATTRIBUTES");
        }
        ////////////////////////////////////////////////////////////////////////////////////////////////////
        /// \fn private bool PerformQuestion(AttributeDictionary entry, List<int> messageIdxs)
        ///
        /// \brief Performs the question action.
        ///
        /// \par Description.
        ///      -  Ask the user if to perform an order change
        ///      -  There can be 3 answers
        ///         -#  Yes
        ///         -#  No
        ///         -#  Remove from the list
        ///
        /// \par Algorithm.
        ///
        /// \par Usage Notes.
        ///
        /// \author Ilanh
        /// \date 27/05/2018
        ///
        /// \param sourceProcess (int) - Source process.
        ///
        /// \param entry       (List&lt;int&gt;) - The permutations.
        /// \param messageIdxs (List&lt;int&gt;) - The message idxs.
        ///
        /// \return True if it succeeds, false if it fails.
        ///
        /// \param MessageQ (AttributeList) - The message q.
        ////////////////////////////////////////////////////////////////////////////////////////////////////

        private bool PerformQuestion(AttributeDictionary entry, List <int> messageIdxs)
        {
            MessageBoxElementData l1 = new MessageBoxElementData("Message from process : " + Element.ToString(), new Font {
                alignment = HorizontalAlignment.Center, fontWeight = FontWeights.Bold
            });
            MessageBoxElementData l2 = new MessageBoxElementData("In Previous running of the algorithm the order of the messages was change");
            MessageBoxElementData l3 = new MessageBoxElementData("The source process is :" + entry[Comps.SourceProcess].ToString());
            MessageBoxElementData l4 = new MessageBoxElementData("The source list is :", new Font {
                fontWeight = FontWeights.Bold
            });
            List <string> originalContent = new List <string>();
            AttributeList messagesQ       = entry[Comps.MessageQ];

            messagesQ.ForEach(a => originalContent.Add(((BaseMessage)a.Value).Description()));
            string originalString;
            string transforedString;

            PermutationString(entry[Comps.Permutations].AsList(), originalContent, out originalString, out transforedString);
            MessageBoxElementData l5 = new MessageBoxElementData(originalString);
            MessageBoxElementData l6 = new MessageBoxElementData("The transformed list is :", new Font {
                fontWeight = FontWeights.Bold
            });
            MessageBoxElementData l7 = new MessageBoxElementData(transforedString);
            MessageBoxElementData l8 = new MessageBoxElementData("Do you want to apply this change ?", new Font {
                fontWeight = FontWeights.Bold
            });
            MessageBoxElementData b1 = new MessageBoxElementData("Yes");
            MessageBoxElementData b2 = new MessageBoxElementData("No");
            MessageBoxElementData b3 = new MessageBoxElementData("Remove");
            string result            = MessageRouter.CustomizedMessageBox(new List <MessageBoxElementData> {
                l1, l2, l3, l4, l5, l6, l7, l8
            },
                                                                          "ChangeMessageOrder Message",
                                                                          new List <MessageBoxElementData> {
                b1, b2, b3
            },
                                                                          Icons.Question, true);
            string s = "";

            switch (result)
            {
            case "Yes":
                return(true);

            case "Remove":
                Remove((Attribute)entry.Parent);
                return(false);

            default:
                return(false);
            }
        }
Ejemplo n.º 3
0
        /**********************************************************************************************//**
        * Gets messages for other elements evaluation.
        *
        * \author  Ilan Hindy
        * \date    29/09/2016
        *
        * \param   processForEvaluation    The process for evaluation.
        *
        * \return  The messages for other elements evaluation.
        *  .
        **************************************************************************************************/

        private List <BaseMessage> GetMessagesForOtherElementsEvaluation(BaseProcess processForEvaluation)
        {
            AttributeList messageAttributes = new AttributeList();
            AttributeList messagesToOneProcessor;

            switch (messageHandlingForOtherElementOperation)
            {
            case MessageHandlingInOtherElementsOperation.FirstMessageForEachProcessor:
                messagesToOneProcessor = GetMessageQ(processForEvaluation);
                if (messagesToOneProcessor.Count > 0)
                {
                    messageAttributes.Add(messagesToOneProcessor[0]);
                }
                break;

            case MessageHandlingInOtherElementsOperation.AllMessagesForEachProcessor:
                messagesToOneProcessor = GetMessageQ(processForEvaluation);
                if (messagesToOneProcessor.Count > 0)
                {
                    messageAttributes = messagesToOneProcessor;
                }
                break;

            case MessageHandlingInOtherElementsOperation.OneFromFirstMessages:
                foreach (BaseProcess p in networkForOtherElementOperation.Processes)
                {
                    messagesToOneProcessor = GetMessageQ(processForEvaluation);
                    if (messagesToOneProcessor.Count > 0)
                    {
                        messageAttributes.Add(messagesToOneProcessor[0]);
                    }
                }
                break;

            case MessageHandlingInOtherElementsOperation.OneMessage:
                foreach (BaseProcess p in networkForOtherElementOperation.Processes)
                {
                    messagesToOneProcessor = GetMessageQ(processForEvaluation);
                    if (messagesToOneProcessor.Count > 0)
                    {
                        messageAttributes = messageAttributes.Concat(GetMessageQ(p)).ToList().ToAttributeList();
                    }
                }
                break;

            case MessageHandlingInOtherElementsOperation.AllMessages:
                foreach (BaseProcess p in networkForOtherElementOperation.Processes)
                {
                    messagesToOneProcessor = GetMessageQ(processForEvaluation);
                    if (messagesToOneProcessor.Count > 0)
                    {
                        messageAttributes = messageAttributes.Concat(GetMessageQ(p)).ToList().ToAttributeList();
                    }
                }
                break;
            }
            List <BaseMessage> result = new List <BaseMessage>();

            messageAttributes.ForEach(attribute => result.Add(attribute.Value));
            return(result);
        }