public async Task goodsLineName(IDialogContext context, LuisResult result) { string machineLineNo = result.Entities[0].Entity; string machineStatus = HttpGet(STATUS_QUERY_URL, ""); QueryGoodsStatus goodsData = (QueryGoodsStatus)JsonConvert.DeserializeObject(machineStatus, typeof(QueryGoodsStatus)); if (true == goodsData.success) { StringBuilder MyStringBuilder = new StringBuilder(); string tempResult = ""; string goodsStockStatus = ""; //int goodsStockNo; for (int i = 0; i < goodsData.goodsdata.Length; i++) { if (goodsData.goodsdata[i].goodsno.ToString() == machineLineNo) { //shortageGoods.Add(goodsData.goodsdata[i]); //goodsStockNo = goodsData.goodsdata[i].goodsno; if (0 == goodsData.goodsdata[i].goodsstock) { goodsStockStatus = "有货"; } else { goodsStockStatus = "缺货"; } tempResult = goodsData.goodsdata[i].goodsno.ToString() + "货道" + "商品名称:" + goodsData.goodsdata[i].goodsname + goodsStockStatus; MyStringBuilder.Append(tempResult); MyStringBuilder.AppendLine(""); break; } } if (goodsStockStatus.Length > 1) { string finalStatusResult = MyStringBuilder.ToString(); await context.PostAsync("0127" + A_MACHINE_PRODUCT_STATUS + finalStatusResult); } else { await context.PostAsync("0127" + A_MACHINE_PRODUCT_STATUS + "货道" + machineLineNo + "不存在"); } } else { await context.PostAsync("无法查询到贩卖机状态,请稍后重试"); } //await context.PostAsync(machineNo + A_MACHINE_PRODUCT_STATUS + num1 + A_MACHINE_PRODUCT_STATUS1 + num2 + A_MACHINE_PRODUCT_STATUS2); //await context.PostAsync(machineStatus); context.Wait(MessageReceived); }
public async Task DecreaseTemp(IDialogContext context, LuisResult result) { Random rd = new Random(); int number1 = rd.Next(1, 50); int number2 = rd.Next(1, 15); int numMachine = rd.Next(1000, 2000); string num1 = Convert.ToString(number1); string num2 = Convert.ToString(number2); string machineNo = Convert.ToString(numMachine); string machineStatus = HttpGet(STATUS_QUERY_URL, ""); QueryGoodsStatus goodsData = (QueryGoodsStatus)JsonConvert.DeserializeObject(machineStatus, typeof(QueryGoodsStatus)); if (true == goodsData.success) { StringBuilder MyStringBuilder = new StringBuilder(); string tempResult = ""; for (int i = 0; i < goodsData.goodsdata.Length; i++) { if (goodsData.goodsdata[i].goodsstatus == 1) { tempResult = goodsData.goodsdata[i].goodsno.ToString() + "货道" + "故障" + "商品名称:" + goodsData.goodsdata[i].goodsname; MyStringBuilder.Append(tempResult); MyStringBuilder.AppendLine(""); } } string finalStatusResult = MyStringBuilder.ToString(); if (finalStatusResult.Length > 1) { await context.PostAsync("0127" + A_MACHINE_PRODUCT_STATUS + finalStatusResult); } await context.PostAsync("0127" + A_MACHINE_PRODUCT_STATUS + "工作正常"); } else { await context.PostAsync("无法查询到贩卖机状态,请稍后重试"); } //await context.PostAsync(machineNo + A_MACHINE_PRODUCT_STATUS + num1 + A_MACHINE_PRODUCT_STATUS1 + num2 + A_MACHINE_PRODUCT_STATUS2); //await context.PostAsync(machineStatus); context.Wait(MessageReceived); }
public async Task goodsStatus(IDialogContext context, LuisResult result) { string machineStatus = HttpGet(STATUS_QUERY_URL, ""); QueryGoodsStatus goodsData = (QueryGoodsStatus)JsonConvert.DeserializeObject(machineStatus, typeof(QueryGoodsStatus)); if (true == goodsData.success) { List <Goodsdata> shortageGoods = new List <Goodsdata>(); List <string> resultGoods = new List <string>(); StringBuilder MyStringBuilder = new StringBuilder(); string tempResult = ""; int goodsStockNo; for (int i = 0; i < goodsData.goodsdata.Length; i++) { if (goodsData.goodsdata[i].goodsstock == 1) { shortageGoods.Add(goodsData.goodsdata[i]); goodsStockNo = goodsData.goodsdata[i].goodsno; tempResult = goodsData.goodsdata[i].goodsno.ToString() + "货道" + goodsData.goodsdata[i].goodsname + "缺货"; MyStringBuilder.Append(tempResult); MyStringBuilder.AppendLine(""); } } string finalStatusResult = MyStringBuilder.ToString(); if (finalStatusResult.Length > 1) { await context.PostAsync("0127" + A_MACHINE_PRODUCT_STATUS + finalStatusResult); } else { await context.PostAsync("0127" + A_MACHINE_PRODUCT_STATUS + "货物充足"); } } else { await context.PostAsync("无法查询到贩卖机状态,请稍后重试"); } //await context.PostAsync(machineNo + A_MACHINE_PRODUCT_STATUS + num1 + A_MACHINE_PRODUCT_STATUS1 + num2 + A_MACHINE_PRODUCT_STATUS2); //await context.PostAsync(machineStatus); context.Wait(MessageReceived); }