public override Activity Create(PredefinedActivity p)
        {
            Activity activity = new Activity();

            try
            {
                activity.Id        = Guid.NewGuid().ToString();
                activity.Type      = "message";
                activity.Text      = m_LocalizationManager.GetLocalized($"{{{{{p.message}}}}}");
                activity.Timestamp = DateTime.UtcNow;
                if (p.hasImage)
                {
                    string       path    = m_Domain + "/" + p.image;
                    MaterialCard matCard = new MaterialCard()
                    {
                        Materials = null, Image = new CardImage(path), Text = activity.Text
                    };
                    JContainer cont = JObject.FromObject(matCard);

                    activity.Attachments = new List <Attachment>()
                    {
                        new Attachment(AttachmentContentType.Material, null, cont)
                    };
                }

                if (p.suggestedActions != null && p.suggestedActions.Length > 0)
                {
                    List <CardAction> actions = new List <CardAction>();
                    for (int i = 0; i < p.suggestedActions.Length; i++)
                    {
                        SuggestedAction a = p.suggestedActions[i];
                        string          localizedMessage = m_LocalizationManager.GetLocalized($"{{{{{a.Message}}}}}");
                        actions.Add(new CardAction(a.Type, localizedMessage, null, localizedMessage));
                    }

                    activity.SuggestedActions = new SuggestedActions()
                    {
                        Actions = actions
                    };
                }
            }
            catch (System.Exception e)
            {
                Debug.LogException(e);
            }

            return(activity);
        }
        public override Activity Create()
        {
            Activity activity = new Activity();

            try
            {
                PredefinedActivity p = m_ActivityLibrary.Get(m_WorkflowService.currentStep);

                activity.Id        = Guid.NewGuid().ToString();
                activity.Type      = "message";
                activity.Text      = m_LocalizationManager.GetLocalized($"{{{{{p.message}}}}}");
                activity.Timestamp = DateTime.UtcNow;
                if (p.hasImage)
                {
                    string       path    = m_Domain + "/" + p.image;
                    MaterialCard matCard = new MaterialCard()
                    {
                        Materials = null, Image = new CardImage(path), Text = activity.Text
                    };
                    JContainer cont = JObject.FromObject(matCard);

                    activity.Attachments = new List <Attachment>()
                    {
                        new Attachment(AttachmentContentType.Material, null, cont)
                    };
                }
            }
            catch (System.Exception e)
            {
                Debug.LogException(e);
            }

            return(activity);
        }
示例#3
0
        private void OnWorkflowCompleted()
        {
            WorkflowData wf = m_WorkflowService.currentWorkflowData;

            try
            {
                if (m_WorkflowService.currentStep == wf.numTotalSteps)
                {
                    m_WorkflowCompleted = true;
                    m_Text.text         = m_LocalizationManager.GetLocalized("{{workflow_completed}}");
                }
            }
            catch (Exception e)
            {
                Debug.LogException(e);
            }
        }
        /// <inheritdoc />
        public void OnEvent(LocalizationChangedArgs args)
        {
            if (textMesh == null)
            {
                textMesh         = GetComponent <TextMeshProUGUI>();
                bufferedStringID = textMesh.text;
            }

            string localized = localizationManager.GetLocalized(bufferedStringID);

            if (localized == null)
            {
                return;
            }
            textMesh.text = localized;
            // recalculate button size if parent is an aci button
            AciButton button = textMesh.gameObject.GetComponentInParent <AciButton>();

            if (button == null)
            {
                return;
            }
            button.RecalculateLayout();
        }
示例#5
0
        public override Activity Create(MilestoneData milestone)
        {
            Activity activity = new Activity();

            try
            {
                activity.Id        = Guid.NewGuid().ToString();
                activity.Type      = "message";
                activity.Text      = m_LocalizationManager.GetLocalized($"{{{{milestone_achieved}}}}");
                activity.Timestamp = DateTime.UtcNow;


                activity.Attachments = new List <Attachment>()
                {
                    new Attachment(AttachmentContentType.MilestoneAchievement, null, milestone)
                };
            }
            catch (System.Exception e)
            {
                Debug.LogException(e);
            }

            return(activity);
        }