コード例 #1
0
ファイル: Deck.cs プロジェクト: luuthevinh/yugioh-new-gen
        public void Shuffle()
        {
            Card[] _cards = new Card[ListCard.Count];
            bool[] _index = new bool[ListCard.Count];

            int temp = 0;

            foreach (Card item in ListCard)
            {
                while (true)
                {
                    temp = Rnd.Rand(0, ListCard.Count - 1);
                    if (_index[temp] == false)
                    {
                        break;
                    }
                }
                _cards[temp] = item;
                _index[temp] = true;
            }
            ListCard.Clear();
            foreach (Card c in _cards)
            {
                ListCard.AddLast(c);
            }
        }
コード例 #2
0
 static void OnRemovePact(ListCard cardToRemove)
 {
     if (cardToRemove.itemObj.type == ItemType.Pact)
     {
         S.I.deCtrl.TriggerAllArtifacts((FTrigger)Enum.Parse(typeof(FTrigger), "OnRemovePact"));
     }
 }
        /// <summary>
        /// Get list card for channel notification.
        /// </summary>
        /// <param name="applicationBasePath">Application base path to get the list card icon.</param>
        /// <param name="teamIdeaEntities">Team idea entities.</param>
        /// <param name="cardTitle">Notification list card title.</param>
        /// <returns>An attachment card for channel notification.</returns>
        public static Attachment GetNotificationListCard(
            string applicationBasePath,
            IEnumerable <IdeaEntity> teamIdeaEntities,
            string cardTitle)
        {
            teamIdeaEntities = teamIdeaEntities ?? throw new ArgumentNullException(nameof(teamIdeaEntities));

            ListCard card = new ListCard
            {
                Title = cardTitle,
                Items = new List <ListItem>(),
            };

            foreach (var teamIdeaEntity in teamIdeaEntities)
            {
                card.Items.Add(new ListItem
                {
                    Type     = "resultItem",
                    Title    = teamIdeaEntity.Title,
                    Subtitle = $"{teamIdeaEntity.CreatedByName} | {teamIdeaEntity.TotalVotes}",
                    Icon     = $"{applicationBasePath}/Artifacts/blogIcon.png",
                });
            }

            var attachment = new Attachment()
            {
                ContentType = "application/vnd.microsoft.teams.card.list",
                Content     = card,
            };

            return(attachment);
        }
コード例 #4
0
        static bool Prefix(ListCard __instance, bool useRemover)
        {
            var     card    = __instance;
            RunCtrl runCtrl = card.deCtrl.runCtrl;

            if (!CustomHell.IsHellEnabled(runCtrl, CustomHellPassEffect.TWO_REMOVES_FOR_PACT))
            {
                return(true);
            }

            if (!IsNormalPact(card) || !useRemover)
            {
                return(true);
            }

            DeckScreen deckScreen = GetDeckScreen(card);

            if (deckScreen.busy)
            {
                return(true);
            }

            // This is clunky, but so is using a transpiler.
            if (runCtrl.currentRun.removals < HELL_PRICE)
            {
                PlayForbiddenEffect(card, deckScreen);
                return(false);
            }

            runCtrl.currentRun.removals -= HELL_PRICE;
            deckScreen.UpdateRemoverCountText();
            PlayRemoveCardEffect(card);
            return(false);
        }
コード例 #5
0
        public static Attachment GetListCardAttachment(IEnumerable <Passenger> passengers, string title)
        {
            var listCard = new ListCard();

            listCard.content       = new Content();
            listCard.content.title = title;
            var list = new List <Item>();

            foreach (var passenger in passengers)
            {
                var item = new Item();
                item.icon     = BaseUrl + $"/public/resources/{GetPictureName(passenger.Name)}.jpg";
                item.type     = "resultItem";
                item.id       = passenger.PNR;
                item.title    = passenger.Name;
                item.subtitle = "Seat: " + passenger.Seat + (passenger.LoyaltyStatus == LoyaltyStatus.None ? "" : $" | {passenger.LoyaltyStatus.ToString()} member") + (string.IsNullOrEmpty(passenger.SpecialAssistance) ? "" : " | Special Assistance Required");
                item.tap      = new Tap()
                {
                    type  = "imBack",
                    title = "PNR",
                    value = "Show Passenger " + passenger.Name + " (" + passenger.PNR + ")"
                };
                list.Add(item);
            }

            listCard.content.items = list.ToArray();

            Attachment attachment = new Attachment();

            attachment.ContentType = listCard.contentType;
            attachment.Content     = listCard.content;
            return(attachment);
        }
コード例 #6
0
        public static Attachment GetListofFlights(IEnumerable <AirCraftInfo> aircraftDetails)
        {
            var listCard = new ListCard();

            listCard.content = new Content();
            var list = new List <Item>();

            foreach (var aircraft in aircraftDetails)
            {
                listCard.content.title = "The following aircrafts are available at " + aircraft.BaseLocation;

                var item = new Item();
                item.icon     = "https://fleetinfobot.azurewebsites.net/resources/Airline-Fleet-Bot-02.png";
                item.type     = "resultItem";
                item.id       = aircraft.FlightNumber;
                item.title    = "Aircraft ID: " + aircraft.AircraftId + "   |" + " Type: " + aircraft.FlightType;
                item.subtitle = "Model: " + aircraft.Model + "   |" + " Capacity: " + aircraft.Capacity;

                item.tap = new Tap()
                {
                    type  = "imBack",
                    title = "Aircraft",
                    value = "Show aircraft by Id " + " (" + aircraft.AircraftId + ")"
                };
                list.Add(item);
            }

            listCard.content.items = list.ToArray();

            Attachment attachment = new Attachment();

            attachment.ContentType = listCard.contentType;
            attachment.Content     = listCard.content;
            return(attachment);
        }
コード例 #7
0
        public static Attachment GetListCardAttachment(IEnumerable <Baggage> baggages)
        {
            var listCard = new ListCard();

            listCard.content = new Content();

            var list = new List <Item>();

            foreach (var baggage in baggages)
            {
                var item = new Item();
                item.icon     = baggage.Gender == "Male" ? "https://airlinebaggage.azurewebsites.net/resources/" + SplitName(baggage.Name) + ".jpg" : "https://airlinebaggage.azurewebsites.net/resources/" + SplitName(baggage.Name) + ".jpg";
                item.type     = "resultItem";
                item.id       = baggage.PNR;
                item.title    = baggage.Name;
                item.subtitle = "PNR: " + baggage.PNR + "   |" + " Ticket: " + baggage.TicketNo + "  |" + " Seat:  " + baggage.SeatNo;

                item.tap = new Tap()
                {
                    type  = "imBack",
                    title = "Aircraft",
                    value = "Show Baggage by Name " + baggage.Name + " (" + baggage.PNR + ")"
                };
                list.Add(item);
            }

            listCard.content.items = list.ToArray();

            Attachment attachment = new Attachment();

            attachment.ContentType = listCard.contentType;
            attachment.Content     = listCard.content;
            return(attachment);
        }
コード例 #8
0
        public async Task Send(IList <ProductDto> products)
        {
            var channel = _context.Activity.ChannelId;

            switch (channel)
            {
            case "facebook":
            {
                var facebookSender       = new SendFacebookTemplate(_context);
                var listFacebookTemplate = new ListCardFacebookTemplate(products).GetTemplate();
                await facebookSender.Send(listFacebookTemplate);

                break;
            }

            default:
            {
                var defaultSender = new SendCardToConversation(_context);
                var listHeroCard  = new ListCard(products);
                await defaultSender.SendCard(listHeroCard);

                break;
            }
            }
        }
        private async Task ShowRecentAnnouncements(IDialogContext context, Activity activity, TeamsChannelData channelData)
        {
            var tid     = channelData.Tenant.Id;
            var emailId = await GetUserEmailId(activity);

            // Fetch my announcements
            var myTenantAnnouncements = await Common.GetMyAnnouncements(emailId, tid);

            var listCard = new ListCard
            {
                content = new Content()
            };

            listCard.content.title = "Here are all your recent announcements:";;
            var list = new List <Item>();

            foreach (var announcement in myTenantAnnouncements.OrderByDescending(a => a.CreatedTime).Take(10))
            {
                if (announcement != null && (announcement.Status == Status.Sent))
                {
                    var item = new Item
                    {
                        icon     = announcement.Author.ProfilePhoto,
                        type     = "resultItem",
                        id       = announcement.Id,
                        title    = announcement.Title,
                        subtitle = "Author: " + announcement.Author?.Name
                                   + $" | Received Date: { (announcement.Status == Status.Sent ? announcement.CreatedTime.ToShortDateString() : announcement.Schedule.ScheduledTime.Date.ToShortDateString()) }",
                        tap = new Tap()
                        {
                            type  = ActionTypes.MessageBack,
                            title = "Id",
                            value = JsonConvert.SerializeObject(new AnnouncementActionDetails()
                            {
                                Id = announcement.Id, ActionType = Constants.ShowSentAnnouncement
                            })                                                                     //  "Show Announcement " + announcement.Title + " (" + announcement.Id + ")"
                        }
                    };
                    list.Add(item);
                }
            }

            if (list.Count > 0)
            {
                listCard.content.items = list.ToArray();
                Attachment attachment = new Attachment
                {
                    ContentType = listCard.contentType,
                    Content     = listCard.content
                };
                var reply = activity.CreateReply();
                reply.Attachments.Add(attachment);
                await context.PostAsync(reply);
            }
            else
            {
                await context.PostAsync("You don't seem to have any messages received recently. Hang on!");
            }
        }
コード例 #10
0
ファイル: Deck.cs プロジェクト: luuthevinh/yugioh-new-gen
        public virtual Card RemoveAt(int index)
        {
            var temp = ListCard.ElementAt <Card>(index);

            ListCard.Remove(temp);
            OnCardRemoved(new CardEventArgs(temp));
            return(temp);
        }
コード例 #11
0
ファイル: Deck.cs プロジェクト: luuthevinh/yugioh-new-gen
        public virtual LinkedListNode <Card> RemoveCard(Card _card)
        {
            LinkedListNode <Card> temp = ListCard.Find(_card);

            ListCard.Remove(temp);
            OnCardRemoved(new CardEventArgs(temp.Value));
            return(temp);
        }
        private async Task ShowAllDrafts(IDialogContext context, Activity activity, TeamsChannelData channelData)
        {
            var tenatInfo = await Cache.Tenants.GetItemAsync(channelData.Tenant.Id);

            var myTenantAnnouncements = new List <Campaign>();

            var listCard = new ListCard();

            listCard.content       = new Content();
            listCard.content.title = "Here are all draft and scheduled announcements:";;
            var list = new List <Item>();

            foreach (var announcementId in tenatInfo.Announcements)
            {
                var announcement = await Cache.Announcements.GetItemAsync(announcementId);

                if (announcement != null && (announcement.Status == Status.Draft || announcement.Status == Status.Scheduled))
                {
                    var item = new Item
                    {
                        icon     = announcement.Author.ProfilePhoto,
                        type     = "resultItem",
                        id       = announcement.Id,
                        title    = announcement.Title,
                        subtitle = "Author: " + announcement.Author?.Name
                                   + $" | Created Date: {announcement.CreatedTime.ToShortDateString()} | { (announcement.Status == Status.Scheduled ? "Scheduled" : "Draft") }",
                        tap = new Tap()
                        {
                            type  = ActionTypes.MessageBack,
                            title = "Id",
                            value = JsonConvert.SerializeObject(new AnnouncementActionDetails()
                            {
                                Id = announcement.Id, ActionType = Constants.ShowAnnouncement
                            })                                                                 //  "Show Announcement " + announcement.Title + " (" + announcement.Id + ")"
                        }
                    };
                    list.Add(item);
                }
            }

            if (list.Count > 0)
            {
                listCard.content.items = list.ToArray();
                var attachment = new Attachment
                {
                    ContentType = listCard.contentType,
                    Content     = listCard.content
                };
                var reply = activity.CreateReply();
                reply.Attachments.Add(attachment);
                await context.PostAsync(reply);
            }
            else
            {
                await context.PostAsync("Thre are no drafts. Please go ahead and create new announcement.");
            }
        }
コード例 #13
0
        public ListCard ListaPromo(int?p, double ULat, double ULon, string tipo = "Local", string q = "")
        {
            ListCard         lc        = new ListCard();
            List <PromoCard> listPromo = new List <PromoCard>();
            int registroPorPagina      = 8;
            int page    = p ?? 1;
            int skipReg = 0;

            if (page > 1)
            {
                skipReg = (page - 1) * registroPorPagina;
            }

            var query = db.Promocaos.Where(x => x.Ativo == true && x.TipoAnuncio == tipo && x.DataFim >= DateTime.Now);

            //q => keyword
            if (!string.IsNullOrEmpty(q))
            {
                query = query.Where(x => x.Titulo.Contains(q) || x.Descricao.Contains(q) || x.Empresa.Nome.Contains(q) || x.Empresa.Descricao.Contains(q));
            }

            foreach (var promo in query)
            {
                PromoCard pc = new PromoCard();
                pc.Distancia = pc.Distance(ULat, ULon, Convert.ToDouble(promo.Empresa.Latitude), Convert.ToDouble(promo.Empresa.Longitude));

                pc.Titulo           = promo.Titulo;
                pc.TipoAnuncio      = promo.TipoAnuncio;
                pc.PromoId          = promo.PromocaoId;
                pc.PrecoNormal      = promo.PrecoNormal;
                pc.PrecoComDesconto = promo.PrecoComDesconto;
                pc.TipoDesconto     = promo.TipoDesconto;
                pc.DescDesconto     = promo.DescDesconto;
                pc.Cidade           = promo.Empresa.Cidade;
                pc.EmpresaNome      = promo.Empresa.Nome;
                pc.Bairro           = promo.Empresa.Bairro;
                pc.Endereco         = promo.Empresa.Logradouro + ", " + promo.Empresa.Numero + " " + promo.Empresa.Complemento;
                pc.Desconto         = promo.Desconto;
                pc.DataFim          = promo.DataFim.Value.ToString("dd/MM/yyyy");
                pc.Site             = promo.LinkPromocao;
                listPromo.Add(pc);
            }
            lc.Registros  = listPromo.Count;
            lc.PromoCards = listPromo.OrderBy(x => x.Distancia).Skip(skipReg).Take(registroPorPagina).ToList();

            if (lc.Registros > registroPorPagina)
            {
                Decimal pags = Convert.ToDecimal(lc.Registros) / Convert.ToDecimal(registroPorPagina);
                //decimal d = pags;
                lc.Paginas = Math.Ceiling(pags);
            }
            else
            {
                lc.Paginas = 1;
            }
            return(lc);
        }
コード例 #14
0
        //[Obsolete]
        public static Attachment UpcomingEventsTraining()
        {
            EandTModel ETlist = new EandTModel();

            ETlist = Helper.GetDataHelper.GetEandT();

            var card = new ListCard();

            card.content = new Content();
            var list = new List <Item>();

            card.content.title = "Upcoming events and training for you";


            DateTime CurrDate = new DateTime(2019, 6, 1);


            for (int i = 0; i < ETlist.EventsAndtraining.Count(); i++)
            {
                if (!ETlist.EventsAndtraining[i].UserAdded)
                {
                    continue;
                }
                else
                {
                    DateTime D = DateTime.ParseExact(ETlist.EventsAndtraining[i].ETStartDate, "MM-dd-yyyy",
                                                     System.Globalization.CultureInfo.InvariantCulture);

                    if (D <= CurrDate.AddDays(7))
                    {
                        var item = new Item();
                        item.icon     = "https://fleetinfobot.azurewebsites.net/resources/Airline-Fleet-Bot-02.png";
                        item.id       = i.ToString();
                        item.subtitle = ETlist.EventsAndtraining[i].ETStartDate + " to " + ETlist.EventsAndtraining[i].ETEndDate;

                        item.type  = "resultItem";
                        item.title = ETlist.EventsAndtraining[i].ETTitle;

                        item.tap = new Tap()
                        {
                            type  = "imBack",
                            title = "titleitem",
                            value = "Event and training item" + i
                        };

                        list.Add(item);
                    }
                }
            }
            card.content.items = list.ToArray();
            Attachment attachment = new Attachment();

            attachment.ContentType = card.contentType;
            attachment.Content     = card.content;
            return(attachment);
        }
コード例 #15
0
        //returns a news ListCard containing specific number of messages
        public static Attachment getNewsCard()
        {
            var card = new ListCard();

            card.content = new Content();
            var list = new List <Item>();

            card.content.title = "Top stories for you";
            NewsModel newsL         = Helper.GetDataHelper.GetNews();
            var       SuggestedNews = newsL.news.Where(w => w.LatestOrTrendingFlag.Equals("Trending"));
            var       LatestNews    = newsL.news.Where(w => w.LatestOrTrendingFlag.Equals("Latest"));
            //int ReqDescriptionLength = 85;

            //MaxNewsCount has total number of news to display
            int MaxNewsCount = 3;

            // if (MaxNewsCount > SuggestedNews.Count())
            MaxNewsCount = SuggestedNews.Count();

            for (int i = 0; i < MaxNewsCount; i++)
            {
                var    news     = SuggestedNews.ElementAt(i);
                string subtitle = news.DetailedNews;
                var    item     = new Item();
                item.title = news.NewsTitle;
                item.icon  = news.NewsThumbnailUrl;
                item.id    = news.NewsID;

                //if (subtitle.Length > ReqDescriptionLength)
                //    item.subtitle = subtitle.Substring(0, ReqDescriptionLength);
                //else
                item.subtitle = subtitle;

                item.type = "resultItem";

                //item.NewBy = "Vedant";      //doesn't display in frontend

                item.tap = new Tap()
                {
                    type  = "messageBack",
                    title = "title",
                    text  = news.NewsID
                };

                list.Add(item);
            }
            card.content.items = list.ToArray();

            Attachment attachment = new Attachment();

            attachment.ContentType = card.contentType;

            attachment.Content = card.content;

            return(attachment);
        }
コード例 #16
0
ファイル: Deck.cs プロジェクト: luuthevinh/yugioh-new-gen
        public virtual LinkedListNode <Card> RemoveTop()
        {
            if (ListCard.Count == 0)
            {
                return(null);
            }
            LinkedListNode <Card> temp = ListCard.Last;

            ListCard.Remove(temp);
            OnCardRemoved(new CardEventArgs(temp.Value));
            return(temp);
        }
コード例 #17
0
        public static Attachment PrepareCardWithAttachment(ExpenseReport expenseReport, Employee employee, bool isManagerCard = false, bool isAdminCard = false)
        {
            var card = new ListCard();

            card.content = new Content();
            var list = new List <Item>();

            card.content.title = "Uploaded Expenses";
            foreach (var exp in expenseReport.ExpenseItems)
            {
                Item item = new Item();
                item.title    = exp.ReportName;
                item.subtitle = "Total Amount: Rs." + exp.TotalAmount;
                item.type     = "resultItem";
                item.icon     = ConfigurationManager.AppSettings["BaseUri"] + "/Images/Expense.PNG";
                var url = "pendingdates";
                //item.tap = new Tap()
                //{
                //    type = "invoke",
                //    title = item.id,
                //    value = "{ \"type\": \"task/fetch\", \"data\": \"" + url + "\"}"
                //};
                list.Add(item);
            }
            if (isManagerCard)
            {
                var approve = new ListButton()
                {
                    title = "Approve", type = "messageBack", value = "{ \"type\": \"ApproveReport\", \"reportId\": \"" + expenseReport.Id + "\", \"employeeId\": \"" + employee.EmailId + "\"}"
                };
                var reject = new ListButton()
                {
                    title = "Reject", type = "messageBack", value = "{ \"type\": \"RejectReport\", \"reportId\": \"" + expenseReport.Id + "\", \"employeeId\": \"" + employee.EmailId + "\"}"
                };
                var buttonLists = new List <ListButton>()
                {
                    approve, reject
                };
                card.content.buttons = buttonLists.ToArray();
                card.content.title   = employee.DisplayName + " has uploaded " + expenseReport.ExpenseItems.Count() + " bills";
            }
            if (isAdminCard)
            {
                card.content.title = employee.DisplayName + " has uploaded " + expenseReport.ExpenseItems.Count() + " bills. Approved by manager";
            }

            card.content.items = list.ToArray();
            Attachment attachment = new Attachment();

            attachment.ContentType = card.contentType;
            attachment.Content     = card.content;
            return(attachment);
        }
コード例 #18
0
        public Page Get(int id)
        {
            var page = new Page
            {
                Id          = id,
                Title       = "Новая страница",
                Description = "Описание новой страницы"
            };
            var text1 = new TextCard
            {
                Id       = 1,
                Text     = new Text("Текст номер один"),
                TextType = TextType.Header1
            };
            var text2 = new TextCard
            {
                Id       = 2,
                Text     = new Text("Новый абзац текста без переноса строки aasdasd asdasd"),
                TextType = TextType.Paragraph
            };

            text2.Text.AddEntity(EntityType.Bold, 0, 11);
            text2.Text.AddEntity(EntityType.Italic, 11, 8);
            text2.Text.AddEntity(EntityType.Strikethrough, 13, 5);
            text2.Text.AddEntity(EntityType.Underline, 18, 7);
            var listText = new Text("очередной пункт списка");

            listText.AddEntity(EntityType.Bold, 0, 11);
            listText.AddEntity(EntityType.Italic, 11, 8);
            var list1 = new ListCard
            {
                Id    = 3,
                Items = new List <Text> {
                    listText, listText, listText, listText
                },
                ListType = ListType.BulletedList
            };
            var list2 = new ListCard
            {
                Id    = 3,
                Items = new List <Text> {
                    listText, listText
                },
                ListType = ListType.OrderedList
            };

            page.Cards.Add(text1);
            page.Cards.Add(text2);
            page.Cards.Add(list1);
            page.Cards.Add(list2);
            return(page);
        }
        /// <summary>
        /// Get list card for channel notification.
        /// </summary>
        /// <param name="teamPosts">Team post list object.</param>
        /// <param name="localizer">The current cultures' string localizer.</param>
        /// <param name="cardTitle">Notification list card title.</param>
        /// <param name="cardPostTypePair">Post type of card.</param>
        /// <param name="applicationManifestId">Application manifest id.</param>
        /// <param name="discoverTabEntityId">Discover tab entity id for personal Bot.</param>
        /// <param name="applicationBasePath">Application bath path.</param>
        /// <returns>An attachment card for channel notification.</returns>
        public static Attachment GetNotificationListCard(
            IEnumerable <PostEntity> teamPosts,
            IStringLocalizer <Strings> localizer,
            string cardTitle,
            Dictionary <int, string> cardPostTypePair,
            string applicationManifestId,
            string discoverTabEntityId,
            string applicationBasePath)
        {
            teamPosts = teamPosts ?? throw new ArgumentNullException(nameof(teamPosts));

            ListCard card = new ListCard
            {
                Title   = cardTitle,
                Items   = new List <ListItem>(),
                Buttons = new List <ButtonAction>(),
            };

            var voteIcon = $"<img src='{applicationBasePath}/Artifacts/voteIconME.png' alt='{localizer.GetString("VoteImageAltText")}' width='15' height='16'";

            foreach (var teamPostEntity in teamPosts)
            {
                string imagePath = string.Empty;
                cardPostTypePair?.TryGetValue(Convert.ToInt32(teamPostEntity.Type, CultureInfo.InvariantCulture), out imagePath);

                card.Items.Add(new ListItem
                {
                    Type     = "resultItem",
                    Id       = Guid.NewGuid().ToString(),
                    Title    = teamPostEntity.Title,
                    Subtitle = $"{teamPostEntity.CreatedByName} | {teamPostEntity.TotalVotes} {voteIcon}",
                    Icon     = imagePath,
                });
            }

            var buttonAction = new ButtonAction()
            {
                Title = localizer.GetString("NotificationListCardViewMoreButtonText"),
                Type  = "openUrl",
                Value = $"https://teams.microsoft.com/l/entity/{applicationManifestId}/{discoverTabEntityId}",
            };

            card.Buttons.Add(buttonAction);

            var attachment = new Attachment()
            {
                ContentType = "application/vnd.microsoft.teams.card.list",
                Content     = card,
            };

            return(attachment);
        }
コード例 #20
0
 public override void Update(GameTime _gameTime)
 {
     //base.Update(_gameTime);
     this.isListCardChanged = false;
     foreach (var item in ListCard.OrderBy(card => card.Sprite.Depth))
     {
         item.Update(_gameTime);
         if (this.isListCardChanged == true)
         {
             break;
         }
     }
 }
        /// <summary>
        /// Get list card for pending review introductions.
        /// </summary>
        /// <param name="introductionEntities">List of introduction entities.</param>
        /// <param name="userGraphAccessToken">User access token.</param>
        /// <returns>Review introduction list card attachment.</returns>
        public async Task <Attachment> GetReviewIntroductionListCardAsync(
            IEnumerable <IntroductionEntity> introductionEntities,
            string userGraphAccessToken)
        {
            introductionEntities = introductionEntities ?? throw new ArgumentNullException(nameof(introductionEntities));

            ListCard card = new ListCard
            {
                Title = this.localizer.GetString("NewEmployeeTitleText"),
                Items = new List <ListCardItem>(),
            };

            var userProfileDetails = await this.graphApiHelper.GetUserProfileAsync(userGraphAccessToken, introductionEntities.Select(row => row.NewHireAadObjectId).ToList());

            foreach (var introduction in introductionEntities)
            {
                var userProfileDetail = userProfileDetails.Where(row => row.Id == introduction.NewHireAadObjectId).FirstOrDefault();

                // get user profile image url from user storage.
                var userDetails = await this.userStorageProvider.GetUserDetailAsync(introduction.NewHireAadObjectId);

                if (userDetails != null)
                {
                    introduction.UserProfileImageUrl = userDetails.UserProfileImageUrl;
                }

                card.Items.Add(new ListCardItem
                {
                    Type     = ListCardItemTypeText,
                    Title    = introduction.NewHireName,
                    Subtitle = string.IsNullOrEmpty(userProfileDetail?.JobTitle) ? string.Empty : userProfileDetail.JobTitle,
                    Icon     = string.IsNullOrEmpty(introduction.UserProfileImageUrl) ? $"{this.botOptions.Value.AppBaseUri}/Artifacts/peopleAvatar.png" : introduction.UserProfileImageUrl,
                    Tap      = new ListCardItemEvent
                    {
                        Type  = CardConstants.MessageBack,
                        Value = $"{this.localizer.GetString("ReviewIntroductionCommandText")}:{introduction.NewHireName}",
                    },
                    Id = introduction.NewHireAadObjectId,
                });
            }

            return(new Attachment
            {
                ContentType = CardConstants.ListCardContentType,
                Content = card,
            });
        }
コード例 #22
0
        private async Task <DialogTurnResult> SearchAsync(WaterfallStepContext stepContext, CancellationToken cancellationToken)
        {
            var text = stepContext.Context.Activity.RemoveRecipientMention();

            if (!string.IsNullOrEmpty(text))
            {
                var matched  = MainDialog.SearchKeyWords.FirstOrDefault(k => text.StartsWith(k));
                var keywords = text.Replace(matched, "").Trim();
                var service  = new FileInfosService(_configuration);
                var result   = service.SearchAsync(keywords);
                var notEmpty = false;
                var items    = new List <Item>();
                await foreach (var item in result)
                {
                    if (!notEmpty)
                    {
                        notEmpty = true;
                    }
                    items.Add(new Item
                    {
                        title    = $"{item.name}({Math.Round(item.size / 1024f, 0)} KB)",
                        subtitle = item.fullname,
                        type     = ItemTypes.ResultItem,
                        tap      = new CardAction
                        {
                            Type  = ActionTypes.OpenUrl,
                            Value = item.fullname
                        }
                    });
                }

                if (notEmpty)
                {
                    var card    = new ListCard("为您查找到以下文件", items).ToAttachment();
                    var message = Activity.CreateMessageActivity();
                    message.Attachments.Add(card);
                    await stepContext.Context.SendActivityAsync(message);
                }
                else
                {
                    await stepContext.Context.SendActivityAsync(MessageFactory.Text($"没有找到与“{keywords}”相关的文件。"));
                }
            }

            return(await stepContext.EndDialogAsync(null, cancellationToken));
        }
コード例 #23
0
        public static Attachment GetListofFlights(IEnumerable <FlightInfo> flights, DateTime JourneyDate)
        {
            var listCard = new ListCard();

            listCard.content = new Content();
            //listCard.content.title = "The following flights are avilibile on " + JourneyDate.ToShortDateString();
            var list  = new List <Item>();
            int count = 0;

            foreach (var flight in flights)
            {
                DateTime journeydate = JourneyDate.Date;//.AddDays(1);
                DateTime dabasedate  = (flight.JourneyDate.Date);
                if (journeydate.Date == dabasedate.Date)
                {
                    listCard.content.title = "The following flights are available on " + flight.JourneyDate.ToShortDateString();
                    count = 1;
                    var item = new Item();
                    item.icon     = "https://flightinfobot.azurewebsites.net/resources/Airline-Flight-Bot-03.png";
                    item.type     = "resultItem";
                    item.id       = flight.FlightNumber;
                    item.title    = "Flight: " + flight.FlightNumber + "   |" + " Departure: " + flight.Departure.ToShortTimeString() + "   |" + " Arrival: " + flight.Arrival.ToShortTimeString();
                    item.subtitle = "From: " + flight.FromCity + "   |" + " To: " + flight.ToCity + "  |" + " Seats:  " + flight.SeatCount;

                    item.tap = new Tap()
                    {
                        type  = "imBack",
                        title = "FlightNumber",
                        value = "Show details of flight" + " (" + flight.FlightNumber + ")"
                    };
                    list.Add(item);
                }
            }
            if (count == 0)
            {
                listCard.content.title = "Flights not available for selected date. Please check some other date";
            }
            listCard.content.items = list.ToArray();

            Attachment attachment = new Attachment();

            attachment.ContentType = listCard.contentType;
            attachment.Content     = listCard.content;
            return(attachment);
        }
        /// <summary>
        /// Prepare the attachments to be displayed in the list card.
        /// </summary>
        /// <param name="list">Items to show on the list card.</param>
        /// <param name="message">message to display on the header of the list card.</param>
        /// <returns>An Attachment</returns>
        public Attachment GetAttachment(List <Item> list, string title, string message, List <Button> btns)
        {
            var listCard = new ListCard()
            {
                content = new Content()
                {
                    title   = title,
                    items   = list.ToArray(),
                    buttons = btns.ToArray(),
                },
            };

            Attachment attachment = new Attachment();

            attachment.ContentType = listCard.contentType;
            attachment.Content     = listCard.content;
            return(attachment);
        }
コード例 #25
0
        //Returns the policies ListCard having Policies for every department.
        public static Attachment GetPoliciesCard()
        {
            var card = new ListCard();

            card.content = new Content();
            var list = new List <Item>();

            card.content.title = "Please select a department to view policies";

            for (int i = 0; i < 5; i++)
            {
                var item = new Item();
                item.icon = "https://fleetinfobot.azurewebsites.net/resources/Airline-Fleet-Bot-02.png";
                item.id   = i.ToString();


                item.type  = "resultItem";
                item.title = "Department " + i;

                item.tap = new Tap()
                {
                    type  = "messageBack",
                    title = "title",
                    text  = "department" + i
                };

                list.Add(item);
            }
            card.content.items = list.ToArray();

            Attachment attachment = new Attachment();

            attachment.ContentType = card.contentType;

            attachment.Content = card.content;

            return(attachment);
        }
コード例 #26
0
        public ListCard ListaPromoByUsuario(Guid uid)
        {
            ListCard         lc        = new ListCard();
            List <PromoCard> listPromo = new List <PromoCard>();


            var query = db.Promocaos.Where(x => x.Empresa.UsuarioEmpresas.Where(y => y.UsuarioId == uid).Any() == true);

            query = query.Where(x => x.Ativo != null);

            foreach (var promo in query)
            {
                PromoCard pc = new PromoCard();
                pc.Distancia = 0;//pc.Distance(ULat, ULon, Convert.ToDouble(promo.Empresa.Latitude), Convert.ToDouble(promo.Empresa.Longitude));

                pc.Titulo           = promo.Titulo;
                pc.TipoAnuncio      = promo.TipoAnuncio;
                pc.PromoId          = promo.PromocaoId;
                pc.PrecoNormal      = promo.PrecoNormal;
                pc.PrecoComDesconto = promo.PrecoComDesconto;
                pc.TipoDesconto     = promo.TipoDesconto;
                pc.DescDesconto     = promo.DescDesconto;
                pc.EmpresaNome      = promo.Empresa.Nome;
                pc.Bairro           = promo.Empresa.Bairro;
                pc.Endereco         = promo.Empresa.Logradouro + ", " + promo.Empresa.Numero + " " + promo.Empresa.Complemento;
                pc.Desconto         = promo.Desconto;
                pc.DataFim          = promo.DataFim.Value.ToString("dd/MM/yyyy");
                pc.Site             = promo.LinkPromocao;
                pc.Ativo            = promo.Ativo;
                listPromo.Add(pc);
            }
            lc.Registros  = listPromo.Count;
            lc.PromoCards = listPromo.OrderBy(x => x.EmpresaNome).ToList();


            return(lc);
        }
コード例 #27
0
        /// <summary>
        /// Get list card attachment having list of favorite rooms along with buttons to manage favorites, book meeting for other rooms and refresh list.
        /// </summary>
        /// <param name="rooms">Rooms schedule response object.</param>
        /// <param name="startUTCDateTime">Start date time of meeting.</param>
        /// <param name="endUTCDateTime">End date time of meeting.</param>
        /// <param name="timeZone">User time zone.</param>
        /// <param name="activityReferenceId">Unique GUID related to activity Id from ActivityEntities table.</param>
        /// <returns>List card attachment having favorite rooms of user.</returns>
        public static Attachment GetFavoriteRoomsListAttachment(RoomScheduleResponse rooms, DateTime startUTCDateTime, DateTime endUTCDateTime, string timeZone, string activityReferenceId = null)
        {
            ListCard card = new ListCard
            {
                Title   = Strings.RoomAvailability,
                Items   = new List <ListItem>(),
                Buttons = new List <CardAction>(),
            };

            // For first run, user configuration will be null.
            if (timeZone != null)
            {
                var startTime = TimeZoneInfo.ConvertTimeFromUtc(startUTCDateTime, TimeZoneInfo.FindSystemTimeZoneById(timeZone));
                var endTime   = TimeZoneInfo.ConvertTimeFromUtc(endUTCDateTime, TimeZoneInfo.FindSystemTimeZoneById(timeZone));
                card.Title = string.Format(CultureInfo.CurrentCulture, "{0} | {1} - {2}", Strings.RoomAvailability, startTime.ToString("t", CultureInfo.CurrentCulture), endTime.ToString("t", CultureInfo.CurrentCulture));
            }

            ListItem room = new ListItem();
            Meeting  meeting;

            if (rooms.Schedules.Count > 0)
            {
                foreach (var item in rooms.Schedules)
                {
                    var availability      = item.ScheduleItems.Count > 0 ? Strings.Unavailable : Strings.Available;
                    var availabilityColor = item.ScheduleItems.Count > 0 ? RedColorCode : GreenColorCode;
                    var subtitle          = string.Format(CultureInfo.CurrentCulture, "{0}&nbsp;|&nbsp;<b><font color='{1}'>{2}</font></b>", item.BuildingName, availabilityColor, availability);

                    meeting = new Meeting
                    {
                        EndDateTime   = DateTime.SpecifyKind(endUTCDateTime, DateTimeKind.Utc).ToString("o"),
                        RoomEmail     = item.ScheduleId,
                        RoomName      = item.RoomName,
                        StartDateTime = DateTime.SpecifyKind(startUTCDateTime, DateTimeKind.Utc).ToString("o"),
                        BuildingName  = item.BuildingName,
                        Status        = availability,
                        Text          = BotCommands.CreateMeeting,
                    };

                    card.Items.Add(new ListItem
                    {
                        Id       = item.ScheduleId,
                        Title    = item.RoomName,
                        Subtitle = subtitle,
                        Type     = "person",
                        Tap      = new CardAction {
                            Type = ActionTypes.MessageBack, DisplayText = string.Empty, Title = BotCommands.CreateMeeting, Value = JsonConvert.SerializeObject(meeting)
                        },
                    });
                }
            }
            else
            {
                room = new ListItem
                {
                    Title = Strings.NoFavoriteRooms,
                    Type  = "section",
                };
            }

            card.Items.Add(room);
            CardAction addFavoriteButton = new TaskModuleAction(Strings.ManageFavorites, new { data = JsonConvert.SerializeObject(new AdaptiveTaskModuleCardAction {
                    Text = BotCommands.ShowFavoriteTaskModule, ActivityReferenceId = activityReferenceId
                }) });

            card.Buttons.Add(addFavoriteButton);

            CardAction otherRoomButton = new TaskModuleAction(Strings.OtherRooms, new { data = JsonConvert.SerializeObject(new AdaptiveTaskModuleCardAction {
                    Text = BotCommands.ShowOtherRoomsTaskModule, ActivityReferenceId = activityReferenceId
                }) });

            card.Buttons.Add(otherRoomButton);

            if (rooms?.Schedules.Count > 0)
            {
                CardAction refreshListButton = new CardAction
                {
                    Title       = Strings.Refresh,
                    Type        = ActionTypes.MessageBack,
                    Text        = BotCommands.RefreshList,
                    DisplayText = string.Empty,
                    Value       = JsonConvert.SerializeObject(new AdaptiveTaskModuleCardAction {
                        Text = BotCommands.RefreshList, ActivityReferenceId = activityReferenceId
                    }),
                };

                card.Buttons.Add(refreshListButton);
            }

            var attachment = new Attachment()
            {
                ContentType = "application/vnd.microsoft.teams.card.list",
                Content     = card,
            };

            return(attachment);
        }
コード例 #28
0
        /// <summary>
        /// Get list card for complete learning plan.
        /// </summary>
        /// <param name="learningPlans">Learning plans list object.</param>
        /// <param name="localizer">The current culture's string localizer.</param>
        /// <param name="cardTitle">Learning plan list card title.</param>
        /// <param name="applicationManifestId">Application manifest id.</param>
        /// <param name="applicationBasePath">Application base path.</param>
        /// <returns>An attachment card for learning plan.</returns>
        public static Attachment GetLearningPlanListCard(
            IEnumerable <LearningPlanListItemField> learningPlans,
            IStringLocalizer <Strings> localizer,
            string cardTitle,
            string applicationManifestId,
            string applicationBasePath)
        {
            learningPlans = learningPlans ?? throw new ArgumentNullException(nameof(learningPlans));

            ListCard card = new ListCard
            {
                Title   = cardTitle,
                Items   = new List <ListCardItem>(),
                Buttons = new List <ListCardButton>(),
            };

            if (!learningPlans.Any())
            {
                card.Items.Add(new ListCardItem
                {
                    Type  = "resultItem",
                    Id    = Guid.NewGuid().ToString(),
                    Title = localizer.GetString("CurrentWeekLearningPlanNotExistText"),
                });
            }

            foreach (var learningPlan in learningPlans)
            {
                card.Items.Add(new ListCardItem
                {
                    Type     = "resultItem",
                    Id       = Guid.NewGuid().ToString(),
                    Title    = learningPlan.Topic,
                    Subtitle = learningPlan.TaskName,
                    Icon     = !string.IsNullOrEmpty(learningPlan?.TaskImage?.Url) ? learningPlan.TaskImage.Url : $"{applicationBasePath}/Artifacts/listCardDefaultImage.png",
                    Tap      = new ListCardItemEvent
                    {
                        Type  = CardConstants.MessageBack,
                        Value = $"{learningPlan.CompleteBy} => {learningPlan.Topic} => {learningPlan.TaskName}",
                    },
                });
            }

            var viewCompletePlanActionButton = new ListCardButton()
            {
                Title = localizer.GetString("ViewCompleteLearningPlanButtonText"),
                Type  = CardConstants.OpenUrlType,
                Value = $"{DeepLinkConstants.TabBaseRedirectURL}/{applicationManifestId}/{CardConstants.OnboardingJourneyTabEntityId}",
            };

            card.Buttons.Add(viewCompletePlanActionButton);

            var shareFeedbackActionButton = new ListCardButton()
            {
                Title = localizer.GetString("ShareFeedbackButtonText"),
                Type  = CardConstants.MessageBack,
                Value = BotCommandConstants.ShareFeedback,
            };

            card.Buttons.Add(shareFeedbackActionButton);

            return(new Attachment
            {
                ContentType = CardConstants.ListCardContentType,
                Content = card,
            });
        }
コード例 #29
0
 static void PlayForbiddenEffect(ListCard card, DeckScreen deckScreen)
 {
     S.I.PlayOnce(card.btnCtrl.lockedSound, false);
     deckScreen.removerAnimator.SetTrigger("FlashRed");
 }
コード例 #30
0
 static void PlayRemoveCardEffect(ListCard card)
 {
     Debug.Log("Playing effect for removing a card.");
     card.StartCoroutine("_RemoveCard");
 }