Ejemplo n.º 1
0
        public Report LoadOldFile()
        {
            Report report = new Report();

            JObject jObject;

            using (StreamReader reader = File.OpenText(this.FilePath))
            {
                jObject = (JObject)JToken.ReadFrom(new JsonTextReader(reader));
            }

            report.Class = (int)jObject["Class"];

            var ruleList = jObject["RuleList"].ToObject <JObject>();

            foreach (var rule in ruleList)
            {
                var ruleContent        = MainViewModel.RuleContent[rule.Key];
                var subRuleContentList = ruleContent.SubRuleContentsList;

                RuleResults ruleResult = new RuleResults(ruleContent)
                {
                    FinalResult = ResultFactory.CreateResult(rule.Value["FinalResult"].ToString())
                };

                var SubRuleContentIndex = 0;
                foreach (JObject sub in rule.Value["SubRuleList"])
                {
                    JArray pictureList = (JArray)sub["Pictures"];

                    SubRuleResult subRule = new SubRuleResult(subRuleContentList[SubRuleContentIndex])
                    {
                        Result = ResultFactory.CreateResult(sub["Result"].ToString()),
                        Text   = sub["Text"].ToString()
                    };

                    for (var i = 0; i < pictureList.Count; i++)
                    {
                        Picture pic = new Picture(
                            i,
                            pictureList[i]["FullPath"].ToString(),
                            pictureList[i]["Caption"].ToString()
                            );
                        subRule.Pictures.Add(pic);
                    }
                    ruleResult.SubRuleList.Add(subRule);
                    SubRuleContentIndex++;
                }
                report.RuleList[rule.Key] = ruleResult;
            }

            return(report);
        }
Ejemplo n.º 2
0
        public Report()
        {
            var contents = MainViewModel.RuleContent;

            this.RuleList = new Dictionary <string, RuleResults>();

            foreach (var rule in contents)
            {
                RuleResults result = new RuleResults(rule.Value);
                result.PropertyChanged += this.Result_PropertyChanged;
                ushort subRuleNumber = 0;
                foreach (var sub in rule.Value.SubRuleContentsList)
                {
                    SubRuleResult subResult = new SubRuleResult(sub);
                    subResult.PropertyChanged += this.SubResult_PropertyChanged;
                    result.SubRuleList.Add(subResult);
                    subRuleNumber++;
                }
                this.RuleList.Add(rule.Key, result);
            }

            this.CurrentOpenedFile = "*未儲存的報告.jsonr";
            this.PropertyChanged  += this.Report_PropertyChanged;
        }