91 lines
		
	
	
		
			3.6 KiB
		
	
	
	
		
			C#
		
	
	
	
	
	
			
		
		
	
	
			91 lines
		
	
	
		
			3.6 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 VEPROMS.CSLA.Library;
 | |
| 
 | |
| namespace DataLoader
 | |
| {
 | |
| 	public partial class Loader
 | |
| 	{
 | |
| 		public Item MigrateDocVersion(DocVersion docver)
 | |
| 		{
 | |
| 			return MigrateDocVersion(docver, true);
 | |
| 		}
 | |
| 
 | |
| 		private OutsideTransition _OutTran;
 | |
| 
 | |
| 		public Item MigrateDocVersion(DocVersion docver, bool convertProcedures)
 | |
| 		{
 | |
| 			string pth = docver.Title;
 | |
| 			// TODO: If set.dbf is missing or curset.dat is missing don't process it.
 | |
| 			if (!File.Exists(pth + @"\set.dbf") || !File.Exists(pth + @"\curset.dat")) return null;			// Open connection
 | |
| 			OleDbConnection cn = new OleDbConnection(@"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + pth + ";Extended Properties=dBase III;Persist Security Info=False");
 | |
| 			if (convertProcedures)
 | |
| 			{
 | |
| 				_OutTran = new OutsideTransition(cn);
 | |
| 				// load rofst (use it later)....
 | |
| 				DocVersionInfo dvi = DocVersionInfo.Get(docver.VersionID);
 | |
| 				rofst = new ROFST(pth + "\\ro.fst",dvi);
 | |
| 				// Migrate library documents
 | |
| 				MigrateLibDocs(cn, pth);
 | |
| 				// Initialize Dictionaries
 | |
| 				dicTrans_ItemDone = new Dictionary<string, Item>();
 | |
| 				dicTrans_ItemIds = new Dictionary<string, Item>();
 | |
| 				dicTrans_MigrationErrors = new Dictionary<string, List<Item>>();
 | |
| 
 | |
| 				// Create a 'dummy' content record.  This will be used for any transitions 'to'
 | |
| 				// that don't exist when dbf is processed.  At end, use this to see if there
 | |
| 				// are missing transitions.
 | |
| 				TransDummyCont = Content.MakeContent(null, "DUMMY CONTENT FOR TRANSITION MIGRATION", null, null, null);
 | |
| 			}
 | |
| 			// Process Procedures
 | |
| 			Item itm = null;
 | |
| 			if (convertProcedures || docver.VersionType == (int)VEPROMS.CSLA.Library.VersionTypeEnum.WorkingDraft)
 | |
| 				itm = MigrateProcedures(cn, pth, docver, convertProcedures);
 | |
| 			// Show any Missing Transtitons (i.e. Transitions which have not been processed)
 | |
| 			if (convertProcedures)
 | |
| 			{
 | |
| 				ShowMissingTransitions();
 | |
| 				log.InfoFormat("Completed Migration of {0}", pth);
 | |
| 				MessageBox.Show("Completed Migration of " + pth);
 | |
| 				rofst.Close();
 | |
| 				dicTrans_ItemDone.Clear();
 | |
| 				dicTrans_ItemDone = null;
 | |
| 			}
 | |
| 			cn.Close();
 | |
| 			if (itm != null)
 | |
| 			{
 | |
| 				docver.MyItem = itm;
 | |
| 				if (convertProcedures) docver.Title = ""; // clearing this tell us this docver (path) was converted?
 | |
| 				if (!docver.IsSavable) ErrorRpt.ErrorReport(docver);
 | |
| 				docver.Save();
 | |
| 			}
 | |
| 			return itm;
 | |
| 		}
 | |
| 		private VEPROMS.CSLA.Library.VersionTypeEnum DocVersionType(string s)
 | |
| 		{
 | |
|             if (s.EndsWith("approved")) return VEPROMS.CSLA.Library.VersionTypeEnum.Approved;
 | |
|             if (s.EndsWith("chgsht")) return VEPROMS.CSLA.Library.VersionTypeEnum.Revision;
 | |
|             if (s.EndsWith("tmpchg")) return VEPROMS.CSLA.Library.VersionTypeEnum.Temporary;
 | |
|             return VEPROMS.CSLA.Library.VersionTypeEnum.WorkingDraft;
 | |
| 		}
 | |
| 	}
 | |
| } | 
