コード例 #1
0
ファイル: FlexMaker.cs プロジェクト: OTL90104/OrderBOT
        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 + "]");
        }