/// <summary>
        /// Wrap BotBuilder action into AdaptiveCard submit action.
        /// </summary>
        /// <param name="action"> Target bot builder action to be adapted.</param>
        /// <returns> The wrapped adaptive card submit action.</returns>
        public static AdaptiveSubmitAction ToAdaptiveCardAction(this CardAction action)
        {
            var adaptiveCardAction = new AdaptiveSubmitAction();

            adaptiveCardAction.RepresentAsBotBuilderAction(action);
            return(adaptiveCardAction);
        }
Пример #2
0
        public AdaptiveCard GetAdaptiveCardForNewJobPosting(string description = null)
        {
            var locations      = _locationService.GetAllLocations().GetAwaiter().GetResult();
            var hiringManagers = _recruiterService.GetAllHiringManagers().GetAwaiter().GetResult();

            var command = new
            {
                commandId = AppCommands.OpenNewTicket
            };

            var wrapAction = new CardAction
            {
                Title = "Create ticket",
                Value = command
            };

            var action = new AdaptiveSubmitAction
            {
                Data = command
            };

            action.RepresentAsBotBuilderAction(wrapAction);

            return(new AdaptiveCard
            {
                Version = "1.0",
                Body = new List <AdaptiveElement>
                {
                    new AdaptiveTextBlock("Enter in ticket description")
                    {
                        IsSubtle = true,
                        Wrap = true,
                        Size = AdaptiveTextSize.Small
                    },
                    new AdaptiveTextBlock("Description"),
                    new AdaptiveTextInput
                    {
                        Id = "description",
                        IsMultiline = true,
                        Placeholder = "E.g There is an application error.",
                        Value = description
                    }
                },
                Actions = new List <AdaptiveAction>
                {
                    action
                }
            });
        }
        public AdaptiveCard GetAdaptiveCardForNewJobPosting(string description = null)
        {
            var locations      = _locationService.GetAllLocations().GetAwaiter().GetResult();
            var hiringManagers = _recruiterService.GetAllHiringManagers().GetAwaiter().GetResult();

            var command = new
            {
                commandId = AppCommands.OpenNewPosition
            };

            var wrapAction = new CardAction
            {
                Title = "Create posting",
                Value = command
            };

            var action = new AdaptiveSubmitAction
            {
                Data = command
            };

            action.RepresentAsBotBuilderAction(wrapAction);

            return(new AdaptiveCard
            {
                Version = "1.0",
                Body = new List <AdaptiveElement>
                {
                    new AdaptiveTextBlock("Enter in basic information about this posting")
                    {
                        IsSubtle = true,
                        Wrap = true,
                        Size = AdaptiveTextSize.Small
                    },
                    new AdaptiveTextBlock("Title")
                    {
                        Wrap = true
                    },
                    new AdaptiveTextInput
                    {
                        Id = "jobTitle",
                        Placeholder = "E.g. Senior PM"
                    },
                    new AdaptiveColumnSet
                    {
                        Columns = new List <AdaptiveColumn>
                        {
                            new AdaptiveColumn
                            {
                                Width = "stretch",
                                Items = new List <AdaptiveElement>
                                {
                                    new AdaptiveTextBlock("Level")
                                    {
                                        Wrap = true
                                    },
                                    new AdaptiveChoiceSetInput
                                    {
                                        Id = "jobLevel",
                                        Style = AdaptiveChoiceInputStyle.Compact,
                                        Choices = Enumerable.Range(7, 4).Select(x =>
                                        {
                                            var s = x.ToString();
                                            return new AdaptiveChoice
                                            {
                                                Title = s,
                                                Value = s
                                            };
                                        }).ToList(),
                                        Value = "7"
                                    }
                                }
                            },

                            new AdaptiveColumn
                            {
                                Width = "stretch",
                                Items = new List <AdaptiveElement>
                                {
                                    new AdaptiveTextBlock("Post by")
                                    {
                                        Wrap = true
                                    },
                                    new AdaptiveDateInput
                                    {
                                        Id = "jobPostingDate",
                                        Placeholder = "Posting date",
                                        Value = DateTime.Now.ToShortDateString()
                                    }
                                }
                            }
                        }
                    },
                    new AdaptiveColumnSet
                    {
                        Columns = new List <AdaptiveColumn>
                        {
                            new AdaptiveColumn
                            {
                                Items = new List <AdaptiveElement>
                                {
                                    new AdaptiveTextBlock("Location"),
                                    new AdaptiveChoiceSetInput
                                    {
                                        Id = "jobLocation",
                                        Style = AdaptiveChoiceInputStyle.Compact,
                                        Choices = locations.Select(x => new AdaptiveChoice
                                        {
                                            Value = x.LocationId.ToString(),
                                            Title = x.City
                                        }).ToList(),
                                        Value = Convert.ToString(locations[0].LocationId)
                                    }
                                }
                            },
                            new AdaptiveColumn
                            {
                                Items = new List <AdaptiveElement>
                                {
                                    new AdaptiveTextBlock("Hiring manager"),
                                    new AdaptiveChoiceSetInput
                                    {
                                        Id = "jobHiringManager",
                                        Style = AdaptiveChoiceInputStyle.Compact,
                                        Choices = hiringManagers.Select(x => new AdaptiveChoice
                                        {
                                            Value = x.RecruiterId.ToString(),
                                            Title = x.Name
                                        }).ToList(),
                                        Value = Convert.ToString(hiringManagers[0].RecruiterId)
                                    }
                                }
                            }
                        }
                    },
                    new AdaptiveTextBlock("Description"),
                    new AdaptiveTextInput
                    {
                        Id = "jobDescription",
                        IsMultiline = true,
                        Placeholder = "E.g. Senior Product Manager in charge of driving complicated work and stuff.",
                        Value = description
                    }
                },
                Actions = new List <AdaptiveAction>
                {
                    action
                }
            });
        }
        public AdaptiveCard GetAdaptiveCardForInterviewRequest(Candidate candidate, DateTime interviewDate)
        {
            var interviewers = _recruiterService.GetAllInterviewers().GetAwaiter().GetResult();

            var command = new
            {
                commandId   = AppCommands.ScheduleInterview,
                candidateId = candidate.CandidateId
            };

            var wrapAction = new CardAction
            {
                Title = "Schedule",
                Value = command
            };

            var action = new AdaptiveSubmitAction
            {
                Data = command
            };

            action.RepresentAsBotBuilderAction(wrapAction);

            return(new AdaptiveCard
            {
                Version = "1.0",
                Body = new List <AdaptiveElement>
                {
                    new AdaptiveTextBlock
                    {
                        Text = $"Set interview date for {candidate.Name}",
                        Weight = AdaptiveTextWeight.Bolder,
                        Size = AdaptiveTextSize.Large
                    },
                    new AdaptiveColumnSet
                    {
                        Columns = new List <AdaptiveColumn>
                        {
                            new AdaptiveColumn
                            {
                                Width = AdaptiveColumnWidth.Auto,
                                Items = new List <AdaptiveElement>
                                {
                                    new AdaptiveImage
                                    {
                                        Url = new Uri(candidate.ProfilePicture),
                                        Size = AdaptiveImageSize.Medium,
                                        Style = AdaptiveImageStyle.Person
                                    }
                                }
                            },
                            new AdaptiveColumn
                            {
                                Width = AdaptiveColumnWidth.Stretch,
                                Items = new List <AdaptiveElement>
                                {
                                    new AdaptiveTextBlock
                                    {
                                        Text = $"Position: {candidate.Position.Title}",
                                        Wrap = true
                                    },
                                    new AdaptiveTextBlock
                                    {
                                        Text = $"Position ID: {candidate.Position.PositionExternalId}",
                                        Spacing = AdaptiveSpacing.None,
                                        Wrap = true,
                                        IsSubtle = true
                                    }
                                }
                            }
                        }
                    },
                    new AdaptiveChoiceSetInput
                    {
                        Id = "interviewerId",
                        Style = AdaptiveChoiceInputStyle.Compact,
                        Choices = interviewers.Select(x => new AdaptiveChoice
                        {
                            Value = x.RecruiterId.ToString(),
                            Title = x.Name
                        }).ToList(),
                        Value = Convert.ToString(interviewers[0].RecruiterId)
                    },
                    new AdaptiveDateInput
                    {
                        Id = "interviewDate", Placeholder = "Enter in a date for the interview", Value = interviewDate.ToShortDateString()
                    },
                    new AdaptiveChoiceSetInput
                    {
                        Id = "interviewType",
                        Style = AdaptiveChoiceInputStyle.Compact,
                        IsMultiSelect = false,
                        Choices = new List <AdaptiveChoice>
                        {
                            new AdaptiveChoice {
                                Title = "Phone screen", Value = "phoneScreen"
                            },
                            new AdaptiveChoice {
                                Title = "Full loop", Value = "fullLoop"
                            },
                            new AdaptiveChoice {
                                Title = "Follow-up", Value = "followUp"
                            }
                        },
                        Value = "phoneScreen"
                    },
                    new AdaptiveToggleInput {
                        Id = "isRemote", Title = "Remote interview"
                    }
                },
                Actions = new List <AdaptiveAction>
                {
                    action
                }
            });
        }
        public AdaptiveCard Convert(Candidate candidate, AdaptiveCard card, ResolutionContext context)
        {
            if (candidate is null)
            {
                return(null);
            }

            if (card is null)
            {
                card = new AdaptiveCard();
            }

            card.Version = "1.0";
            card.Body    = new List <AdaptiveElement>
            {
                new AdaptiveColumnSet
                {
                    Columns = new List <AdaptiveColumn>
                    {
                        new AdaptiveColumn
                        {
                            Width = "auto",
                            Items = new List <AdaptiveElement>
                            {
                                new AdaptiveImage(candidate.ProfilePicture)
                                {
                                    Size  = AdaptiveImageSize.Large,
                                    Style = AdaptiveImageStyle.Person
                                }
                            }
                        },
                        new AdaptiveColumn
                        {
                            Width = "stretch",
                            Items = new List <AdaptiveElement>
                            {
                                new AdaptiveTextBlock(candidate.Name)
                                {
                                    Weight = AdaptiveTextWeight.Bolder,
                                    Size   = AdaptiveTextSize.Medium
                                },
                                new AdaptiveTextBlock(candidate.Summary)
                                {
                                    Wrap = true
                                }
                            }
                        }
                    }
                },
                new AdaptiveFactSet
                {
                    Facts = new List <AdaptiveFact>
                    {
                        new AdaptiveFact("Current role:", candidate.CurrentRole),
                        new AdaptiveFact("Location:", candidate.Location.GetLocationString()),
                        new AdaptiveFact("Stage:", candidate.Stage.ToString()),
                        new AdaptiveFact("Position applied:", candidate.Position.Title),
                        new AdaptiveFact("Date applied:", candidate.DateApplied.ToLongDateString()),
                        new AdaptiveFact("Phone number:", candidate.Phone)
                    }
                }
            };

            card.Actions = new List <AdaptiveAction>();

            if (candidate.Stage != InterviewStageType.Offered)
            {
                card.Actions.Add(new AdaptiveShowCardAction
                {
                    Title = "Schedule an interview",
                    Card  = _templateService.GetAdaptiveCardForInterviewRequest(candidate, DateTime.Now.Date.AddDays(1.0))
                });
            }

            if (candidate.Comments.Any() || candidate.Interviews.Any())
            {
                var contentUrl = ConfigurationManager.AppSettings["BaseUrl"] + $"/StaticViews/CandidateFeedback.html?candidateId={candidate.CandidateId}";
                card.Actions.Add(new AdaptiveOpenUrlAction
                {
                    Title = "Open candidate feedback",
                    Url   = new Uri(string.Format(CommonConstants.TaskModuleUrlFormat, ConfigurationManager.AppSettings["TeamsAppId"],
                                                  contentUrl, "Feedback for " + candidate.Name,
                                                  ConfigurationManager.AppSettings["MicrosoftAppId"], "large", "large"))
                });
            }

            var leaveCommentCommand = new
            {
                commandId   = AppCommands.LeaveInternalComment,
                candidateId = candidate.CandidateId
            };

            var wrapAction = new CardAction
            {
                Title = "Submit",
                Value = leaveCommentCommand
            };

            var action = new AdaptiveSubmitAction
            {
                Data = leaveCommentCommand
            };

            action.RepresentAsBotBuilderAction(wrapAction);

            card.Actions.Add(new AdaptiveShowCardAction
            {
                Title = "Leave comment",
                Card  = new AdaptiveCard
                {
                    Body = new List <AdaptiveElement>
                    {
                        new AdaptiveTextInput
                        {
                            Id          = "comment",
                            Placeholder = "Leave an internal comment for this candidate",
                            IsMultiline = true
                        }
                    },
                    Actions = new List <AdaptiveAction>
                    {
                        action
                    }
                }
            });

            return(card);
        }