public static Attachment GetResponseAttachment(string[] filepath, InitialSequentialCard data, out string cardJsonString)
        {
            var adaptiveCardJson          = File.ReadAllText(Path.Combine(filepath));
            AdaptiveCardTemplate template = new AdaptiveCardTemplate(adaptiveCardJson);
            var payloadData = new
            {
                incidentTitle  = data.action.data.IncidentTitle,
                assignedTo     = data.action.data.AssignedTo,
                category       = data.action.data.Category,
                subCategory    = data.action.data.SubCategory,
                createdBy      = data.action.data.CreatedBy,
                assignedToName = data.action.data.AssignedToName,
                userMRI        = data.action.data.UserMRI,
                incidentId     = data.action.data.IncidentId
            };

            cardJsonString = template.Expand(payloadData);
            var adaptiveCardAttachment = new Attachment()
            {
                ContentType = AdaptiveCard.ContentType,
                Content     = JsonConvert.DeserializeObject(cardJsonString),
            };

            return(adaptiveCardAttachment);
        }
Exemple #2
0
        // Get next card.
        private AdaptiveCardInvokeResponse GetNextActionCard(string[] path, InitialSequentialCard data)
        {
            var cardJson = File.ReadAllText(Path.Combine(path));
            AdaptiveCardTemplate template = new AdaptiveCardTemplate(cardJson);

            var payloadData = new
            {
                requestTitle       = data.action.data.RequestTitle,
                requestDescription = data.action.data.RequestDescription,
                assignedTo         = data.action.data.AssignedTo,
                createdBy          = data.action.data.CreatedBy,
                createdById        = data.action.data.CreatedById,
                assignedToName     = data.action.data.AssignedToName,
                userMRI            = data.action.data.UserMRI
            };

            //"Expand" the template -this generates the final Adaptive Card payload
            var cardJsonstring = template.Expand(payloadData);
            var card           = JObject.Parse(cardJsonstring);

            var adaptiveCardResponse = new AdaptiveCardInvokeResponse()
            {
                StatusCode = 200,
                Type       = "application/vnd.microsoft.card.adaptive",
                Value      = card
            };

            return(adaptiveCardResponse);
        }
Exemple #3
0
        // Get response attachment
        private Attachment GetResponseAttachment(string[] filepath, InitialSequentialCard data, out string cardJsonString)
        {
            var adaptiveCardJson          = File.ReadAllText(Path.Combine(filepath));
            AdaptiveCardTemplate template = new AdaptiveCardTemplate(adaptiveCardJson);

            var payloadData = new
            {
                requestTitle       = data.action.data.RequestTitle,
                requestDescription = data.action.data.RequestDescription,
                assignedTo         = data.action.data.AssignedTo,
                createdBy          = data.action.data.CreatedBy,
                assignedToName     = data.action.data.AssignedToName,
                userMRI            = data.action.data.UserMRI,
                userId             = data.action.data.UserId,
                createdById        = data.action.data.CreatedById,
            };

            //"Expand" the template -this generates the final Adaptive Card payload
            cardJsonString = template.Expand(payloadData);
            var adaptiveCardAttachment = new Attachment()
            {
                ContentType = "application/vnd.microsoft.card.adaptive",
                Content     = JsonConvert.DeserializeObject(cardJsonString),
            };

            return(adaptiveCardAttachment);
        }
Exemple #4
0
        public AdaptiveCardInvokeResponse GetNextActionCard(string[] path, InitialSequentialCard data, List <string> subCategory = null)
        {
            var cardJson = File.ReadAllText(Path.Combine(path));
            AdaptiveCardTemplate template = new AdaptiveCardTemplate(cardJson);
            string subCat1 = "";
            string subCat2 = "";

            if (subCategory != null)
            {
                subCat1 = subCategory[0];
                subCat2 = subCategory[1];
            }

            var payloadData = new
            {
                assignees      = memberDetails,
                incidentTitle  = data.action.data.IncidentTitle,
                assignedTo     = data.action.data.AssignedTo,
                category       = data.action.data.Category,
                subCategory1   = subCat1,
                subCategory2   = subCat2,
                subCategory    = data.action.data.SubCategory,
                createdBy      = data.action.data.CreatedBy,
                assignedToName = data.action.data.AssignedToName,
                userMRI        = data.action.data.UserMRI,
                incidentId     = data.action.data.IncidentId
            };

            //"Expand" the template -this generates the final Adaptive Card payload
            var cardJsonstring = template.Expand(payloadData);
            var card           = JsonConvert.DeserializeObject(cardJsonstring);

            var adaptiveCardResponse = new AdaptiveCardInvokeResponse()
            {
                StatusCode = 200,
                Type       = AdaptiveCard.ContentType,
                Value      = card
            };

            return(adaptiveCardResponse);
        }