private bool ConditionsTabSelected(ScenarioNode node) { listConditions.Items.Clear(); textConditionView.Text = ""; foreach (var condition in SelectedNode.ConditionDeclarations) { var item = listConditions.Items.Add(condition.Name); item.Tag = condition; } return true; }
private bool FormulasTabSelected(ScenarioNode node) { listDeclarations.Items.Clear(); textFormulaView.Text = ""; foreach (var declaration in SelectedNode.FormulaDeclarations) { var item = listDeclarations.Items.Add(declaration.Name); item.Tag = declaration; declaration.NameChanged += x => item.Text = x; item.SubItems.Add(declaration.HumanType); } return true; }
private void LoadBranch(ScenarioNode scenarioNode, TreeNode parent) { if (parent == null) // root { parent = new TreeNode {Text = scenarioNode.Name, Tag = scenarioNode, NodeFont = new Font("Tahoma", 8, FontStyle.Bold),}; treeScenario.Nodes.Add(parent); } foreach (ScenarioNode node in scenarioNode.GetChildren()) { var n = new TreeNode {Text = node.Name, Tag = node,}; parent.Nodes.Add(n); LoadBranch(node, n); } }
internal bool PreviewTabSelected(ScenarioNode node) { if (templateEditor.InnerHtml == null) { previewBrowser.DocumentText = ""; return true; } var topicNumber = ""; var title = ""; var tableCounter = 1; #warning Review this: eval sessions now lock the vault for reading #if VAULT_EVAL_1 using (_evalSession1 = new Esath.Eval.Ver1.EvalSession(Scenario.Vault)) { #endif #if VAULT_EVAL_2 using (var repo = RepositoryEditor.Repository()) using (_evalSession2 = new Esath.Eval.Ver2.EvalSession(Scenario.Vault, repo, null)) { #endif #if VAULT_EVAL_3 using (_evalSession3 = new Esath.Eval.Ver3.EvalSession(Scenario.VaultCompiler)) { #endif var preview = Regex.Replace(templateEditor.InnerHtml, StartUp.VFIELD_PATTERN, vpathEvaluator, RegexOptions.Compiled); if (node.Title != "") { title = node.Title; switch (node.NodeType) { case ScenarioNodeType.Topic: topicNumber = "1"; title = string.Format("<h{1}>{2} {0}</h{1}>", title, "1", topicNumber); break; case ScenarioNodeType.Subtopic2: topicNumber = "1.1"; title = string.Format("<h{1}>{2} {0}</h{1}>", title, "2", topicNumber); break; case ScenarioNodeType.Subtopic3: topicNumber = "1.1.1"; title = string.Format("<h{1}>{2} {0}</h{1}>", title, "3", topicNumber); break; case ScenarioNodeType.Subtopic4: topicNumber = "1.1.1.1"; title = string.Format("<h{1}>{2} {0}</h{1}>", title, "4", topicNumber); break; case ScenarioNodeType.Subtopic5: topicNumber = "1.1.1.1.1"; title = string.Format("<h{1}>{2} {0}</h{1}>", title, "5", topicNumber); break; default: break; } topicNumber += "."; // for tables only } preview = Regex.Replace(preview, @"<table\s", match => string.Format(@"<div style='text-align:right'>Таблица {1}{0}</div><table ", tableCounter++, topicNumber), RegexOptions.Compiled | RegexOptions.IgnoreCase); if (title != "") preview = title + preview; previewBrowser.DocumentText = preview; #if VAULT_EVAL_1 } #endif #if VAULT_EVAL_2 } #endif #if VAULT_EVAL_3 } #endif return true; }
private bool GlossaryTabSelected(ScenarioNode node) { return true; }
private bool TemplateTabSelected(ScenarioNode node) { return true; }
private bool SourceDataTabSelected(ScenarioNode node) { listSourceValues.Items.Clear(); propertyGridSourceValue.SelectedObject = null; foreach (var sourceValueDeclaration in SelectedNode.SourceValueDeclarations) { var item = listSourceValues.Items.Add(sourceValueDeclaration.Name); item.Tag = sourceValueDeclaration; sourceValueDeclaration.NameChanged += x => item.Text = x; item.SubItems.Add(sourceValueDeclaration.HumanType); } return true; }
private void MergeNodes(ScenarioNode source, ScenarioNode dest) { foreach (ScenarioNode child in source.GetChildren()) { var @new = dest.AddChild(child.Name, new Guid(child.Model.Name.Replace('_','-'))); foreach (var declaration in child.SourceValueDeclarations) { var newDeclaration = @new.AddSourceValueDeclaration(declaration.Type, new Guid(declaration.Model.Name.Replace('_', '-'))); newDeclaration.Name = declaration.Name; newDeclaration.Comment = declaration.Comment; newDeclaration.DefaultValue = declaration.DefaultValue; newDeclaration.MeasurementUnit = declaration.MeasurementUnit; //newDeclaration.RepositoryValuePath = declaration.RepositoryValuePath; newDeclaration.ValueForTesting = declaration.ValueForTesting; } foreach (var declaration in child.FormulaDeclarations) { var newDeclaration = @new.AddFormulaDeclaration(declaration.Type, new Guid(declaration.Model.Name.Replace('_', '-'))); newDeclaration.Name = declaration.Name; newDeclaration.ElfCode = declaration.ElfCode; newDeclaration.HumanText = declaration.HumanText; } foreach (var declaration in child.ConditionDeclarations) { var newDeclaration = @new.AddConditionDeclaration(); newDeclaration.Name = declaration.Name; newDeclaration.Handler = declaration.Handler; newDeclaration.Model = declaration.Model; } @new.NodeType = child.NodeType; @new.IsAppendix = child.IsAppendix; @new.SortingWeight = child.SortingWeight; @new.Template = child.Template; @new.Title = child.Title; MergeNodes(child, @new); } }
private void menuItemReportExport_Click(object sender, EventArgs e) { #if DEBUG && USE_TDISK var basePath = Path.Combine(@"T:\", Scenario.LastReportId.ToString()); #else var basePath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments), Scenario.LastReportId.ToString()); #endif var reportFile = new FileInfo(basePath + ".doc"); //var calcFile = new FileInfo(basePath + ".c.html"); //var sourceDataFile = new FileInfo(basePath + ".s.html"); if (!reportFile.Exists) { MessageBox.Show(this, "Для того, чтобы выгрузить отчет, последний должен быть сперва сгенерирован", "Модуль выгрузки данных", MessageBoxButtons.OK, MessageBoxIcon.Warning, MessageBoxDefaultButton.Button1); return; } var fullPath = ""; var ww = new WaitWindow(); try { ww.Show(this); Func<IBranch, ScenarioNodeType> nodeType = b => b.GetValue("nodeType") == null ? ScenarioNodeType.Default : (ScenarioNodeType) Enum.Parse(typeof (ScenarioNodeType), b.GetValue("nodeType").ContentString); var all = Scenario.Vault.GetBranchesRecursive().ToDictionary(b => b, nodeType); var forExport = all.Where(kvp => kvp.Value == ScenarioNodeType.ForExport).FirstOrDefault(); Application.DoEvents(); using (var repo = RepositoryEditor.Repository()) { var now = DateTime.Now; var name = String.Format("{0:00}.{1:00}.{2:0000} {3:00}{4:00}{5:00}", now.Day, now.Month, now.Year, now.Hour, now.Minute, now.Second); var root = repo.GetOrCreateBranch("Для выгрузки"); var receiver = root.GetOrCreateBranch(name); fullPath = receiver.VPath.Path; if (!TryCreateFileStreamForTempCopy(reportFile, x => receiver.CreateValue("Отчет.doc", x).SetTypeToken2("binary"))) return; if (forExport.Key != null) { var node = new ScenarioNode(forExport.Key); //#warning Review this: eval sessions now lock the vault for reading #if VAULT_EVAL_1 using (_evalSession1 = new Esath.Eval.Ver1.EvalSession(Scenario.Vault, repo)) { #endif #if VAULT_EVAL_2 using (_evalSession2 = new Esath.Eval.Ver2.EvalSession(Scenario.Vault, repo, null)) { #endif #if VAULT_EVAL_3 using (_evalSession3 = new Esath.Eval.Ver3.EvalSession(Scenario.VaultCompiler, repo)) { #endif var source = Regex.Replace(node.Template, StartUp.VFIELD_PATTERN, vpathEvaluator, RegexOptions.Compiled); source = "<html><head></head><body>" + source + "</body></html>"; receiver.CreateValue("Расчетные Данные.html", new TempHtmlFile(source).Content).SetTypeToken2("binary"); } } var buf = new StringBuilder(32*1024); buf.Append("<html><head></head><body>"); buf.Append("<table border=1>"); buf.Append("<tr><th>Имя</th><th>Значение</th><th>Ед Изм</th><th>Тип</th></tr>"); foreach (var sourceValueDeclaration in Scenario.AllSourceValueDeclarations) { buf.AppendFormat("<tr><td>{0}</td><td>{1}</td><td>{2}</td><td>{3}</td></tr>", sourceValueDeclaration.Name, sourceValueDeclaration.Value, sourceValueDeclaration.MeasurementUnit == "" ? " " : sourceValueDeclaration.MeasurementUnit, sourceValueDeclaration.HumanType ); } buf.Append("</table>"); buf.Append("</body></html>"); receiver.CreateValue("Исходные Данные.html", new TempHtmlFile(buf.ToString()).Content).SetTypeToken2("binary"); repo.Save(); } } finally { ww.Hide(); ww = null; Application.DoEvents(); } MessageBox.Show(this, string.Format("Данные текущего отчета успешно выгружены в ветвь Репозитория '{0}'", fullPath), "Модуль выгрузки данных", MessageBoxButtons.OK, MessageBoxIcon.Information); }
private void LoadNodeMethodology(ScenarioNode x) { if (x.ConditionDeclarations.Count() > 0) return; if (x.SourceValueDeclarations.Count() > 0) { var group = _listView.Groups.Add(Id, x.Name); foreach (var sourceValueDeclaration in x.SourceValueDeclarations) { var item = new ListViewItem {Text = sourceValueDeclaration.Name}; item.SubItems.Add(sourceValueDeclaration.MeasurementUnit); item.SubItems.Add(sourceValueDeclaration.ValueForTesting); item.Tag = sourceValueDeclaration; item.Group = group; _listView.Items.Add(item); } } foreach (var branch in x.Model.GetBranches()) { if (branch.Name.StartsWith("_")) continue; // internal folder but not a visible child LoadNodeMethodology(new ScenarioNode(branch)); } }
public ScenarioNode AddChild(string name, Guid id) { var child = new ScenarioNode(Model.CreateBranch(id.ToString().Replace('-', '_'))) { Name = name, }; return child; }
private bool FormulasTabSelected(ScenarioNode node) { listDeclarations.Items.Clear(); textFormulaView.Text = ""; foreach (var declaration in SelectedNode.FormulaDeclarations .Where(f => f.Type != "text" && f.Type != "string" && f.Model != FormulaBeingEdited)) { var item = listDeclarations.Items.Add(declaration.Name); item.Tag = declaration; declaration.NameChanged += x => item.Text = x; item.SubItems.Add(declaration.HumanType); } return true; }