872 lines
		
	
	
		
			27 KiB
		
	
	
	
		
			C#
		
	
	
	
	
	
			
		
		
	
	
			872 lines
		
	
	
		
			27 KiB
		
	
	
	
		
			C#
		
	
	
	
	
	
| using System;
 | |
| using System.Collections.Generic;
 | |
| using System.ComponentModel;
 | |
| using System.Drawing;
 | |
| using System.Data;
 | |
| using System.Text;
 | |
| using System.Windows.Forms;
 | |
| using System.IO;
 | |
| using VEPROMS.CSLA.Library;
 | |
| using DevComponents.DotNetBar;
 | |
| using DevComponents.AdvTree;
 | |
| using System.Text.RegularExpressions;
 | |
| using Volian.Base.Library;
 | |
| 
 | |
| 
 | |
| namespace Volian.Controls.Library
 | |
| {
 | |
| 	public partial class DisplayReports : UserControl
 | |
| 	{
 | |
| 		#region Events
 | |
| 		public event DisplayReportsEvent PrintRequest;
 | |
| 		private void OnPrintRequest(DisplayReportsEventArgs args)
 | |
| 		{
 | |
| 			if (PrintRequest != null)
 | |
| 				PrintRequest(this, args);
 | |
| 		}
 | |
| 		#endregion
 | |
| 		private List<DocVersionInfo> lstCheckedDocVersions = new List<DocVersionInfo>();
 | |
| 		//private List<ROFSTLookup> lstCheckedROs = new List<ROFSTLookup>();
 | |
| 		private List<object> lstCheckedROs = new List<object>();
 | |
| 		private List<ItemInfoList> lstReportResults = new List<ItemInfoList>();
 | |
| 		private List<string> ROList = new List<string>();
 | |
| 		private List<object> lstROObj = new List<object>();
 | |
| 		private int _MyRODbID;
 | |
| 		private string DocVersionList
 | |
| 		{
 | |
| 			get
 | |
| 			{
 | |
| 				// append list of document versions to search
 | |
| 				if (lstCheckedDocVersions.Count > 0)
 | |
| 				{
 | |
| 					string strRtnStr = "";
 | |
| 					// get list of doc versions to search
 | |
| 					foreach (DocVersionInfo dvi in lstCheckedDocVersions)
 | |
| 					{
 | |
| 						strRtnStr += string.Format(",{0}", dvi.VersionID.ToString());
 | |
| 					}
 | |
| 					return strRtnStr.Substring(1);
 | |
| 				}
 | |
| 				return "";
 | |
| 			}
 | |
| 		}
 | |
| 		private DocVersionInfo _MyDocVersion;
 | |
| 		public DocVersionInfo Mydocversion
 | |
| 		{
 | |
| 			get { return _MyDocVersion; }
 | |
| 			set
 | |
| 			{
 | |
| 				_MyDocVersion = value;
 | |
| 				if (_MyDocVersion != null)
 | |
| 				{
 | |
| 					if (_MyDocVersion.DocVersionAssociationCount > 0)
 | |
| 					{
 | |
| 						// if the count variable is not consistent with the actual list count,
 | |
| 						// do a refresh. There was a bug, B2012-040, that was not reproducable..
 | |
| 						// so this is an attempt to fix it.
 | |
| 						if (_MyDocVersion.DocVersionAssociations.Count == 0)
 | |
| 						{
 | |
| 							_MyDocVersion.RefreshDocVersionAssociations();
 | |
| 							if (_MyDocVersion.DocVersionAssociations.Count == 0) return;
 | |
| 						}
 | |
| 						MyROFSTLookup = _MyDocVersion.DocVersionAssociations[0].MyROFst.ROFSTLookup;
 | |
| 						_MyRODbID = _MyDocVersion.DocVersionAssociations[0].MyROFst.RODbID;
 | |
| 					}
 | |
| 				}
 | |
| 			}
 | |
| 		}
 | |
| 		private ROFSTLookup _MyROFSTLookup;
 | |
| 		public ROFSTLookup MyROFSTLookup
 | |
| 		{
 | |
| 			get { return _MyROFSTLookup; }
 | |
| 			set
 | |
| 			{
 | |
| 				//if (!Visible) return;		// don't reset anything if the form is invisible.
 | |
| 				_MyROFSTLookup = value;			// define the tree nodes based on this rofst
 | |
| 				advTreeROFillIn(true);
 | |
| 				//LoadROComboTree();
 | |
| 			}
 | |
| 		}
 | |
| 
 | |
| 		private ItemInfoList _ReportResult;
 | |
| 		public ItemInfoList ReportResult
 | |
| 		{
 | |
| 			get { return _ReportResult; }
 | |
| 			set
 | |
| 			{
 | |
| 				_ReportResult = value;
 | |
| 				//if (value != null) // Don't select an item from the list when it is updated
 | |
| 				//    _ReportResult.ListChanged += new ListChangedEventHandler(_SearchResults_ListChanged);
 | |
| 				//DisplayResults();
 | |
| 			}
 | |
| 		}
 | |
| 
 | |
| 
 | |
| 		private void GenerateROList()
 | |
| 		{
 | |
| 			string rtnStr = "";
 | |
| 			ROFSTLookup.rochild[] chld = null;
 | |
| 			ROFSTLookup.rochild ch;
 | |
| 			ROList.Clear();
 | |
| 			foreach (object rolkup in lstCheckedROs)
 | |
| 			{
 | |
| 				if (rolkup is ROFSTLookup.rodbi)
 | |
| 				{
 | |
| 					rtnStr = _MyRODbID.ToString() + ":" + string.Format("{0}", ((ROFSTLookup.rodbi)rolkup).dbiID.ToString("D4"));
 | |
| 				}
 | |
| 				else if (rolkup is ROFSTLookup.rochild)
 | |
| 				{
 | |
| 					ch = (ROFSTLookup.rochild)rolkup;
 | |
| 					chld = ch.children;
 | |
| 					rtnStr = _MyRODbID.ToString() + ":" + GetROChildren(rolkup);
 | |
| 				}
 | |
| 				//else if (rolkup is ROFSTLookup.rogrp)
 | |
| 				//    Console.WriteLine("RO Group");
 | |
| 				//else if (rolkup is ROFSTLookup.roHdr)
 | |
| 				//    Console.WriteLine("RO Header");
 | |
| 				ROList.Add(rtnStr);
 | |
| 			}
 | |
| 		}
 | |
| 
 | |
| 		//private string GetROList(ROFSTLookup.rochild[] chld)
 | |
| 		private string GetROChildren(object roObj)
 | |
| 		{
 | |
| 			ROFSTLookup.rochild chld = (ROFSTLookup.rochild)roObj;
 | |
| 			string rtnstr = "";
 | |
| 			if (chld.children == null) // get a single ROID
 | |
| 			{
 | |
| 				//ROFSTLookup.rochild ro = (ROFSTLookup.rochild)roObj;
 | |
| 				rtnstr += string.Format("{0}", chld.roid); 
 | |
| 			}
 | |
| 			else
 | |
| 			{ // spin through the child list and get the ROIDs.
 | |
| 				// if the child has children, then call this function recursivly 
 | |
| 				foreach (ROFSTLookup.rochild roc in chld.children)
 | |
| 				{
 | |
| 					if (roc.children != null)
 | |
| 						rtnstr += GetROChildren(roc);
 | |
| 					else
 | |
| 						rtnstr += string.Format("{0},", roc.roid);
 | |
| 				}
 | |
| 			}
 | |
| 			return rtnstr;
 | |
| 		}
 | |
| 		private string GetListOfROs(bool keepREDbID)
 | |
| 		{
 | |
| 			string rtnStr = "";
 | |
| 			string strRODbID = "";
 | |
| 			int cnt = 0;
 | |
| 			foreach (string rostr in ROList)
 | |
| 			{
 | |
| 				int ndxOf = rostr.IndexOf(":");
 | |
| 				if (ndxOf > 0)
 | |
| 				{
 | |
| 					string tstr = rostr.Substring(0, ndxOf + 1);
 | |
| 					if (tstr != strRODbID && keepREDbID)
 | |
| 					{
 | |
| 						strRODbID = tstr;
 | |
| 						rtnStr += rostr;
 | |
| 					}
 | |
| 					else
 | |
| 						rtnStr += rostr.Substring(ndxOf + 1);
 | |
| 				}
 | |
| 				else
 | |
| 					rtnStr += rostr;
 | |
| 				if (rtnStr.EndsWith(",")) rtnStr = rtnStr.Substring(0, rtnStr.Length - 1);
 | |
| 				if (++cnt < ROList.Count)
 | |
| 					rtnStr += ",";
 | |
| 			}
 | |
| 			return rtnStr;
 | |
| 		}
 | |
| 		public DisplayReports()
 | |
| 		{
 | |
| 			InitializeComponent();
 | |
| 			EnableOrDisablePrintButton();
 | |
| 			cmbxROUsageSort.SelectedIndex = 0;
 | |
| 			tabTransitionReports.Visible = false;
 | |
| 			cbxComplete.Enabled = false;
 | |
| 			cbxSummary.Enabled = false;
 | |
| 		}
 | |
| 
 | |
| 		public void SelectReferencedObjectTab()
 | |
| 		{
 | |
| 			tabROReports.PerformClick();
 | |
| 		}
 | |
| 
 | |
| 		private void EnableOrDisablePrintButton()
 | |
| 		{
 | |
| 			switch (tctrlReports.SelectedTabIndex)
 | |
| 			{
 | |
| 				case 0: // Transition Reports
 | |
| 					btnPrintReport.Enabled = (lstCheckedDocVersions.Count > 0);
 | |
| 					break;
 | |
| 				case 1: // Referenced Objects Reports
 | |
| 					if (cbxROUsage.Checked)
 | |
| 						btnPrintReport.Enabled = (lstCheckedDocVersions.Count > 0 && lstCheckedROs.Count > 0);
 | |
| 					else
 | |
| 						btnPrintReport.Enabled = ((cbxComplete.Checked || cbxSummary.Checked) && lstCheckedROs.Count > 0);
 | |
| 					break;
 | |
| 			}
 | |
| 		}
 | |
| 
 | |
| 		private void tabTransitionReports_Click(object sender, EventArgs e)
 | |
| 		{
 | |
| 			xpSetToReport.Enabled = true;
 | |
| 			xpSetToReport.Expanded = true;
 | |
| 			xpSelROs.Expanded = false;
 | |
| 			xpSelROs.Enabled = false;
 | |
| 			EnableOrDisablePrintButton();
 | |
| 		}
 | |
| 
 | |
| 		private void tabROReports_Click(object sender, EventArgs e)
 | |
| 		{
 | |
| 			xpSetToReport.Enabled = cbxROUsage.Checked;
 | |
| 			xpSetToReport.Expanded = cbxROUsage.Checked;
 | |
| 			cmbxROUsageSort.Enabled = cbxROUsage.Checked;
 | |
| 			xpSelROs.Enabled = true;
 | |
| 			xpSelROs.Expanded = true;
 | |
| 			EnableOrDisablePrintButton();
 | |
| 		}
 | |
| 
 | |
| 		private void cbxROUsage_CheckedChanged(object sender, EventArgs e)
 | |
| 		{
 | |
| 			xpSetToReport.Enabled = cbxROUsage.Checked;
 | |
| 			xpSetToReport.Expanded = cbxROUsage.Checked;
 | |
| 			cmbxROUsageSort.Enabled = cbxROUsage.Checked;
 | |
| 			EnableOrDisablePrintButton();
 | |
| 		}
 | |
| 		#region Procedure List
 | |
| 		private DevComponents.AdvTree.Node NewAdvTreeNode(string nodetext, bool selectable, bool chxbxvisable)
 | |
| 		{
 | |
| 			DevComponents.AdvTree.Node newnode;
 | |
| 			newnode = new DevComponents.AdvTree.Node();
 | |
| 			newnode.Text = nodetext;
 | |
| 			newnode.Selectable = selectable;
 | |
| 			newnode.CheckBoxAlignment = DevComponents.AdvTree.eCellPartAlignment.NearCenter;
 | |
| 			newnode.CheckBoxStyle = eCheckBoxStyle.CheckBox;
 | |
| 			newnode.CheckBoxThreeState = false;
 | |
| 			newnode.CheckBoxVisible = chxbxvisable;
 | |
| 			return newnode;
 | |
| 		}
 | |
| 
 | |
| 
 | |
| 		public void advTreeProcSetsFillIn(bool blSeachTabClicked)
 | |
| 		{
 | |
| 			DevComponents.AdvTree.Node topnode = null;
 | |
| 			int cntnd = 0;
 | |
| 			VETreeNode vtn = VETreeNode.GetFolder(1);
 | |
| 			FolderInfo fi = vtn.VEObject as FolderInfo;
 | |
| 			int fiCount = fi.ChildFolderCount;
 | |
| 			advTreeProcSets.Nodes.Clear();
 | |
| 			lstCheckedDocVersions.Clear();
 | |
| 			topnode = new DevComponents.AdvTree.Node();
 | |
| 			topnode.Text = "Available Procedure Sets";
 | |
| 			topnode.Tag = fi;
 | |
| 			advTreeProcSets.Nodes.Add(topnode);
 | |
| 			//advTreeProcSets.AfterNodeInsert += new TreeNodeCollectionEventHandler(advTreeProcSets_AfterNodeInsert);
 | |
| 
 | |
| 
 | |
| 			foreach (FolderInfo fic in fi.ChildFolders)
 | |
| 			{
 | |
| 				DevComponents.AdvTree.Node newnode = new DevComponents.AdvTree.Node();
 | |
| 				newnode.Text = fic.ToString();
 | |
| 				newnode.Tag = fic;
 | |
| 
 | |
| 				//int tmp;
 | |
| 				//if (topnode == null)
 | |
| 				//{
 | |
| 				//    newnode.Text = "Available Procedure Sets";
 | |
| 				//    tmp = advTreeProcSets.Nodes.Add(newnode);
 | |
| 				//    topnode = newnode;
 | |
| 				//}
 | |
| 				//else
 | |
| 				//{
 | |
| 				//    newnode.Selectable = true;
 | |
| 				//    newnode.CheckBoxAlignment = DevComponents.AdvTree.eCellPartAlignment.NearCenter;
 | |
| 				//    newnode.CheckBoxStyle = eCheckBoxStyle.CheckBox;
 | |
| 				//    newnode.CheckBoxThreeState = false;
 | |
| 				//    newnode.CheckBoxVisible = true;
 | |
| 				//    tmp = topnode.Nodes.Add(newnode);
 | |
| 				//}
 | |
| 				cntnd++;
 | |
| 				if (fic.ChildFolderCount > 0 || fic.FolderDocVersionCount > 0)		// allow for '+' for tree expansion
 | |
| 				{
 | |
| 					DevComponents.AdvTree.Node tnt = new DevComponents.AdvTree.Node();
 | |
| 					tnt.Text = "VLN_DUMMY";
 | |
| 					newnode.Nodes.Add(tnt);
 | |
| 					topnode.Nodes.Add(newnode);
 | |
| 				}
 | |
| 			}
 | |
| 
 | |
| 			// if nothing was added to the tree, just put in the node above the docversions...
 | |
| 			if (advTreeProcSets.Nodes.Count == 0)
 | |
| 			{
 | |
| 				cntnd++;
 | |
| 				fi = Mydocversion.MyFolder;
 | |
| 				topnode = new DevComponents.AdvTree.Node();
 | |
| 				topnode.Text = fi.ToString();
 | |
| 				advTreeProcSets.Nodes.Add(topnode);
 | |
| 				topnode.Tag = fi;
 | |
| 			}
 | |
| 
 | |
| 			advTreeProcSets.BeforeExpand += new DevComponents.AdvTree.AdvTreeNodeCancelEventHandler(advTreeProcSets_BeforeExpand);
 | |
| 
 | |
| 			// position to the procedure set in the tree if we have a procedure open
 | |
| 			if (Mydocversion != null)
 | |
| 				advTreeProcSetsPreSelect();
 | |
| 			else
 | |
| 				advTreeProcSets.Nodes[0].SelectedCell = advTreeProcSets.Nodes[0].Cells[0]; // select the first node - fixes cosmetic problem
 | |
| 
 | |
| 			//if (blSeachTabClicked)
 | |
| 			//    cbxTextSearchText.Focus(); // set initial focus to enter search text
 | |
| 		}
 | |
| 		void advTreeProcSets_BeforeExpand(object sender, DevComponents.AdvTree.AdvTreeNodeCancelEventArgs e)
 | |
| 		{
 | |
| 			DevComponents.AdvTree.Node par = e.Node;
 | |
| 			// get first child's text, if it has one & if the text is VLN_DUMMY, load children
 | |
| 			DevComponents.AdvTree.Node tn = null;
 | |
| 			if (par.Nodes.Count > 0) tn = par.Nodes[0];
 | |
| 			if (tn.Text == "VLN_DUMMY")		// expand this
 | |
| 			{
 | |
| 				par.Nodes.Clear();
 | |
| 				Object obj = par.Tag;
 | |
| 				if (!(obj is FolderInfo)) return;   // should always be folderinfo on expand
 | |
| 				FolderInfo fi = (FolderInfo)obj;
 | |
| 				if (fi.ChildFolderCount > 0)
 | |
| 				{
 | |
| 					foreach (FolderInfo fic in fi.ChildFolders)
 | |
| 					{
 | |
| 						DevComponents.AdvTree.Node newnode = new DevComponents.AdvTree.Node();
 | |
| 						newnode.Text = fic.ToString();
 | |
| 						newnode.Tag = fic;
 | |
| 						par.Nodes.Add(newnode);
 | |
| 						if (fic.HasChildren)		// allow for '+' for tree expansion
 | |
| 						{
 | |
| 							DevComponents.AdvTree.Node tnt = new DevComponents.AdvTree.Node();
 | |
| 							tnt.Text = "VLN_DUMMY";
 | |
| 							newnode.Nodes.Add(tnt);
 | |
| 						}
 | |
| 					}
 | |
| 				}
 | |
| 				else if (fi.FolderDocVersionCount > 0)
 | |
| 				{
 | |
| 					foreach (DocVersionInfo dv in fi.FolderDocVersions)
 | |
| 					{
 | |
| 						//if ((VersionTypeEnum)dv.VersionType == VersionTypeEnum.WorkingDraft)
 | |
| 						//{
 | |
| 						DevComponents.AdvTree.Node newnode = new DevComponents.AdvTree.Node();
 | |
| 						newnode.Text = dv.ToString();
 | |
| 						newnode.Tag = dv;
 | |
| 						newnode.Selectable = true;
 | |
| 						newnode.CheckBoxAlignment = DevComponents.AdvTree.eCellPartAlignment.NearCenter;
 | |
| 						newnode.CheckBoxStyle = eCheckBoxStyle.CheckBox;
 | |
| 						newnode.CheckBoxThreeState = false;
 | |
| 						newnode.CheckBoxVisible = true;
 | |
| 						par.Nodes.Add(newnode);
 | |
| 						//}
 | |
| 					}
 | |
| 				}
 | |
| 			}
 | |
| 		}
 | |
| 		private void advTreeProcSets_AfterCheck(object sender, DevComponents.AdvTree.AdvTreeCellEventArgs e)
 | |
| 		{
 | |
| 			DevComponents.AdvTree.Node n = advTreeProcSets.SelectedNode;
 | |
| 			if (n.Checked)
 | |
| 			{
 | |
| 				n.Style = DevComponents.AdvTree.NodeStyles.Apple;
 | |
| 				lstCheckedDocVersions.Add((DocVersionInfo)n.Tag);
 | |
| 				if (lstCheckedDocVersions.Count == 1)//Mydocversion == null)
 | |
| 				{
 | |
| 					Mydocversion = (DocVersionInfo)n.Tag;
 | |
| 					//advTreeStepTypesFillIn();
 | |
| 				}
 | |
| 			}
 | |
| 			else
 | |
| 			{
 | |
| 				n.Style = null;
 | |
| 				lstCheckedDocVersions.Remove((DocVersionInfo)n.Tag);
 | |
| 				if (lstCheckedDocVersions.Count == 1)
 | |
| 				{
 | |
| 					if (Mydocversion != lstCheckedDocVersions[0])
 | |
| 					{
 | |
| 						Mydocversion = lstCheckedDocVersions[0];
 | |
| 						//advTreeStepTypesFillIn();
 | |
| 					}
 | |
| 				}
 | |
| 				else
 | |
| 				{
 | |
| 					if (lstCheckedDocVersions.Count == 0)
 | |
| 						Mydocversion = null;
 | |
| 					// do this if either none, or more than one procedure set selected
 | |
| 					//advTreeStepTypes.Nodes.Clear();
 | |
| 					//lstCheckedStepTypes.Clear();
 | |
| 					//lstCheckedStepTypesStr.Clear();
 | |
| 					//Node newnode = new DevComponents.AdvTree.Node();
 | |
| 					//newnode.Text = "....select a procedure set for types to appear...";
 | |
| 					//advTreeStepTypes.Nodes.Add(newnode);
 | |
| 					//buildStepTypePannelTitle();
 | |
| 				}
 | |
| 			}
 | |
| 			//// Enable the RO combo list only if at least one procedure set node
 | |
| 			//// is selected
 | |
| 			//cmboTreeROs.Enabled = (lstCheckedDocVersions.Count > 0);
 | |
| 			//gpFindROs.Enabled = cmboTreeROs.Enabled;
 | |
| 
 | |
| 			//SetupContextMenu();
 | |
| 
 | |
| 			//buildSetToSearchPanelTitle();
 | |
| 			EnableOrDisablePrintButton();
 | |
| 		}
 | |
| 		private void advTreeProcSets_AfterNodeSelect(object sender, AdvTreeNodeEventArgs e)
 | |
| 		{
 | |
| 			DevComponents.AdvTree.Node n = advTreeProcSets.SelectedNode;
 | |
| 			//if (advTreeStepTypes.Nodes.Count == 1 && n.Checked)
 | |
| 			//{
 | |
| 			//    Mydocversion = (DocVersionInfo)n.Tag;
 | |
| 			//    advTreeStepTypesFillIn();
 | |
| 			//}
 | |
| 		}
 | |
| 		private void advTreeProcSetsPreSelect()
 | |
| 		{
 | |
| 			bool keeplooking = true;
 | |
| 			//build a stack (bread crumb trail) of where is procedure set came from within the tree.
 | |
| 			Stack<string> crumbs = new Stack<string>();
 | |
| 			//crumbs.Push(Mydocversion.Name); // ex: "working draft"
 | |
| 			//crumbs.Push(Mydocversion.MyFolder.Name); // ex: "Emergency Procedures"
 | |
| 			//crumbs.Push(Mydocversion.MyFolder.MyParent.Name); // ex: "STPNOC-South Texas"
 | |
| 			//crumbs.Push(advTreeProcSets.Nodes[0].Text); //top node of my tree
 | |
| 
 | |
| 			crumbs.Push(Mydocversion.Name); // ex: "working draft"
 | |
| 			crumbs.Push(Mydocversion.MyFolder.Name); // ex: "Emergency Procedures"
 | |
| 			FolderInfo fi = Mydocversion.MyFolder.MyParent;
 | |
| 			while (fi != null)
 | |
| 			{
 | |
| 				if (fi.MyParent != null)
 | |
| 					crumbs.Push(fi.Name);
 | |
| 				fi = fi.MyParent;
 | |
| 			}
 | |
| 			crumbs.Push(advTreeProcSets.Nodes[0].Text); //top node of my tree
 | |
| 
 | |
| 			// now walk the tree, looking for the node names we saved in the stack.
 | |
| 			NodeCollection monkeys = advTreeProcSets.Nodes;
 | |
| 			while (keeplooking)
 | |
| 			{
 | |
| 				Node climber = LookInTree(monkeys, crumbs.Pop());
 | |
| 				keeplooking = (climber != null && crumbs.Count > 0);
 | |
| 				if (keeplooking)
 | |
| 					monkeys = climber.Nodes;
 | |
| 				if (!keeplooking && climber != null)
 | |
| 				{
 | |
| 					climber.Checked = true;
 | |
| 				}
 | |
| 			}
 | |
| 		}
 | |
| 		private Node LookInTree(NodeCollection monkeys, string bananna)
 | |
| 		{
 | |
| 			Node foundit = null;
 | |
| 			foreach (Node chimp in monkeys)
 | |
| 			{
 | |
| 				if (chimp.Text.Equals(bananna))
 | |
| 				{
 | |
| 					foundit = chimp;
 | |
| 					// need to select the node (cell) for it to be checked
 | |
| 					chimp.SelectedCell = chimp.Cells[0];
 | |
| 					if (chimp.Nodes.Count > 0)
 | |
| 						chimp.Expand();
 | |
| 					break;
 | |
| 				}
 | |
| 				chimp.Collapse();
 | |
| 			}
 | |
| 			return foundit;
 | |
| 		}
 | |
| 		#endregion
 | |
| 		#region RO Tree
 | |
| 		public void advTreeROFillIn(bool blSeachTabClicked)
 | |
| 		{
 | |
| 			DevComponents.AdvTree.Node topnode = null;
 | |
| 			int cntnd = 0;
 | |
| 			//VETreeNode vtn = VETreeNode.GetFolder(1);
 | |
| 			//FolderInfo fi = vtn.VEObject as FolderInfo;
 | |
| 			//int fiCount = fi.ChildFolderCount;
 | |
| 			advTreeRO.Nodes.Clear();
 | |
| 			if (_MyROFSTLookup == null) return;
 | |
| 			advTreeRO.BeforeExpand +=new AdvTreeNodeCancelEventHandler(advTreeRO_BeforeExpand);
 | |
| 			advTreeRO.AfterExpand += new AdvTreeNodeEventHandler(advTreeRO_AfterExpandorCollapse);
 | |
| 			advTreeRO.AfterCollapse += new AdvTreeNodeEventHandler(advTreeRO_AfterExpandorCollapse);
 | |
| 			//lstCheckedDocVersions.Clear();
 | |
| 			topnode = new DevComponents.AdvTree.Node();
 | |
| 			topnode.Text = "All Referenced Objects";
 | |
| 			topnode.Tag = null;//fi;
 | |
| 			topnode.CheckBoxVisible = true;
 | |
| 			advTreeRO.Nodes.Add(topnode);
 | |
| 
 | |
| 			for (int i = 0; i < _MyROFSTLookup.myHdr.myDbs.Length; i++)
 | |
| 			{
 | |
| 				DevComponents.AdvTree.Node tn = new DevComponents.AdvTree.Node();
 | |
| 				tn.Text = _MyROFSTLookup.myHdr.myDbs[i].dbiTitle;
 | |
| 				tn.Tag = _MyROFSTLookup.myHdr.myDbs[i];
 | |
| 				tn.CheckBoxVisible = true;
 | |
| 				topnode.Nodes.Add(tn);
 | |
| 				//cmboTreeROs.Nodes.Add(tn);
 | |
| 				AddDummyGroup(_MyROFSTLookup.myHdr.myDbs[i], tn);
 | |
| 			}
 | |
| 
 | |
| 
 | |
| 			//foreach (FolderInfo fic in fi.ChildFolders)
 | |
| 			//{
 | |
| 			//    DevComponents.AdvTree.Node newnode = new DevComponents.AdvTree.Node();
 | |
| 			//    newnode.Text = fic.ToString();
 | |
| 			//    newnode.Tag = fic;
 | |
| 
 | |
| 			//    cntnd++;
 | |
| 			//    if (fic.ChildFolderCount > 0 || fic.FolderDocVersionCount > 0)		// allow for '+' for tree expansion
 | |
| 			//    {
 | |
| 			//        DevComponents.AdvTree.Node tnt = new DevComponents.AdvTree.Node();
 | |
| 			//        tnt.Text = "VLN_DUMMY";
 | |
| 			//        newnode.Nodes.Add(tnt);
 | |
| 			//        topnode.Nodes.Add(newnode);
 | |
| 			//    }
 | |
| 			//}
 | |
| 
 | |
| 			//// if nothing was added to the tree, just put in the node above the docversions...
 | |
| 			//if (advTreeProcSets.Nodes.Count == 0)
 | |
| 			//{
 | |
| 			//    cntnd++;
 | |
| 			//    fi = Mydocversion.MyFolder;
 | |
| 			//    topnode = new DevComponents.AdvTree.Node();
 | |
| 			//    topnode.Text = fi.ToString();
 | |
| 			//    advTreeProcSets.Nodes.Add(topnode);
 | |
| 			//    topnode.Tag = fi;
 | |
| 			//}
 | |
| 
 | |
| 			//advTreeProcSets.BeforeExpand += new DevComponents.AdvTree.AdvTreeNodeCancelEventHandler(advTreeProcSets_BeforeExpand);
 | |
| 
 | |
| 			//// position to the procedure set in the tree if we have a procedure open
 | |
| 			//if (Mydocversion != null)
 | |
| 			//    advTreeProcSetsPreSelect();
 | |
| 			//else
 | |
| 			//    advTreeProcSets.Nodes[0].SelectedCell = advTreeProcSets.Nodes[0].Cells[0]; // select the first node - fixes cosmetic problem
 | |
| 
 | |
| 			//if (blSeachTabClicked)
 | |
| 			//    cbxTextSearchText.Focus(); // set initial focus to enter search text
 | |
| 		}
 | |
| 
 | |
| 		private void AddDummyGroup(ROFSTLookup.rodbi rodbi, DevComponents.AdvTree.Node tn)
 | |
| 		{
 | |
| 			if (rodbi.children != null && rodbi.children.Length > 0)
 | |
| 			{
 | |
| 				DevComponents.AdvTree.Node tmp = new DevComponents.AdvTree.Node();
 | |
| 				tmp.Text = "VLN_DUMMY_FOR_TREE";
 | |
| 				tn.Nodes.Add(tmp);
 | |
| 			}
 | |
| 		}
 | |
| 		private void advTreeRO_BeforeExpand(object sender, DevComponents.AdvTree.AdvTreeNodeCancelEventArgs e)
 | |
| 		{
 | |
| 			LoadChildren(e.Node);
 | |
| 		}
 | |
| 
 | |
| 		private void LoadChildren(DevComponents.AdvTree.Node tn)
 | |
| 		{
 | |
| 			object tag = tn.Tag;
 | |
| 			if (tn.HasChildNodes && tn.Nodes[0].Text != "VLN_DUMMY_FOR_TREE") return;  // already loaded.
 | |
| 			if (tn.HasChildNodes && tn.Nodes[0].Text == "VLN_DUMMY_FOR_TREE") tn.Nodes[0].Remove();
 | |
| 			ROFSTLookup.rochild[] chld = null;
 | |
| 
 | |
| 			if (tn.Tag is ROFSTLookup.rodbi)
 | |
| 			{
 | |
| 				ROFSTLookup.rodbi db = (ROFSTLookup.rodbi)tn.Tag;
 | |
| 				chld = db.children;
 | |
| 			}
 | |
| 			else if (tn.Tag is ROFSTLookup.rochild)
 | |
| 			{
 | |
| 				ROFSTLookup.rochild ch = (ROFSTLookup.rochild)tn.Tag;
 | |
| 				chld = ch.children;
 | |
| 			}
 | |
| 			else
 | |
| 			{
 | |
| 				Console.WriteLine("error - no type");
 | |
| 				return;
 | |
| 			}
 | |
| 			// if children, add dummy node
 | |
| 			if (chld != null && chld.Length > 0)
 | |
| 			{
 | |
| 				//ProgressBar_Initialize(chld.Length, tn.Text);
 | |
| 				for (int i = 0; i < chld.Length; i++)
 | |
| 				{
 | |
| 					//ProgressBar_SetValue(i);
 | |
| 					DevComponents.AdvTree.Node tmp = null;
 | |
| 					// if this is a group, i.e. type 0, add a dummy node
 | |
| 					if (chld[i].type == 0 && chld[i].children == null)
 | |
| 						//skip it.
 | |
| 						// TODO: KBR how to handle this?
 | |
| 						//Console.WriteLine("ro junk");
 | |
| 						continue;
 | |
| 					else if (chld[i].value == null)
 | |
| 					{
 | |
| 						tmp = new DevComponents.AdvTree.Node();
 | |
| 						tmp.Text = chld[i].title;
 | |
| 						tmp.Tag = chld[i];
 | |
| 						tmp.CheckBoxVisible = true;
 | |
| 						tn.Nodes.Add(tmp);
 | |
| 						DevComponents.AdvTree.Node sub = new DevComponents.AdvTree.Node();
 | |
| 						sub.Text = "VLN_DUMMY_FOR_TREE";
 | |
| 						tmp.Nodes.Add(sub);
 | |
| 					}
 | |
| 					else
 | |
| 					{
 | |
| 						tmp = new DevComponents.AdvTree.Node();
 | |
| 						tmp.Text = chld[i].title;
 | |
| 						tmp.Tag = chld[i];
 | |
| 						tmp.CheckBoxVisible = true;
 | |
| 						int index = FindIndex(tn.Nodes, tmp.Text);
 | |
| 						tn.Nodes.Insert(index, tmp);
 | |
| 						//tn.Nodes.Add(tmp);
 | |
| 					}
 | |
| 				}
 | |
| 			}
 | |
| 			//ProgressBar_Clear();
 | |
| 		}
 | |
| 		void advTreeRO_AfterExpandorCollapse(object sender, AdvTreeNodeEventArgs e)
 | |
| 		{
 | |
| 			Node bottomNode = BottomTreeNode(advTreeRO.Nodes);
 | |
| 			Node lastNode = advTreeRO.Nodes[advTreeRO.Nodes.Count - 1];
 | |
| 			int top = advTreeRO.Nodes[0].Bounds.Top;
 | |
| 			int bottom = bottomNode.Bounds.Bottom + 5;
 | |
| 			int hScrollBarHeight = advTreeRO.HScrollBar != null ? advTreeRO.HScrollBar.Height : 0;
 | |
| 			bottom = bottomNode.Bounds.Bottom + 5;
 | |
| 			advTreeRO.Size = new Size(advTreeRO.Size.Width, Math.Min(525, bottom - top + hScrollBarHeight));
 | |
| 			if (advTreeRO.VScrollBar != null && bottom < advTreeRO.Size.Height)
 | |
| 			{
 | |
| 				int yLookFor = (bottom - advTreeRO.Size.Height) + 2 * hScrollBarHeight;
 | |
| 				Node topNode = FindTreeNodeAt(advTreeRO.Nodes, yLookFor);
 | |
| 				if (topNode != null)
 | |
| 					topNode.EnsureVisible();
 | |
| 			}
 | |
| 		}
 | |
| 		private Node FindTreeNodeAt(NodeCollection nodes, int y)
 | |
| 		{
 | |
| 			foreach (Node node in nodes)
 | |
| 			{
 | |
| 				if (node.Bounds.Top <= y && node.Bounds.Bottom >= y)
 | |
| 					return node;
 | |
| 				if (node.Bounds.Top > y)
 | |
| 				{
 | |
| 					if (node.PrevNode != null && node.PrevNode.Expanded)
 | |
| 						return FindTreeNodeAt(node.PrevNode.Nodes, y);
 | |
| 					return node;
 | |
| 				}
 | |
| 			}
 | |
| 			return null;
 | |
| 		}
 | |
| 		private Node BottomTreeNode(NodeCollection nodes)
 | |
| 		{
 | |
| 			Node bottomNode = nodes[nodes.Count - 1]; // Return bottom node in collection
 | |
| 			if (bottomNode.Expanded) // If expanded return bottom child
 | |
| 				return BottomTreeNode(bottomNode.Nodes);
 | |
| 			return bottomNode;
 | |
| 		}
 | |
| 		private int FindIndex(NodeCollection nodes, string value)
 | |
| 		{
 | |
| 			int index = 0;
 | |
| 			foreach (Node node in nodes)
 | |
| 			{
 | |
| 				if (GreaterValue(node.Text, value)) return index;
 | |
| 				index++;
 | |
| 			}
 | |
| 			return index;
 | |
| 		}
 | |
| 		private static Regex _RegExGetNumber = new Regex(@"^ *[+-]?[.,0-9]+(E[+-]?[0-9]+)?");
 | |
| 		private bool GreaterValue(string value1, string value2)
 | |
| 		{
 | |
| 			Match match1 = _RegExGetNumber.Match(value1);
 | |
| 			Match match2 = _RegExGetNumber.Match(value2);
 | |
| 			if (match1.Success && match2.Success) // Compare the numeric value
 | |
| 			{
 | |
| 				double dbl1 = double.Parse(match1.ToString());
 | |
| 				double dbl2 = double.Parse(match2.ToString());
 | |
| 				return dbl1 > dbl2;
 | |
| 			}
 | |
| 			return String.Compare(value1, value2, true) > 0;
 | |
| 		}
 | |
| 
 | |
| 
 | |
| 		#endregion
 | |
| 		private void DisplayReports_Load(object sender, EventArgs e)
 | |
| 		{
 | |
| 			tabTransitionReports.PerformClick();
 | |
| 		}
 | |
| 
 | |
| 		private void advTreeRO_AfterCheck(object sender, AdvTreeCellEventArgs e)
 | |
| 		{
 | |
| 			DevComponents.AdvTree.Node n = advTreeRO.SelectedNode;
 | |
| 			//ROFSTLookup. rolkup = (ROFSTLookup)n.Tag;
 | |
| 			if (n.Checked)
 | |
| 				//lstCheckedROs.Add((ROFSTLookup)n.Tag);
 | |
| 				//lstCheckedROs.Add(rolkup);
 | |
| 				//lstROObj.Add(n.Tag);
 | |
| 				lstCheckedROs.Add(n.Tag);
 | |
| 			else
 | |
| 				//lstCheckedROs.Remove((ROFSTLookup)n.Tag);
 | |
| 				//lstCheckedROs.Remove(rolkup);
 | |
| 				//lstROObj.Remove(n.Tag);
 | |
| 				lstCheckedROs.Remove(n.Tag);
 | |
| 			EnableOrDisablePrintButton();
 | |
| 		}
 | |
| 
 | |
| 		private void cbxTransToProcs_CheckedChanged(object sender, EventArgs e)
 | |
| 		{
 | |
| 			EnableOrDisablePrintButton();
 | |
| 		}
 | |
| 
 | |
| 		private void cbxTransFromProcs_CheckedChanged(object sender, EventArgs e)
 | |
| 		{
 | |
| 			EnableOrDisablePrintButton();
 | |
| 		}
 | |
| 
 | |
| 		private void cbxComplete_CheckedChanged(object sender, EventArgs e)
 | |
| 		{
 | |
| 			EnableOrDisablePrintButton();
 | |
| 		}
 | |
| 
 | |
| 		private void cbxSummary_CheckedChanged(object sender, EventArgs e)
 | |
| 		{
 | |
| 			EnableOrDisablePrintButton();
 | |
| 		}
 | |
| 		private string BuildRODataFile(string ROList)
 | |
| 		{
 | |
| 			DocVersionInfo MyDVI = Mydocversion;
 | |
| 			string roDataFile = "PRINT.TMP";
 | |
| 
 | |
| 			if (VlnSettings.ReleaseMode.Equals("DEMO"))
 | |
| 			{
 | |
| 				MessageBox.Show("Referenced Object Reports not available in the Demo version.", "PROMS Demo Version");
 | |
| 				return "";
 | |
| 			}
 | |
| 			string roapp = Environment.GetEnvironmentVariable("roapp");
 | |
| 			if (roapp == null)
 | |
| 			{
 | |
| 				MessageBox.Show("Could not find path to Ro Editor, check 'roapp' environment variable");
 | |
| 				return "";
 | |
| 			}
 | |
| 			if (MyDVI == null || MyDVI.DocVersionAssociationCount < 1)
 | |
| 			{
 | |
| 				MessageBox.Show("Could not find associated path for ro data.");
 | |
| 				return "";
 | |
| 			}
 | |
| 			string roloc = "\"" + MyDVI.DocVersionAssociations[0].MyROFst.MyRODb.FolderPath + "\" " + "\"" + ROList + "\"";
 | |
| 			if (!Directory.Exists(MyDVI.DocVersionAssociations[0].MyROFst.MyRODb.FolderPath))
 | |
| 			{
 | |
| 				MessageBox.Show(string.Format("RO Database directory does not exist: {0}", MyDVI.DocVersionAssociations[0].MyROFst.MyRODb.FolderPath));
 | |
| 				return "";
 | |
| 			}
 | |
| 			string cmpRptExePath = roapp.Substring(0, roapp.LastIndexOf("\\")) + "\\CmpRpt.exe ";
 | |
| 			try
 | |
| 			{
 | |
| 				System.Diagnostics.Process.Start(cmpRptExePath, roloc);
 | |
| 			}
 | |
| 			catch (Exception ex)
 | |
| 			{
 | |
| 				while (ex.InnerException != null)
 | |
| 					ex = ex.InnerException;
 | |
| 				string tmpmsg = ex.Message;
 | |
| 				MessageBox.Show(tmpmsg, "RO Report Error: " + ex.GetType().Name);
 | |
| 			}
 | |
| 			roDataFile = MyDVI.DocVersionAssociations[0].MyROFst.MyRODb.FolderPath + "\\" + roDataFile;
 | |
| 			return roDataFile;
 | |
| 		}
 | |
| 		private void btnPrintReport_Click(object sender, EventArgs e)
 | |
| 		{
 | |
| 			Cursor curcur = Cursor;
 | |
| 			Cursor = Cursors.WaitCursor;
 | |
| 			if (cbxSummary.Checked) // RO Summary Report
 | |
| 			{
 | |
| 			}
 | |
| 			else if (cbxComplete.Checked) // Complete RO Report
 | |
| 			{
 | |
| 				GenerateROList();
 | |
| 				string ROList = GetListOfROs(false);//don't include the RODbID in the RO list
 | |
| 				string roDataFile = BuildRODataFile(ROList);
 | |
| 				OnPrintRequest(new DisplayReportsEventArgs("RO Complete Report", "RO Report", roDataFile, cbxComplete.Checked));
 | |
| 			}
 | |
| 			else if (cbxROUsage.Checked)
 | |
| 			{
 | |
| 				bool usageSortedByProcedure = (cmbxROUsageSort.SelectedIndex == 1);
 | |
| 				GenerateROList();
 | |
| 				string SearchString = GetListOfROs(true);// Include the RODbID in the RO list
 | |
| 				ItemInfoList SearchResults = ItemInfoList.GetListFromROReport(DocVersionList, "", SearchString, "");
 | |
| 				//OnPrintRequest(new DisplaySearchEventArgs(ReportTitle, TypesSelected, SearchString, lbSrchResults.DataSource as ICollection<ItemInfo>));
 | |
| 				if (!usageSortedByProcedure) // sort on ROs
 | |
| 				{
 | |
| 					Csla.SortedBindingList<ItemInfo> sortedResults = new Csla.SortedBindingList<ItemInfo>(SearchResults);
 | |
| 					sortedResults.ApplySort("FoundROID", ListSortDirection.Ascending);
 | |
| 					OnPrintRequest(new DisplayReportsEventArgs("Referenced Objects Usage By RO", "RO Usage", sortedResults, usageSortedByProcedure));
 | |
| 				}
 | |
| 				else
 | |
| 					OnPrintRequest(new DisplayReportsEventArgs("Referenced Objects Usage By Procedure", "RO Usage", SearchResults, usageSortedByProcedure));
 | |
| 			}
 | |
| 			else if (cbxTransFromProcs.Checked)
 | |
| 			{
 | |
| 			}
 | |
| 			else if (cbxTransToProcs.Checked)
 | |
| 			{
 | |
| 			}
 | |
| 			Cursor = curcur;
 | |
| 		}
 | |
| 
 | |
| 	}
 | |
| 	public class DisplayReportsEventArgs
 | |
| 	{
 | |
| 		private string _ReportTitle;
 | |
| 		public string ReportTitle
 | |
| 		{
 | |
| 			get { return _ReportTitle; }
 | |
| 			set { _ReportTitle = value; }
 | |
| 		}
 | |
| 		private string _TypesSelected;
 | |
| 		public string TypesSelected
 | |
| 		{
 | |
| 			get { return _TypesSelected; }
 | |
| 			set { _TypesSelected = value; }
 | |
| 		}
 | |
| 		private ICollection<ItemInfo> _MyItemInfoList;
 | |
| 		public ICollection<ItemInfo> MyItemInfoList
 | |
| 		{
 | |
| 			get { return _MyItemInfoList; }
 | |
| 			set { _MyItemInfoList = value; }
 | |
| 		}
 | |
| 		private bool _SortUsageByProcedure;
 | |
| 		public bool SortUsageByProcedure
 | |
| 		{
 | |
| 			get { return _SortUsageByProcedure; }
 | |
| 			set { _SortUsageByProcedure = value; }
 | |
| 		}
 | |
| 		private string _RODataFile = "";
 | |
| 		public string RODataFile
 | |
| 		{
 | |
| 			get { return _RODataFile; }
 | |
| 			set { _RODataFile = value; }
 | |
| 		}
 | |
| 		private bool _CompleteROReport = true;
 | |
| 		public bool CompleteROReport
 | |
| 		{
 | |
| 			get { return _CompleteROReport; }
 | |
| 			set { _CompleteROReport = value; }
 | |
| 		}
 | |
| 		public DisplayReportsEventArgs(string reportTitle, string typesSelected, ICollection<ItemInfo> myItemInfoList, bool sortByProcedure)
 | |
| 		{
 | |
| 			_ReportTitle = reportTitle;
 | |
| 			_TypesSelected = typesSelected;
 | |
| 			_MyItemInfoList = myItemInfoList;
 | |
| 			_SortUsageByProcedure = sortByProcedure;
 | |
| 		}
 | |
| 		public DisplayReportsEventArgs(string reportTitle, string typesSelected, string roDataFile,  bool completeROReport)
 | |
| 		{
 | |
| 			_ReportTitle = reportTitle;
 | |
| 			_TypesSelected = typesSelected;
 | |
| 			_RODataFile = roDataFile;
 | |
| 			_CompleteROReport = completeROReport;
 | |
| 		}
 | |
| 	}
 | |
| 	public delegate void DisplayReportsEvent(object sender, DisplayReportsEventArgs args);
 | |
| }
 |