private static async Task SendCreateNewJobPostingMessage(IDialogContext context)
        {
            IMessageActivity reply = context.MakeMessage();

            reply.Attachments = new List <Attachment>();

            AdaptiveCard card       = CardHelper.CreateCardForNewJobPosting();
            Attachment   attachment = new Attachment()
            {
                ContentType = AdaptiveCard.ContentType,
                Content     = card
            };

            reply.Attachments.Add(attachment);

            await context.PostAsync(reply);
        }
        private static async Task SendCandidateDetailsMessage(IDialogContext context, Candidate c)
        {
            IMessageActivity reply = context.MakeMessage();

            reply.Attachments = new List <Attachment>();

            AdaptiveCard card       = CardHelper.CreateFullCardForCandidate(c);
            Attachment   attachment = new Attachment()
            {
                ContentType = AdaptiveCard.ContentType,
                Content     = card
            };

            reply.Attachments.Add(attachment);
            System.Diagnostics.Debug.WriteLine(card.ToJson());

            await context.PostAsync(reply);
        }
        private static async Task SendScheduleInterviewMessage(IDialogContext context, string name, string reqId)
        {
            OfficeDev.Talent.Management.InterviewRequest request = new OfficeDev.Talent.Management.InterviewRequest
            {
                Candidate     = new OfficeDev.Talent.Management.CandidatesDataController().GetCandidateByName(name),
                Date          = new DateTime(DateTime.Today.Year, DateTime.Today.Month, DateTime.Today.Day),
                PositionTitle = new OfficeDev.Talent.Management.OpenPositionsDataController().GetPositionForReqId(reqId).Title,
                Remote        = false,
                ReqId         = reqId
            };

            IMessageActivity reply = context.MakeMessage();

            reply.Attachments = new List <Attachment>();
            reply.Text        = $"Here's your request to schedule an interview:";

            O365ConnectorCard card = CardHelper.CreateCardForInterviewRequest(request);

            reply.Attachments.Add(card.ToAttachment());

            ConnectorClient  client = new ConnectorClient(new Uri(context.Activity.ServiceUrl));
            ResourceResponse resp   = await client.Conversations.ReplyToActivityAsync((Activity)reply);
        }
Beispiel #4
0
        public static async Task <ComposeExtensionResponse> CreateResponse(Activity activity)
        {
            ComposeExtensionResponse response = null;

            var     query = activity.GetComposeExtensionQueryData();
            JObject data  = activity.Value as JObject;

            //Check to make sure a query was actually made:
            if (query.CommandId == null || query.Parameters == null)
            {
                return(null);
            }
            else if (query.Parameters.Count > 0)
            {
                // query.Parameters has the parameters sent by client
                var results = new ComposeExtensionResult()
                {
                    AttachmentLayout = "list",
                    Type             = "result",
                    Attachments      = new List <ComposeExtensionAttachment>(),
                };

                if (query.CommandId == "searchPositions")
                {
                    OpenPositionsDataController controller = new OpenPositionsDataController();
                    IEnumerable <OpenPosition>  positions;

                    if (query.Parameters[0].Name == "initialRun")
                    {
                        // Default query => list all
                        positions = controller.ListOpenPositions(10);
                    }
                    else
                    {
                        // Basic search.
                        string title = query.Parameters[0].Value.ToString().ToLower();
                        positions = controller.ListOpenPositions(10).Where(x => x.Title.ToLower().Contains(title));
                    }

                    // Generate cards for the response.
                    foreach (OpenPosition pos in positions)
                    {
                        var card = CardHelper.CreateCardForPosition(pos, true);

                        var composeExtensionAttachment = card.ToAttachment().ToComposeExtensionAttachment();
                        results.Attachments.Add(composeExtensionAttachment);
                    }
                }
                else if (query.CommandId == "searchCandidates")
                {
                    string name = query.Parameters[0].Value.ToString();
                    CandidatesDataController controller = new CandidatesDataController();

                    foreach (Candidate c in controller.GetTopCandidates("ABCD1234"))
                    {
                        c.Name = c.Name.Split(' ')[0] + " " + CultureInfo.CurrentCulture.TextInfo.ToTitleCase(name);
                        var card = CardHelper.CreateSummaryCardForCandidate(c);

                        var composeExtensionAttachment = card.ToAttachment().ToComposeExtensionAttachment(CardHelper.CreatePreviewCardForCandidate(c).ToAttachment());
                        results.Attachments.Add(composeExtensionAttachment);
                    }
                }

                response = new ComposeExtensionResponse()
                {
                    ComposeExtension = results
                };
            }

            return(response);
        }
        public static async Task <ComposeExtensionResponse> CreateResponse(Activity activity)
        {
            ComposeExtensionResponse response = null;

            var     query = activity.GetComposeExtensionQueryData();
            JObject data  = activity.Value as JObject;

            //Check to make sure a query was actually made:
            if (query.CommandId == null || query.Parameters == null)
            {
                return(null);
            }
            else if (query.Parameters.Count > 0)
            {
                // query.Parameters has the parameters sent by client
                var results = new ComposeExtensionResult()
                {
                    AttachmentLayout = "list",
                    Type             = "result",
                    Attachments      = new List <ComposeExtensionAttachment>(),
                };


                if (query.CommandId == "searchInventory")
                {
                    InventoryDataController inventoryDataController = new InventoryDataController();
                    IEnumerable <Inventory> inventories;

                    if (query.Parameters[0].Name == "initialRun")
                    {
                        // Default query => list all
                        inventories = inventoryDataController.ListInventory(10);
                    }
                    else
                    {
                        // Basic search.
                        string title = query.Parameters[0].Value.ToString().ToLower();
                        inventories = inventoryDataController.ListInventory(10).Where(x => x.Title.ToLower().Contains(title));
                    }

                    // Generate cards for the response.
                    foreach (Inventory inv in inventories)
                    {
                        var card = CardHelper.CreateCardForInventory(inv, true);

                        var composeExtensionAttachment = card.ToAttachment().ToComposeExtensionAttachment();
                        results.Attachments.Add(composeExtensionAttachment);
                    }
                }

                else if (query.CommandId == "searchSupplier")
                {
                    SupplierDataController supplierDataController = new SupplierDataController();
                    IEnumerable <Supplier> suppliers;

                    if (query.Parameters[0].Name == "initialRun")
                    {
                        // Default query => list all
                        suppliers = supplierDataController.ListSupplier(10);
                    }
                    else
                    {
                        string title = query.Parameters[0].Value.ToString().ToLower();
                        suppliers = supplierDataController.ListSupplier(10).Where(x => x.Title.ToLower().Contains(title));
                    }

                    foreach (Supplier sup in suppliers)
                    {
                        var card = CardHelper.CreateCardForSupplier(sup, true);

                        var composeExtensionAttachment = card.ToAttachment().ToComposeExtensionAttachment();
                        results.Attachments.Add(composeExtensionAttachment);
                    }
                }

                response = new ComposeExtensionResponse()
                {
                    ComposeExtension = results
                };
            }

            return(response);
        }