Ejemplo n.º 1
0
        /// <summary>
        /// 判断此路径是否发生变化
        /// 数据库中路径信息 暂定:有效性为一个月 即 每个月全部清空一次
        /// </summary>
        /// <param name="path"></param>
        /// <returns></returns>
        public static bool IsUpdate(Model.Config config, SftpFile sf, MonitorServer ms)
        {
            //判断是否更新
            bool isUpdate = false;

            try
            {
                SSHPathInfo spi = new SSHPathInfo()
                {
                    MonitorServerIP = ms.monitorServerIP,
                    MacPath         = sf.FullName,
                    LastName        = sf.FullName.Substring(sf.FullName.LastIndexOf('/') + 1),
                    depth           = GetDepth(sf.FullName),
                    typeflag        = sf.IsDirectory ? 0 : 1,
                    updateTime      = (Int32)(sf.Attributes.LastWriteTime.Subtract(new DateTime(1970, 1, 1))).TotalSeconds
                };

                SSHPathInfoDAL spidal = new SSHPathInfoDAL();
                isUpdate = spidal.IsUpdate(config, spi);
            }
            catch (System.Exception ex)
            {
                isUpdate = true;
                BudSSH.Common.Util.LogManager.WriteLog(Common.Util.LogFile.Error, MessageUtil.GetExceptionMsg(ex, ""));
            }

            return(isUpdate);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// 判断某个mac上的文件或目录是否更新
        /// </summary>
        /// <param name="path"></param>
        /// <param name="ip"></param>
        /// <returns></returns>
        public bool IsUpdate(Model.Config config, SSHPathInfo spi)
        {
            string connstr = config.DB.ConnString;

            SqlParameter[] spin = new SqlParameter[] {
                new SqlParameter("@monitorServerIP", SqlDbType.VarChar)
                {
                    Value = spi.MonitorServerIP
                },
                new SqlParameter("@macPath", SqlDbType.NVarChar)
                {
                    Value = spi.MacPath
                },
                new SqlParameter("@lastName", SqlDbType.NVarChar)
                {
                    Value = spi.LastName
                },
                new SqlParameter("@depth", SqlDbType.Int)
                {
                    Value = spi.depth
                },
                new SqlParameter("@typeflag", SqlDbType.Bit)
                {
                    Value = spi.typeflag
                },
                new SqlParameter("@updateTime", SqlDbType.VarChar)
                {
                    Value = spi.updateTime
                },
            };

            SqlParameter spout = new SqlParameter("@IsUpdate", SqlDbType.Bit)
            {
                Direction = ParameterDirection.Output
            };

            return(Convert.ToBoolean(DBHelper.GetOutValue(connstr, "CheckSSHPath", spout, spin)));
        }