364 lines
		
	
	
		
			12 KiB
		
	
	
	
		
			C#
		
	
	
	
	
	
			
		
		
	
	
			364 lines
		
	
	
		
			12 KiB
		
	
	
	
		
			C#
		
	
	
	
	
	
| // ========================================================================
 | |
| // Copyright 2006 - Volian Enterprises, Inc. All rights reserved.          
 | |
| // Volian Enterprises - Proprietary Information - DO NOT COPY OR DISTRIBUTE
 | |
| // ------------------------------------------------------------------------
 | |
| // $Workfile: $     $Revision: $                                           
 | |
| // $Author: $   $Date: $                                                   
 | |
| //                                                                         
 | |
| // $History: $                                                             
 | |
| // ========================================================================
 | |
| using System;
 | |
| using System.Drawing;
 | |
| using System.Collections;
 | |
| using System.ComponentModel;
 | |
| using System.Windows.Forms;
 | |
| using System.Data;
 | |
| using System.Data.OleDb; 
 | |
| using System.Collections.Specialized;
 | |
| using System.Collections.Generic;
 | |
| using System.Xml;
 | |
| using System.IO;
 | |
| using System.Text;
 | |
| using Volian.MSWord;
 | |
| using vlnObjectLibrary;
 | |
| using vlnServerLibrary;
 | |
| using VEPROMS.CSLA.Library;
 | |
| using Config;
 | |
| 
 | |
| 
 | |
| [assembly: log4net.Config.XmlConfigurator(Watch = true)]
 | |
| 
 | |
| namespace DataLoader
 | |
| {	
 | |
|     public partial class frmLoader : Form
 | |
| 	{
 | |
| 		private bool _Loading = true;
 | |
| 
 | |
| 		private FolderTreeNode _topnode;
 | |
| 		private bool UseVeTree = false;
 | |
|         #region Log4Net
 | |
| 		public static readonly log4net.ILog _MyLog = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
 | |
| 		//public static readonly log4net.ILog log = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
 | |
|         #endregion
 | |
| 		private Loader ldr;
 | |
| 		public bool cbSaveDocChecked { get { return cbSaveDoc.Checked; } }
 | |
| 		public bool cbSaveRTFChecked { get { return cbSaveRTF.Checked; } }
 | |
| 		public TreeView TV { get { return tv; } }
 | |
| 		public int pbProcMaximum { get { return pbProc.Maximum; } set { pbProc.Maximum = value; } }
 | |
| 		public int pbSectMaximum { get { return pbSect.Maximum; } set { pbSect.Maximum = value; } }
 | |
| 		public int pbSectValue { get { return pbSect.Value; } set { pbSect.Value = value; } }
 | |
| 		public int pbStepMaximum { get { return pbStep.Maximum; } set { pbStep.Maximum = value; } }
 | |
| 		public int pbStepValue { get { return pbStep.Value; } set { pbStep.Value = value; } }
 | |
| 		public int pbProcValue { get { return pbProc.Value; } set { pbProc.Value = value; } }
 | |
| 		
 | |
| 		public string Status
 | |
| 		{
 | |
| 			get { return toolStripStatusLabel1.Text; }
 | |
| 			set 
 | |
| 			{ 
 | |
| 				toolStripStatusLabel1.Text = value;
 | |
| 				Application.DoEvents();
 | |
| 			}
 | |
| 		}
 | |
| 
 | |
| 		public string tbSourceText { get { return tbSource.Text; } set { tbSource.Text = value; } }
 | |
| 
 | |
| 		public frmLoader()
 | |
| 		{
 | |
| 			ldr = new Loader(_MyLog, this);
 | |
| 			InitializeComponent();
 | |
| 			lblTime.Tag = DateTime.Now;
 | |
| 			switch (SystemInformation.ComputerName.ToUpper())
 | |
| 			{
 | |
| 				case "KATHYXP":
 | |
| 					//tbSource.Text = "G:\\VEIP2\\PROCS";     // basic data
 | |
| 					//tbSource.Text = "G:\\VEFNP\\AOP1.PRC";  // test subsections, checkoffs, comments & continuous action flag
 | |
| 					//tbSource.Text = "G:\\vecal\\eops.bck";  // test link seq STP_LNK_SEQ
 | |
| 					tbSource.Text = "G:\\vehlp\\procs";//  G:\\vewcnckl\\ckl.prc - multiple change ids.
 | |
| 					break;
 | |
| 				case "RHMDESKTOP":
 | |
| 					//tbSource.Text = @"I:\UNZIPPED ACTIVE BASELINE DATA\vehlp\Procs"; // Sub-sections
 | |
| 					tbSource.Text = @"I:\veDATA\vehlp\Procs"; // Sub-sections
 | |
| 					break;
 | |
| 				case "RMARK-PC":
 | |
| 					//tbSource.Text = @"I:\UNZIPPED ACTIVE BASELINE DATA\vehlp\Procs"; // Sub-sections
 | |
| 					tbSource.Text = @"C:\VE_PROMS Data\Plant\HLP\vehlp\Procs"; // Sub-sections
 | |
| 					break;
 | |
| 				case "JOHN":
 | |
| 					tbSource.Text = @"G:\PROMSDAT\vehlp\procs";//  South Texas EOPS
 | |
| 					//tbSource.Text = @"G:\PromsDat\VEHP1B\SAMGS.PRC";//  South Texas STPNOC
 | |
| 					break;
 | |
| 				default:
 | |
| 					throw new Exception("Not configured for " + SystemInformation.ComputerName);
 | |
| 			}
 | |
| 		}
 | |
| 		private void btnConvertSelected_Click(object sender, EventArgs e)
 | |
| 		{
 | |
|             if (UseVeTree)
 | |
|             {
 | |
|                 VETreeNode tn = (VETreeNode)tv.SelectedNode;
 | |
|                 if (tn == null)
 | |
|                 {
 | |
|                     MessageBox.Show("Must select a version node (working draft, approved, etc)", "No Node Selected");
 | |
|                     return;
 | |
|                 }
 | |
|                 object o = tn.VEObject;
 | |
|                 if (o.GetType() != typeof(DocVersionInfo))
 | |
|                 {
 | |
|                     MessageBox.Show("Must select a version node (working draft, approved, etc)", "No Node Selected");
 | |
|                     return;
 | |
|                 }
 | |
|                 DocVersion v = ((DocVersionInfo)o).Get();
 | |
|                 Item itm = ldr.MigrateDocVersion(v);
 | |
| 				if (itm != null)
 | |
|                 {
 | |
| 					tn.Checked = true;
 | |
|                 }
 | |
| 				
 | |
|             }
 | |
|             else
 | |
|             {
 | |
|                 TreeNode tn = tv.SelectedNode;
 | |
|                 if (tn == null)
 | |
|                 {
 | |
|                     MessageBox.Show("Must select a version node (working draft, approved, etc)", "No Node Selected");
 | |
|                     return;
 | |
|                 }
 | |
|                 object o = tn.Tag;
 | |
|                 if (o.GetType() != typeof(DocVersion))
 | |
|                 {
 | |
|                     MessageBox.Show("Must select a version node (working draft, approved, etc)", "No Node Selected");
 | |
|                     return;
 | |
|                 }
 | |
|                 DocVersion v = (DocVersion)o;
 | |
|                 Item itm = ldr.MigrateDocVersion(v);
 | |
| 				if (itm != null)
 | |
|                 {
 | |
|                     tn.Checked = true;
 | |
|                 }
 | |
|             }
 | |
| 		}
 | |
| 		private void tv_BeforeExpand(object sender, TreeViewCancelEventArgs e)
 | |
| 		{
 | |
|             if (UseVeTree)
 | |
|             {
 | |
|                 ((VETreeNode)e.Node).LoadChildren();
 | |
|                 return;
 | |
|             }
 | |
| 
 | |
|             TreeNode tn = e.Node;
 | |
|             object o = tn.Tag;
 | |
|             switch (o.GetType().ToString())
 | |
|             {
 | |
|                 case "Volian.CSLA.Library.FolderInfo":
 | |
|                     FolderInfo fld = (FolderInfo)o;
 | |
|                     if (fld.ChildFolderCount>0)
 | |
| 						tn.Checked = ldr.LoadChildren(fld, tn);  // load docversions.
 | |
|                     break;
 | |
|                 default:
 | |
|                     break;
 | |
|             }
 | |
| 		}
 | |
| 		private void tv_AfterSelect(object sender, TreeViewEventArgs e)
 | |
| 		{
 | |
|             if (UseVeTree) return;
 | |
| 
 | |
| 			TreeNode tn = e.Node;
 | |
| 			object o = tn.Tag;
 | |
| 			tn.Expand();
 | |
| 			if (o.GetType() == typeof(DocVersion)) tbSource.Text = ((DocVersion)o).Title;
 | |
| 		}
 | |
| 
 | |
|        
 | |
| 		private void btnLoadTreeDB_Click(object sender, EventArgs e)
 | |
| 		{
 | |
| 			// When loading folders, i.e. the tree from dBase (old 16-bit) 
 | |
|             // always clear the data
 | |
| 			ldr.ClearData();
 | |
|             bool suc = ldr.LoadFolders();
 | |
| 		}
 | |
| 
 | |
| 		private void btnConvert_Click(object sender, System.EventArgs e)
 | |
| 		{
 | |
| 			Database.LoggingInfo = false;
 | |
|             bool success = true;
 | |
|             // if purge data, purge it all & reload folders & security.
 | |
|             if (cbPurgeData.Checked)
 | |
|             {
 | |
|                ldr.ClearData();
 | |
|                success=ldr.LoadFolders();
 | |
| 			   if (success) success = ldr.LoadSecurity(tbVesamPath.Text);
 | |
|             }
 | |
| 				if (success)
 | |
| 				{
 | |
| 					DateTime tstart = DateTime.Now;
 | |
| 					DocVersionInfoList vl = DocVersionInfoList.Get();
 | |
| 					DocVersion v = null;
 | |
| 					foreach (DocVersionInfo vi in vl)
 | |
| 					{
 | |
| 						if (vi.Title.ToUpper() == tbSource.Text.ToUpper()) // is this the procedure set we want to convert?
 | |
| 						{
 | |
| 							v = DocVersion.Get(vi.VersionID);
 | |
| 							Item itm = ldr.MigrateDocVersion(v, true);
 | |
| 						}
 | |
| 						//v = DocVersion.Get(vi.VersionID);
 | |
| 						//bool convertProcedures = (vi.Title.ToUpper() == tbSource.Text.ToUpper());
 | |
| 						//Item itm = ldr.MigrateDocVersion(v, convertProcedures);
 | |
| 
 | |
| 					}
 | |
| 					MessageBox.Show(string.Format("{0} seconds", TimeSpan.FromTicks(DateTime.Now.Ticks - tstart.Ticks).TotalSeconds));
 | |
| 				}
 | |
| 		}
 | |
| 		public void UpdateLabels(int incPrc, int incSec, int incStp)
 | |
| 		{
 | |
| 			if (incPrc == 0 && incSec == 0 && incStp == 0)//Reset
 | |
| 			{
 | |
| 				lblTime.Tag = DateTime.Now;
 | |
| 				pbProc.Value = 0;
 | |
| 				pbSect.Value = 0;
 | |
| 				pbStep.Value = 0;
 | |
| 			}
 | |
| 			else
 | |
| 			{
 | |
| 				try
 | |
| 				{
 | |
| 					pbProc.Value += incPrc;
 | |
| 					pbSect.Value += incSec;
 | |
| 					pbStep.Value += incStp;
 | |
| 				}
 | |
| 				catch (Exception ex)
 | |
| 				{
 | |
| 					_MyLog.ErrorFormat("{0}\r\n\r\n{1}", ex.Message, ex.InnerException);
 | |
| 				}
 | |
| 			}
 | |
| 			//Database.LoggingInfo = (pbProc.Value > 153 && pbSect.Value > 11 && pbStep.Value > 61);
 | |
| 			lblProc.Text = string.Format("{0} Procedures", pbProc.Value);
 | |
| 			lblSection.Text = string.Format("{0} Sections", pbSect.Value);
 | |
| 			lblStep.Text = string.Format("{0} Steps", pbStep.Value);
 | |
| 			//pbProc.Value = iPrc;
 | |
| 			//pbSect.Value = iSec;
 | |
| 			//pbStep.Value = iStp;
 | |
| 			TimeSpan ts = new TimeSpan(DateTime.Now.Ticks - ((DateTime)lblTime.Tag).Ticks);
 | |
| 			lblTime.Text = string.Format("{0:D2}:{1:D2}:{2:D2} Elapsed", ts.Hours, ts.Minutes, ts.Seconds);
 | |
| 			Application.DoEvents();
 | |
| 		}
 | |
| 		private void btnBrowse_Click(object sender, EventArgs e)
 | |
| 		{
 | |
| 			fbd.SelectedPath = tbSource.Text;
 | |
| 			if (fbd.ShowDialog() == DialogResult.OK)
 | |
| 				tbSource.Text = fbd.SelectedPath;
 | |
| 		}
 | |
| 		private void cbSaveRTF_Click(object sender, EventArgs e)
 | |
| 		{
 | |
| 			if (cbSaveRTF.Checked) cbSaveDoc.Checked = false;
 | |
| 		}
 | |
| 		private void cbSaveDoc_Click(object sender, EventArgs e)
 | |
| 		{
 | |
| 			if (cbSaveDoc.Checked) cbSaveRTF.Checked = false;
 | |
| 		}
 | |
| 
 | |
| 		
 | |
|         private void btnLoadTreeCSLA_Click(object sender, EventArgs e)
 | |
|         {
 | |
|             _topnode = FolderTreeNode.BuildTreeList();
 | |
|             tv.Nodes.Add(_topnode);
 | |
|             tv.Nodes[0].Expand();
 | |
|             UseVeTree = false;
 | |
|         }
 | |
| 
 | |
|         private void btnBrowseVesam_Click(object sender, EventArgs e)
 | |
|         {
 | |
|             fbd.SelectedPath = tbVesamPath.Text;
 | |
|             if (fbd.ShowDialog() == DialogResult.OK)
 | |
|                 tbVesamPath.Text = fbd.SelectedPath;
 | |
|         }
 | |
| 
 | |
| 
 | |
|         private void btnVesam_Click(object sender, EventArgs e)
 | |
|         {
 | |
|             // if purge data, purge it all & reload folders.
 | |
|             if (cbPurgeData.Checked)
 | |
|             {
 | |
|                 ldr.ClearData();
 | |
|                 ldr.LoadFolders();
 | |
|             }
 | |
|             bool sec = ldr.LoadSecurity(tbVesamPath.Text);
 | |
|         }
 | |
| 
 | |
|         private void btnVETree_CSLA_Click(object sender, EventArgs e)
 | |
|         {
 | |
|             tv.Nodes.Add(VETreeNode.GetFolder(1));
 | |
|             UseVeTree = true;
 | |
|         }
 | |
| 
 | |
|         private void btnGroup_Click(object sender, EventArgs e)
 | |
|         {
 | |
|             GroupProp f = new GroupProp();
 | |
|             f.ShowDialog();
 | |
|         }
 | |
| 
 | |
|         private void tbSource_TextChanged(object sender, EventArgs e)
 | |
|         {
 | |
| 
 | |
|         }
 | |
| 
 | |
|         private void btnCtTok_Click(object sender, EventArgs e)
 | |
|         {
 | |
|             frmCntTkn frm = new frmCntTkn();
 | |
|             frm.ShowDialog();
 | |
|         }
 | |
| 		public void UpdateLabelsSetProc(int prc)
 | |
| 		{
 | |
| 			pbProc.Maximum = prc;
 | |
| 		}
 | |
| 		public void UpdateLabelsSetSect(int sec)
 | |
| 		{
 | |
| 			pbSect.Maximum = sec;
 | |
| 		}
 | |
| 		public void UpdateLabelsLibDocs(int incLib, int incUsages)
 | |
| 		{
 | |
| 			if (incLib == 0 && incUsages == 0)//Reset
 | |
| 			{
 | |
| 				lblTime.Tag = DateTime.Now;
 | |
| 				pbProc.Value = 0;
 | |
| 				pbSect.Value = 0;
 | |
| 			}
 | |
| 			else
 | |
| 			{
 | |
| 				pbProc.Value += incLib;
 | |
| 				pbSect.Value += incUsages;
 | |
| 			}
 | |
| 			lblProc.Text = string.Format("{0} Lib Docs", pbProc.Value);
 | |
| 			lblSection.Text = string.Format("{0} Usages", pbSect.Value);
 | |
| 			lblStep.Text = "";
 | |
| 			TimeSpan ts = new TimeSpan(DateTime.Now.Ticks - ((DateTime)lblTime.Tag).Ticks);
 | |
| 			lblTime.Text = string.Format("{0:D2}:{1:D2}:{2:D2} Elapsed", ts.Hours, ts.Minutes, ts.Seconds);
 | |
| 			Application.DoEvents();
 | |
| 		}
 | |
| 
 | |
| 		private void frmLoader_Load(object sender, EventArgs e)
 | |
| 		{
 | |
| 			if (Properties.Settings.Default["VeSamFilename"] != null)
 | |
| 				this.tbVesamPath.Text = Properties.Settings.Default.VeSamFilename;
 | |
| 			if (Properties.Settings.Default["DbfPathname"] != null)
 | |
| 				this.tbSource.Text = Properties.Settings.Default.DbfPathname;
 | |
| 			if (Properties.Settings.Default["LoadWordDoc"] != null)
 | |
| 				this.cbSaveDoc.CheckState = Properties.Settings.Default.LoadWordDoc;
 | |
| 			if (Properties.Settings.Default["PurgeData"] != null)
 | |
| 				this.cbPurgeData.CheckState = Properties.Settings.Default.PurgeData;
 | |
| 			if (Properties.Settings.Default["LoadRTFDoc"] != null)
 | |
| 				this.cbSaveRTF.CheckState = Properties.Settings.Default.LoadRTFDoc;
 | |
| 			_Loading = false;
 | |
| 		}
 | |
| 
 | |
| 		private void frmLoader_FormClosing(object sender, FormClosingEventArgs e)
 | |
| 		{
 | |
| 			Properties.Settings.Default.VeSamFilename = tbVesamPath.Text;
 | |
| 			Properties.Settings.Default.DbfPathname = tbSource.Text;
 | |
| 			Properties.Settings.Default.LoadWordDoc = cbSaveDoc.CheckState;
 | |
| 			Properties.Settings.Default.LoadRTFDoc = cbSaveRTF.CheckState;
 | |
| 			Properties.Settings.Default.PurgeData = cbPurgeData.CheckState;
 | |
| 			Properties.Settings.Default.Save();
 | |
| 		}
 | |
| 	}
 | |
| } | 
