Пример #1
0
        private static async Task SearchGarmentStyle(IMessageActivity replyMessage, string pi_GarmentStyle)
        {
            StyleProduct l_styleProduct = await new GarmentStyleHelper().GarmentStyleSearch(pi_GarmentStyle);

            if (l_styleProduct != null)
            {
                replyMessage.Text = l_styleProduct.linePlanProducts.productID + "(" + l_styleProduct.linePlanProducts.productVersion + l_styleProduct.linePlanProducts.productVersionSerialNo + ")";

                //button
                var actions = new List <CardAction>();
                actions.Add(new CardAction
                {
                    Title = $"ViewBOM",
                    Value = $"Search Garment Style",//this action will send message to Bot
                    Type  = ActionTypes.ImBack,
                    Image = "https://placeholdit.imgix.net/~text?txtsize=16&txt=WesChen&w=125&h=40&txttrack=0&txtclr=000&txtfont=bold"
                });

                if (l_styleProduct.linePlanProducts.productMaterialConfigs != null && l_styleProduct.linePlanProducts.productMaterialConfigs.Count() > 0)
                {
                    //attachment layout style
                    replyMessage.AttachmentLayout = AttachmentLayoutTypes.Carousel;

                    //foreach add herocard
                    foreach (var getColorway in l_styleProduct.linePlanProducts.productMaterialConfigs)
                    {
                        replyMessage.Attachments.Add(new ThumbnailCard
                        {
                            Title    = getColorway.colorway + "(" + getColorway.optionNo + ")",
                            Subtitle = getColorway.primaryFabricID,
                            Text     = getColorway.pluNumber,
                            Images   = new List <CardImage>
                            {
                                new CardImage
                                {
                                    Url = getColorway.PrimaryFabricImageUrl,
                                    Alt = getColorway.colorway + "(" + getColorway.optionNo + ")"
                                }
                            },
                            Buttons = actions
                                      //,
                                      //Tap = new CardAction()
                                      //{
                                      //    Title="imBack title",
                                      //    Type= "imBack",
                                      //    Image= "https://placeholdit.imgix.net/~text?txtsize=16&txt=WesChen&w=125&h=40&txttrack=0&txtclr=000&txtfont=bold",
                                      //    Value="ss"
                                      //}
                        }.ToAttachment());
                    }
                }
            }
            else
            {
                replyMessage.Text = "Sorry , Can Not Found Garment Style.";
            }
        }
Пример #2
0
        //----------------------------------------------------------------------------------------------------------------------------------

        private static async Task SearchGarmentStyle(IMessageActivity replyMessage, string pi_GarmentStyle)
        {
            char[] charsToTrim = { ' ', '\r' };
            pi_GarmentStyle = pi_GarmentStyle.Trim(charsToTrim);
            pi_GarmentStyle = pi_GarmentStyle.Replace(" ", string.Empty);

            StyleProduct l_styleProduct = await new GarmentStyleHelper().GarmentStyleSearch(pi_GarmentStyle);

            if (l_styleProduct != null)
            {
                replyMessage.Text = l_styleProduct.linePlanProducts.productID + "(" + l_styleProduct.linePlanProducts.productVersion + l_styleProduct.linePlanProducts.productVersionSerialNo + ")";

                if (l_styleProduct.linePlanProducts.productMaterialConfigs != null && l_styleProduct.linePlanProducts.productMaterialConfigs.Count() > 0)
                {
                    //attachment layout style
                    replyMessage.AttachmentLayout = AttachmentLayoutTypes.Carousel;

                    //foreach add herocard
                    foreach (var getColorway in l_styleProduct.linePlanProducts.productMaterialConfigs)
                    {
                        replyMessage.Attachments.Add(new ThumbnailCard
                        {
                            Title    = getColorway.colorway + "(" + getColorway.optionNo + ")",
                            Subtitle = getColorway.primaryFabricID,
                            Text     = getColorway.pluNumber,
                            Images   = new List <CardImage>
                            {
                                new CardImage
                                {
                                    Url = getColorway.PrimaryFabricImageUrl,
                                    Alt = getColorway.colorway + "(" + getColorway.optionNo + ")"
                                }
                            }
                            ,
                            Buttons = new List <CardAction>()
                            {
                                new CardAction
                                {
                                    Title = $"Primary Fabric",
                                    Value = $"search fabric { getColorway.primaryFabricID }",
                                    Type  = ActionTypes.ImBack,
                                    Image = getColorway.PrimaryFabricImageUrl
                                }
                            }
                        }.ToAttachment());
                    }
                }
            }
            else
            {
                replyMessage.Text = $"sorry , the garment style [ { pi_GarmentStyle } ] can not found.";
            }
        }
Пример #3
0
        public async Task <StyleProduct> GarmentStyleSearch(string pi_GarmentStyleNo)
        {
            StyleProduct l_returnValue = null;
            string       l_APIUrl      = Common.ConfigHelper.GetConfigValue("LPD-GarmentStyleSearchAPIUrl");

            try
            {
                if (!string.IsNullOrEmpty(l_APIUrl) && !string.IsNullOrEmpty(pi_GarmentStyleNo))
                {
                    #region search entity
                    var requestEntity = new Model.SelectionFilter()
                    {
                        FilterType    = Model.SelectionFilter.FilterTypeLeaf,
                        Filters       = new Model.SelectionFilter[] { },
                        AttributeName = "item_number",
                        FilterValue   = pi_GarmentStyleNo
                    };
                    #endregion

                    string l_returnjson = await new Common.HttpClientHelper().HttpClient_PostAsync(l_APIUrl, JsonConvert.SerializeObject(requestEntity).ToString());
                    BaseResponse <List <PagingData <StyleProduct> > > l_returnEntity = await JsonConvert.DeserializeObjectAsync <BaseResponse <List <PagingData <StyleProduct> > > >(l_returnjson);

                    #region get style entity
                    if (l_returnEntity != null)
                    {
                        if (l_returnEntity.results != null && l_returnEntity.results.Count > 0)
                        {
                            if (l_returnEntity.results.First().data != null && l_returnEntity.results.First().data.Count() > 0)
                            {
                                l_returnValue = l_returnEntity.results.First().data.First();
                            }
                        }
                    }
                    #endregion
                }
            }
            catch (Exception ex)
            {
            }

            return(l_returnValue);
        }