Esempio n. 1
0
        /// <summary>
        /// 重发命令
        /// </summary>
        /// <param name="log_id"></param>
        /// <param name="upDb">是否成功更新数据</param>
        /// <param name="msg">错误信息</param>
        /// <returns>是否成功下发命令</returns>
        public bool YdToGwAgain(long log_id, out bool upDb, out string msg)
        {
            upDb = false;
            msg  = "";
            v2_commandVModel rstCmd = bll.GetYdToGwOfCmd(log_id);

            if (rstCmd == null)
            {
                msg = "远程命令已撤销";
                return(false);
            }
            if (rstCmd.ErrCode == 1)
            {
                msg = "远程命令已执行";
                return(false);
            }

            CommandVModel cmd = bll.GetYdToGwOfSendCmd(log_id);
            bool          rst = false;

            try
            {
                rst = this.SendCmd(cmd, false);
            }
            catch (Exception ex)
            {
                msg = ex.Message;
                FileLog.WriteLog("发送到设备错误(YdToGwAgain)", ex.Message + ex.StackTrace);
                bll.UpErrYdToGwOfCmd(log_id, msg);
            }

            int timeout = 1000;

            while (rst == true && timeout <= 5000)
            {/*等待是否更新成功*/
                System.Threading.Thread.Sleep(1000);
                rstCmd = bll.GetYdToGwOfCmd(log_id);
                if (rstCmd != null && rstCmd.ErrCode == 1)
                {
                    upDb = true;
                    break;
                }
                timeout = timeout + 1000;
            }
            return(rst);
        }
Esempio n. 2
0
        /// <summary>
        /// 获取远程命令
        /// </summary>
        /// <param name="log_id"></param>
        /// <returns></returns>
        public v2_commandVModel GetYdToGwOfCmd(long log_id)
        {
            object params01 = new
            {
                Log_id = log_id,
            };
            StringBuilder strSql = new StringBuilder();

            strSql.Append("select Log_id,CDate,Ledger,Co_id,Module_id,ModuleAddr,Fun_id,FunType,DataValue,Create_by,Create_dt,ErrCode");
            strSql.Append(" from v2_command where Log_id=@Log_id");
            DataTable        dt  = SQLHelper.Query(strSql.ToString(), params01);
            v2_commandVModel cmd = null;

            if (dt.Rows.Count > 0)
            {
                cmd = ModelHandler <v2_commandVModel> .FillModel(dt.Rows[0]);
            }
            return(cmd);
        }