示例#1
0
        /// <summary>
        /// 添加脚本流节点配置的实例(后期执行脚本流时,按此配置顺序执行相应节点)
        /// </summary>
        /// <param name="scriptID">脚本流ID</param>
        /// <param name="scriptCaseID">脚本流实例ID</param>
        /// <returns></returns>
        public List <long> AddReturnNodeIDList(long scriptID, long scriptCaseID)
        {
            IList <EM_SCRIPT_REF_NODE.Entity> refList = EM_SCRIPT_REF_NODE.Instance.GetNodeListByScriptID(scriptID);
            //用于去重
            Dictionary <long, byte> dic = new Dictionary <long, byte>();

            if (refList != null && refList.Count > 0)
            {
                using (BDBHelper dbHelper = new BDBHelper())
                {
                    //开始事务
                    dbHelper.BeginTrans();
                    foreach (EM_SCRIPT_REF_NODE.Entity refEntity in refList)
                    {
                        try
                        {
                            Entity entity = new Entity();
                            if (Main.KeyFieldIsUseSequence)
                            {
                                entity.ID = GetNextValueFromSeq();
                            }
                            entity.SCRIPT_ID      = scriptID;
                            entity.SCRIPT_CASE_ID = scriptCaseID;
                            entity.PARENT_NODE_ID = refEntity.PARENT_NODE_ID;
                            entity.CURR_NODE_ID   = refEntity.CURR_NODE_ID;
                            entity.REMARK         = refEntity.REMARK;

                            int i = Add(entity);
                            if (i < 0)
                            {
                                dbHelper.RollbackTrans();
                                dic.Clear();
                                break;
                            }
                            if (dic.ContainsKey(entity.CURR_NODE_ID) == false)
                            {
                                dic.Add(entity.CURR_NODE_ID, 1);
                            }
                        }
                        catch (Exception ex)
                        {
                            BLog.Write(BLog.LogLevel.ERROR, "添加脚本流节点配置的实例出错\t" + ex.ToString());
                            //出错回滚
                            dbHelper.RollbackTrans();
                            return(new List <long>());
                        }
                    }
                    //提交事务
                    dbHelper.CommitTrans();
                    dbHelper.Close();
                }
            }

            return(dic.Keys.ToList <long>());
        }
示例#2
0
        /// <summary>
        /// 限定和处理待
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private static void DoWork3(object sender, DoWorkEventArgs e)
        {
            while (Main.IsRun)
            {
                try
                {
                    BLog.Write(BLog.LogLevel.INFO, "开始处理限定的监控文件夹任务");

                    #region 查询当前非并行执行中的任务实例的数量,如果数量小于MonitFolderCount,则补齐执行中的数量。
                    //修改等待中的任务为执行中(补齐差量)
                    string sql = string.Format(@"SELECT COUNT (1)
                          FROM EM_SCRIPT_CASE
                         WHERE IS_SUPERVENE <> 1 AND RUN_STATUS = 2");
                    object obj = null;
                    using (BDBHelper dbop = new BDBHelper())
                    {
                        obj = dbop.ExecuteScalar(sql);//获得执行中的非并行任务数

                        BLog.Write(BLog.LogLevel.INFO, "获取到执行中任务数:" + obj);

                        if (obj != null && Convert.ToInt32(obj) < Main.MaxMonitCount) //当执行中的数量小于MaxMonitCount
                        {
                            int difCount = Main.MaxMonitCount - Convert.ToInt32(obj); //差量
                            sql = string.Format(@"SELECT COUNT(1)
                                FROM (SELECT A.ID,
                                            ROW_NUMBER () OVER (ORDER BY ID) RN
                                        FROM EM_SCRIPT_CASE A WHERE RUN_STATUS = 1)
                                WHERE RN <= {0}", difCount);
                            object o2 = o2 = dbop.ExecuteScalar(sql);

                            BLog.Write(BLog.LogLevel.INFO, "按差量获取等待中任务数:" + o2);
                            if (o2 != null && Convert.ToInt32(o2) > 0)
                            {
                                sql = string.Format(@"MERGE INTO EM_SCRIPT_CASE A
                                     USING (SELECT ID
                                              FROM (SELECT ID,
                                                           ROW_NUMBER ()
                                                              OVER ( ORDER BY ID)
                                                              RN
                                                      FROM EM_SCRIPT_CASE
                                                     WHERE RUN_STATUS = 1)
                                             WHERE RN <= {0}) B
                                        ON (A.ID = B.ID)
                                WHEN MATCHED
                                THEN
                                   UPDATE SET RUN_STATUS = 2", difCount);

                                dbop.ExecuteNonQuery(sql);//修改等待的任务为执行中
                                BLog.Write(BLog.LogLevel.INFO, "执行把等待中任务改为执行中");
                            }
                        }
                        dbop.Close();//关闭连接
                    }
                    #endregion
                }
                catch (Exception ex)
                {
                    BLog.Write(BLog.LogLevel.ERROR, "限定监控的文件夹任务出现异常:" + ex.ToString());
                }
                Thread.Sleep(100000);//100秒执行一次
            }
        }
示例#3
0
        /// <summary>
        /// 往待拷贝列表中加入文件编号
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private static void DoWork2(object sender, DoWorkEventArgs e)
        {
            while (Main.IsRun)
            {
                try
                {
                    #region 再次验证和清理未在线终端
                    //var ipArr = global.ipList.ToArray();
                    //for (int i = 0; i < ipArr.Count(); i++)
                    //{
                    //    if (Request.PingIP(ipArr[i].Value) && global.ipList.ContainsKey(ipArr[i].Key))
                    //    {
                    //        global.ipList.Remove(ipArr[i].Key);//移除已在线的终端
                    //    }
                    //}
                    var ipNotLists = global.OpIpNotList("getall");
                    if (ipNotLists != null && ipNotLists.Count > 0)
                    {
                        int cnt = ipNotLists.Count;
                        for (int i = cnt - 1; i >= 0; i--)
                        {
                            var item = ipNotLists[i];
                            if (Librarys.ApiRequest.Request.OldPingIP(item.V))
                            {
                                global.OpIpNotList("remove", item);
                            }
                        }
                        ipNotLists = global.OpIpNotList("getall");
                        BLog.Write(BLog.LogLevel.INFO, "输出未在线的ip:" + string.Join(",", ipNotLists.Select(p => p.V)));
                    }
                    #endregion

                    BLog.Write(BLog.LogLevel.INFO, "已在列表中的数量:" + global.GetMonitKVCount());
                    if (global.GetEffectMonitKVCount() < 200)
                    //if (global.GetMonitKVCount() < 200)
                    {
                        //var ipNotLists = global.OpIpNotList("getall");

                        #region 获取MaxUploadCount条待拷贝记录(排除未在线终端)
                        //采集待插入的文件列表
                        //采集未在线的终端列表

                        //lcz, 这个地方的sql可以只返回同一客户机ip的,便于下面的一个连接多个文件拷贝
                        //获取不返回一个ip的文件,在从monitKVList中获取5个一样ip的终端去处理
                        //string sql = string.Format(@"SELECT A.ID, B.IP, A.COMPUTER_ID
                        //                          FROM (SELECT ID, COMPUTER_ID
                        //                                  FROM (SELECT A.ID,
                        //                                               A.COMPUTER_ID,
                        //                                               ROW_NUMBER () OVER (ORDER BY A.ID) RN
                        //                                          FROM FM_MONIT_FILE A
                        //                                               LEFT JOIN (    SELECT DISTINCT REGEXP_SUBSTR ('{0}',
                        //                                                                                             '[^,]+',
                        //                                                                                             1,
                        //                                                                                             LEVEL)
                        //                                                                                 AS COMPUTER_ID
                        //                                                                FROM DUAL
                        //                                                          CONNECT BY REGEXP_SUBSTR ('{0}',
                        //                                                                                    '[^,]+',
                        //                                                                                    1,
                        //                                                                                    LEVEL)
                        //                                                                        IS NOT NULL) C
                        //                                                  ON (A.COMPUTER_ID = C.COMPUTER_ID)
                        //                                                LEFT JOIN FM_FILE_FORMAT F ON (F.ID=A.FILE_FORMAT_ID)
                        //                                         WHERE     NVL (C.COMPUTER_ID, 0) = 0 AND F.NAME<>'Folder'
                        //                                               AND (A.COPY_STATUS = 0 OR A.COPY_STATUS = 3))
                        //                                 WHERE RN <={1}) A
                        //                               LEFT JOIN FM_COMPUTER B ON (A.COMPUTER_ID = B.ID)", string.Join(",", ipNotLists.Select(p => p.K).Distinct()), Main.EachSearchUploadCount);

                        string sql = string.Format(@"SELECT A.ID, B.IP, A.COMPUTER_ID
  FROM (SELECT A.ID, A.COMPUTER_ID
          FROM FM_MONIT_FILE A
               LEFT JOIN (    SELECT DISTINCT REGEXP_SUBSTR ('{0}',
                                                             '[^,]+',
                                                             1,
                                                             LEVEL)
                                                 AS COMPUTER_ID
                                FROM DUAL
                          CONNECT BY REGEXP_SUBSTR ('{0}',
                                                    '[^,]+',
                                                    1,
                                                    LEVEL)
                                        IS NOT NULL) C
                  ON (A.COMPUTER_ID = C.COMPUTER_ID)
               LEFT JOIN FM_FILE_FORMAT F ON (F.ID = A.FILE_FORMAT_ID)
         WHERE     NVL (C.COMPUTER_ID, 0) = 0
               AND F.NAME <> 'Folder'
               AND (A.COPY_STATUS = 0 OR A.COPY_STATUS = 3)
               AND ROWNUM <= {1}) A
       LEFT JOIN FM_COMPUTER B ON (A.COMPUTER_ID = B.ID)", string.Join(",", ipNotLists.Select(p => p.K).Distinct()), Main.EachSearchUploadCount);

                        StringBuilder sb = new StringBuilder();           //待处理
                                                                          //StringBuilder sbNotAlive = new StringBuilder();//未在线
                        List <string> notAliveList = new List <string>(); //当前查询的未在线
                        DataTable     dt           = null;
                        using (BDBHelper dbop = new BDBHelper())
                        {
                            dt = dbop.ExecuteDataTable(sql);
                            if (dt != null && dt.Rows.Count > 0)
                            {
                                string updateSql = string.Format(@"update FM_MONIT_FILE set COPY_STATUS=5 where id in({0})", string.Join(",", dt.AsEnumerable().Select(r => r["ID"]).Distinct().ToArray()).TrimEnd(','));
                                dbop.ExecuteNonQuery(updateSql);
                            }
                            dbop.Close();
                        }
                        //log("查询出的数量为:【" + dt.Rows.Count + "】");
                        BLog.Write(BLog.LogLevel.INFO, "查询出的数量为:【" + dt.Rows.Count + "】");
                        if (dt != null && dt.Rows.Count > 0)
                        {
                            List <string> hasAliveIps = new List <string>();//当前批次的在线ip

                            for (int i = 0; i < dt.Rows.Count; i++)
                            {
                                sb.Append(dt.Rows[i][0] + ",");
                                //校验ip
                                string curIp = dt.Rows[i][1].ToString().Trim();
                                //log("当前ip【" + curIp + "】");
                                var curKv = new KV {
                                    K = Convert.ToInt64(dt.Rows[i][2].ToString()), V = dt.Rows[i][1].ToString()
                                };                                                                                                 //不在线的ip

                                if (string.IsNullOrEmpty(curIp))
                                {
                                    BLog.Write(BLog.LogLevel.INFO, "文件编号:" + dt.Rows[i][0] + "为空");
                                    //log("ip[" + curIp + "]为空");//20180701注释
                                    //BLog.Write(BLog.LogLevel.INFO, "ip[" + curIp + "]为空");
                                }
                                else if (hasAliveIps.Contains(curIp))
                                {
                                    BLog.Write(BLog.LogLevel.INFO, "文件编号:" + dt.Rows[i][0] + "IP在线");
                                    global.OpMonitKVList("add", new KV {
                                        K = Convert.ToInt64(dt.Rows[i][0].ToString()), V = dt.Rows[i][1].ToString()
                                    });                                                                                                                 //20180701注释
                                    //log("ip[" + curIp + "]在已在线列表中");
                                }
                                else
                                {
                                    if (ipNotLists.Exists(p => p.K == curKv.K))
                                    {
                                        BLog.Write(BLog.LogLevel.INFO, "文件编号:" + dt.Rows[i][0] + "IP不在线");
                                        //log("ip[" + curIp + "]未在线2");
                                        using (BDBHelper dbop = new BDBHelper())
                                        {
                                            string updateSql = string.Format(@"update FM_MONIT_FILE set COPY_STATUS=0 where id ={0}", dt.Rows[i][0].ToString());
                                            dbop.ExecuteNonQuery(updateSql);
                                            dbop.Close();
                                        }
                                        if (!notAliveList.Contains(curKv.V))
                                        {
                                            notAliveList.Add(curKv.V);
                                        }
                                    }
                                    else if (!Request.PingIP(curIp))
                                    {
                                        BLog.Write(BLog.LogLevel.INFO, "文件编号2:" + dt.Rows[i][0] + "IP不在线");
                                        //log("ip[" + curIp + "]未在线");
                                        using (BDBHelper dbop = new BDBHelper())
                                        {
                                            string updateSql = string.Format(@"update FM_MONIT_FILE set COPY_STATUS=0 where id ={0}", dt.Rows[i][0].ToString());
                                            dbop.ExecuteNonQuery(updateSql);
                                            dbop.Close();
                                        }
                                        global.OpIpNotList("add", curKv);
                                        notAliveList.Add(dt.Rows[i][1].ToString());
                                        if (!ipNotLists.Exists(p => p.K == curKv.K))
                                        {
                                            ipNotLists.Add(curKv);
                                        }
                                    }
                                    else
                                    {
                                        global.OpMonitKVList("add", new KV {
                                            K = Convert.ToInt64(dt.Rows[i][0].ToString()), V = dt.Rows[i][1].ToString()
                                        });
                                        hasAliveIps.Add(curIp);
                                        BLog.Write(BLog.LogLevel.INFO, "文件编号:" + dt.Rows[i][0] + "添加文件");
                                        //log("ip[" + curIp + "]在线");
                                        //BLog.Write(BLog.LogLevel.INFO, "ip[" + curIp + "]在线");//20180701注释
                                    }
                                }
                            }
                            //log("再次输出未在线ip:" + string.Join(",", global.OpIpNotList("getall").Select(p => p.V)));
                            #endregion

                            //log("内存中无监控的文件列表,从数据库中去获取", 4, string.Format(@"执行查询的sql:\r\n{0}。\r\n查询的结果为:{1}", sql, sb));
                            BLog.Write(BLog.LogLevel.INFO, "内存中无监控的文件列表,从数据库中去获取." + string.Format(@"执行查询的sql:\r\n{0}。\r\n查询的结果为:{1}", sql, sb));
                            BLog.Write(BLog.LogLevel.INFO, "获取到未在线的ip【" + (notAliveList.Count > 0 ? string.Join(",", notAliveList.Distinct()) : "") + "】,当前未在线的ip列表为【" + string.Join(" , ", global.ipNotList.Select(p => p.V)) + "】");
                            //log("获取到未在线的ip【" + (notAliveList.Count > 0 ? string.Join(",", notAliveList.Distinct()) : "") + "】,当前未在线的ip列表为【" + string.Join(" , ", global.ipNotList.Select(p => p.V)) + "】");
                        }
                        else
                        {
                            //string msg = "未在库中查询到需要拷贝的文件,当前不存在需拷贝文件";
                            //log(msg);
                            //log(msg, 3, string.Format(@"执行查询的sql:\r\n{0}。", sql));
                            BLog.Write(BLog.LogLevel.INFO, string.Format(@"执行查询的sql:\r\n{0}。", sql));
                            //return null;
                        }
                    }
                }
                catch (Exception ex)
                {
                    BLog.Write(BLog.LogLevel.ERROR, "查询添加待拷贝文件出错:" + ex.ToString());
                }
                Thread.Sleep(2000);
            }
        }
示例#4
0
        /// <summary>
        /// 启动
        /// </summary>
        public static void Start()
        {
            IsRun = true;

            try
            {
                BLog.Write(BLog.LogLevel.INFO, "程序即将启动。");

                MaxExecuteNodeCount = BConfig.GetConfigToInt("MaxExecuteNodeCount");
                if (MaxExecuteNodeCount < 1)
                {
                    MaxExecuteNodeCount = 10;
                }

                MaxUploadCount = BConfig.GetConfigToInt("MaxUploadCount");

                EachUploadCount = BConfig.GetConfigToInt("EachUploadCount");

                EachSearchUploadCount = BConfig.GetConfigToInt("EachSearchUploadCount");

                MaxMonitCount = BConfig.GetConfigToInt("MaxMonitCount");

                NeedClearCount = BConfig.GetConfigToInt("NeedClearCount");


                //if (MaxExecuteNodeCount < 1)
                //{
                //    MaxExecuteNodeCount = 10;
                //}

                if (bool.TryParse(BConfig.GetConfigToString("KeyFieldIsAutoIncrement"), out KeyFieldIsAutoIncrement) == false)
                {
                    KeyFieldIsAutoIncrement = true;
                }

                if (bool.TryParse(BConfig.GetConfigToString("KeyFieldIsUseSequence"), out KeyFieldIsUseSequence) == false)
                {
                    BLog.Write(BLog.LogLevel.FATAL, "KeyFieldIsUseSequence配置不正确,请在.config中配置为true或false。");
                    IsRun = false;
                    return;
                }

                if (KeyFieldIsAutoIncrement && KeyFieldIsUseSequence)
                {
                    BLog.Write(BLog.LogLevel.FATAL, "KeyFieldIsAutoIncrement和KeyFieldIsUseSequence不可以同时配置为true,即:数据库已经可以自己实现自增长了,就不再需要另外配置序列,请在.config中修改配置。");
                    IsRun = false;
                    return;
                }

                if (KeyFieldIsAutoIncrement == false && KeyFieldIsUseSequence == false)
                {
                    BLog.Write(BLog.LogLevel.FATAL, "KeyFieldIsAutoIncrement和KeyFieldIsUseSequence不可以同时配置为false,即:数据库不能实现自增长,对于oracle和DB2来说,就需要使用序列,请在.config中修改配置。");
                    IsRun = false;
                    return;
                }

                //节点任务记录器
                _dicRunningNodeCaseID = new Dictionary <long, DateTime>();

                lock (_dicRunningNodeCaseID)
                {
                    _dicRunningNodeCaseID = new Dictionary <long, DateTime>();
                }
                _bw = new BackgroundWorker();
                _bw.WorkerSupportsCancellation = true;
                _bw.DoWork += bw_DoWork;
                _bw.RunWorkerAsync();

                #region 并行+非并行:停止遗留的(等待+执行中)任务组 (2018/12/13,与非并行的处理合并)
                var supCaseList = BLL.EM_SCRIPT_CASE.Instance.GetNotStopCaseList();
                if (supCaseList != null && supCaseList.Count > 0)
                {
                    foreach (var sc in supCaseList)
                    {
                        BLL.EM_SCRIPT_CASE.Instance.SetStop(sc.ID, Enums.ReturnCode.Warn);//标记停止的为警告状态
                    }
                }
                #endregion

                #region 作废: 非并行:停止等待中的任务组 (2018/12/13注释,与以上并行的处理合并)
                //var noSupCaseList = BLL.EM_SCRIPT_CASE.Instance.GetRunningNoSuperveneCaseList();
                //if (noSupCaseList != null && noSupCaseList.Count > 0)
                //{
                //    foreach (var sc in noSupCaseList)
                //    {
                //        BLL.EM_SCRIPT_CASE.Instance.SetStop(sc.ID, Enums.ReturnCode.Success);
                //    }
                //}
                #endregion

                #region 5回复为0
                using (BDBHelper dbop = new BDBHelper())
                {
                    dbop.ExecuteNonQuery(string.Format(@"update FM_MONIT_FILE set COPY_STATUS=0 where COPY_STATUS= 5"));
                    dbop.Close();//主动关闭
                }
                #endregion

                #region 重启时删除临时表FM_MONIT_FILE_TEMP_PRO FM_MONIT_FILE_TEMP
                using (BDBHelper dbop = new BDBHelper())
                {
                    dbop.ExecuteNonQuery(string.Format(@"truncate table  FM_MONIT_FILE_TEMP"));
                    dbop.ExecuteNonQuery(string.Format(@"truncate table  FM_MONIT_FILE_TEMP_PRO"));
                    dbop.Close();//主动关闭
                }
                #endregion

                //启动手动任务线程
                Task.Hand.Start();

                //启动节点扫描线程(含监控任务数量的限制处理,含添加的待拷贝文件列表)
                Task.Scanner.Start();

                BLog.Write(BLog.LogLevel.INFO, "程序已经启动。");
            }
            catch (Exception ex)
            {
                BLog.Write(BLog.LogLevel.FATAL, "程序启动失败。" + ex.ToString());
            }
        }
示例#5
0
文件: Node.cs 项目: radtek/FmsScript
        //作废
        private void AddMonitKv()
        {
            var ipNotLists = global.OpIpNotList("getall");

            log("输出未在线的ip:" + string.Join(",", ipNotLists.Select(p => p.V)));

            #region 获取MaxUploadCount条待拷贝记录(排除未在线终端)
            //采集待插入的文件列表
            //采集未在线的终端列表

            //lcz, 这个地方的sql可以只返回同一客户机ip的,便于下面的一个连接多个文件拷贝
            //获取不返回一个ip的文件,在从monitKVList中获取5个一样ip的终端去处理
            string sql = string.Format(@"SELECT A.ID, B.IP, A.COMPUTER_ID
                                                  FROM (SELECT ID, COMPUTER_ID
                                                          FROM (SELECT A.ID,
                                                                       A.COMPUTER_ID,
                                                                       ROW_NUMBER () OVER (ORDER BY A.ID) RN
                                                                  FROM FM_MONIT_FILE A
                                                                       LEFT JOIN (    SELECT DISTINCT REGEXP_SUBSTR ('{0}',
                                                                                                                     '[^,]+',
                                                                                                                     1,
                                                                                                                     LEVEL)
                                                                                                         AS COMPUTER_ID
                                                                                        FROM DUAL
                                                                                  CONNECT BY REGEXP_SUBSTR ('{0}',
                                                                                                            '[^,]+',
                                                                                                            1,
                                                                                                            LEVEL)
                                                                                                IS NOT NULL) C
                                                                          ON (A.COMPUTER_ID = C.COMPUTER_ID)
                                                                        LEFT JOIN FM_FILE_FORMAT F ON (F.ID=A.FILE_FORMAT_ID)   
                                                                 WHERE     NVL (C.COMPUTER_ID, 0) = 0 AND F.NAME<>'Folder'
                                                                       AND (A.COPY_STATUS = 0 OR A.COPY_STATUS = 3))
                                                         WHERE RN <={1}) A
                                                       LEFT JOIN FM_COMPUTER B ON (A.COMPUTER_ID = B.ID)", string.Join(",", ipNotLists.Select(p => p.K).Distinct()), Main.EachSearchUploadCount);


            StringBuilder sb = new StringBuilder();           //待处理
                                                              //StringBuilder sbNotAlive = new StringBuilder();//未在线
            List <string> notAliveList = new List <string>(); //当前查询的未在线
            DataTable     dt           = null;
            using (BDBHelper dbop = new BDBHelper())
            {
                dt = dbop.ExecuteDataTable(sql);
                if (dt != null && dt.Rows.Count > 0)
                {
                    string updateSql = string.Format(@"update FM_MONIT_FILE set COPY_STATUS=5 where id in({0})", string.Join(",", dt.AsEnumerable().Select(r => r["ID"]).Distinct().ToArray()).TrimEnd(','));
                    dbop.ExecuteNonQuery(updateSql);
                }
                dbop.Close();
            }
            log("查询出的数量为:【" + dt.Rows.Count + "】");
            if (dt != null && dt.Rows.Count > 0)
            {
                List <string> hasAliveIps = new List <string>();//当前批次的在线ip

                for (int i = 0; i < dt.Rows.Count; i++)
                {
                    sb.Append(dt.Rows[i][0] + ",");
                    //校验ip
                    string curIp = dt.Rows[i][1].ToString().Trim();
                    //log("当前ip【" + curIp + "】");
                    var curKv = new KV {
                        K = Convert.ToInt64(dt.Rows[i][2].ToString()), V = dt.Rows[i][1].ToString()
                    };                                                                                                 //不在线的ip

                    if (string.IsNullOrEmpty(curIp))
                    {
                        log("ip[" + curIp + "]为空");
                    }
                    else if (hasAliveIps.Contains(curIp))
                    {
                        global.OpMonitKVList("add", new KV {
                            K = Convert.ToInt64(dt.Rows[i][0].ToString()), V = dt.Rows[i][1].ToString()
                        });
                        //log("ip[" + curIp + "]在已在线列表中");
                    }
                    else
                    {
                        if (ipNotLists.Exists(p => p.K == curKv.K))
                        {
                            //log("ip[" + curIp + "]未在线2");
                            using (BDBHelper dbop = new BDBHelper())
                            {
                                string updateSql = string.Format(@"update FM_MONIT_FILE set COPY_STATUS=0 where id ={0}", dt.Rows[i][0].ToString());
                                dbop.ExecuteNonQuery(updateSql);
                            }
                            if (!notAliveList.Contains(curKv.V))
                            {
                                notAliveList.Add(curKv.V);
                            }
                        }
                        else if (!Request.OldPingIP(curIp))
                        {
                            //log("ip[" + curIp + "]未在线");
                            using (BDBHelper dbop = new BDBHelper())
                            {
                                string updateSql = string.Format(@"update FM_MONIT_FILE set COPY_STATUS=0 where id ={0}", dt.Rows[i][0].ToString());
                                dbop.ExecuteNonQuery(updateSql);
                            }
                            global.OpIpNotList("add", curKv);
                            notAliveList.Add(dt.Rows[i][1].ToString());
                            if (!ipNotLists.Exists(p => p.K == curKv.K))
                            {
                                ipNotLists.Add(curKv);
                            }
                        }
                        else
                        {
                            global.OpMonitKVList("add", new KV {
                                K = Convert.ToInt64(dt.Rows[i][0].ToString()), V = dt.Rows[i][1].ToString()
                            });
                            hasAliveIps.Add(curIp);
                            log("ip[" + curIp + "]在线");
                        }
                    }
                }
                log("再次输出未在线ip:" + string.Join(",", global.OpIpNotList("getall").Select(p => p.V)));
                #endregion

                log("内存中无监控的文件列表,从数据库中去获取", 4, string.Format(@"执行查询的sql:\r\n{0}。\r\n查询的结果为:{1}", sql, sb));
                log("获取到未在线的ip【" + (notAliveList.Count > 0 ? string.Join(",", notAliveList.Distinct()) : "") + "】,当前未在线的ip列表为【" + string.Join(" , ", global.ipNotList.Select(p => p.V)) + "】");
            }
            else
            {
                string msg = "未在库中查询到需要拷贝的文件,当前不存在需拷贝文件";
                //log(msg);
                log(msg, 3, string.Format(@"执行查询的sql:\r\n{0}。", sql));
                //return null;
            }
        }
        /// <summary>
        /// 添加节点实例列表
        /// </summary>
        /// <param name="scriptCaseID">脚本实例ID</param>
        /// <param name="nodeIDList">脚本相关节点ID列表</param>
        /// <returns>添加成功的节点实例ID列表</returns>
        public List <long> AddCaseReturnList(long scriptCaseID, List <long> nodeIDList)
        {
            List <long> list = new List <long>();

            if (scriptCaseID < 1 || nodeIDList.Count < 1)
            {
                return(list);
            }

            int i      = 0;
            int caseid = 0;

            using (BDBHelper dbHelper = new BDBHelper())
            {
                //开始事务
                dbHelper.BeginTrans();
                foreach (long nodeID in nodeIDList)
                {
                    try
                    {
                        EM_SCRIPT_NODE.Entity ne = EM_SCRIPT_NODE.Instance.GetEntityByKey <EM_SCRIPT_NODE.Entity>(nodeID);
                        Entity entity            = new Entity();
                        if (Main.KeyFieldIsUseSequence)
                        {
                            entity.ID = GetNextValueFromSeq();
                        }
                        entity.SCRIPT_CASE_ID      = scriptCaseID;
                        entity.SCRIPT_NODE_ID      = ne.ID;
                        entity.SCRIPT_NODE_TYPE_ID = ne.SCRIPT_NODE_TYPE_ID;
                        entity.NAME         = ne.NAME;
                        entity.CODE         = ne.CODE;
                        entity.DB_SERVER_ID = ne.DB_SERVER_ID;
                        entity.SCRIPT_MODEL = ne.SCRIPT_MODEL;
                        if (entity.SCRIPT_MODEL == Enums.ScriptModel.CreateTb.GetHashCode())
                        {
                            entity.CONTENT      = ne.CONTENT.ToUpper();
                            entity.E_TABLE_NAME = ne.E_TABLE_NAME.ToUpper();
                        }
                        else
                        {
                            entity.CONTENT      = ne.CONTENT;
                            entity.E_TABLE_NAME = ne.E_TABLE_NAME;
                        }
                        entity.REMARK       = ne.REMARK;
                        entity.C_TABLE_NAME = ne.C_TABLE_NAME;
                        entity.TABLE_TYPE   = ne.TABLE_TYPE;
                        entity.TABLE_MODEL  = ne.TABLE_MODEL;
                        entity.CREATE_TIME  = ne.CREATE_TIME;
                        entity.CREATE_UID   = ne.CREATE_UID;

                        caseid = Add(entity, true);
                        if (caseid > 0)
                        {
                            i++;
                            list.Add(caseid);
                        }
                    }
                    catch (Exception ex)
                    {
                        i = 0;
                        dbHelper.RollbackTrans();
                        list.Clear();

                        break;
                    }
                }

                if (i != nodeIDList.Count)
                {
                    i = 0;
                    dbHelper.RollbackTrans();
                    list.Clear();
                }

                //提交事务
                dbHelper.CommitTrans();
                dbHelper.Close();
            }

            return(list);
        }