Exemplo n.º 1
0
 public void Send(HttpContext context)
 {
     if (operaSocket.CONNECT_POOL.ContainsKey("002001"))
     {
         MechineUtil.sendErrorMsg("25", "4", "25", "1111");
     }
 }
Exemplo n.º 2
0
        public void SendLDError(HttpContext context)
        {
            try
            {
                string ldno      = context.Request["ldno"].ToString();
                string mechineID = context.Request["mechineID"].ToString();

                MechineUtil.sendErrorMsg(mechineID, "1", "", ldno);
            }
            catch {
            }
        }
Exemplo n.º 3
0
        /// <summary>
        /// 处理下位机长时间没有工作的异常警告
        /// </summary>
        /// <param name="mechineID">机器编号</param>
        /// <param name="samtypeString">下位机传回的json 数据</param>
        /// <returns></returns>
        public static async Task samtypeNew(string mechineID, string samtypeString, string mechineString)

        {
            try
            {
                JObject samtype = JObject.Parse(samtypeString);

                JArray jay = RedisUtil.DeserializeObject(mechineString);

                bool bs = false;
                //现在的
                int lastLXTime = int.Parse(samtype["lastLXTime"].ToString());
                //之前的
                int mech_lastLXTime = int.Parse(jay[0]["lastLXTime"].ToString());
                Util.log("lastLXTime" + lastLXTime + ";" + mech_lastLXTime, mechineID + "heartbeat.txt");
                if (lastLXTime > mech_lastLXTime)
                {
                    bs = true;
                    //长时间没连接上下位机
                    jay[0]["lastLXTime"] = lastLXTime;

                    string msg = "机器下位机连接发生异常:" + int.Parse(samtype["lastLXTime"].ToString()) + "分钟请及时处理";
                    MechineUtil.updateMechineStatus(mechineID, "5", "1", msg);
                    MechineUtil.sendErrorMsg(mechineID, "5", msg, "");//推送错误给管理员
                }
                if (mech_lastLXTime > 0 && lastLXTime == 0)
                {
                    bs = true;
                    jay[0]["lastLXTime"] = 0;
                    string msg = "机器下位机已重新连接!";
                    MechineUtil.updateMechineStatus(mechineID, "5", "0", msg);
                }
                int openDoorTime      = int.Parse(samtype["openDoorTime"].ToString());
                int mech_openDoorTime = int.Parse(jay[0]["openDoorTime"].ToString());
                Util.log("openDoorTime" + openDoorTime + ";" + mech_openDoorTime, mechineID + "heartbeat.txt");
                if (openDoorTime > mech_openDoorTime && (openDoorTime / (60 * 5) > 1))
                {
                    bs = true;

                    jay[0]["openDoorTime"] = openDoorTime;

                    string msg = "出货门异常:" + (int)(openDoorTime / 60) + "分钟请及时处理";
                    log("AA4:" + msg, "samtype_" + mechineID + "_所有指令.txt");

                    MechineUtil.updateMechineStatus(mechineID, "6", "1", msg);
                    MechineUtil.sendErrorMsg(mechineID, "6", msg, "");
                }
                if (mech_openDoorTime > 0 && openDoorTime == 0)
                {
                    bs = true;
                    jay[0]["openDoorTime"] = 0;
                    string msg = "出货门已关闭!";
                    MechineUtil.updateMechineStatus(mechineID, "6", "0", msg);
                }


                if (bs)
                {//发生更改 更新 Redis
                    Util.log("jay.ToString()" + jay.ToString(), mechineID + "heartbeat.txt");
                    RedisHelper.SetRedisModel <string>(mechineID + "_mechineInfoSet", jay.ToString());
                }
            }
            catch (Exception e)
            {
                log("AA7:" + e.ToString(), "samtype_" + mechineID + "_所有指令.txt");
            }
        }
Exemplo n.º 4
0
        /// <summary>
        /// 处理下位机长时间没有工作的异常警告
        /// </summary>
        /// <param name="mechineID">机器编号</param>
        /// <param name="samtypeString">下位机传回的json 数据</param>
        /// <returns></returns>
        public static async Task samtype(string mechineID, string samtypeString)

        {
            try
            {
                log("AA1:" + samtypeString, "samtype_" + mechineID + "_所有指令.txt");
                JObject samtype = JObject.Parse(samtypeString);


                string Rsamtype = RedisHelper.GetRedisModel <string>(mechineID + "_samtype");
                log("AA2:" + Rsamtype, "samtype_" + mechineID + "_所有指令.txt");

                if (!string.IsNullOrEmpty(Rsamtype))
                {
                    log("AASSS:", "samtype_" + mechineID + "_所有指令.txt");
                    bool bs = false;
                    //Redis里面有数据
                    JObject Redisjson = JObject.Parse(Rsamtype);
                    Redisjson["samtype"] = samtypeString;
                    int t1      = int.Parse(samtype["t1"].ToString());
                    int mech_C1 = int.Parse(Redisjson["mech_C1"].ToString());
                    if (t1 > mech_C1)
                    {
                        bs = true;
                        //长时间没连接上下位机
                        Redisjson["mech_C1"] = t1;

                        string msg = "机器下位机连接发生异常:" + int.Parse(samtype["t1"].ToString()) + "分钟请及时处理";
                        log("AA3:" + msg, "samtype_" + mechineID + "_所有指令.txt");
                        MechineUtil.sendErrorMsg(mechineID, "5", msg, "");//推送错误给管理员
                    }
                    if (mech_C1 > 0 && t1 == 0)
                    {
                        bs = true;
                        Redisjson["mech_C1"] = 0;
                    }
                    int t4      = int.Parse(samtype["t4"].ToString());
                    int t5      = int.Parse(samtype["t5"].ToString()) / 5;
                    int mech_C2 = int.Parse(Redisjson["mech_C2"].ToString());
                    if (t1 == 0 && t4 > 0 && t5 > mech_C2 && mech_C2 == 0)
                    {
                        bs = true;
                        Redisjson["mech_C2"] = t5;
                        string msg = "出货门异常:" + int.Parse(samtype["t5"].ToString()) + "分钟请及时处理";
                        log("AA4:" + msg, "samtype_" + mechineID + "_所有指令.txt");

                        MechineUtil.sendErrorMsg(mechineID, "6", msg, "");
                    }
                    if (mech_C2 > 0 && t4 == 0)
                    {
                        bs = true;
                        Redisjson["mech_C2"] = 0;
                    }

                    if (bs)
                    {//发生更改 更新 Redis
                        log("AA5:" + Redisjson.ToString(), "samtype_" + mechineID + "_所有指令.txt");
                        RedisHelper.SetRedisModel <string>(mechineID + "_samtype", Redisjson.ToString(), new TimeSpan(12, 0, 0));
                    }
                }
                else
                {//"samtype":"{\"TEXT\":\"Video_的一些状态\",\"t1\":0,\"t2\":4,\"t3\":1,\"t4\":0,\"t5\":0}
                    log("AASBB:", "samtype_" + mechineID + "_所有指令.txt");
                    JObject Redisjson = new JObject();


                    Redisjson.Add("samtype", samtypeString); //
                    Redisjson.Add("mech_C1", 0);             //Video_连接不到下位机发送次数
                    Redisjson.Add("mech_C2", 0);             //Video_不复位发送短信次数
                    log("AA6:" + Redisjson.ToString(), "samtype_" + mechineID + "_所有指令.txt");
                    RedisHelper.SetRedisModel <string>(mechineID + "_samtype", Redisjson.ToString(), new TimeSpan(12, 0, 0));
                }
            }
            catch (Exception e)
            {
                log("AA7:" + e.ToString(), "samtype_" + mechineID + "_所有指令.txt");
            }
        }