private void WriteTestData(Table resultTable, RuleResults currentRule) { //取得table行數 int rowNumber = resultTable.RowCount; //取得佐證資料欄位的paragraph var resultTextPara = resultTable.Rows[rowNumber - 1].Cells[0].Paragraphs[0]; //將結果文字與圖片寫入到佐證資料欄位的paragraph foreach (var subRule in currentRule.SubRuleList) { //輸出Text resultTextPara.Append(subRule.Text + "\r\n").Font(Font); resultTextPara.Alignment = Alignment.left; //輸出圖片 if (subRule.Pictures.Count != 0) { InsertPicture(resultTextPara, subRule.Pictures); } resultTextPara = resultTable.Rows[rowNumber - 1].Cells[0].InsertParagraph(); } }
private void WriteTestResult(Table resultTable, RuleResults currentRule) { for (int j = 0; j < currentRule.SubRuleList.Count; j++) { //取得目前要編輯的cell Paragraph currentPara = resultTable.Rows[j + 1].Cells[0].Paragraphs[0]; var result = currentRule.SubRuleList[j].Result.GetDisplayString(); var color = currentRule.SubRuleList[j].Result.GetDisplayColor(); currentPara.Append(result).Color(color).Font(Font); } }
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); }
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; }