Exemple #1
0
        private void btnExtract_Click(object sender, RoutedEventArgs e)
        {
            DateTime before = System.DateTime.Now;

            getProperties();
            DateTime after = System.DateTime.Now;
            TimeSpan ts    = after.Subtract(before);

            CheckLog.Logger("[info]" + "时间统计" + ts);
        }
Exemple #2
0
        /// <summary>
        /// 模型预检查
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void doPreCheck(object sender, DoWorkEventArgs e)
        {
            DateTime before = System.DateTime.Now;



            String modelPath = _parentWindow.GetOpenedModelFileName();

            if (modelPath == null)
            {
                MessageBox.Show("请载入模型文件", "提示", MessageBoxButton.OK, MessageBoxImage.Information);
                return;
            }
            String normSelector = GetSelectedNorm();

            if (normSelector.Equals(""))
            {
                MessageBox.Show("请选择规则", "提示", MessageBoxButton.OK, MessageBoxImage.Information);
                return;
            }
            normFilter(normSelector);



            Dispatcher.BeginInvoke(new Action(delegate
            {
                HashSet <string> TargetIfcSet = GenerateIfcFromRules();
                PropertyExtract extractHelper = new PropertyExtract(_parentWindow.Model, _parentWindow.GetContext());


                //通过规则生成中间文件
                IFCFile file = extractHelper.getFilterIfcProperty(TargetIfcSet);
                List <ResultRow> resultRows = new List <ResultRow>();
                foreach (var rule in preRules)
                {
                    resultRows.Add(CheckSingleRule(file, rule));
                }
                showResultForPreCheck(resultRows);

                //生成结果赋值
                result = resultRows;

                //生成总体描述
                PreCheckReportInfo report = new PreCheckReportInfo(resultRows);
                ResultSummary.Text        = report.GenerateSummary();
            }));

            DateTime after = System.DateTime.Now;
            TimeSpan ts    = after.Subtract(before);

            CheckLog.Logger("[precheck时间]" + ts);
        }
Exemple #3
0
        //导出模型数据
        private void getProperties()
        {
            IfcStore           curModel    = _parentWindow.Model;
            Xbim3DModelContext context     = _parentWindow.GetContext();
            PropertyExtract    extractTool = new PropertyExtract(curModel, context);

            //CheckLog.Logger(curModel.Instances.CountOf<IIfcProduct>().ToString());

            IFCFile fileProperties = extractTool.getAllIfcProperty();
            string  str            = JsonConvert.SerializeObject(fileProperties);

            CheckLog.Logger("[info]" + str);
        }
        //返回List<RuleDetail>, 用作真正检查
        public List <RuleDetail> parseDeliveryDetail()
        {
            Initialize();

            int               firstClass    = 0;
            int               secondClass   = 0;
            int               thirdClass    = 0;
            RuleDetail        curFirstRule  = null;
            RuleDetail        curSecondRule = null;
            List <RuleDetail> allRules      = new List <RuleDetail>();

            do
            {
                //对于每一行
                while (excelInfo.Read())
                {
                    //跳过第一列有值的行
                    if (excelInfo.GetValue(0) != null)
                    {
                        continue;
                    }

                    //如果第二列有值
                    if (excelInfo.GetValue(1) != null)
                    {
                        firstClass++;
                        secondClass = 0;

                        curFirstRule        = new RuleDetail();
                        curFirstRule.Entity = excelInfo.GetValue(1).ToString();


                        try
                        {
                            curFirstRule.EntityIfd = excelInfo.GetValue(8).ToString();
                        }
                        catch (Exception ex)
                        {
                            //如果出现nullptr的exception,代表用户没有填写IFD
                        }
                    }

                    //如果第三列有值
                    if (excelInfo.GetValue(2) != null)
                    {
                        secondClass++;
                        thirdClass = 0;

                        string name = excelInfo.GetValue(2).ToString();
                        curSecondRule = new RuleDetail();

                        if (name == "属性")
                        {
                            curSecondRule.type = RuleType.Property;
                        }
                        else if (name == "组成结构")
                        {
                            curSecondRule.type = RuleType.Structure;
                        }
                        else if (name == "几何")
                        {
                            curSecondRule.type = RuleType.Geometry;
                        }
                        else
                        {
                            //规则类别错误
                            throw new Exception("规则类别错误");
                        }
                    }

                    //如果第四列有值
                    if (excelInfo.GetValue(3) != null)
                    {
                        thirdClass++;
                        string name      = firstClass.ToString() + '.' + secondClass.ToString() + '.' + thirdClass.ToString() + ':' + excelInfo.GetValue(3).ToString();
                        var    thirdRule = new RuleDetail();
                        //处理基本信息
                        thirdRule.No        = firstClass.ToString() + '.' + secondClass.ToString() + '.' + thirdClass.ToString();
                        thirdRule.Entity    = curFirstRule.Entity;
                        thirdRule.EntityIfd = curFirstRule.EntityIfd;
                        thirdRule.type      = curSecondRule.type;
                        //根据类别处理内容
                        if (thirdRule.type == RuleType.Structure)
                        {
                            try
                            {
                                thirdRule.content  = excelInfo.GetValue(8).ToString();
                                thirdRule.Descript = thirdRule.Entity + "的组成结构包含" + excelInfo.GetValue(3).ToString();
                            }
                            catch
                            {
                                //用户没有写IFD编码
                            }
                        }
                        else
                        {
                            thirdRule.content = excelInfo.GetValue(3).ToString();
                            if (thirdRule.type == RuleType.Property)
                            {
                                thirdRule.Descript = thirdRule.Entity + "的属性包括" + thirdRule.content;
                            }
                            if (thirdRule.type == RuleType.Geometry)
                            {
                                thirdRule.Descript = thirdRule.Entity + "的几何表达形式为" + thirdRule.content;
                            }
                        }
                        CheckLog.Logger(thirdRule.ToString());
                        //把合理的Rule放入返回列表
                        if (thirdRule.isValidate())
                        {
                            thirdRule.IFDtoIFC();
                            allRules.Add(thirdRule);
                        }
                    }
                }
            } while (excelInfo.NextResult());

            return(allRules);
        }
Exemple #5
0
        private void doCheck(object sender, DoWorkEventArgs e)
        {
            DateTime before = System.DateTime.Now;

            StopProgressBarAnimation(true);

            Process process   = new Process();
            String  datafrom  = "ifc";
            String  checkType = "ConsistencyCheck";
            String  checkMode = "1";
            //String normPath = "E:\\1实验室工作\\SPLdoc\\rulechecker功能基准测试.spl";
            //String normSelector = "2.2.1;2.2.3";
            String modelPath = _parentWindow.GetOpenedModelFileName();

            if (modelPath == null)
            {
                MessageBox.Show("请载入模型文件", "提示", MessageBoxButton.OK, MessageBoxImage.Information);
                return;
            }
            String normPath = SplPath;

            if (normPath == null)
            {
                MessageBox.Show("请载入规则文件", "提示", MessageBoxButton.OK, MessageBoxImage.Information);
                return;
            }
            String normSelector = GetSelectedNorm();

            if (normSelector.Equals(""))
            {
                MessageBox.Show("请选择规则", "提示", MessageBoxButton.OK, MessageBoxImage.Information);
                return;
            }

            process.StartInfo.FileName               = Config_Global.DIR + "\\BC.exe";
            process.StartInfo.Arguments              = " -datafrom " + datafrom + " -checktype " + checkType + " -checkmode " + checkMode + " -normpath " + "\"" + normPath + "\"" + " -normsel " + "\"" + normSelector + "\""; // Note the /c command (*)
            process.StartInfo.UseShellExecute        = false;
            process.StartInfo.RedirectStandardInput  = true;
            process.StartInfo.RedirectStandardOutput = true;
            process.StartInfo.RedirectStandardError  = true;
            process.StartInfo.CreateNoWindow         = true;


            process.OutputDataReceived += new DataReceivedEventHandler(OutputHandler);
            //process.ErrorDataReceived += new DataReceivedEventHandler(OutputHandler);



            process.Start();
            process.BeginOutputReadLine();
            process.BeginErrorReadLine();


            StreamWriter myinput = process.StandardInput;

            myinput.WriteLine(modelPath);
            //myinput.WriteLine("E:\\1实验室工作\\SPLdoc\\AC20-Institute-Var-2.ifc");
            myinput.Close();
            process.WaitForExit();

            DateTime after = System.DateTime.Now;

            TimeSpan ts = after.Subtract(before);

            CheckLog.Logger("[check时间]" + ts);
        }
Exemple #6
0
        //旧版xls打开
        private void btnXlsCheck_Click(object sender, RoutedEventArgs e)
        {
            //打开xls
            string         xlsPath        = null;
            OpenFileDialog openFileDialog = new OpenFileDialog {
                Filter = "Rules Files|*.xls;*.xlsx"
            };

            if (openFileDialog.ShowDialog() == true)
            {
                xlsPath = openFileDialog.FileName;
            }

            //parse xls
            if (xlsPath == null)
            {
                MessageBox.Show("规则文件为空", "Alert", MessageBoxButton.OK, MessageBoxImage.Error);
                return;
            }
            RuleXLS XlsToSNL = new RuleXLS(xlsPath);

            try
            {
                //储存SNL文件
                string SNLPath = Config_Global.DIR + "\\docs\\Baselinelibrary\\" + System.IO.Path.GetFileNameWithoutExtension(xlsPath) + ".snl";
                Directory.CreateDirectory(System.IO.Path.GetDirectoryName(SNLPath));

                XlsToSNL.xlsread();
                XlsToSNL.GenerateSNL();
                XlsToSNL.xml(SNLPath);

                //加载config文件
                string ConfigPath = Config_Global.DIR + "\\default_config.cfg";
                string config     = File.ReadAllText(ConfigPath, Encoding.GetEncoding(1252));


                string ConfigNewPath = Config_Global.DIR + "\\docs\\Config\\" + System.IO.Path.GetFileNameWithoutExtension(xlsPath) + ".cfg";
                Directory.CreateDirectory(System.IO.Path.GetDirectoryName(ConfigNewPath));
                System.IO.File.WriteAllText(ConfigNewPath, config, Encoding.GetEncoding(1252));
            }
            catch (Exception except)
            {
                MessageBox.Show("规则文件解析错误", "Alert", MessageBoxButton.OK, MessageBoxImage.Error);
                CheckLog.Logger("[error]" + "btnXlsCheck_Click" + except.Data);
                return;
            }

            try
            {
                Process process   = new Process();
                String  outputdir = Config_Global.DIR + "\\" + System.IO.Path.GetFileNameWithoutExtension(xlsPath) + ".spl";
                String  filename  = Config_Global.DIR + "\\docs\\Baselinelibrary\\" + System.IO.Path.GetFileNameWithoutExtension(xlsPath) + ".snl";



                process.StartInfo.FileName               = Config_Global.DIR + "\\baseline.exe";
                process.StartInfo.Arguments              = " -cmd -outdir " + outputdir + " -filename " + filename;
                process.StartInfo.UseShellExecute        = false;
                process.StartInfo.RedirectStandardInput  = true;
                process.StartInfo.RedirectStandardOutput = true;
                process.StartInfo.RedirectStandardError  = true;
                process.StartInfo.CreateNoWindow         = true;



                process.Start();


                //* Read the output (or the error)
                string output = process.StandardOutput.ReadToEnd();
                //Console.WriteLine(output);
                string err = process.StandardError.ReadToEnd();

                process.WaitForExit();

                SplPath = outputdir;
                xmlparser(SplPath);
            }
            catch (Exception except)
            {
                MessageBox.Show("baseline调用错误", "Alert", MessageBoxButton.OK, MessageBoxImage.Error);
                CheckLog.Logger("[error]" + "btnXlsCheck_Click, baseline" + except.Data);
                return;
            }
        }