public bool SendCMD(int id, string value) { bool bSend = false; if (!string.IsNullOrWhiteSpace(id.ToString())) { using (LedDb db = new LedDb()) { string strError = string.Empty; GlareSysEfDbAndModels.CmdLogs aLog = new GlareSysEfDbAndModels.CmdLogs() { CardInfoId = id, CmdInfo = value, CmdType = GlareLedSysDefPub.CmdDefSetOilValue, CommDevId = id, CreateTime = DateTime.Now, IsDetele = 0, Result = 0, ResultInfo = "", UpdateTime = DateTime.Now }; bSend = CmdLogsBll.AddCommDevInfo(ref aLog, out strError); bSend = InsertCmdToMemcached(aLog.Id); if (bSend) { for (int i = 1; i < 10; i++) { Thread.Sleep(1000); if (RemoveCmdHandledInMemcached(aLog.Id)) { bSend = true; break; } } } } } else { bSend = false; } return(bSend); }
/// <summary> /// 设置小数点 /// </summary> /// <param name="point"></param> /// <returns></returns> public bool SetPoint(int id, int IsDouble, int ScreenCount, string CardModel, int CardPointCount) { string strCardPointCount = string.Format("{0}-{0}-{0}-{0}-{0}-{0}-{0}-{0}-{0}-{0}-{0}-{0}", CardPointCount); // 设置小数点位数 GlareSysEfDbAndModels.CmdLogs cmd = new GlareSysEfDbAndModels.CmdLogs() { CardInfoId = 1, CmdInfo = strCardPointCount,//(默认重复12次,如果carkpoint是2,那么就是2-2-2-2....-2,如果是1则是1-1-1-1...-1),Web界面Add一个save界面 CmdType = GlareLedSysDefPub.CmdDefSetOilDigiCfg, CommDevId = 1, CreateTime = DateTime.Now, Id = 0, IsDetele = 0, Result = 0, ResultInfo = "", UpdateTime = DateTime.Now }; string strError = ""; CmdLogsBll.AddCommDevInfo(ref cmd, out strError); bool bSend = InsertCmdToMemcached(cmd.Id); bool bRecived = false; if (bSend) { for (int i = 1; i < 10; i++) { Thread.Sleep(1000); if (RemoveCmdHandledInMemcached(cmd.Id)) { bRecived = true; break; } } } if (bRecived) { SaveDev(id, IsDouble, ScreenCount, CardModel, CardPointCount); } return(bRecived); }
public ActionResult Setcfg(int id, int IsDouble, int ScreenCount, string CardModel, int CardPointCount) { object objResult = null; if (!string.IsNullOrWhiteSpace(id.ToString())) { using (LedDb db = new LedDb()) { string strError = string.Empty; //1 //双面显示(单面为0x00) isdouble //3 //一面三个牌 screencount //5 //每个牌5个8(包含小8) 价格数字的数量(CardModel,例如:GL-88888,那就填写5,GL-88888-8(上标小字),填写6 //0 //是否显示9/10(如果是GL-888-8-910,则为1,否则为0) //8 //亮度等级,永远写8 string CmdInfo = ""; if (IsDouble == 1)//双面显示 { CmdInfo = "1"; } else { CmdInfo = "0x00"; } CmdInfo = CmdInfo + "-" + ScreenCount.ToString();//screencount string strEightModel = CardModel.Replace("GL", "").Replace("-", ""); int iEightCount = strEightModel.Length; CmdInfo = CmdInfo + "-" + iEightCount.ToString(); //每个牌5个8(包含小8) if (CardModel.Contains("910")) //是否显示9/10 { CmdInfo = CmdInfo + "-1"; } else { CmdInfo = CmdInfo + "-0"; } CmdInfo = CmdInfo + "-8";//亮度 GlareSysEfDbAndModels.CmdLogs cmd = new GlareSysEfDbAndModels.CmdLogs() { CardInfoId = id, CmdInfo = CmdInfo, CmdType = GlareLedSysDefPub.CmdDefSetOilCfg, CommDevId = id, CreateTime = DateTime.Now, Id = 0, IsDetele = 0, Result = 0, ResultInfo = "", UpdateTime = DateTime.Now }; CmdLogsBll.AddCommDevInfo(ref cmd, out strError); bool bSend = InsertCmdToMemcached(cmd.Id); bool bRecived = false; if (bSend) { for (int i = 1; i < 10; i++) { Thread.Sleep(1000); if (RemoveCmdHandledInMemcached(cmd.Id)) { bRecived = true; break; } } } if (bRecived) { bool bSetPoint = SetPoint(id, IsDouble, ScreenCount, CardModel, CardPointCount); if (bSetPoint) { objResult = new ResultHelper() { Desc = "Command issued Success", Msg = "Command issued Success", Obj = cmd, Ret = 1, Status = true }; } else { objResult = new ResultHelper() { Desc = "Setcfg Success,Command issued Faile,please try again", Msg = "Setcfg Success,Command issued Faile,please try again", Obj = cmd, Ret = -1, Status = false }; } } else { objResult = new ResultHelper() { Status = false, Ret = -1, Obj = null, Msg = strError, Desc = strError }; } } } else { objResult = new ResultHelper() { Status = false, Ret = -1, Obj = null, Msg = "id is null,Please try again later", Desc = "id is null,Please try again later" }; } return(Json(objResult)); }
public ActionResult SendCMD(int id, string value) { object objResult = null; if (!string.IsNullOrWhiteSpace(id.ToString())) { using (LedDb db = new LedDb()) { string strError = string.Empty; GlareSysEfDbAndModels.CmdLogs aLog = new GlareSysEfDbAndModels.CmdLogs() { CardInfoId = id, CmdInfo = value, CmdType = GlareLedSysDefPub.CmdDefSetOilValue, CommDevId = id, CreateTime = DateTime.Now, IsDetele = 0, Result = 0, ResultInfo = "", UpdateTime = DateTime.Now }; bool bSend = CmdLogsBll.AddCommDevInfo(ref aLog, out strError); bSend = InsertCmdToMemcached(aLog.Id); bool bRecived = false; if (bSend) { for (int i = 1; i < 10; i++) { Thread.Sleep(1000); if (RemoveCmdHandledInMemcached(aLog.Id)) { bRecived = true; break; } } } if (bRecived) { objResult = new ResultHelper() { Desc = "Command issued Success", Msg = "Command issued Success", Obj = aLog, Ret = 1, Status = true }; } else { objResult = new ResultHelper() { Status = false, Ret = -1, Obj = null, Msg = strError, Desc = strError }; } } } else { objResult = new ResultHelper() { Status = false, Ret = -1, Obj = null, Msg = "id is null,Please try again later", Desc = "id is null,Please try again later" }; } return(Json(objResult)); }