Beispiel #1
0
        internal static ButtonsTemplate Make(int QIDnow, int OIDnow, string data)
        {
            //建立actions,作為ButtonTemplate的用戶回覆行為
            var actions = new List <isRock.LineBot.TemplateActionBase>();

            // 以傳進來的QID找到按鈕選項
            QuestionDetail        questionDetail     = new QuestionDetail(QIDnow);
            List <QuestionDetail> questionDetailList = questionDetail.SelectByQid();

            // 以選項的QID跟OID找到button裡要藏的QID和OID (即按下按鈕後下一個出現的QID和OID)
            for (int i = 0; i < questionDetailList.Count; i++)
            {
                NextHelper     nextHelper         = new NextHelper(questionDetailList[i].QID, questionDetailList[i].OID);
                QuestionDetail questionDetailNext = nextHelper.GetNext();

                actions.Add(new isRock.LineBot.PostbackAction()
                {
                    label = questionDetailList[i].AnswerOption,
                    data  = DateTime.Now.ToString() + $",{questionDetailNext.QID},{questionDetailNext.OID},{data}"
                });
            }

            // QID 19和29都有四個button了不能加上一步
            if (!(QIDnow == 19 || QIDnow == 29))
            {
                // 製作上一步的button
                PreviousHelper previousHelper         = new PreviousHelper(QIDnow, OIDnow);
                QuestionDetail questionDetailPrevious = previousHelper.GetPrevious();

                actions.Add(new isRock.LineBot.PostbackAction()
                {
                    label = "上一步",
                    data  = DateTime.Now.ToString() + $",{questionDetailPrevious.QID}," + $"{questionDetailPrevious.OID},default"
                });
            }

            //製作模板框架
            Question question = new Question(QIDnow);

            question.SelectByQid();

            var ButtonTemplate = new isRock.LineBot.ButtonsTemplate()
            {
                altText = $"請使用手機查看喔~{question.QuestionTitle}",
                //title = question.QuestionTitle,
                text = question.QuestionText,
                //設定圖片
                thumbnailImageUrl = new Uri(question.ImageUrl),
                actions           = actions //設定回覆動作
            };


            return(ButtonTemplate);
        }
Beispiel #2
0
        internal static ButtonsTemplate DateTimeBtnMake(int QIDnow, int OIDnow, string data)
        {
            NextHelper     nextHelper         = new NextHelper(QIDnow, OIDnow);
            QuestionDetail questionDetailNext = nextHelper.GetNext();

            PreviousHelper previousHelper         = new PreviousHelper(QIDnow, OIDnow);
            QuestionDetail questionDetailPrevious = previousHelper.GetPrevious();

            var ButtonTemplate = new isRock.LineBot.ButtonsTemplate();
            var actions        = new List <isRock.LineBot.TemplateActionBase>();

            actions.Add(new isRock.LineBot.DateTimePickerAction()
            {
                label = "選擇開始日期和時間",
                mode  = "datetime",
                data  = $"{DateTime.Now},{questionDetailNext.QID},{questionDetailNext.OID},start"
            });
            actions.Add(new isRock.LineBot.DateTimePickerAction()
            {
                label = "選擇結束日期和時間",
                mode  = "datetime",
                data  = $"{DateTime.Now},{questionDetailNext.QID},{questionDetailNext.OID},end"
            });

            actions.Add(new isRock.LineBot.PostbackAction()
            {
                label = "上一步",
                data  = DateTime.Now.ToString() + $",{questionDetailPrevious.QID}," + $"{questionDetailPrevious.OID},default"
            });
            ButtonTemplate = new isRock.LineBot.ButtonsTemplate()
            {
                text = "訂單",
                // title = "選擇日期",
                //設定圖片
                thumbnailImageUrl = new Uri("https://i220.photobucket.com/albums/dd130/jung_04/DateTime.png"),
                actions           = actions
            };


            return(ButtonTemplate);
        }
Beispiel #3
0
        internal static string MakeShopItem(string UserID, int QID, int OID, string shopID)
        {
            List <ShopInfo> shopInfos = new List <ShopInfo>();
            List <ShopItem> shopItems = new List <ShopItem>();;
            ShopInfo        shopInfo  = new ShopInfo();
            ShopItem        shopItem;

            shopInfo.ShopID = shopID;
            switch (QID)
            {
            case 201:
                shopInfos = shopInfo.MyShopSelectShopNameByShopid();
                shopItem  = new ShopItem(shopID);
                shopItems = shopItem.SelectByMyShopID();
                break;

            case 202:
                shopInfos = shopInfo.BossShopSelectShopNameByShopid();
                shopItem  = new ShopItem(shopID);
                shopItems = shopItem.SelectByBossShopID();
                break;

            case 211:
                shopInfos = shopInfo.MyShopSelectShopNameByShopid();
                shopItem  = new ShopItem(shopID);
                shopItems = shopItem.SelectByMyShopID();
                break;

            case 212:
                shopInfos = shopInfo.BossShopSelectShopNameByShopid();
                shopItem  = new ShopItem(shopID);
                shopItems = shopItem.SelectByBossShopID();
                break;

            case 231:
                shopInfos = shopInfo.MyShopSelectShopNameByShopid();
                shopItem  = new ShopItem(shopID);
                shopItems = shopItem.SelectByMyShopID();
                break;

            case 232:
                shopInfos = shopInfo.BossShopSelectShopNameByShopid();
                shopItem  = new ShopItem(shopID);
                shopItems = shopItem.SelectByBossShopID();
                break;

            case 241:
                shopInfos = shopInfo.ClubShopSelectShopNameByShopid();
                shopItem  = new ShopItem(shopID);
                shopItems = shopItem.SelectByClubShopID();
                break;

            case 242:
                shopInfos = shopInfo.BossShopSelectShopNameByShopid();
                shopItem  = new ShopItem(shopID);
                shopItems = shopItem.SelectByBossShopID();
                break;

            case 251:
                shopInfos = shopInfo.ClubShopSelectShopNameByShopid();
                shopItem  = new ShopItem(shopID);
                shopItems = shopItem.SelectByClubShopID();
                break;

            case 252:
                shopInfos = shopInfo.BossShopSelectShopNameByShopid();
                shopItem  = new ShopItem(shopID);
                shopItems = shopItem.SelectByBossShopID();
                break;

            case 261:
                shopInfos = shopInfo.ClubShopSelectShopNameByShopid();
                shopItem  = new ShopItem(shopID);
                shopItems = shopItem.SelectByClubShopID();
                break;

            case 262:
                shopInfos = shopInfo.BossShopSelectShopNameByShopid();
                shopItem  = new ShopItem(shopID);
                shopItems = shopItem.SelectByBossShopID();
                break;

            default:
                break;
            }



            FlexBublbe flexBublbe = new FlexBublbe();

            flexBublbe.contents.contents[0].body.contents[1].text = shopInfos[0].ShopName;


            flexBublbe.contents.contents[0].body.contents[3].contents = new List <FlexBublbe.Content>();
            FlexBublbe.Content content = new FlexBublbe.Content();



            foreach (ShopItem shopItemm in shopItems)
            {
                content        = new FlexBublbe.Content();
                content.type   = "box";
                content.layout = "horizontal";
                //flexBublbe.contents.contents[0].body.contents[3].contents.Add(content);
                ShopItemText shopItemText = new ShopItemText();
                shopItemText.type  = "text";
                shopItemText.text  = shopItemm.shopItem;
                shopItemText.size  = "md";
                shopItemText.color = "#111111";
                content.contents.Add(shopItemText);
                shopItemText       = new ShopItemText();
                shopItemText.type  = "text";
                shopItemText.text  = shopItemm.ShopItemPrice.ToString("0.##") + "  TWD";
                shopItemText.size  = "md";
                shopItemText.color = "#111111";
                shopItemText.align = "end";
                content.contents.Add(shopItemText);
                flexBublbe.contents.contents[0].body.contents[3].contents.Add(content);
            }

            flexBublbe.contents.contents[0].body.contents.Add(new PartitionLine());

            //底下Btn
            FooterBtn      footerBtn      = new FooterBtn();
            NextHelper     nextHelper     = new NextHelper(QID, OID);
            QuestionDetail questionDetail = nextHelper.GetNext();

            footerBtn.contents[0].action.data = $"{DateTime.Now},{questionDetail.QID},{questionDetail.OID},{shopID}";
            PreviousHelper previousHelper = new PreviousHelper(QID, OID);

            questionDetail = previousHelper.GetPrevious();
            footerBtn.contents[1].action.data = $"{DateTime.Now},{questionDetail.QID},{questionDetail.OID},{shopID}";
            flexBublbe.contents.contents[0].body.contents.Add(footerBtn);



            JsonSerializerSettings settings = new JsonSerializerSettings();

            settings.NullValueHandling = NullValueHandling.Ignore;
            var json = JsonConvert.SerializeObject(flexBublbe, settings);

            //  string json = JsonConvert.SerializeObject(flexBublbe);

            return("[" + json + "]");
        }