internal static string ClubMakeWeekFlex(string UserID, int QIDnow, int OIDnow, string shopID) { WeekFlex weekFlex = new WeekFlex(); weekFlex.contents.contents[0].body.contents[1].text = "選擇固定星期 (可複選)"; for (int i = 0; i < 7; i++) { weekFlex.contents.contents[0].body.contents[3].contents[i].action.data = $"{DateTime.Now},142,21,{i + 1}"; } weekFlex.contents.contents[0].body.contents[3].contents[7].action.data = $"{DateTime.Now},142,3,"; PeriodOrderTmp periodOrderTmp = new PeriodOrderTmp(UserID);//此處開始檢查按鈕有沒有被按下 periodOrderTmp.SelectAllByUserID(); string selectColor = "#4b607c";//在此處更改已選擇按鈕顏色 if (periodOrderTmp.Monday == "Y") { weekFlex.contents.contents[0].body.contents[3].contents[0].color = selectColor; } if (periodOrderTmp.Tuesday == "Y") { weekFlex.contents.contents[0].body.contents[3].contents[1].color = selectColor; } if (periodOrderTmp.Wednesday == "Y") { weekFlex.contents.contents[0].body.contents[3].contents[2].color = selectColor; } if (periodOrderTmp.Thursday == "Y") { weekFlex.contents.contents[0].body.contents[3].contents[3].color = selectColor; } if (periodOrderTmp.Friday == "Y") { weekFlex.contents.contents[0].body.contents[3].contents[4].color = selectColor; } if (periodOrderTmp.Saturday == "Y") { weekFlex.contents.contents[0].body.contents[3].contents[5].color = selectColor; } if (periodOrderTmp.Sunday == "Y") { weekFlex.contents.contents[0].body.contents[3].contents[6].color = selectColor; } JsonSerializerSettings settings = new JsonSerializerSettings(); settings.NullValueHandling = NullValueHandling.Ignore; var json = JsonConvert.SerializeObject(weekFlex, settings); return("[" + json + "]"); }
internal void process(Event item, ReceievedMessage receivedMessage, string channelAccessToken, Bot bot) { string userDisplayName = isRock.LineBot.Utility.GetUserInfo(item.source.userId, channelAccessToken).displayName; UserStatus userStatus = new UserStatus(item.source.userId, userDisplayName); userStatus.InitializeByUserID(); PeriodOrderTmp periodOrderTmp = new PeriodOrderTmp(item.source.userId); periodOrderTmp.InsertInitialPeriodOrderTmp(); OrderTemp orderTmp = new OrderTemp(item.source.userId); orderTmp.InsertInitialOrderTmp(); ShopTemp shopTemp = new ShopTemp(item.source.userId); shopTemp.InsertInitialShopTemp(); }
internal static string CheckPeriodOrderTmpWeek(string userId, int QID, int OID, string selectWeekofDay) { PeriodOrderTmp periodOrderTmp = new PeriodOrderTmp(userId); periodOrderTmp.WeekofDaySelectByUserID(); switch (selectWeekofDay) { case "1": switch (periodOrderTmp.Monday) { case "Y": periodOrderTmp.UpdateWeekofDayToNo(selectWeekofDay); return("取消選擇了星期一"); case "N": periodOrderTmp.UpdateWeekofDayToYes(selectWeekofDay); return("選擇了星期一"); default: break; } break; case "2": switch (periodOrderTmp.Tuesday) { case "Y": periodOrderTmp.UpdateWeekofDayToNo(selectWeekofDay); return("取消選擇了星期二"); case "N": periodOrderTmp.UpdateWeekofDayToYes(selectWeekofDay); return("選擇了星期二"); default: break; } break; case "3": switch (periodOrderTmp.Wednesday) { case "Y": periodOrderTmp.UpdateWeekofDayToNo(selectWeekofDay); return("取消選擇了星期三"); case "N": periodOrderTmp.UpdateWeekofDayToYes(selectWeekofDay); return("選擇了星期三"); default: break; } break; case "4": switch (periodOrderTmp.Thursday) { case "Y": periodOrderTmp.UpdateWeekofDayToNo(selectWeekofDay); return("取消選擇了星期四"); case "N": periodOrderTmp.UpdateWeekofDayToYes(selectWeekofDay); return("選擇了星期四"); default: break; } break; case "5": switch (periodOrderTmp.Friday) { case "Y": periodOrderTmp.UpdateWeekofDayToNo(selectWeekofDay); return("取消選擇了星期五"); case "N": periodOrderTmp.UpdateWeekofDayToYes(selectWeekofDay); return("選擇了星期五"); default: break; } break; case "6": switch (periodOrderTmp.Saturday) { case "Y": periodOrderTmp.UpdateWeekofDayToNo(selectWeekofDay); return("取消選擇了星期六"); case "N": periodOrderTmp.UpdateWeekofDayToYes(selectWeekofDay); return("選擇了星期六"); default: break; } break; case "7": switch (periodOrderTmp.Sunday) { case "Y": periodOrderTmp.UpdateWeekofDayToNo(selectWeekofDay); return("取消選擇了星期日"); case "N": periodOrderTmp.UpdateWeekofDayToYes(selectWeekofDay); return("選擇了星期日"); default: break; } break; default: break; } return("系統錯誤"); }
internal static bool CommunicatePeriodOrderTmpForDate(string userId, int QID, int OID, string seletedDateTimeStatus, string selecteddateTime, string channelAccessToken) { PeriodOrderTmp periodOrderTmp = new PeriodOrderTmp(userId); DateTime dateTime = Convert.ToDateTime(selecteddateTime); bool BothTimeHasFilledIn = false; string message = ""; if (DateTimeChecker.DateTimeCheckIsEarlierThanNowForPeriod(dateTime)) { message = "不要選擇過時的時間哦~"; } else { switch (seletedDateTimeStatus) { case "start": //先判斷有沒有比暫存結束時間晚 if (!DateTimeChecker.DateTimeCompareIsLaterThanEndTime(dateTime, periodOrderTmp)) { periodOrderTmp.StartDate = dateTime; periodOrderTmp.UpdateStartDate(); BothTimeHasFilledIn = periodOrderTmp.CheckBothDateHasFilledIn(periodOrderTmp); if (!BothTimeHasFilledIn) { message = $"週期開始日期: {dateTime.ToShortDateString()}"; } else { isRock.LineBot.Utility.PushMessage(userId, $"週期開始日期: {dateTime.ToShortDateString()}", channelAccessToken); message = "選擇時間完畢!"; } } else { message = "開始時間無法比結束時間晚~"; } break; case "end": //先判斷有沒有比暫存結束時間晚 if (!DateTimeChecker.DateTimeCompareIsEarlierThanStartTime(dateTime, periodOrderTmp)) { periodOrderTmp.EndDate = dateTime; periodOrderTmp.UpdateEndDate(); BothTimeHasFilledIn = periodOrderTmp.CheckBothDateHasFilledIn(periodOrderTmp); if (!BothTimeHasFilledIn) { message = $"週期結束日期: {dateTime.ToShortDateString()}"; } else { isRock.LineBot.Utility.PushMessage(userId, $"週期結束日期: {dateTime.ToShortDateString()}", channelAccessToken); message = "選擇時間完畢!"; } } else { message = "開始時間無法比結束時間晚哦~"; } break; default: break; } } isRock.LineBot.Utility.PushMessage(userId, message, channelAccessToken); return(BothTimeHasFilledIn); }
internal static string ClubPeriodOrderCommunicate(string userId, int QID, int OID, string OrderName, string channelAccessToken) { PeriodOrderTmp periodOrderTmp = new PeriodOrderTmp(userId); periodOrderTmp.SelectAllByUserID(); OrderInfo orderinfo = new OrderInfo(); //準備輸入SQL switch (QID) //根據QID不同初始化clubOrderAndMyOrder { case 251: periodOrderTmp.ClubIDSelectByUserID(); //撈取ClubID orderinfo = new OrderInfo(periodOrderTmp.ClubID, OrderName); break; default: break; } //切割週期時間 DateTime st1 = periodOrderTmp.StartDate.Add(periodOrderTmp.StartTime); //第一次開單時間點 DateTime et1 = periodOrderTmp.EndDate.Add(periodOrderTmp.StartTime); //最後一次開單時間點 DateTime st2 = periodOrderTmp.StartDate.Add(periodOrderTmp.EndTime); //第一次收單時間點 DateTime et2 = periodOrderTmp.EndDate.Add(periodOrderTmp.EndTime); //最後一次收單時間點 List <string> weekList = new List <string>(); if (periodOrderTmp.Monday == "Y") { weekList.Add("Monday"); } if (periodOrderTmp.Tuesday == "Y") { weekList.Add("Tuesday"); } if (periodOrderTmp.Wednesday == "Y") { weekList.Add("Wednesday"); } if (periodOrderTmp.Thursday == "Y") { weekList.Add("Thursday"); } if (periodOrderTmp.Friday == "Y") { weekList.Add("Friday"); } if (periodOrderTmp.Saturday == "Y") { weekList.Add("Saturday"); } if (periodOrderTmp.Sunday == "Y") { weekList.Add("Sunday"); } List <DateTime> dateTimes = PeriodSplitter.Cut(st1, et1, weekList); //得到每次的開單時間點 List <DateTime> dateTimes2 = PeriodSplitter.Cut(st2, et2, weekList); //得到每次的收單時間點 orderinfo.OrderType = "Period"; orderinfo.OrderStatus = "wait"; //開始撈取使用者選擇的複數商店 ShopListTemp shopListTemp = new ShopListTemp(userId); List <ShopListTemp> shopListTemps = shopListTemp.SelectByUserID(); //選取的商店清單 List <ShopListTemp> randomshopListTemps = new List <ShopListTemp>(); //準備一個要裝進符合選取天數的清單 //將randomshopListTemps打亂 while (randomshopListTemps.Count <= dateTimes.Count) { for (int i = 0; i < shopListTemps.Count; i++) { Swap(shopListTemps); } for (int i = 0; i < shopListTemps.Count; i++) { randomshopListTemps.Add(shopListTemps[i]); } } int result = 0; int count = 0; //用來檢查迴圈有沒有跑完 string clubOrderAndMyOrderID; switch (QID) { case 251: clubOrderAndMyOrderID = orderinfo.OrderID; for (int i = 0; i < dateTimes.Count; i++) { orderinfo.StartTime = dateTimes[i]; orderinfo.EndTime = dateTimes2[i]; orderinfo.ShopID = randomshopListTemps[i].ShopID; orderinfo.OrderPartitionID = "COP" + clubOrderAndMyOrderID + $"-{ dateTimes[i].ToString("yyyyMMdd")}"; result = orderinfo.InserClubOrderTableToSQL(); if (result <= 0) { break; } count++; } break; default: break; } if (count == dateTimes.Count) { UserStatus userStatus = new UserStatus(userId); userStatus.InitializeUserStatusByUserID(); periodOrderTmp = new PeriodOrderTmp(userId); periodOrderTmp.UpdateInitialPeriodOrderTmp(); shopListTemp.DeleteByUserID(); return("訂單建立成功"); } else { return("訂單建立失敗"); } }
internal static string MyPeriodOrderCommunicate(string userId, int QID, int OID, string OrderName, string channelAccessToken) { PeriodOrderTmp periodOrderTmp = new PeriodOrderTmp(userId); periodOrderTmp.SelectAllByUserID(); OrderInfo orderinfo = new OrderInfo(); //準備輸入SQL switch (QID) //根據QID不同初始化clubOrderAndMyOrder { case 211: orderinfo = new OrderInfo(userId, OrderName); break; default: break; } //切割週期時間 DateTime st1 = periodOrderTmp.StartDate.Add(periodOrderTmp.StartTime); //第一次開單時間點 DateTime et1 = periodOrderTmp.EndDate.Add(periodOrderTmp.StartTime); //最後一次開單時間點 DateTime st2 = periodOrderTmp.StartDate.Add(periodOrderTmp.EndTime); //第一次收單時間點 DateTime et2 = periodOrderTmp.EndDate.Add(periodOrderTmp.EndTime); //最後一次收單時間點 if (DateTimeChecker.DateTimeCheckIsEarlierThanNow(st1)) //週期單開始時間點若是比現在時間點早則往後一天 { st1 = st1.AddDays(1); st2 = st2.AddDays(1); } List <string> weekList = new List <string>(); if (periodOrderTmp.Monday == "Y") { weekList.Add("Monday"); } if (periodOrderTmp.Tuesday == "Y") { weekList.Add("Tuesday"); } if (periodOrderTmp.Wednesday == "Y") { weekList.Add("Wednesday"); } if (periodOrderTmp.Thursday == "Y") { weekList.Add("Thursday"); } if (periodOrderTmp.Friday == "Y") { weekList.Add("Friday"); } if (periodOrderTmp.Saturday == "Y") { weekList.Add("Saturday"); } if (periodOrderTmp.Sunday == "Y") { weekList.Add("Sunday"); } List <DateTime> dateTimes = PeriodSplitter.Cut(st1, et1, weekList); //得到每次的開單時間點 List <DateTime> dateTimes2 = PeriodSplitter.Cut(st2, et2, weekList); //得到每次的收單時間點 // orderinfo.OrderType = "Period"; orderinfo.OrderStatus = "wait"; //開始撈取使用者選擇的複數商店 ShopListTemp shopListTemp = new ShopListTemp(userId); List <ShopListTemp> shopListTemps = shopListTemp.SelectByUserID(); //選取的商店清單 List <ShopListTemp> randomshopListTemps = new List <ShopListTemp>(); //準備一個要裝進符合選取天數的清單 //將randomshopListTemps打亂 while (randomshopListTemps.Count <= dateTimes.Count) { for (int i = 0; i < shopListTemps.Count; i++) { Swap(shopListTemps); } for (int i = 0; i < shopListTemps.Count; i++) { randomshopListTemps.Add(shopListTemps[i]); } } // int result = 0; int count = 0; //用來檢查迴圈有沒有跑完 string OrderID; switch (QID) { case 211: OrderID = orderinfo.OrderID; for (int i = 0; i < dateTimes.Count; i++) { orderinfo.StartTime = dateTimes[i]; orderinfo.EndTime = dateTimes2[i]; orderinfo.ShopID = randomshopListTemps[i].ShopID; orderinfo.OrderPartitionID = "MOP" + OrderID + $"-{ dateTimes[i].ToString("yyyyMMdd")}"; result = orderinfo.InserMyOrderTableToSQL(); if (result <= 0) { break; } count++; } break; default: break; } if (count == dateTimes.Count) { UserStatus userStatus = new UserStatus(userId); userStatus.InitializeUserStatusByUserID(); periodOrderTmp = new PeriodOrderTmp(userId); periodOrderTmp.UpdateInitialPeriodOrderTmp(); orderinfo.InsertOrdeUserTable(); shopListTemp.DeleteByUserID(); isRock.LineBot.Utility.PushMessage(userId, orderinfo.OrderID, channelAccessToken); // string orderCreateMessage = "上面是你的訂單參加碼,可以將此參加碼分享給其他人,讓其他人加入你的訂單喔~"; // isRock.LineBot.Utility.PushMessage(userId, orderCreateMessage, channelAccessToken); return("訂單建立成功喔~~\n上面是你的訂單參加碼,可以將此參加碼分享給其他人,讓其他人加入你的訂單喔~"); } else { return("訂單建立失敗"); } }
internal static bool CommunicatePeriodOrderTmpTime(string userId, int QID, int OID, string seletedDateTimeStatus, string selecteddateTime, string channelAccessToken) { PeriodOrderTmp periodOrderTmp = new PeriodOrderTmp(userId); TimeSpan dateTime = TimeSpan.Parse(selecteddateTime); bool BothTimeHasFilledIn = false; string message = ""; switch (seletedDateTimeStatus) { case "start": //先判斷有沒有比暫存結束時間晚 if (!DateTimeChecker.TimeCompareIsLaterThanEndTime(dateTime, periodOrderTmp)) { periodOrderTmp.StartTime = dateTime; periodOrderTmp.UpdateStartTime(); BothTimeHasFilledIn = periodOrderTmp.CheckBothTimeHasFilledIn(periodOrderTmp); if (!BothTimeHasFilledIn) { message = $"每次開單時間: {dateTime.ToString(@"hh\:mm")}"; } else { isRock.LineBot.Utility.PushMessage(userId, $"每次開單時間: {dateTime.ToString(@"hh\:mm")}", channelAccessToken); message = "選擇時間完畢!"; } } else { message = "開始時間無法比結束時間晚~"; } break; case "end": //先判斷有沒有比暫存結束時間晚 if (!DateTimeChecker.TimeCompareIsEarlierThanStartTime(dateTime, periodOrderTmp)) { periodOrderTmp.EndTime = dateTime; periodOrderTmp.UpdateEndTime(); BothTimeHasFilledIn = periodOrderTmp.CheckBothTimeHasFilledIn(periodOrderTmp); if (!BothTimeHasFilledIn) { message = $"每次結單時間: {dateTime.ToString(@"hh\:mm")}"; } else { isRock.LineBot.Utility.PushMessage(userId, $"每次結單時間: {dateTime.ToString(@"hh\:mm")}", channelAccessToken); message = "選擇時間完畢!"; } } else { message = "開單時間無法比結單時間晚哦~"; } break; default: break; } isRock.LineBot.Utility.PushMessage(userId, message, channelAccessToken); return(BothTimeHasFilledIn); }
internal static ImagemapMessage MakeMenu(Event item) { // 先做初始化 UserStatus userStatus = new UserStatus(item.source.userId); userStatus.InitializeUserStatusByUserID(); ShopTemp shopTemp = new ShopTemp(item.source.userId); shopTemp.InitializeShopTempByUserID(); shopTemp.DeleteShopItemTempByUserID(); OrderTemp orderTemp = new OrderTemp(item.source.userId); orderTemp.UpdateInitialOrderTemp(); PeriodOrderTmp periodOrderTmp = new PeriodOrderTmp(item.source.userId); periodOrderTmp.UpdateInitialPeriodOrderTmp(); ShopListTemp shopListTemp = new ShopListTemp(item.source.userId); shopListTemp.DeleteByUserID(); BuyerTemp buyerTemp = new BuyerTemp(item.source.userId); buyerTemp.DeleteByBuyerID(); // 先做初始化 ImagemapMessage imagemapMessage = new ImagemapMessage(); Uri uri = new Uri("https://i220.photobucket.com/albums/dd130/jung_04/Menu2.png#"); imagemapMessage.baseUrl = uri; imagemapMessage.altText = "這是imagemap"; Size size = new Size(1040, 1040); imagemapMessage.baseSize = size; #region LeftUp isRock.LineBot.ImagemapArea imagemapAreaLeftUp = new isRock.LineBot.ImagemapArea() { x = 0, y = 0, width = 520, height = 520 }; isRock.LineBot.ImagemapMessageAction imagemapMessageActionLeftUp = new ImagemapMessageAction(); imagemapMessageActionLeftUp.area = imagemapAreaLeftUp; imagemapMessageActionLeftUp.text = "我要進入訂單模式!!!"; imagemapMessage.actions.Add(imagemapMessageActionLeftUp); #endregion #region RightUp isRock.LineBot.ImagemapArea imagemapAreaRightUp = new isRock.LineBot.ImagemapArea() { x = 520, y = 0, width = 520, height = 520 }; isRock.LineBot.ImagemapMessageAction imagemapMessageActionRightUp = new ImagemapMessageAction(); imagemapMessageActionRightUp.area = imagemapAreaRightUp; imagemapMessageActionRightUp.text = "我要進入個人模式!!!"; imagemapMessage.actions.Add(imagemapMessageActionRightUp); #endregion #region LeftDown isRock.LineBot.ImagemapArea imagemapAreaLeftDown = new isRock.LineBot.ImagemapArea() { x = 0, y = 520, width = 520, height = 520 }; isRock.LineBot.ImagemapMessageAction imagemapMessageActionLeftDown = new ImagemapMessageAction(); imagemapMessageActionLeftDown.area = imagemapAreaLeftDown; imagemapMessageActionLeftDown.text = "我要進入社團模式!!!"; imagemapMessage.actions.Add(imagemapMessageActionLeftDown); #endregion #region RightDown var actions1 = new List <isRock.LineBot.ImagemapActionBase>(); isRock.LineBot.ImagemapArea imagemapAreaRightDown = new isRock.LineBot.ImagemapArea() { x = 520, y = 520, width = 520, height = 520 }; isRock.LineBot.ImagemapMessageAction imagemapMessageActionRightDown = new ImagemapMessageAction(); imagemapMessageActionRightDown.area = imagemapAreaRightDown; imagemapMessageActionRightDown.text = "我要進入商店模式!!!"; imagemapMessage.actions.Add(imagemapMessageActionRightDown); #endregion return(imagemapMessage); }