예제 #1
0
 protected override async Task OnMembersAddedAsync(IList <ChannelAccount> membersAdded, ITurnContext <IConversationUpdateActivity> turnContext, CancellationToken cancellationToken)
 {
     foreach (var member in membersAdded)
     {
         if (member.Id != turnContext.Activity.Recipient.Id)
         {
             var    path        = TimeOffBL.GetPath();
             string WelcomeCard = File.ReadAllText(path + "\\Cards\\WelcomeMeassage.json");
             await turnContext.SendActivityAsync(MessageFactory.Attachment(SendCards.SendAdaptiveCard(WelcomeCard)), cancellationToken);
         }
     }
 }
예제 #2
0
        public async void Initialize()
        {
            Employee   employees   = new Employee();
            Department departments = new Department();
            Card       card        = new Card();
            Favorite   favorite    = new Favorite();

            //下のやつは、ログイン者のEmployee情報をAuthorizedEMployeeに入れてます。
            this.AuthorizedEmployee = SessionService.Instance.AuthorizedEmployee;
            if (SessionService.Instance.AuthorizedEmployee != null)
            {
                this.Employees = await employees.GetEmployeesAsync();

                this.Departments = await departments.GetDepartmentsAsync();

                this.AllCards = await card.GetCardsAsync();

                this.Favorites = await favorite.GetFavoritesAsync();
            }


            #region FavoriteCards
            this.FavoriteCards = Favorites.Where(f => f.EmployeeId == this.AuthorizedEmployee.Id).ToList();
            for (var i = 0; i < FavoriteCards.Count; i++)
            {
                favorite = FavoriteCards.ElementAt(i);
                favorite.Card.Favorite = true;

                FavoriteCards.RemoveAt(i);
                FavoriteCards.Insert(i, favorite);
            }
            #endregion

            #region SendCards
            this.SendCards = AllCards.Where(al => al.From.Id == this.AuthorizedEmployee.Id).ToList();
            for (var i = 0; i < SendCards.Count; i++)
            {
                if (Favorites.Any(f => f.CardId == card.Id && f.EmployeeId == this.AuthorizedEmployee.Id))
                {
                    card          = SendCards.ElementAt(i);
                    card.Favorite = true;

                    SendCards.RemoveAt(i);
                    SendCards.Insert(i, card);
                }
            }
            #endregion

            #region ReceiveCards
            this.ReceiveCards = AllCards.Where(al => al.To.Id == this.AuthorizedEmployee.Id).ToList();
            for (var i = 0; i < ReceiveCards.Count; i++)
            {
                if (Favorites.Any(f => f.CardId == card.Id && f.EmployeeId == this.AuthorizedEmployee.Id))
                {
                    card          = ReceiveCards.ElementAt(i);
                    card.Favorite = true;

                    ReceiveCards.RemoveAt(i);
                    ReceiveCards.Insert(i, card);
                }
            }
            #endregion

            var FavoriteCheckCards = new List <Card>();

            for (var i = 0; i < AllCards.Count; i++)
            {
                card = AllCards.ElementAt(i);

                if (Favorites.Any(f => f.CardId == card.Id && f.EmployeeId == this.AuthorizedEmployee.Id))
                {
                    card          = AllCards.ElementAt(i);
                    card.Favorite = true;

                    FavoriteCheckCards.Add(card);
                }
            }
            this.Cards = FavoriteCheckCards;
            this.Cards = Cards.OrderBy(ac => ac.Date).ToList();
        }