示例#1
0
        public IEnumerable <string> Get()
        {
            //byte[] result = _memoryCache.Get("Terminal:800020002");
            Common.Redis.Helper redisHelper = new Common.Redis.Helper();
            string tt   = redisHelper.StringGet("TT:tt");
            string s    = _memoryCache.GetString("tt");
            long   time = Common.Time.GetUTCTimestamp(DateTime.Now);

            Models.IOT.Instruction ins = Data.Instruction.Get("9755100001");
            //return result;
            return(new string[] { "value1", "value2" });
        }
示例#2
0
        public override JObject Send(long terminalID, string uniCode, string apiURL, string accessSecret = null)
        {
            Models.IOT.Command cmd         = this.Create(terminalID, uniCode);
            JObject            requestBody = new JObject();

            requestBody.Add("TerminalID", terminalID);
            requestBody.Add("HexPacket", cmd.HexPacket);

            string key       = "Terminal:" + terminalID;
            string transeURL = new Common.Redis.Helper().HashGet(key, "TranseURL");
            string response  = Common.HttpClientHelper.HttpPost(transeURL, requestBody.ToString(Newtonsoft.Json.Formatting.None));

            return(JObject.Parse(response));
        }
示例#3
0
        /// <summary>
        ///
        /// </summary>
        /// <returns></returns>
        public static Models.IOT.Instruction Get(string unicode)
        {
            string key  = "INS:" + unicode;
            string json = new Common.Redis.Helper().StringGet(key);

            if (!string.IsNullOrEmpty(json))
            {
                Models.IOT.Instruction ins = Newtonsoft.Json.JsonConvert.DeserializeObject <Models.IOT.Instruction>(json);
                ins.Cmd = ins.Cmd.Replace("-", "").Replace(" ", "");
                if (!string.IsNullOrEmpty(ins.ChildCmd))
                {
                    ins.ChildCmd = ins.ChildCmd.Replace("-", "").Replace(" ", "");
                }
                return(ins);
            }

            return(null);
        }
示例#4
0
        public string Send([FromBody] JObject jObject)
        {
            uint   terminalID = (uint)jObject["TerminalID"];
            string uniCode    = jObject["UniCode"].ToString();
            bool   Top        = false;

            if (jObject["Top"] != null)
            {
                Top = (bool)jObject["Top"];
            }

            if (Top)
            {
                //转发该参数
                return("该功能还未实现!");
            }

            Common.Redis.Helper redis = new Common.Redis.Helper();
            string key          = "Terminal:" + terminalID;
            string accessSecret = redis.HashGet("Access", "TranseURL");
            string transeURL    = redis.HashGet(key, "TranseURL");
            string tlp          = "TCP";//默认TCP
            string cacheTLP     = redis.HashGet(key, "TLP");

            if (!string.IsNullOrWhiteSpace(cacheTLP))
            {
                tlp = cacheTLP;
            }

            string instanceName = "ZeYu.Intelligence.WebAPI.Business." + tlp;

            Business.AbstractCommand instance = Assembly.Load("ZeYu.Intelligence.WebAPI").CreateInstance(instanceName) as Business.AbstractCommand;

            string response = instance.Send(terminalID, uniCode, transeURL, null).ToString();

            //Models.IOT.Command cmd = instance.Create (terminalID, uniCode); //,transeURL,accessSecret
            //string postCmdData = JsonConvert.SerializeObject(cmd);

            //string response = Common.HttpClientHelper.Request(transeURL, System.Text.Encoding.UTF8 ,postCmdData);


            return(response);
        }