public static void DownScheduleHandler() { ServiceStack.Redis.IRedisClient client = GlobalVariable.RedisClient; while (true) { try { int count = client.GetListCount(GlobalVariable.PAGE_SEND_CONTENT); for (int i = 0; i < count; i++) { string strUserKey = client.DequeueItemFromList(GlobalVariable.PAGE_SEND_CONTENT); int machineId = client.Get <int>(GlobalVariable.PRE_DOWN_INFO_MACHINE + strUserKey); byte[] buff = client.Get <byte[]>(GlobalVariable.PRE_DOWN_INFO + strUserKey); string strUser = strUserKey.Substring(0, strUserKey.LastIndexOf('-')); int intUser = int.Parse(strUser); enumErrorCode result = CommunicateWithClient(machineId, buff, intUser); if (result != enumErrorCode.HandlerSuccess) { int intResult = (int)result; client.Set <int>(GlobalVariable.PRE_RESP_DOWN_INFO + strUserKey, intResult); } } } catch (Exception ex) { db.InsertErrorInfo(enumSystemErrorCode.TcpSenderException, ex, "outside", null); } Thread.Sleep(2000); } }
protected void setRedis(WMSModel.WMSData data) { //ServiceStack.Redis.RedisClient redisClient=new ServiceStack.Redis.RedisClient(); //redisClient. ServiceStack.Redis.IRedisClient redisClient = RedisManager.GetClient(); redisClient.Set <WMSModel.WMSData>("data", data); }
private enumErrorCode SendScheduleHandler(int machineId, byte[] buff, int userId, string infoType) { string strUserKey = string.Format("{0}-{1}", userId, DateTime.Now.ToString("yyyyMMddHHmmssFFF")); client.EnqueueItemOnList(PAGE_SEND_CONTENT, strUserKey); client.Set <int>(PRE_DOWN_INFO_MACHINE + strUserKey, machineId); client.Set(PRE_DOWN_INFO + strUserKey, buff); client.Set <string>(infoType + machineId.ToString(), strUserKey); enumErrorCode result = App_Start.TcpProtocolClient.WaittingSendForResp(strUserKey); client.Remove(PRE_DOWN_INFO_MACHINE + strUserKey); client.Remove(PRE_DOWN_INFO + strUserKey); client.Remove(infoType + machineId.ToString()); return(result); }
public ActionResult MachineEdit(int id, string Name, string RemarkInfo) { Machines machine = db.Machines.Find(id); db.Machines.Attach(machine); machine.Name = Name; machine.RemarkInfo = RemarkInfo; db.SaveChanges(); string strName = client.Get <string>(PRE_MACHINE_NAME_NUMBER + machine.Number); if (strName != null && strName != string.Empty) { client.Set <string>(PRE_MACHINE_NAME_NUMBER + machine.Number, Name); } return(RedirectToAction("Machines")); }
public byte[] HandlerClientData(byte[] buff) { NetStructure.ClientResp outInfo = this.DecodeData(buff); using (ServiceStack.Redis.IRedisClient client = GlobalVariable.RedisClient) { string strUserKey = client.Get <string>(GlobalVariable.PRE_INFO_TYPE_DISCARD + outInfo.MachineId.ToString()); client.Set <int>(GlobalVariable.PRE_RESP_DOWN_INFO + strUserKey, (int)outInfo.RespResult); } return(null); }
private void RefreshOnlineInfo(Machines machine) { const string ONLINE_FACTRORY_ROOM = "ONLINEFACTORYROOM", PRE_ROOM_NAME_NUMBER = "PREROOMNAMENUMBER", PRE_ONLINE_MACHINE = "PREONLINEMACHINE", PRE_MACHINE_NAME_NUMBER = "PREMACHINENAMENUMBER", PRE_ONLINE_TIME = "PREONLINETIME"; using (ServiceStack.Redis.IRedisClient client = GlobalVariable.RedisClient) { HashSet <string> roomList = client.GetAllItemsFromSet(ONLINE_FACTRORY_ROOM); if (!roomList.Contains(machine.RoomNumber)) { client.AddItemToSet(ONLINE_FACTRORY_ROOM, machine.RoomNumber); client.Set <string>(PRE_ROOM_NAME_NUMBER + machine.RoomNumber, machine.RoomName); } string strMachineValue = PRE_ONLINE_MACHINE + machine.RoomNumber; HashSet <string> machineList = client.GetAllItemsFromSet(strMachineValue); if (!machineList.Contains(machine.Number)) { client.AddItemToSet(strMachineValue, machine.Number); client.Set <string>(PRE_MACHINE_NAME_NUMBER + machine.Number, machine.Name); } client.Set <long>(PRE_ONLINE_TIME + machine.Number, DateTime.Now.Ticks); } }
public void Set(string key, string value) { LeavePipelining(); _client.Set(key, value); }