Ejemplo n.º 1
0
        /// <summary>
        /// 检查指定表的逻辑关联性
        /// </summary>
        /// <param name="sql"></param>
        /// <param name="table"></param>
        /// <param name="crl"></param>
        /// <param name="tName"></param>
        public void CheckLuoJi(string sql, KeyValuePair <string, string> table, MainCrl crl, string tName)
        {
            AccessHelper accessHelper = new AccessHelper();
            AccessHelper ah           = new AccessHelper();
            //字段值大于等于某一字段值
            DataTable dt = accessHelper.SelectToDataTable("select * from GuiZe where 规则类型='逻辑关联性'");

            if (dt.Rows.Count > 0)
            {
                if (table.Key.Equals("ZBXXB"))
                {
                    string    path      = table.Value;
                    DataTable dataTable = ah.SelectToDataTable("select * from ZBXXB", path);
                    for (int i = 0; i < dt.Rows.Count; i++)
                    {
                        DataTable ResultTable = ah.SelectToDataTable(dt.Rows[i]["表达式"].ToString(), path);
                        if (ResultTable.Rows.Count > 0)
                        {
                            for (int j = 0; j < ResultTable.Rows.Count; j++)
                            {
                                for (int k = 0; k < dataTable.Rows.Count; k++)
                                {
                                    if (ResultTable.Rows[j]["ZDTYBM"].Equals(dataTable.Rows[k]["ZDTYBM"]))
                                    {
                                        ComMsg.ResultShow.Add(new ResultEntity(tName, dt.Rows[i]["规则类型"].ToString(), dt.Rows[i]["规则编号"].ToString(), dt.Rows[i]["规则名称"].ToString(),
                                                                               dt.Rows[i]["字段名"] + dt.Rows[i]["错误描述"].ToString(), (k + 1) + "", dt.Rows[i]["严重程度"].ToString(), DateTime.Now.ToShortDateString()));
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
Ejemplo n.º 2
0
 /// <summary>
 /// 检查指定表的逻辑关联性
 /// </summary>
 /// <param name="sql"></param>
 /// <param name="table"></param>
 /// <param name="crl"></param>
 /// <param name="tName"></param>
 public void CheckLuoJi(string sql, KeyValuePair<string, string> table, MainCrl crl, string tName)
 {
     AccessHelper accessHelper = new AccessHelper();
     AccessHelper ah = new AccessHelper();
     //字段值大于等于某一字段值
     DataTable dt = accessHelper.SelectToDataTable("select * from GuiZe where 规则类型='逻辑关联性'");
     if (dt.Rows.Count > 0)
     {
         if (table.Key.Equals("ZBXXB"))
         {
             string path = table.Value;
             DataTable dataTable = ah.SelectToDataTable("select * from ZBXXB", path);
             for(int i=0;i<dt.Rows.Count;i++)
             {
                 DataTable ResultTable = ah.SelectToDataTable(dt.Rows[i]["表达式"].ToString(), path);
                 if(ResultTable.Rows.Count>0)
                 {
                     for (int j = 0; j < ResultTable.Rows.Count;j++ )
                     {
                         for (int k = 0; k < dataTable.Rows.Count;k++ )
                         {
                             if (ResultTable.Rows[j]["ZDTYBM"].Equals(dataTable.Rows[k]["ZDTYBM"]))
                             {
                                 ComMsg.ResultShow.Add(new ResultEntity(tName, dt.Rows[i]["规则类型"].ToString(), dt.Rows[i]["规则编号"].ToString(), dt.Rows[i]["规则名称"].ToString(),
                 dt.Rows[i]["字段名"] + dt.Rows[i]["错误描述"].ToString(), (k + 1) + "", dt.Rows[i]["严重程度"].ToString(), DateTime.Now.ToShortDateString()));
                             }
                         }
                     }
                 }
             }
         }
     }
 }
Ejemplo n.º 3
0
 /// <summary>
 /// 检查加载进来的文件夹下面的所有文件信息
 /// </summary>
 /// <param name="path">文件夹路径</param>
 /// <param name="mainCrl">检查主窗体</param>
 public List <FileInfo> ReturnFiles(string path, MainCrl mainCrl)
 {
     if (path.Length == 0)
     {
         MessageBox.Show("请选择路径");
         return(null);
     }
     System.IO.DirectoryInfo aDir = null;
     try
     {
         //获取当前目录
         aDir = new System.IO.DirectoryInfo(path);
     }
     catch (Exception)
     {
         MessageBox.Show("路径不合法");
         return(null);
     }
     DirectoryInfo[] dirs = aDir.GetDirectories();//获取当前目录的所有子目录
     if (dirs.Count() > 0)
     {
         //记录当前目录下所有的子目录名称
         List <string> AllFileName = new List <string>();
         foreach (DirectoryInfo dir in dirs)
         {
             AllFileName.Add(dir.FullName);//当前目录的子目录
             if (dir.GetFiles().Count() != 0)
             {
                 ComMsg.infoList.AddRange(dir.GetFiles());
             }
             AllFile(AllFileName, dir);
         }
     }
     return(ComMsg.infoList);
 }
Ejemplo n.º 4
0
        /// <summary>
        /// 检查规则
        /// </summary>
        /// <param name="crl">选定文件夹中的所有文件</param>
        public void CheckSempleGuiZe(string path,MainCrl crl)
        {
            crl.rtbLog.Text += "\n " + DateTime.Now.ToLongTimeString() + "开始检查质检规则";
            List<FileInfo> infoList= ComMsg.infoList;
            List<string> files = new List<string>();//去除所有父级目录后的文件信息
            string tName = path.Substring(path.IndexOf(@"\") + 1);//成果名称
            tName = tName.Substring(tName.LastIndexOf(@"\") + 1);
            //读取了目标文件夹下所有的文件信息,将这些文件和数据库的信息进行成果比对
            for (int i = 0; i < infoList.Count(); i++)
            {
                //去除选定目录的所有父级目录,只保留选定文件夹所包含的文件夹路径
                files.Add(infoList[i].FullName);
            }
            List<string> accessFiles = new List<string>();
            //获取所有的access文件
            foreach (string file in files)
            {
                if (file.Contains("mdb") || file.Contains("accdb"))
                {
                    accessFiles.Add(file);
                }
            }
            AccessHelper ah = new AccessHelper();
            Dictionary<string, string> tables = new Dictionary<string, string>();
            List<string> columns = new List<string>();
            //检查access文件中是否有表名
            foreach (string p in accessFiles)
            {
                string[] tableNames = ah.GetShemaTableName(p, "");
                if (tableNames.Count() > 0)
                {
                    for (int i = 0; i < tableNames.Count(); i++)
                    {
                        tables.Add(tableNames[i], p);
                        columns.AddRange(ah.GetTableColumn(p, tableNames[i]));
                    }
                }
            }

            if (tables.Count >= 0)
            {
                AccessHelper accessHelper = new AccessHelper();

                foreach(KeyValuePair<string,string> table in tables)
                {
                    string sql = "select * from " + table.Key;
                    //字段值大于等于某一值
                    ZDZDYDYMZ(sql, table, crl,tName);
                    //检查字段值是否在字典表中
                    CheckZidianCode(sql, table, crl, tName);
                    //检查字典名称是否在字典表中
                    CheckZiDianName(sql, table, crl, tName);

                    //逻辑检查
                    CheckLuoJi(sql, table, crl, tName);
                }
            }
            crl.rtbLog.Text += "\n " + DateTime.Now.ToLongTimeString() + "质检规则检查完毕";
        }
Ejemplo n.º 5
0
        /// <summary>
        /// 检查数据是否在字典表中的字典名称值域内
        /// </summary>
        /// <param name="sql"></param>
        /// <param name="table"></param>
        /// <param name="crl"></param>
        /// <param name="tName"></param>
        public void CheckZiDianName(string sql, KeyValuePair <string, string> table, MainCrl crl, string tName)
        {
            AccessHelper accessHelper = new AccessHelper();
            AccessHelper ah           = new AccessHelper();
            //字段值大于等于某一字段值
            DataTable dt = accessHelper.SelectToDataTable("select * from GuiZe where 规则类型='基础指标' and 校验类型='DICTName'");

            if (dt.Rows.Count > 0)
            {
                ZiDianService       zdService = new ZiDianService();
                List <ZiDianEntity> zdList    = zdService.GetZiDianList();//规则集合
                if (table.Key.Equals("ZBXXB"))
                {
                    string             path         = table.Value;
                    ZBXXBService       zbxxbService = new ZBXXBService();
                    List <ZBXXBEntity> zbxxbList    = zbxxbService.GetZBXXBList(path);                        //待检查数据集合
                    DataTable          zbxxbTable   = ah.SelectToDataTable("select * from ZBXXB", path);      //待检查数据table
                    DataTable          zdTable      = accessHelper.SelectToDataTable("select * from ZiDian"); //字典表
                    for (int i = 0; i < dt.Rows.Count; i++)                                                   //需要检查字典的数据条数
                    {
                        List <string> codeList = zdService.GetZiDianCodeByLXBM(dt.Rows[i]["字段名"].ToString());
                        string        checkSql = "select * from ZBXXB where " + dt.Rows[i]["字段名"] + " not in (";
                        for (int j = 0; j < codeList.Count; j++)
                        {
                            if (codeList.Count == 1)
                            {
                                checkSql += "'" + codeList[j] + "'" + ")";
                            }
                            else if (j != (codeList.Count - 1))
                            {
                                checkSql += "'" + codeList[j] + "'" + ",";
                            }
                            else
                            {
                                checkSql += "'" + codeList[j] + "'" + ")";
                            }
                        }
                        DataTable resultTable = ah.SelectToDataTable(checkSql, path);
                        if (resultTable != null)
                        {
                            for (int j = 0; j < resultTable.Rows.Count; j++)
                            {
                                ComMsg.ResultShow.Add(new ResultEntity(tName, "基础指标", "130000001", "字段值在字典值域内", dt.Rows[i]["字段名"].ToString() + "字段值不在" + zdService.GetZiDianName(dt.Rows[i]["字段名"].ToString()) + "字典值域内,字段值为:" + resultTable.Rows[j][dt.Rows[i]["字段名"].ToString()], j + "", dt.Rows[i]["严重程度"].ToString(), DateTime.Now.ToShortDateString()));
                            }
                        }
                    }
                }
            }
        }
Ejemplo n.º 6
0
        /// <summary>
        /// 字段值大于等于某一值
        /// </summary>
        /// <param name="sql">检查的sql语句</param>
        /// <param name="table">检查的数据表</param>
        /// <param name="crl">主页面需要显示的窗体</param>
        public void ZDZDYDYMZ(string sql, KeyValuePair <string, string> table, MainCrl crl, string tName)
        {
            AccessHelper accessHelper = new AccessHelper();
            AccessHelper ah           = new AccessHelper();
            DataTable    checkTable   = ah.SelectToDataTable(sql, table.Value); //待检查数据
            //字段值大于等于某一字段值
            DataTable dt = accessHelper.SelectToDataTable("select * from GuiZe where 规则类型='基础指标' and 校验类型='SQL'");

            if (dt.Rows.Count > 0)
            {
                for (int i = 0; i < dt.Rows.Count; i++)
                {
                    if (dt.Rows[i]["表名"].Equals(table.Key))
                    {
                        string    checkSql    = "select * from " + table.Key + " where " + dt.Rows[i]["表达式"];
                        DataTable resultTable = ah.SelectToDataTable(checkSql, table.Value);

                        //获取两个数据源的差集
                        IEnumerable <DataRow> query2 = checkTable.AsEnumerable().Except(resultTable.AsEnumerable(), DataRowComparer.Default);
                        //两个数据源的差集集合
                        if (query2 != null && query2.Count() > 0)
                        {
                            DataTable dt3 = query2.CopyToDataTable();
                            if (dt3.Rows.Count > 0)
                            {
                                for (int j = 0; j < checkTable.Rows.Count; j++)
                                {
                                    for (int k = 0; k < dt3.Rows.Count; k++)
                                    {
                                        if (dt3.Rows[k]["ZDTYBM"].Equals(checkTable.Rows[j]["ZDTYBM"]))
                                        {
                                            ComMsg.ResultShow.Add(new ResultEntity(tName, dt.Rows[i]["规则类型"].ToString(), dt.Rows[i]["规则编号"].ToString(), dt.Rows[i]["规则名称"].ToString(),
                                                                                   dt.Rows[i]["字段名"] + dt.Rows[i]["错误描述"].ToString(), (j + 1) + "", dt.Rows[i]["严重程度"].ToString(), DateTime.Now.ToShortDateString()));
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
Ejemplo n.º 7
0
        /// <summary>
        /// 检查文件信息
        /// </summary>
        /// <param name="infoList"></param>
        public void CheckFileMsg(List<FileInfo> infoList,string path,MainCrl crl)
        {
            crl.rtbLog.Text += "\n " + DateTime.Now.ToLongTimeString() + "开始检查文件目录及文件";
            List<string> files = new List<string>();//去除所有父级目录后的文件信息
            //读取了目标文件夹下所有的文件信息,将这些文件和数据库的信息进行成果比对
            if (infoList == null) return;
            for (int i = 0; i < infoList.Count(); i++)
            {
                //去除选定目录的所有父级目录,只保留选定文件夹所包含的文件夹路径
                files.Add(infoList[i].FullName.Replace(path + @"\", ""));
                //截取文件夹
                //folders.Add(files[i].Substring(0, files[i].LastIndexOf(@"\")));
                //截取文件
                // folderFiles.Add(files[i].Substring(files[i].LastIndexOf(@"\")+1));
            }
            //检查当前文件是否在数据库配置中
            AccessHelper ah = new AccessHelper();
            System.Data.DataTable dt = ah.SelectToDataTable("select * from WenJian");
            List<string> dateList = new List<string>();
            for (int i = 0; i < dt.Rows.Count; i++)
            {
                if(((bool)dt.Rows[i]["是否必填"]))
                {
                    bool showError = true;//是否显示问题数据
                    for (int j = 0; j < files.Count; j++)
                    {
                        if(dt.Rows[i]["文件开始字符"].ToString().Contains("|"))
                        {
                            string[] actionList = dt.Rows[i]["文件开始字符"].ToString().Split("|".ToArray());
                            if (actionList.Contains(files[j].Substring(0,files[j].LastIndexOf(@"\"))))
                            {
                                if (dt.Rows[i]["文件结束字符"].ToString().Contains("|"))//有“|”说明有多种选择,将字符按|进行分割比较
                                {
                                    string[] fileNameList = dt.Rows[i]["文件结束字符"].ToString().Split("|".ToArray());
                                    foreach(string temp in fileNameList)
                                    {
                                        if(files[j].Contains(temp))
                                        {
                                            //在此判断后缀
                                            if (dt.Rows[i]["文件扩展名"].ToString().Contains("|"))
                                            {
                                                string[] fileEndList = dt.Rows[i]["文件扩展名"].ToString().Split("|".ToArray());
                                                foreach(string endTemp in fileEndList)
                                                {
                                                    if (endTemp.Contains(files[j].Substring(files[j].LastIndexOf(".") + 1)))
                                                    {
                                                        files.Remove(files[j]);
                                                        showError = false;
                                                        break;
                                                    }
                                                }
                                                break;
                                            }
                                            else
                                            {
                                                if(dt.Rows[i]["文件扩展名"].ToString().Contains(files[j].Substring(files[j].LastIndexOf(".") + 1)))
                                                {
                                                    files.Remove(files[j]);
                                                    showError = false;
                                                    break;
                                                }
                                                break;
                                            }
                                        }
                                    }
                                }
                                else if (files[j].Contains(dt.Rows[i]["文件结束字符"].ToString()))
                                {
                                    if (dt.Rows[i]["文件扩展名"].ToString().Contains("|"))
                                    {
                                        string[] fileEndList = dt.Rows[i]["文件扩展名"].ToString().Split("|".ToArray());
                                        foreach (string endTemp in fileEndList)
                                        {
                                            if (endTemp.Contains(files[j].Substring(files[j].LastIndexOf(".") + 1)))
                                            {
                                                files.Remove(files[j]);
                                                showError = false;
                                                break;
                                            }
                                            break;
                                        }
                                    }
                                    else
                                    {
                                        if (dt.Rows[i]["文件扩展名"].ToString().Contains(files[j].Substring(files[j].LastIndexOf(".") + 1)))
                                        {
                                            files.Remove(files[j]);
                                            showError = false;
                                            break;
                                        }
                                    }
                                }
                            }
                        }
                        else if (files[j].Contains(dt.Rows[i]["文件开始字符"].ToString()))
                        {
                            if (dt.Rows[i]["文件结束字符"].ToString().Contains("|"))//有“|”说明有多种选择,将字符按|进行分割比较
                            {
                                string[] fileNameList = dt.Rows[i]["文件结束字符"].ToString().Split("|".ToArray());
                                if (fileNameList.Contains(files[j]))
                                {
                                    if (dt.Rows[i]["文件扩展名"].ToString().Contains("|"))
                                    {
                                        string[] fileEndList = dt.Rows[i]["文件扩展名"].ToString().Split("|".ToArray());
                                        foreach (string endTemp in fileEndList)
                                        {
                                            if (files[j].Contains(endTemp))
                                            {
                                                files.Remove(files[j]);
                                                showError = false;
                                                break;
                                            }
                                        }
                                    }
                                    else
                                    {
                                        if (dt.Rows[i]["文件扩展名"].ToString().Contains(files[j].Substring(files[j].LastIndexOf(".") + 1)))
                                        {
                                            files.Remove(files[j]);
                                            showError = false;
                                            break;
                                        }
                                    }
                                }
                            }
                            else if (files[j].Contains(dt.Rows[i]["文件结束字符"].ToString()))
                            {
                                if (dt.Rows[i]["文件扩展名"].ToString().Contains("|"))
                                {
                                    string[] fileEndList = dt.Rows[i]["文件扩展名"].ToString().Split("|".ToArray());
                                    foreach (string endTemp in fileEndList)
                                    {
                                        if (files[j].Contains(endTemp))
                                        {
                                            files.Remove(files[j]);
                                            showError = false;
                                            break;
                                        }
                                    }
                                }
                                else
                                {
                                    if (dt.Rows[i]["文件扩展名"].ToString().Contains(files[j].Substring(files[j].LastIndexOf(".") + 1)))
                                    {
                                        files.Remove(files[j]);
                                        showError = false;
                                        break;
                                    }
                                }
                            }
                        }
                    }
                    if (showError)
                    {
                        ComMsg.ResultShow.Add(new ResultEntity(path.Substring(path.LastIndexOf(@"\") + 1), "数据完整性", "900000001", "成果完整性符合标准",
                           "目录结构或者文件不符合标准;缺少文件:" + dt.Rows[i]["文件结束字符"].ToString(), "", "重缺陷", DateTime.Now.ToShortDateString()));

                    }

                }
            }
        }
Ejemplo n.º 8
0
 /// <summary>
 /// 检查加载进来的文件夹下面的所有文件信息
 /// </summary>
 /// <param name="path">文件夹路径</param>
 /// <param name="mainCrl">检查主窗体</param>
 public List<FileInfo> ReturnFiles(string path,MainCrl mainCrl)
 {
     if(path.Length==0)
     {
         MessageBox.Show("请选择路径");
         return null;
     }
     System.IO.DirectoryInfo aDir = null;
     try
     {
         //获取当前目录
         aDir = new System.IO.DirectoryInfo(path);
     }
     catch (Exception)
     {
         MessageBox.Show("路径不合法");
         return null;
     }
     DirectoryInfo[] dirs = aDir.GetDirectories();//获取当前目录的所有子目录
     if(dirs.Count()>0)
     {
         //记录当前目录下所有的子目录名称
         List<string> AllFileName = new List<string>();
         foreach (DirectoryInfo dir in dirs)
         {
             AllFileName.Add(dir.FullName);//当前目录的子目录
             if (dir.GetFiles().Count() != 0)
             {
                 ComMsg.infoList.AddRange(dir.GetFiles());
             }
             AllFile(AllFileName, dir);
         }
     }
     return  ComMsg.infoList;
 }
Ejemplo n.º 9
0
        /// <summary>
        /// 字段值大于等于某一值
        /// </summary>
        /// <param name="sql">检查的sql语句</param>
        /// <param name="table">检查的数据表</param>
        /// <param name="crl">主页面需要显示的窗体</param>
        public void ZDZDYDYMZ(string sql,KeyValuePair<string,string> table,MainCrl crl,string tName)
        {
            AccessHelper accessHelper = new AccessHelper();
            AccessHelper ah = new AccessHelper();
            DataTable checkTable = ah.SelectToDataTable(sql, table.Value); //待检查数据
            //字段值大于等于某一字段值
            DataTable dt = accessHelper.SelectToDataTable("select * from GuiZe where 规则类型='基础指标' and 校验类型='SQL'");
            if (dt.Rows.Count > 0)
            {
                for (int i = 0; i < dt.Rows.Count; i++)
                {
                    if (dt.Rows[i]["表名"].Equals(table.Key))
                    {
                        string checkSql = "select * from " + table.Key + " where " + dt.Rows[i]["表达式"];
                        DataTable resultTable = ah.SelectToDataTable(checkSql, table.Value);

                        //获取两个数据源的差集
                        IEnumerable<DataRow> query2 = checkTable.AsEnumerable().Except(resultTable.AsEnumerable(), DataRowComparer.Default);
                        //两个数据源的差集集合
                        if (query2 != null && query2.Count() > 0)
                        {
                            DataTable dt3 = query2.CopyToDataTable();
                            if (dt3.Rows.Count > 0)
                            {
                                for (int j = 0; j < checkTable.Rows.Count; j++)
                                {
                                    for (int k = 0; k < dt3.Rows.Count;k++ )
                                    {
                                        if (dt3.Rows[k]["ZDTYBM"].Equals(checkTable.Rows[j]["ZDTYBM"]))
                                        {
                                            ComMsg.ResultShow.Add(new ResultEntity(tName, dt.Rows[i]["规则类型"].ToString(), dt.Rows[i]["规则编号"].ToString(), dt.Rows[i]["规则名称"].ToString(),
                            dt.Rows[i]["字段名"]+dt.Rows[i]["错误描述"].ToString(), (j + 1) + "", dt.Rows[i]["严重程度"].ToString(), DateTime.Now.ToShortDateString()));
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
Ejemplo n.º 10
0
        /// <summary>
        /// 检查数据是否在字典表中的字典名称值域内
        /// </summary>
        /// <param name="sql"></param>
        /// <param name="table"></param>
        /// <param name="crl"></param>
        /// <param name="tName"></param>
        public void CheckZiDianName(string sql, KeyValuePair<string, string> table, MainCrl crl, string tName)
        {
            AccessHelper accessHelper = new AccessHelper();
            AccessHelper ah = new AccessHelper();
            //字段值大于等于某一字段值
            DataTable dt = accessHelper.SelectToDataTable("select * from GuiZe where 规则类型='基础指标' and 校验类型='DICTName'");
            if (dt.Rows.Count > 0)
            {
                ZiDianService zdService = new ZiDianService();
                List<ZiDianEntity> zdList = zdService.GetZiDianList();//规则集合
                if (table.Key.Equals("ZBXXB"))
                {
                    string path = table.Value;
                    ZBXXBService zbxxbService = new ZBXXBService();
                    List<ZBXXBEntity> zbxxbList = zbxxbService.GetZBXXBList(path);//待检查数据集合
                    DataTable zbxxbTable = ah.SelectToDataTable("select * from ZBXXB", path);//待检查数据table
                    DataTable zdTable = accessHelper.SelectToDataTable("select * from ZiDian");//字典表
                    for (int i = 0; i < dt.Rows.Count; i++)//需要检查字典的数据条数
                    {
                        List<string> codeList = zdService.GetZiDianCodeByLXBM(dt.Rows[i]["字段名"].ToString());
                        string checkSql = "select * from ZBXXB where " + dt.Rows[i]["字段名"] + " not in (";
                        for (int j = 0; j < codeList.Count; j++)
                        {
                            if (codeList.Count == 1)
                                checkSql += "'" + codeList[j] + "'" + ")";
                            else if (j != (codeList.Count - 1))
                                checkSql += "'" + codeList[j] + "'" + ",";
                            else
                                checkSql += "'" + codeList[j] + "'" + ")";
                        }
                        DataTable resultTable = ah.SelectToDataTable(checkSql, path);
                        if (resultTable != null)
                        {
                            for (int j = 0; j < resultTable.Rows.Count; j++)
                            {
                                ComMsg.ResultShow.Add(new ResultEntity(tName, "基础指标", "130000001", "字段值在字典值域内", dt.Rows[i]["字段名"].ToString() + "字段值不在" + zdService.GetZiDianName(dt.Rows[i]["字段名"].ToString()) + "字典值域内,字段值为:" + resultTable.Rows[j][dt.Rows[i]["字段名"].ToString()], j + "", dt.Rows[i]["严重程度"].ToString(), DateTime.Now.ToShortDateString()));
                            }
                        }

                    }
                }

            }
        }
Ejemplo n.º 11
0
 //检查文件路径信息
 public void CheckPathMsg(string path,MainCrl crl)
 {
     if(path.Length==0)
     {
         MessageBox.Show("请选择路径");
         return;
     }
     System.IO.DirectoryInfo aDir = null;
     try
     {
         //获取当前目录
         aDir = new System.IO.DirectoryInfo(path);
     }
     catch (Exception)
     {
         MessageBox.Show("路径不合法");
         return;
     }
     DirectoryInfo[] dirs =aDir.GetDirectories();//获取当前目录的所有子目录
     if(dirs.Count()>0)
     {
         //记录当前目录下所有的子目录名称
         List<string> AllFileName = new List<string>();
         foreach(DirectoryInfo dir in dirs)
         {
             AllFileName.Add(dir.FullName);//当前目录的子目录
             AllFile(AllFileName,dir);
         }
         //获取配置库中需要检查的目录信息
         AccessHelper ah = new AccessHelper();
         string sql = "select * from MuLu";
         DataTable dt = ah.SelectToDataTable(sql);
         if(dt.Rows.Count>0)
         {
             for (int i = 0; i < AllFileName.Count();i++ )
             {
                 AllFileName[i] = AllFileName[i].Replace(path+@"\", "");//截取当前目录所有子目录,使其符合数据库配置规则。
             }
             //检查当前目录是否在数据库配置库中,
             for (int i = 0; i < dt.Rows.Count; i++)
             {
                 string temp = dt.Rows[i]["目录名称"].ToString();
                 if(!AllFileName.Contains(temp))//如果不存在,说明当前目录的子目录缺少必须的目录
                 {
                     crl.rtbLog.Text += "\n 目录结构不完整,缺少" + temp+"文件夹";
                     if(path.Contains("\\"))
                     {
                         path=path.Substring(path.LastIndexOf(@"\")+1);
                     }
                     ComMsg.ResultShow.Add(new ResultEntity(path, "数据完整性", "900000001", "成果完整性符合标准",
                     "目录结构或者文件不符合标准;缺少文件:" + path + @"\" + temp, "", "重缺陷", DateTime.Now.ToShortDateString()));
                     crl.rtbLog.Text += "\n " + DateTime.Now.ToShortTimeString()+" 目录结构或者文件不符合标准,缺少文件" + path + @"\" + temp;
                 }
             }
             //检查当前目录存在的多余文件夹
             for(int j=0;j<dt.Rows.Count;j++)
             {
                 for(int i=0;i<AllFileName.Count;i++)
                 {
                     if(AllFileName[i].Equals(dt.Rows[j]["目录名称"].ToString()))
                     {
                         AllFileName.Remove(AllFileName[i]);
                         break;
                     }
                 }
             //dt的rows中都没有allfileName,将AllFileName[i]写入ResultShow中
             }
             foreach(string file in AllFileName)
             {
                 crl.rtbLog.Text += "\n 目录结构或者文件不符合标准;存在多余的文件:" +path + @"\" + file;
                 ComMsg.ResultShow.Add(new ResultEntity(path, "数据完整性", "900000001", "成果完整性符合标准",
                     "目录结构或者文件不符合标准;存在多余的文件:"+path+@"\" + file, "", "重缺陷", DateTime.Now.ToShortDateString()));
                 crl.rtbLog.Text += "\n " + "目录结构或者文件不符合标准,存在多余的文件" + path + @"\" + file;
             }
         }
     }
 }
Ejemplo n.º 12
0
        /// <summary>
        /// 检查文件信息
        /// </summary>
        /// <param name="infoList"></param>
        public void CheckFileMsg(List <FileInfo> infoList, string path, MainCrl crl)
        {
            crl.rtbLog.Text += "\n " + DateTime.Now.ToLongTimeString() + "开始检查文件目录及文件";
            List <string> files = new List <string>();//去除所有父级目录后的文件信息

            //读取了目标文件夹下所有的文件信息,将这些文件和数据库的信息进行成果比对
            if (infoList == null)
            {
                return;
            }
            for (int i = 0; i < infoList.Count(); i++)
            {
                //去除选定目录的所有父级目录,只保留选定文件夹所包含的文件夹路径
                files.Add(infoList[i].FullName.Replace(path + @"\", ""));
                //截取文件夹
                //folders.Add(files[i].Substring(0, files[i].LastIndexOf(@"\")));
                //截取文件
                // folderFiles.Add(files[i].Substring(files[i].LastIndexOf(@"\")+1));
            }
            //检查当前文件是否在数据库配置中
            AccessHelper ah = new AccessHelper();

            System.Data.DataTable dt       = ah.SelectToDataTable("select * from WenJian");
            List <string>         dateList = new List <string>();

            for (int i = 0; i < dt.Rows.Count; i++)
            {
                if (((bool)dt.Rows[i]["是否必填"]))
                {
                    bool showError = true;//是否显示问题数据
                    for (int j = 0; j < files.Count; j++)
                    {
                        if (dt.Rows[i]["文件开始字符"].ToString().Contains("|"))
                        {
                            string[] actionList = dt.Rows[i]["文件开始字符"].ToString().Split("|".ToArray());
                            if (actionList.Contains(files[j].Substring(0, files[j].LastIndexOf(@"\"))))
                            {
                                if (dt.Rows[i]["文件结束字符"].ToString().Contains("|"))//有“|”说明有多种选择,将字符按|进行分割比较
                                {
                                    string[] fileNameList = dt.Rows[i]["文件结束字符"].ToString().Split("|".ToArray());
                                    foreach (string temp in fileNameList)
                                    {
                                        if (files[j].Contains(temp))
                                        {
                                            //在此判断后缀
                                            if (dt.Rows[i]["文件扩展名"].ToString().Contains("|"))
                                            {
                                                string[] fileEndList = dt.Rows[i]["文件扩展名"].ToString().Split("|".ToArray());
                                                foreach (string endTemp in fileEndList)
                                                {
                                                    if (endTemp.Contains(files[j].Substring(files[j].LastIndexOf(".") + 1)))
                                                    {
                                                        files.Remove(files[j]);
                                                        showError = false;
                                                        break;
                                                    }
                                                }
                                                break;
                                            }
                                            else
                                            {
                                                if (dt.Rows[i]["文件扩展名"].ToString().Contains(files[j].Substring(files[j].LastIndexOf(".") + 1)))
                                                {
                                                    files.Remove(files[j]);
                                                    showError = false;
                                                    break;
                                                }
                                                break;
                                            }
                                        }
                                    }
                                }
                                else if (files[j].Contains(dt.Rows[i]["文件结束字符"].ToString()))
                                {
                                    if (dt.Rows[i]["文件扩展名"].ToString().Contains("|"))
                                    {
                                        string[] fileEndList = dt.Rows[i]["文件扩展名"].ToString().Split("|".ToArray());
                                        foreach (string endTemp in fileEndList)
                                        {
                                            if (endTemp.Contains(files[j].Substring(files[j].LastIndexOf(".") + 1)))
                                            {
                                                files.Remove(files[j]);
                                                showError = false;
                                                break;
                                            }
                                            break;
                                        }
                                    }
                                    else
                                    {
                                        if (dt.Rows[i]["文件扩展名"].ToString().Contains(files[j].Substring(files[j].LastIndexOf(".") + 1)))
                                        {
                                            files.Remove(files[j]);
                                            showError = false;
                                            break;
                                        }
                                    }
                                }
                            }
                        }
                        else if (files[j].Contains(dt.Rows[i]["文件开始字符"].ToString()))
                        {
                            if (dt.Rows[i]["文件结束字符"].ToString().Contains("|"))//有“|”说明有多种选择,将字符按|进行分割比较
                            {
                                string[] fileNameList = dt.Rows[i]["文件结束字符"].ToString().Split("|".ToArray());
                                if (fileNameList.Contains(files[j]))
                                {
                                    if (dt.Rows[i]["文件扩展名"].ToString().Contains("|"))
                                    {
                                        string[] fileEndList = dt.Rows[i]["文件扩展名"].ToString().Split("|".ToArray());
                                        foreach (string endTemp in fileEndList)
                                        {
                                            if (files[j].Contains(endTemp))
                                            {
                                                files.Remove(files[j]);
                                                showError = false;
                                                break;
                                            }
                                        }
                                    }
                                    else
                                    {
                                        if (dt.Rows[i]["文件扩展名"].ToString().Contains(files[j].Substring(files[j].LastIndexOf(".") + 1)))
                                        {
                                            files.Remove(files[j]);
                                            showError = false;
                                            break;
                                        }
                                    }
                                }
                            }
                            else if (files[j].Contains(dt.Rows[i]["文件结束字符"].ToString()))
                            {
                                if (dt.Rows[i]["文件扩展名"].ToString().Contains("|"))
                                {
                                    string[] fileEndList = dt.Rows[i]["文件扩展名"].ToString().Split("|".ToArray());
                                    foreach (string endTemp in fileEndList)
                                    {
                                        if (files[j].Contains(endTemp))
                                        {
                                            files.Remove(files[j]);
                                            showError = false;
                                            break;
                                        }
                                    }
                                }
                                else
                                {
                                    if (dt.Rows[i]["文件扩展名"].ToString().Contains(files[j].Substring(files[j].LastIndexOf(".") + 1)))
                                    {
                                        files.Remove(files[j]);
                                        showError = false;
                                        break;
                                    }
                                }
                            }
                        }
                    }
                    if (showError)
                    {
                        ComMsg.ResultShow.Add(new ResultEntity(path.Substring(path.LastIndexOf(@"\") + 1), "数据完整性", "900000001", "成果完整性符合标准",
                                                               "目录结构或者文件不符合标准;缺少文件:" + dt.Rows[i]["文件结束字符"].ToString(), "", "重缺陷", DateTime.Now.ToShortDateString()));
                    }
                }
            }
        }
Ejemplo n.º 13
0
        /// <summary>
        /// 检查规则
        /// </summary>
        /// <param name="crl">选定文件夹中的所有文件</param>
        public void CheckSempleGuiZe(string path, MainCrl crl)
        {
            crl.rtbLog.Text += "\n " + DateTime.Now.ToLongTimeString() + "开始检查质检规则";
            List <FileInfo> infoList = ComMsg.infoList;
            List <string>   files    = new List <string>();                    //去除所有父级目录后的文件信息
            string          tName    = path.Substring(path.IndexOf(@"\") + 1); //成果名称

            tName = tName.Substring(tName.LastIndexOf(@"\") + 1);
            //读取了目标文件夹下所有的文件信息,将这些文件和数据库的信息进行成果比对
            for (int i = 0; i < infoList.Count(); i++)
            {
                //去除选定目录的所有父级目录,只保留选定文件夹所包含的文件夹路径
                files.Add(infoList[i].FullName);
            }
            List <string> accessFiles = new List <string>();

            //获取所有的access文件
            foreach (string file in files)
            {
                if (file.Contains("mdb") || file.Contains("accdb"))
                {
                    accessFiles.Add(file);
                }
            }
            AccessHelper ah = new AccessHelper();
            Dictionary <string, string> tables = new Dictionary <string, string>();
            List <string> columns = new List <string>();

            //检查access文件中是否有表名
            foreach (string p in accessFiles)
            {
                string[] tableNames = ah.GetShemaTableName(p, "");
                if (tableNames.Count() > 0)
                {
                    for (int i = 0; i < tableNames.Count(); i++)
                    {
                        tables.Add(tableNames[i], p);
                        columns.AddRange(ah.GetTableColumn(p, tableNames[i]));
                    }
                }
            }

            if (tables.Count >= 0)
            {
                AccessHelper accessHelper = new AccessHelper();

                foreach (KeyValuePair <string, string> table in tables)
                {
                    string sql = "select * from " + table.Key;
                    //字段值大于等于某一值
                    ZDZDYDYMZ(sql, table, crl, tName);
                    //检查字段值是否在字典表中
                    CheckZidianCode(sql, table, crl, tName);
                    //检查字典名称是否在字典表中
                    CheckZiDianName(sql, table, crl, tName);

                    //逻辑检查
                    CheckLuoJi(sql, table, crl, tName);
                }
            }
            crl.rtbLog.Text += "\n " + DateTime.Now.ToLongTimeString() + "质检规则检查完毕";
        }
Ejemplo n.º 14
0
 //检查文件路径信息
 public void CheckPathMsg(string path, MainCrl crl)
 {
     if (path.Length == 0)
     {
         MessageBox.Show("请选择路径");
         return;
     }
     System.IO.DirectoryInfo aDir = null;
     try
     {
         //获取当前目录
         aDir = new System.IO.DirectoryInfo(path);
     }
     catch (Exception)
     {
         MessageBox.Show("路径不合法");
         return;
     }
     DirectoryInfo[] dirs = aDir.GetDirectories();//获取当前目录的所有子目录
     if (dirs.Count() > 0)
     {
         //记录当前目录下所有的子目录名称
         List <string> AllFileName = new List <string>();
         foreach (DirectoryInfo dir in dirs)
         {
             AllFileName.Add(dir.FullName);//当前目录的子目录
             AllFile(AllFileName, dir);
         }
         //获取配置库中需要检查的目录信息
         AccessHelper ah  = new AccessHelper();
         string       sql = "select * from MuLu";
         DataTable    dt  = ah.SelectToDataTable(sql);
         if (dt.Rows.Count > 0)
         {
             for (int i = 0; i < AllFileName.Count(); i++)
             {
                 AllFileName[i] = AllFileName[i].Replace(path + @"\", "");//截取当前目录所有子目录,使其符合数据库配置规则。
             }
             //检查当前目录是否在数据库配置库中,
             for (int i = 0; i < dt.Rows.Count; i++)
             {
                 string temp = dt.Rows[i]["目录名称"].ToString();
                 if (!AllFileName.Contains(temp))//如果不存在,说明当前目录的子目录缺少必须的目录
                 {
                     crl.rtbLog.Text += "\n 目录结构不完整,缺少" + temp + "文件夹";
                     if (path.Contains("\\"))
                     {
                         path = path.Substring(path.LastIndexOf(@"\") + 1);
                     }
                     ComMsg.ResultShow.Add(new ResultEntity(path, "数据完整性", "900000001", "成果完整性符合标准",
                                                            "目录结构或者文件不符合标准;缺少文件:" + path + @"\" + temp, "", "重缺陷", DateTime.Now.ToShortDateString()));
                     crl.rtbLog.Text += "\n " + DateTime.Now.ToShortTimeString() + " 目录结构或者文件不符合标准,缺少文件" + path + @"\" + temp;
                 }
             }
             //检查当前目录存在的多余文件夹
             for (int j = 0; j < dt.Rows.Count; j++)
             {
                 for (int i = 0; i < AllFileName.Count; i++)
                 {
                     if (AllFileName[i].Equals(dt.Rows[j]["目录名称"].ToString()))
                     {
                         AllFileName.Remove(AllFileName[i]);
                         break;
                     }
                 }
                 //dt的rows中都没有allfileName,将AllFileName[i]写入ResultShow中
             }
             foreach (string file in AllFileName)
             {
                 crl.rtbLog.Text += "\n 目录结构或者文件不符合标准;存在多余的文件:" + path + @"\" + file;
                 ComMsg.ResultShow.Add(new ResultEntity(path, "数据完整性", "900000001", "成果完整性符合标准",
                                                        "目录结构或者文件不符合标准;存在多余的文件:" + path + @"\" + file, "", "重缺陷", DateTime.Now.ToShortDateString()));
                 crl.rtbLog.Text += "\n " + "目录结构或者文件不符合标准,存在多余的文件" + path + @"\" + file;
             }
         }
     }
 }
Ejemplo n.º 15
0
        /// <summary>
        /// 检查基础指标信息
        /// </summary>
        /// <param name="infoList"></param>
        public bool CheckZhiBiaoMsg(List <FileInfo> infoList, string path, MainCrl crl)
        {
            crl.rtbLog.Text += "\n " + DateTime.Now.ToLongTimeString() + "开始检查基础指标";
            List <string> files = new List <string>();                    //去除所有父级目录后的文件信息
            string        tName = path.Substring(path.IndexOf(@"\") + 1); //成果名称

            tName = tName.Substring(tName.LastIndexOf(@"\") + 1);
            //读取了目标文件夹下所有的文件信息,将这些文件和数据库的信息进行成果比对
            for (int i = 0; i < infoList.Count(); i++)
            {
                //去除选定目录的所有父级目录,只保留选定文件夹所包含的文件夹路径
                files.Add(infoList[i].FullName);
            }
            List <string> accessFiles = new List <string>();

            //获取所有的access文件
            foreach (string file in files)
            {
                if (file.Contains("mdb") || file.Contains("accdb"))
                {
                    accessFiles.Add(file);
                }
            }
            AccessHelper ah = new AccessHelper();
            Dictionary <string, string> tables = new Dictionary <string, string>();
            List <string> columns = new List <string>();

            //检查access文件中是否有表名
            foreach (string p in accessFiles)
            {
                string[] tableNames = ah.GetShemaTableName(p, "");
                if (tableNames.Count() > 0)
                {
                    for (int i = 0; i < tableNames.Count(); i++)
                    {
                        tables.Add(tableNames[i], p);
                        columns.AddRange(ah.GetTableColumn(p, tableNames[i]));
                    }
                }
            }

            if (tables.Count > 0)
            {
                AccessHelper accessHelper = new AccessHelper();
                DataTable    dt           = accessHelper.SelectToDataTable("select * from ZhiBiao ");
                for (int i = 0; i < dt.Rows.Count; i++)
                {
                    string    tablePath = tables[dt.Rows[i]["表名"].ToString()];
                    string    sql       = "select  " + dt.Rows[i]["列名"].ToString() + "  from  " + dt.Rows[i]["表名"].ToString();
                    DataTable tempDT    = ah.SelectToDataTable(sql, tablePath);
                    if (tempDT.Rows.Count > 0)
                    {
                        for (int j = 0; j < tempDT.Rows.Count; j++)
                        {
                            String check = tempDT.Rows[j][(dt.Rows[i]["列名"].ToString())].ToString();
                            //除去数据类型为date的数据,都需要检查字段长度
                            if (!dt.Rows[i]["数据类型"].ToString().Equals("Date"))//长度检查
                            {
                                if (check.Length > (int)dt.Rows[i]["数据长度"])
                                {
                                    ComMsg.ResultShow.Add(new ResultEntity(tName, "结构符合性", "100000004", "字段值长度不能超过数据库标准的字段长度", "字段值长度不能超过数据库标准的字段长度", j + "", "重缺陷", DateTime.Now.ToShortDateString()));
                                }
                            }
                            if (dt.Rows[i]["是否必填"].ToString().Equals("M"))//是否必填
                            {
                                if (tempDT.Rows[j][(dt.Rows[i]["列名"].ToString())].ToString().Length == 0)
                                {
                                    ComMsg.ResultShow.Add(new ResultEntity(tName, "结构符合性", "100000002", "指标信息不能缺少字段", "指标信息不能缺少字段", j + "", "重缺陷", DateTime.Now.ToShortDateString()));
                                }
                            }

                            //字段类型为int
                            if (dt.Rows[i]["数据类型"].ToString().Equals("Int"))
                            {
                                try
                                {
                                    int temp = Convert.ToInt32(tempDT.Rows[j][(dt.Rows[i]["列名"].ToString())]);
                                }
                                catch (Exception)
                                {
                                    if (tempDT.Rows[j][(dt.Rows[i]["列名"].ToString())].ToString().Length > 0)
                                    {
                                        ComMsg.ResultShow.Add(new ResultEntity(tName, "结构符合性", "100000003", "字段值符合标准数据库字段类型", "字段值不符合标准数据库字段类型", j + "", "重缺陷", DateTime.Now.ToShortDateString()));
                                    }
                                }
                            }
                            //字段类型为double
                            if (dt.Rows[i]["数据类型"].ToString().Equals("Double") && tempDT.Rows[j][(dt.Rows[i]["列名"].ToString())].ToString().Length > 0)
                            {
                                try
                                {
                                    string temp = tempDT.Rows[j][(dt.Rows[i]["列名"].ToString())].ToString();
                                    //检查小数位
                                    if (temp.Contains("."))
                                    {
                                        temp = temp.Substring(temp.LastIndexOf(".") + 1);
                                        if (temp.Length > (int)dt.Rows[i]["数据精度"])
                                        {
                                            string a = dt.Rows[i]["列名"].ToString();
                                            ComMsg.ResultShow.Add(new ResultEntity(tName, "结构符合性", "100000005", "字段值小数位数不能超过数据库标准的小数位数", (dt.Rows[i]["列名"] + "字段值小数位数不能超过数据库标准的小数位数"), (j + 1) + "", "重缺陷", DateTime.Now.ToShortDateString()));
                                        }
                                    }
                                }
                                catch (Exception)
                                {
                                    if (tempDT.Rows[j][(dt.Rows[i]["列名"].ToString())].ToString().Length > 0)
                                    {
                                        ComMsg.ResultShow.Add(new ResultEntity(tName, "结构符合性", "100000003", "字段值符合标准数据库字段类型", "字段值不符合标准数据库字段类型", j + "", "重缺陷",
                                                                               DateTime.Now.ToShortDateString()));
                                    }
                                }
                            }
                            //字段类型为date
                            if (dt.Rows[i]["数据类型"].ToString().Equals("Date"))
                            {
                            }
                        }
                    }
                }
            }
            ah.Close();
            return(true);
        }