コード例 #1
0
        public ActionResult LostCoffee(CoffeeInit req)
        {
            var    clientInfo = this.TempData["ClientInfo"] as ClientInfo;
            string EtmID      = clientInfo.EtmCode;
            //string EtmID = "ETM0027";
            var list = ObjectXmlSerializer.LoadFromXml <List <CoffeeInit> >(Server.MapPath("~/cache/Coffee.xml"));

            if (list.Find(o => o.EtmID == EtmID).CupNumber < req.CupNumber)
            {
                return(this.Json(new { retCode = 1, Message = "提交失败,饮品剩余数量不足!" }));
            }
            list.Find(o => o.EtmID == EtmID).CupNumber -= req.CupNumber;
            //检测剩余杯数,发短信
            try
            {
                if (list.Find(o => o.EtmID == EtmID).CupNumber <= int.Parse(ConfigurationManager.AppSettings["EnableSmsCupNumber"]) && list.Find(o => o.EtmID == EtmID).SendSMS == "0" && ConfigurationManager.AppSettings["EnableSms"] == "true")
                {
                    list.Find(o => o.EtmID == EtmID).CupNumber = 1;
                    const string takedateUrl = "api/Coffee/SendSms";
                    var          fullPath    = ETong.Coffee.Web.Models.Config.GetApiFullPath(takedateUrl);
                    var          client      = new HttpClientUtility(new Uri(fullPath));
                    Logger.Write(Log.Log_Type.Info, string.Format("调用{0}", fullPath));
                    var resultT = SecurityHttpClient.Post <string, ResponseData <string> >(fullPath, EtmID);
                    Logger.Write(Log.Log_Type.Info, string.Format("{0}结束,result={1}", fullPath, Json(resultT.dataMap)));
                }
            }
            catch (Exception ex)
            {
                Logger.Write(Log.Log_Type.Info, string.Format("短信发送失败etmid={0},err={1}", EtmID, ex.ToString()));
            }
            Logger.Write(Log.Log_Type.Info, string.Format("减库存etmid={0},CupNumber={1}", EtmID, req.CupNumber));
            ObjectXmlSerializer.SaveToXml <List <CoffeeInit> >(Server.MapPath("~/cache/Coffee.xml"), list);
            return(this.Json(new { retCode = 0, Message = "成功" }));
        }
コード例 #2
0
 public void WriteSetting()
 {
     try
     {
         ObjectXmlSerializer.SaveToXml <RegSetting>(this.SETTING_PATH, RegSetting._instance);
     }
     catch (System.Exception err)
     {
         Log.WriteError("写入配置信息错误", err);
     }
 }
コード例 #3
0
        public ActionResult Rest()
        {
            var    clientInfo = this.TempData["ClientInfo"] as ClientInfo;
            string EtmID      = clientInfo.EtmCode;
            //string EtmID = "ETM0027";
            var list = ObjectXmlSerializer.LoadFromXml <List <CoffeeInit> >(Server.MapPath("~/cache/Coffee.xml"));

            list.Find(o => o.EtmID == EtmID).SendSMS   = "0";
            list.Find(o => o.EtmID == EtmID).CupNumber = list.Find(o => o.EtmID == "ETMDefault").CupNumber;
            ObjectXmlSerializer.SaveToXml <List <CoffeeInit> >(Server.MapPath("~/cache/Coffee.xml"), list);
            return(this.Json(new { retCode = 0, Message = "" }));
        }
コード例 #4
0
        public ActionResult Init()
        {
            var    clientInfo = this.TempData["ClientInfo"] as ClientInfo;
            string EtmID      = clientInfo.EtmCode;
            //string EtmID = "ETM0027";
            var list   = ObjectXmlSerializer.LoadFromXml <List <CoffeeInit> >(Server.MapPath("~/cache/Coffee.xml"));
            var result = list.Find(o => o.EtmID == EtmID);

            if (result == null)
            {
                var defaultResult = list.Find(o => o.EtmID == "ETMDefault");
                result           = (CoffeeInit)Copy(defaultResult);
                result.EtmID     = EtmID;
                result.DrinkList = null;
                list.Add(result);
                ObjectXmlSerializer.SaveToXml <List <CoffeeInit> >(Server.MapPath("~/cache/Coffee.xml"), list);
            }
            result.DrinkList = list.Find(o => o.EtmID == "ETMDefault").DrinkList;
            return(this.Json(result));
        }