Esempio n. 1
0
        public string CreateCardBackSide(CardProvider cardProvider, string imageCard, string cardValueCode, bool showCVCNo = true)
        {
            if (!string.IsNullOrEmpty(cardValueCode) && cardValueCode.Length < 3)
            {
                cardValueCode = cardValueCode.PadLeft(3, '0');
            }
            Bitmap source;

            using (FileStream stream = new FileStream(imageCard, FileMode.Open, FileAccess.Read))
            {
                source = (Bitmap)Image.FromStream(stream);
            }

            Bitmap result = new Bitmap(source.Width, source.Height);

            result.SetResolution(source.HorizontalResolution, source.VerticalResolution);

            int   opacity = 255;
            Brush brush   = new SolidBrush(Color.FromArgb(opacity, Color.Black));//Brushes.Silver;

            string   fontType = "Arial";
            Graphics G        = Graphics.FromImage(result);

            G.DrawImage(source, 0, 0, new Rectangle(0, 0, source.Width, source.Height), GraphicsUnit.Pixel);

            G.DrawString("CVC-Number", new Font(fontType, 10, FontStyle.Regular), brush, new PointF(95, 74));
            if (showCVCNo)
            {
                G.DrawString(cardValueCode, new Font(fontType, 11, FontStyle.Italic), brush, new PointF(187, 74));
            }

            G.Dispose();

            return(BitmapToBase64(result));
        }
Esempio n. 2
0
        static void Main(string[] args)
        {
            Console.WriteLine("Initialising cash card...");

            var cardProvider = new CardProvider();
            var card         = cardProvider.GetCard();

            Console.WriteLine("Cash card initialised!");

            while (true)
            {
                Console.WriteLine();
                Console.WriteLine("Choose from the following options:\n1. Top up card\n2. Withdraw money\n3. Exit");

                var result = Console.ReadKey(true);

                if (result.KeyChar == '1')
                {
                    TopUp(card);
                }
                else if (result.KeyChar == '2')
                {
                    Withdraw(card);
                }
                else if (result.KeyChar == '3')
                {
                    break;
                }
                else
                {
                    continue;
                }
            }
        }
        private async Task <DialogTurnResult> PromptForProjectCollectionAndProjectName(WaterfallStepContext stepContext, CancellationToken cancellationToken)
        {
            var cardText = await CardProvider.GetCardText("ProjectInformationCard").ConfigureAwait(false);

            var replyActivity = JsonConvert.DeserializeObject <Activity>(cardText);

            return(await stepContext.PromptAsync(nameof(ActivityInfoPrompt), new PromptOptions { Prompt = replyActivity }, cancellationToken));
        }
Esempio n. 4
0
    protected virtual void Start()
    {
        _cardProvider = CardProvider.Instance();
        _processCard  = ProcessCard.Instance();
        _processCard.Reset();

        _inverseMoveTime  = 1f / MoveTime;
        _yInitialPosition = CurrentCard.transform.position.y;
        NextCard(CurrentCard);
    }
		protected override void OnSizeChanged (int w, int h, int oldw, int oldh)
		{
			base.OnSizeChanged (w, h, oldw, oldh);

			radius = Resources.GetDimensionPixelSize (Resource.Dimension.card_corner_radius);
			vw = w;
			vh = h;
			var vop = new CardProvider (this);
			OutlineProvider = vop;
			ClipToOutline = true;
		}
        protected override void OnSizeChanged(int w, int h, int oldw, int oldh)
        {
            base.OnSizeChanged(w, h, oldw, oldh);

            radius = Resources.GetDimensionPixelSize(Resource.Dimension.card_corner_radius);
            vw     = w;
            vh     = h;
            var vop = new CardProvider(this);

            OutlineProvider = vop;
            ClipToOutline   = true;
        }
Esempio n. 7
0
        private async Task <DialogTurnResult> PromptStepAsync(WaterfallStepContext stepContext, CancellationToken cancellationToken)
        {
            // Reply to the activity we received with an activity.
            var cardText = await CardProvider.GetCardText("WelcomeCard").ConfigureAwait(false);

            var replyActivity = JsonConvert.DeserializeObject <Activity>(cardText);

            replyActivity.Attachments.Add(GetSignInCard(stepContext.Context.Activity).ToAttachment());

            await stepContext.Context.SendActivityAsync(replyActivity, cancellationToken).ConfigureAwait(false);

            return(await stepContext.BeginDialogAsync(nameof(ConfirmPrompt), new PromptOptions { Prompt = MessageFactory.Text("Did you have a successful login?") }, cancellationToken));
        }
Esempio n. 8
0
 public static CustomerCreate GetCustomerCreateModelWithCard(CardProvider cardProvider = CardProvider.Visa)
 {
     return(new CustomerCreate()
     {
         Name = RandomData.FullName,
         Description = RandomData.String,
         Email = RandomData.Email,
         Phone = GetPhone(),
         Metadata = new Dictionary <string, string>()
         {
             { "channelInfo", RandomData.CompanyName }
         },
         Card = GetCardCreateModel(cardProvider)
     });
 }
        private async Task <DialogTurnResult> PromptForWorkItemDetails(WaterfallStepContext stepContext, CancellationToken cancellationToken)
        {
            var workItemInput = await workItemInputAccessor.GetAsync(stepContext.Context, cancellationToken : cancellationToken).ConfigureAwait(false);

            var activity = stepContext.Result as Activity;

            var replaceInfo = new Dictionary <string, string>();

            replaceInfo.Add("{{workitemType}}", workItemInput.WorkItemType.ToString());
            var cardText = await CardProvider.GetCardText("CreateWorkItemCard", replaceInfo).ConfigureAwait(false);

            var replyActivity = JsonConvert.DeserializeObject <Activity>(cardText);

            return(await stepContext.PromptAsync(nameof(ActivityInfoPrompt), new PromptOptions { Prompt = replyActivity }, cancellationToken));
        }
Esempio n. 10
0
        public VirtualCreditCard(OrbiscomResponse response, int responseCPN_AVV, string responseCPN_Expiry, string frontCard, string backCard)
        {
            this.pAN = response.CPN.PAN;
            this.aVV = responseCPN_AVV.ToString();

            this.expiry = string.Empty;
            string year  = responseCPN_Expiry.Substring(0, 2);
            string month = responseCPN_Expiry.Substring(2, 2);

            this.expiry = month + year;

            this.cardholderName = response.AVSData.CardholderName;
            this.cardProvider   = CardProvider.AirPlus;
            this.cA_FrontCard   = frontCard;
            this.cA_BackCard    = backCard;
        }
Esempio n. 11
0
        public VirtualCreditCard(maintainPreAuthorizationResponseType response, int responseCPN_AVV, string responseCPN_Expiry, string frontCard, string backCard, string cardHolder = "Test Name")
        {
            this.pAN = response.Response.maintainPreAuthorizationResp.accountNumber;
            this.aVV = responseCPN_AVV.ToString();

            this.expiry = string.Empty;
            // Template
            string year  = responseCPN_Expiry.Substring(2, 2);
            string month = responseCPN_Expiry.Substring(4, 2);

            this.expiry = month + year;

            this.cardholderName = cardHolder;
            this.cardProvider   = CardProvider.AMEX;

            this.cA_FrontCard = frontCard;
            this.cA_BackCard  = backCard;
        }
Esempio n. 12
0
        public VirtualCreditCard(AmexResponse response, int responseCPN_AVV, string responseCPN_Expiry, string frontCard, string backCard, string cardHolder = "Test Name")
        {
            this.pAN = response.TokenIssuanceData.TokenDetails.TokenNumber;
            this.aVV = responseCPN_AVV.ToString();

            this.expiry = string.Empty;
            // Template
            string year  = responseCPN_Expiry.Substring(2, 2);
            string month = responseCPN_Expiry.Substring(4, 2);

            this.expiry = month + year;

            this.cardholderName = cardHolder;
            this.cardProvider   = CardProvider.AMEX;

            this.cA_FrontCard = frontCard;
            this.cA_BackCard  = backCard;
        }
Esempio n. 13
0
        public string CreateCardFontSide(CardProvider cardProvider, string imageCard, string cardNumber, string dateExpire, string cardHolderName, string traveler)
        {
            // specify embedded resource name
            string resource = AppDomain.CurrentDomain.BaseDirectory + @"Font\CREDC___.ttf";

            System.Drawing.Text.PrivateFontCollection private_fonts;
            FontFamily font = LoadFontFamily(resource, out private_fonts);

            Bitmap source;

            using (FileStream stream = new FileStream(imageCard, FileMode.Open, FileAccess.Read))
            {
                source = (Bitmap)Image.FromStream(stream);
            }

            Bitmap result = new Bitmap(source.Width, source.Height);

            result.SetResolution(source.HorizontalResolution, source.VerticalResolution);

            //string fontType = "Credit Card";

            int   opacity = 255;
            Brush brush   = new SolidBrush(Color.FromArgb(opacity, Color.Black));//Brushes.Silver;

            Graphics G = Graphics.FromImage(result);

            G.DrawImage(source, 0, 0, new Rectangle(0, 0, source.Width, source.Height), GraphicsUnit.Pixel);
            G.DrawString(cardNumber, new Font(private_fonts.Families[0], 13), brush, new PointF(30, 120));
            G.DrawString(dateExpire, new Font(private_fonts.Families[0], 8), brush, new PointF(150, 160));

            if (string.IsNullOrWhiteSpace(traveler))
            {
                G.DrawString(cardHolderName.ToUpper(), new Font(private_fonts.Families[0], 8), brush, new PointF(20, 173));
                G.DrawString(string.Empty, new Font(private_fonts.Families[0], 8), brush, new PointF(20, 188));
            }
            else
            {
                G.DrawString(traveler.ToUpper(), new Font(private_fonts.Families[0], 8), brush, new PointF(20, 173));
                G.DrawString(cardHolderName.ToUpper(), new Font(private_fonts.Families[0], 8), brush, new PointF(20, 188));
            }
            G.Dispose();

            return(BitmapToBase64(result));
        }
Esempio n. 14
0
        public Monster(ContentManager _content, SpriteID _spriteId, eCardType _cardType = eCardType.MONSTER)//cái tham số mặc nhiên để tạm
            : base(_content, ID.CARD, _spriteId, _cardType)
        {
            this.Original      = new MonsterCardData((MonsterCardData)CardProvider.GetInstance().GetCardById(_spriteId.ToString()));
            this.IsEffect      = Original.IsEffect;
            this.Attribute     = Original.Attribute;
            this.MonsterType   = Original.MonsterType;
            this.Level         = Original.Level;
            this.Atk           = Original.Atk;
            this.Def           = Original.Def;
            this.Rank          = Original.Rank;
            this.PendulumScale = Original.PendulumScale;
            this.SpellSpeed    = Original.SpellSpeed;
            this.CanATK        = true;

            this.num_atk   = new Num(_content, Vector2.Zero, SpriteID.font_710_whitenum);
            this.num_def   = new Num(_content, Vector2.Zero, SpriteID.font_710_whitenum);
            this.num_slash = new Num(_content, Vector2.Zero, SpriteID.font_710_whitenum);
        }
Esempio n. 15
0
        public static async Task NotifySubscribers(UserScubaData userScubaData, BotAdapter adapter, MicrosoftAppCredentials workingCredentials, ConversationReference reserverReference = null)
        {
            if (reserverReference != null)
            {
                var scubaReservation = new Tuple <ConversationReference, UserScubaData>(reserverReference, userScubaData);
                _recentReservations.AddOrUpdate(reserverReference.User.Id, scubaReservation, (key, oldValue) => scubaReservation);
                //todo: this should not be a hard coded url
                userScubaData.ChatWithUserUrl = "https://contososcubademo.azurewebsites.net?chatWithId=" + reserverReference.User.Id;
                //chatWithUserIdUrl = "Use this URL to chat with them: http://localhost:3979?chatWithId=" + reserverReference.User.Id;
            }
            string message = $"New scuba booking for {userScubaData.PersonalInfo.Name}";

            var replaceInfo = new Dictionary <string, string>();

            replaceInfo.Add("{{destination}}", userScubaData.Destination);
            replaceInfo.Add("{{school}}", userScubaData.School);
            replaceInfo.Add("{{longdate}}", Convert.ToDateTime(userScubaData.Date).ToString("dddd, MMMM dd"));
            replaceInfo.Add("{{number_of_people}}", userScubaData.NumberOfPeople);
            replaceInfo.Add("{{phone}}", userScubaData.PersonalInfo.Phone);
            replaceInfo.Add("{{email}}", userScubaData.PersonalInfo.Email);
            replaceInfo.Add("{{name}}", userScubaData.PersonalInfo.Name);
            replaceInfo.Add("{{protein_preference}}", userScubaData.MealOptions.ProteinPreference);
            replaceInfo.Add("{{vegan}}", userScubaData.MealOptions.Vegan ? "Yes" : "No");
            replaceInfo.Add("{{allergy}}", userScubaData.MealOptions.Alergy);

            if (!string.IsNullOrEmpty(userScubaData.ChatWithUserUrl))
            {
                replaceInfo.Add("{{url}}", userScubaData.ChatWithUserUrl);
            }


            var subscriberCardText = await CardProvider.GetCardText("SubscriberNotification", replaceInfo);

            var conversationCallback = GetConversationCallback(message, workingCredentials, subscriberCardText);

            await SendActionableMessage(userScubaData);

            foreach (var subscriber in _reservationSubscribers.Values)
            {
                await adapter.ContinueConversation(subscriber.Bot.Id, subscriber, conversationCallback);
            }
        }
Esempio n. 16
0
        public Monster(ContentManager _content, string _cardId)
            : base(_content, ID.CARD, (SpriteID)(Enum.Parse(typeof(SpriteID), "C" + _cardId)), eCardType.MONSTER)
        {
            this.Original      = new MonsterCardData((MonsterCardData)CardProvider.GetInstance().GetCardById("C" + _cardId));
            this.IsEffect      = Original.IsEffect;
            this.Attribute     = Original.Attribute;
            this.MonsterType   = Original.MonsterType;
            this.Level         = Original.Level;
            this.Atk           = Original.Atk;
            this.Def           = Original.Def;
            this.Rank          = Original.Rank;
            this.PendulumScale = Original.PendulumScale;
            this.SpellSpeed    = Original.SpellSpeed;
            this.CanATK        = true;

            this.num_atk              = new Num(_content, Vector2.Zero, SpriteID.font_710_whitenum);
            this.num_def              = new Num(_content, Vector2.Zero, SpriteID.font_710_whitenum);
            this.num_slash            = new Num(_content, Vector2.Zero, SpriteID.font_710_whitenum);
            this.num_slash.FrameWidth = 10;
        }
Esempio n. 17
0
 public static BaseCard GetBaseCardModel(CardProvider cardProvider=CardProvider.Visa)
 {
     if( cardProvider == CardProvider.Visa )
     {
         return new BaseCard()
           {
               ExpiryMonth = "06",
               ExpiryYear = "2018",
               Name = RandomData.FullName,
               BillingDetails = GetAddressModel()
           };
     }else
     {
         return new BaseCard()
           {
               ExpiryYear = "2017",
               ExpiryMonth = "06",
               Name = RandomData.FullName,
               BillingDetails = GetAddressModel()
           };
     }
 }
Esempio n. 18
0
    public void OpenShop(PlayerClass player)
    {
        ActivePlayer = player;

        var TownName = ActivePlayer.gameObject.GetComponent <PlayerMover>().GetWaypointName();

        if (!TownName.Equals(LastTownName))
        {
            LastTownName = TownName;

            ShopItems.Clear();
            foreach (Transform t in GridLayoutGroup_ShopItems.transform)
            {
                GameObject.Destroy(t.gameObject);
            }

            var cards = CardProvider.GetShopCards(TownName);
            foreach (var c in cards)
            {
                AddShopItem(c);
            }
        }

        var idx = 0;

        foreach (var c in player.Deck)
        {
            var obj = Instantiate(prefab_ShopItem, ShopInventoryController.Gridlayout_ShopInventory.transform);
            obj.GetComponent <ShopItemController>().GenerateShopItem(this, c, true);
            obj.name = "item_" + ++idx;
        }

        foreach (var item in ShopItems)
        {
            item.GetComponentInChildren <Button>(true).interactable = player.Gold >= item.Card.Price;
        }

        StartCoroutine(CoroutineOpenShop());
    }
Esempio n. 19
0
        public static CardCreate GetCardCreateModel(CardProvider cardProvider = CardProvider.Visa)
        {
            CardCreate card     = new CardCreate();
            var        baseCard = GetBaseCardModel(cardProvider);

            card.Name           = baseCard.Name;
            card.ExpiryMonth    = baseCard.ExpiryMonth;
            card.ExpiryYear     = baseCard.ExpiryYear;
            card.BillingDetails = baseCard.BillingDetails;

            if (cardProvider == CardProvider.Visa)
            {
                card.Cvv    = "100";
                card.Number = "4242424242424242";
            }
            else
            {
                card.Cvv    = "257";
                card.Number = "5313581000123430";
            }

            return(card);
        }
Esempio n. 20
0
 public static BaseCard GetBaseCardModel(CardProvider cardProvider = CardProvider.Visa)
 {
     if (cardProvider == CardProvider.Visa)
     {
         return(new BaseCard()
         {
             ExpiryMonth = "06",
             ExpiryYear = "2018",
             Name = RandomData.FullName,
             BillingDetails = GetAddressModel()
         });
     }
     else
     {
         return(new BaseCard()
         {
             ExpiryYear = "2017",
             ExpiryMonth = "06",
             Name = RandomData.FullName,
             BillingDetails = GetAddressModel()
         });
     }
 }
Esempio n. 21
0
        public static CardCreate GetCardCreateModel(CardProvider cardProvider=CardProvider.Visa)
        {
            CardCreate card=new CardCreate();
            var baseCard = GetBaseCardModel(cardProvider);

            card.Name = baseCard.Name;
            card.ExpiryMonth = baseCard.ExpiryMonth;
            card.ExpiryYear = baseCard.ExpiryYear;
            card.BillingDetails = baseCard.BillingDetails;

            if (cardProvider == CardProvider.Visa)
            {
                card.Cvv = "100";
                card.Number = "4242424242424242";
            }
            else
            {
                card.Cvv = "257";
                card.Number = "5313581000123430";
            }

            return card;
        }
Esempio n. 22
0
            /// <summary>
            /// Template setup
            /// </summary>
            /// <param name="provider">Card provider type. Used for testing purposes only</param>
            /// <param name="prefixes">comma delimited list of prefix digits, e.g. "1,12,123"</param>
            /// <param name="lengths">Valid numbers of digits</param>
            public CardTemplate(CardProvider provider, string prefixes, params int[] lengths)
            {
                m_Provider = provider;

                string[] prefixesArray = prefixes.Split(new char[] { ',' });
                m_Prefixes = new int[prefixesArray.Length][];

                int prefixesIndex = 0;
                foreach (string prefixStr in prefixesArray)
                {
                    int[] prefix = new int[prefixStr.Length];
                    for (int prefixIndex = 0; prefixIndex < prefixStr.Length; ++prefixIndex)
                    {
                        prefix[prefixIndex] = int.Parse(prefixStr[prefixIndex].ToString());
                    }
                    m_Prefixes[prefixesIndex++] = prefix;
                }

                m_ValidLengths = lengths;
            }
Esempio n. 23
0
 /// <summary>
 /// Returns a CardTemplate for a given provider
 /// </summary>
 public static CardTemplate ProviderTemplate(CardProvider provider)
 {
     foreach (CardTemplate template in CardTemplates)
     {
         if (template.Provider == provider)
         {
             return template;
         }
     }
     return null;
 }
Esempio n. 24
0
 public Spell(ContentManager _content, SpriteID _spriteId)
     : base(_content, ID.CARD, _spriteId, eCardType.SPELL)
 {
     this.Original = new SpellCardData((SpellCardData)CardProvider.GetInstance().GetCardById(_spriteId.ToString()));
 }
Esempio n. 25
0
 public Spell(ContentManager _content, string _cardId)
     : base(_content, ID.CARD, (SpriteID)(Enum.Parse(typeof(SpriteID), "C" + _cardId)), eCardType.SPELL)
 {
     this.Original = new SpellCardData((SpellCardData)CardProvider.GetInstance().GetCardById("C" + _cardId));
 }
Esempio n. 26
0
 public static CustomerCreate GetCustomerCreateModelWithCard(CardProvider cardProvider = CardProvider.Visa)
 {
     return new CustomerCreate()
     {
         Name = RandomData.FullName,
         Description = RandomData.String,
         Email = RandomData.Email,
         Phone = GetPhone(),
         Metadata = new Dictionary<string, string>() { { "channelInfo", RandomData.CompanyName } },
         Card = GetCardCreateModel(cardProvider)
     };
 }
        private async Task <DialogTurnResult> FinalStepAsync(WaterfallStepContext stepContext, CancellationToken cancellationToken)
        {
            if (stepContext.Result == null || !(stepContext.Result is Activity))
            {
                return(await stepContext.EndDialogAsync(null, cancellationToken));
            }

            var workItemInput = await workItemInputAccessor.GetAsync(stepContext.Context, cancellationToken : cancellationToken).ConfigureAwait(false);

            try
            {
                var authenticatedProfile = await this.authHelper.GetAuthenticatedProfileAsync(stepContext.Context, cancellationToken).ConfigureAwait(false);

                var activity     = stepContext.Result as Activity;
                var workItemInfo = JObject.Parse(activity.Value.ToString());

                var      fieldToValueMappings = GetFieldToValueMappings(workItemInfo["WorkItemTitle"].ToString(), workItemInfo["WorkItemDescription"].ToString(), workItemInfo["Priority"].ToString(), workItemInfo["AreaPath"].ToString(), workItemInfo["IterationPath"].ToString());
                WorkItem workItem             = await vsoApiController.CreateWorkItemAsync(workItemInput.ProjectCollection, workItemInput.ProjectName, fieldToValueMappings, workItemInput.WorkItemType, authenticatedProfile.Token.AccessToken).ConfigureAwait(false);

                if (workItem == null)
                {
                    this.logger.LogError($"Error while creating the {workItemInput.WorkItemType}");
                    await stepContext.Context.SendActivityAsync(MessageFactory.Text($"Sorry something went wrong when creating {workItemInput.WorkItemType}."), cancellationToken);

                    return(await stepContext.EndDialogAsync(null, cancellationToken));
                }

                var replaceInfo = new Dictionary <string, string>();
                replaceInfo.Add("{{workitemId}}", workItem.Id.ToString());
                replaceInfo.Add("{{workitemUrl}}", $"https://{workItemInput.ProjectCollection}.visualstudio.com/{workItemInput.ProjectName}/_workitems/edit/{workItem.Id}");
                if (workItem.Fields.Count == 0)
                {
                    this.logger.LogWarning($"Work item details are miising for {workItem.Id}");
                }

                if (workItem.Fields.TryGetValue("System.WorkItemType", out object workItemType))
                {
                    replaceInfo.Add("{{workitemType}}", workItemType.ToString());
                }

                if (workItem.Fields.TryGetValue("System.Title", out object title))
                {
                    replaceInfo.Add("{{workitemTitle}}", title.ToString());
                }

                if (workItem.Fields.TryGetValue("System.State", out object status))
                {
                    replaceInfo.Add("{{workitemStatus}}", status.ToString());
                }

                if (workItem.Fields.TryGetValue("System.ChangedDate", out object lastUpdatedDate))
                {
                    replaceInfo.Add("{{lastUpdated}}", lastUpdatedDate.ToString());
                }

                var cardText = await CardProvider.GetCardText("WorkItemDetailsCard", replaceInfo).ConfigureAwait(false);

                var replyActivity = JsonConvert.DeserializeObject <Activity>(cardText);
                replyActivity.Text = $"Created {workItemInput.WorkItemType} successfully";
                await stepContext.Context.SendActivityAsync(replyActivity, cancellationToken);

                return(await stepContext.EndDialogAsync(workItemInput, cancellationToken));
            }
            catch (Exception)
            {
                await stepContext.Context.SendActivityAsync(MessageFactory.Text($"Sorry something went wrong when creating {workItemInput.WorkItemType}."), cancellationToken);

                return(await stepContext.EndDialogAsync(null, cancellationToken));
            }
        }
Esempio n. 28
0
        private async Task <DialogTurnResult> FinalStepAsync(WaterfallStepContext stepContext, CancellationToken cancellationToken)
        {
            if (stepContext.Result == null || !(stepContext.Result is Activity) || !(stepContext.Options is RecognizerResult))
            {
                return(await stepContext.EndDialogAsync(null, cancellationToken));
            }

            var recognizerResult = (RecognizerResult)stepContext.Options;
            // We need to get the result from the LUIS JSON which at every level returns an array.
            WorkItemInput workItemInput = new WorkItemInput();
            Match         match         = Regex.Match(recognizerResult.Entities["id"].ToString(), @"(\d+)");

            if (match.Success)
            {
                workItemInput.WorkItemId = match.Groups[1].Value;
            }

            try
            {
                var authenticatedProfile = await this.authHelper.GetAuthenticatedProfileAsync(stepContext.Context, cancellationToken).ConfigureAwait(false);

                var      activity    = stepContext.Result as Activity;
                var      projectInfo = JObject.Parse(activity.Value.ToString());
                WorkItem workItem    = await vsoApiController.GetWorkItemAsync(workItemInput.WorkItemId, projectInfo["ProjectCollection"].ToString(), projectInfo["ProjectName"].ToString(), authenticatedProfile.Token.AccessToken).ConfigureAwait(false);

                var replaceInfo = new Dictionary <string, string>();
                replaceInfo.Add("{{workitemId}}", workItem.Id.ToString());
                replaceInfo.Add("{{workitemUrl}}", $"https://{projectInfo["ProjectCollection"].ToString()}.visualstudio.com/{projectInfo["ProjectName"].ToString()}/_workitems/edit/{workItemInput.WorkItemId}");
                if (workItem.Fields.Count == 0)
                {
                    this.logger.LogWarning($"Work item details are miising for {workItem.Id}");
                }

                if (workItem.Fields.TryGetValue("System.Title", out object title))
                {
                    replaceInfo.Add("{{workitemTitle}}", title.ToString());
                }

                if (workItem.Fields.TryGetValue("System.WorkItemType", out object workItemType))
                {
                    replaceInfo.Add("{{workitemType}}", workItemType.ToString());
                }

                if (workItem.Fields.TryGetValue("System.State", out object status))
                {
                    replaceInfo.Add("{{workitemStatus}}", status.ToString());
                }

                if (workItem.Fields.TryGetValue("System.ChangedDate", out object lastUpdatedDate))
                {
                    replaceInfo.Add("{{lastUpdated}}", lastUpdatedDate.ToString());
                }

                var cardText = await CardProvider.GetCardText("WorkItemDetailsCard", replaceInfo).ConfigureAwait(false);

                var replyActivity = JsonConvert.DeserializeObject <Activity>(cardText);
                await stepContext.Context.SendActivityAsync(replyActivity, cancellationToken);

                return(await stepContext.EndDialogAsync(workItemInput, cancellationToken));
            }
            catch (Exception)
            {
                await stepContext.Context.SendActivityAsync(MessageFactory.Text($"Sorry something went wrong when fetching {workItemInput.WorkItemId}."), cancellationToken);

                return(await stepContext.EndDialogAsync(null, cancellationToken));
            }
        }
Esempio n. 29
0
 public Trap(ContentManager _content, SpriteID _spriteId)
     : base(_content, ID.CARD, _spriteId, eCardType.TRAP)
 {
     this.Original = new TrapCardData((TrapCardData)CardProvider.GetInstance().GetCardById(_spriteId.ToString()));
 }