Beispiel #1
0
        internal static string CommunicateUserInfo(string userId, int QID, int OID, string postbackData, string channelAccessToken)
        {
            UserStatus userStatus;
            OrderInfo  orderInfo;
            int        result;

            switch (QID)
            {
            case 71:
                switch (OID)
                {
                case 3:
                    // 先拿到UserStatus裡面的TempData,上一步存的是OrderID
                    userStatus = new UserStatus(userId);
                    userStatus.SelectByUserID();

                    // 把資料存進OrderUserTable裡
                    orderInfo         = new OrderInfo(userId);
                    orderInfo.OrderID = userStatus.TempData;
                    result            = orderInfo.InsertOrdeUserTable();

                    if (result > 0)
                    {
                        List <OrderInfo> list = orderInfo.SelectMyOrderByOrderID();
                        if (list[0].OrderStatus == "available")
                        {
                            string CheckMessage = "成功參加訂單~~\n此訂單正在推播中~~\n可以直接點選上面選項直接訂購喔~~";
                            //   isRock.LineBot.Utility.PushMessage(userId, CheckMessage, channelAccessToken);
                            OrderTemp orderTemp = new OrderTemp(userId);
                            orderTemp.OrderPartitionID = list[0].OrderPartitionID;
                            orderTemp.UpdateOrderPartitionIDByUserID();
                            string JasonMessage = FlexMaker.MakeSearchingItem(QID, OID, userId);
                            isRock.LineBot.Utility.PushMessagesWithJSON(userId, JasonMessage, channelAccessToken);
                            return(CheckMessage);
                        }
                        else
                        {
                            return("成功參加訂單");
                        }
                    }
                    else
                    {
                        return("參加訂單失敗");
                    }

                default:
                    break;
                }
                break;

            case 82:
                switch (OID)
                {
                case 2:
                    OrderTemp orderTemp = new OrderTemp(userId);
                    orderTemp.SelectByUserID();

                    orderInfo = new OrderInfo(userId);
                    orderInfo.OrderPartitionID = orderTemp.OrderPartitionID;
                    orderInfo.SelectMyOrderTableByOrderPartitionID();

                    switch (postbackData)
                    {
                    case "MyOrderPartition":             // 刪除我的週期性訂單的其中一筆
                        result = orderInfo.DeleteMyOrderPartitionByUserIDandOrderPartitionID();
                        if (result > 0)
                        {
                            return("成功刪除訂單");
                        }
                        else
                        {
                            return("刪除訂單失敗");
                        }

                    case "MyOrder":             // 刪除完整我的週期性訂單
                        result = orderInfo.DeleteMyOrderByUserIDandOrderID();
                        if (result > 0)
                        {
                            return("成功刪除訂單");
                        }
                        else
                        {
                            return("刪除訂單失敗");
                        }

                    case "MyOnceOrder":             // 刪除一次性我的訂單
                        result = orderInfo.DeleteMyOrderByUserIDandOrderID();
                        if (result > 0)
                        {
                            return("成功刪除訂單");
                        }
                        else
                        {
                            return("刪除訂單失敗");
                        }

                    default:
                        break;
                    }

                    break;

                default:
                    break;
                }
                break;

            default:
                break;
            }
            return("資料庫溝通失敗");
        }
Beispiel #2
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("資料庫溝通失敗");
        }