Exemple #1
0
        // 參數postbackData是藏在button裡,經由postback傳進來的
        // 參加社團和退出社團需要clubID,建立社團需要ClubName
        internal static string CommunicateClubInfo(string userId, int QID, int OID, string postbackData, string channelAccessToken)
        {
            UserStatus userStatus;
            ClubInfo   clubInfo;

            switch (QID)
            {
            case 91:
                switch (OID)
                {
                case 3:
                    try
                    {
                        clubInfo = new ClubInfo(userId, postbackData, "");           // 這裡的postbackData是clubID
                        clubInfo.InsertClubInfoToSQL();
                        OrderInfo        orderInfo    = new OrderInfo(postbackData); //ClubID
                        List <OrderInfo> list         = orderInfo.CheckClubOrderByUserID();
                        string           CheckMessage = "成功加入社團";
                        foreach (OrderInfo item in list)
                        {
                            if (item.OrderStatus == "available")
                            {
                                CheckMessage = "成功加入社團~~\n此社團有訂單正在推播中~~\n可以直接點選上面選項直接訂購喔~~";
                                //   isRock.LineBot.Utility.PushMessage(userId, CheckMessage, channelAccessToken);
                                OrderTemp orderTemp = new OrderTemp(userId);
                                orderTemp.OrderPartitionID = item.OrderPartitionID;
                                orderTemp.UpdateOrderPartitionIDByUserID();
                                string JasonMessage = FlexMaker.MakeSearchingItem(QID, OID, userId);
                                isRock.LineBot.Utility.PushMessagesWithJSON(userId, JasonMessage, channelAccessToken);
                                userStatus = new UserStatus(userId, 0, 0);
                                userStatus.UpdateByUserID();
                            }
                            //    return CheckMessage;
                        }

                        userStatus = new UserStatus(userId, 0, 0);
                        userStatus.UpdateByUserID();
                        return(CheckMessage);
                    }
                    catch (Exception e)
                    {
                        return("加入社團失敗,或是已加入社團");
                    }

                default:
                    break;
                }
                break;

            case 92:
                switch (OID)
                {
                case 3:
                    clubInfo = new ClubInfo(userId, postbackData);         // 這裡的postbackData是clubName
                    clubInfo.InsertClubInfoToSQL();
                    userStatus = new UserStatus(userId, 0, 0);
                    userStatus.UpdateByUserID();
                    isRock.LineBot.Utility.PushMessage(userId, clubInfo.ClubID, channelAccessToken);
                    return("你的社團已經建立嘍~~\n上方是你的社團參加碼~\n將此參加碼分享給要參加此社團的人~");

                default:
                    break;
                }
                break;

            case 102:
                switch (OID)
                {
                case 2:
                    clubInfo = new ClubInfo(userId, postbackData, "");
                    clubInfo.DeleteClubInfoToSQL();
                    userStatus = new UserStatus(userId, 0, 0);
                    userStatus.UpdateByUserID();
                    return(MessageMaker.MakeLeaveClubMessage(userId, QID, OID, postbackData));

                default:
                    break;
                }
                break;

            default:
                break;
            }
            return("資料庫溝通失敗");
        }