示例#1
0
        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);
            }
        }
示例#2
0
        public static enumErrorCode WaittingSendForResp(string strKey)
        {
            int           intResp    = 0;
            string        strTempKey = PRE_RESP_DOWN_INFO + strKey;
            enumErrorCode sendResult;
            int           i = 0, iMax = 50;

            for (; i < iMax; i++)
            {
                intResp = client.Get <int>(strTempKey);
                if (intResp == 0)
                {
                    Thread.Sleep(100);
                    continue;
                }
                else
                {
                    break;
                }
            }
            if (intResp == 0)
            {
                sendResult = enumErrorCode.DeviceReciveTimeOut;
            }
            else
            {
                sendResult = (enumErrorCode)intResp;
                client.Remove(strTempKey);
            }

            return(sendResult);
        }
示例#3
0
        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"));
        }
示例#4
0
        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);
        }
示例#5
0
 public ActionResult GetData()
 {
     try
     {
         string name    = Request.QueryString["data"];
         bool   ret     = Regex.IsMatch(name, "[0-9]+");
         string channel = "";
         if (ret)
         {
             channel = name + "#阀室";
             using (ServiceStack.Redis.IRedisClient redis = RedisHelper.CreateRedisPool().GetClient())
             {
                 double[] rest = JsonConvert.DeserializeObject <double[]>(redis.Get <string>(channel));
                 return(Content(JsonConvert.SerializeObject(new Vala {
                     loggerName = channel, Data = rest[0].ToString("f2")
                 })));
             }
         }
         else
         {
             channel = name;
             List <string> list = new List <string>();
             using (ServiceStack.Redis.IRedisClient redis = RedisHelper.CreateRedisPool().GetClient())
             {
                 double[] rest = JsonConvert.DeserializeObject <double[]>(redis.Get <string>(channel));
                 foreach (double item in rest)
                 {
                     list.Add(item.ToString("f2"));
                 }
                 return(Content(JsonConvert.SerializeObject(new Station {
                     loggerName = channel, Data = list.ToArray()
                 })));
             }
         }
     }
     catch (System.Exception ex)
     {
         LogHelper.WriteLog(typeof(MapController), ex.StackTrace + ex.Message);
         return(null);
     }
 }
示例#6
0
 public string GetString(string key)
 {
     LeavePipelining();
     return(_client.Get <string>(key));
 }