BGE: Added an x-Location of end message for a section
Use x-location of end message for a section; tab format for sequential tabs at 4th level; hls tab spaces; indent in transition format 9
BGE: Use x-location of end message for a section
BGE: support for top continue messages that contain tab for continued step
resolve {Step Text} token in transition; modify code that processes transition format to use collection matches rather than search for ‘{‘
support AllUnits ro flag
support ‘{‘ and ‘}’ around ro value
top continue message with tab; location of top continue message in both AER/RNO columns for dual column; support indent in transition format during print
support two top continue messages (aer/rno) that can have different text; fix bug in splitting procedure title text if it contains hard spaces
		
	
		
			
				
	
	
		
			140 lines
		
	
	
		
			5.5 KiB
		
	
	
	
		
			C#
		
	
	
	
	
	
			
		
		
	
	
			140 lines
		
	
	
		
			5.5 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
 | |
| 	{
 | |
| 		private List<string> InvalidROs = new List<string>();
 | |
| 		private string MigrateRos(OleDbConnection cn, string textm, string seqcvt, Content content, DocVersion docver, bool conv_caret,ref int rotype)
 | |
| 		{
 | |
| 			StringBuilder rotxt = new StringBuilder();
 | |
| 			int instance = 0;
 | |
| 			int beg = 0;
 | |
| 			DataTable dt = null;
 | |
| 			DataSet ds = null;
 | |
| 			OleDbDataAdapter da = null;
 | |
| 
 | |
|             string cmd = "SELECT * FROM USAGERO WHERE [NUMBER]='" + ProcNumber.Replace("'", "''") + "' AND [SEQUENCE] ='" + seqcvt + "' ORDER BY [INSTANCE]";
 | |
| 			da = new OleDbDataAdapter(cmd, cn);
 | |
| 			// get usage records for the ROID.
 | |
| 			ds = new DataSet();
 | |
| 			try
 | |
| 			{
 | |
| 				da.Fill(ds);
 | |
| 				dt = ds.Tables[0];
 | |
| 				dt.CaseSensitive = true;
 | |
| 			}
 | |
| 			catch (Exception ex)
 | |
| 			{
 | |
| 				frmMain.AddError(ex, "migrateRos");
 | |
| 				log.Error("Error getting RO Usages");
 | |
| 				log.ErrorFormat("proc number = {0}, oldstepsequence = {1}",ProcNumber, seqcvt);
 | |
| 				do
 | |
| 				{
 | |
| 					log.ErrorFormat("{0} - {1}", ex.GetType().Name, ex.Message);
 | |
| 					ex = ex.InnerException;
 | |
| 				} while (ex != null);
 | |
| 				ds.Dispose();
 | |
| 				da.Dispose();
 | |
| 				return textm;
 | |
| 			}
 | |
| 			char[] chrrotrn = { '\x15', '\x3a6' };
 | |
| 			int tok = textm.IndexOfAny(chrrotrn);
 | |
| 			while (tok > -1)
 | |
| 			{
 | |
| 				// found a token, add the roid & value into the string and
 | |
| 				// add an ro usage for it.
 | |
| 				rotxt.Append(textm.Substring(beg, tok - beg));
 | |
|                 if (instance < dt.Rows.Count)
 | |
|                 {
 | |
|                     DataRow dr = dt.Rows[instance];
 | |
|                     string ROID = dr["ROID"].ToString();
 | |
| 					RoUsage ro = RoUsage.MakeRoUsage(content, ROID, null, DateTime.Now, "Migration", rodb);
 | |
| 					try
 | |
| 					{
 | |
| 						ROFSTLookup mylookup = rofstinfo.GetROFSTLookup(DocVersionInfo.Get(docver.VersionID));
 | |
| 						ROFSTLookup.rochild myro = mylookup.GetRoChild12(ROID.ToUpper());
 | |
| 						rotype = Math.Max(rotype, myro.type);
 | |
| 						string roval = mylookup.GetTranslatedRoValue(ROID.ToUpper(), conv_caret);
 | |
| 						if (textm[tok] == '\x3a6' && roval.IndexOf('\n')>-1)  // figure - just get image name
 | |
| 						{
 | |
| 							roval = roval.Substring(0, roval.IndexOf('\n'));
 | |
| 						}
 | |
| 						roval = roval.Replace("{", @"\{");
 | |
| 						roval = roval.Replace("}", @"\}");
 | |
| 						// add an annotation stating  "Invalid Unit RO 'ROID'.  Need an Item for this, so just add
 | |
| 						// it to a list of 'invalid ros' so that calling method can add annotations to the Item.
 | |
| 						if (roval == "?")
 | |
| 						{
 | |
| 							if (ROID.StartsWith("FFFF"))
 | |
| 								InvalidROs.Add(string.Format("Invalid Unit RO '{0}'", ROID.Substring(0, 12)));
 | |
| 							else
 | |
| 								InvalidROs.Add(string.Format("Invalid RO '{0}'", ROID.Substring(0, 12)));
 | |
| 						}
 | |
| 						//if (roval.Contains("\r") || roval.Contains("\n"))
 | |
| 						//    Console.WriteLine("RO has new Lines");
 | |
| 						//string results = string.Format(@"\v <START]\v0 {0}\v #Link:ReferencedObject:{1} {2} {3}\v0 \v [END>\v0 ",
 | |
| 						//    rofstinfo.ROFSTLookup.GetRoValue(ROID.Substring(0, 12).ToUpper()), ro.ROUsageID, ROID, rodb.RODbID);
 | |
| 						// RHM 20100308 - string results = string.Format(@"\v <START]\v0\cf1 {0}\cf0\v #Link:ReferencedObject:{1} {2} {3}\v0 \v [END>\v0 ",
 | |
| 						// RHM 20100308 - 	roval.Replace("\r\n","\\par\r\n"), ro.ROUsageID, ROID, rodb.RODbID);
 | |
| 						string results = string.Format(@"\v <START]\v0 {0}\v #Link:ReferencedObject:{1} {2} {3}[END>\v0 ",
 | |
| 							roval, ro.ROUsageID, ROID, rodb.RODbID);
 | |
| 						rotxt.Append(results);
 | |
| 					}
 | |
| 					catch (Exception ex)
 | |
| 					{
 | |
| 						
 | |
| 						frmMain.AddError(ex, "MigrateRos '{0}' '{1}' {2}", ProcNumber, seqcvt, instance);
 | |
| 						log.Error("Error setting RO data in text field");
 | |
| 						log.ErrorFormat("Error Message = {0}", ex.Message);
 | |
| 						log.ErrorFormat("proc number = {0}, oldstepsequence = {1}, instance = {2}", ProcNumber, seqcvt, instance);
 | |
| 					}
 | |
|                     instance++;
 | |
|                 }
 | |
|                 else
 | |
|                 {
 | |
| 					rotxt.Append("?");
 | |
| 					InvalidROs.Add("The ? in the step text represents an RO that was not connected to the ro database.");
 | |
|                     log.Error("Error setting RO data in text field");
 | |
|                     log.ErrorFormat("proc number = {0}, oldstepsequence = {1}, instance = {2}", ProcNumber, seqcvt, instance);
 | |
|                 }
 | |
| 				beg = tok + 1;
 | |
| 				if (beg > textm.Length)
 | |
| 				{
 | |
| 					tok = -1;
 | |
| 					da.Dispose();
 | |
| 				}
 | |
| 				else
 | |
| 					tok = textm.IndexOf('\x15', beg);  // there would only be one figure - only check for ro after 1st time
 | |
| 			}
 | |
| 			if (beg <= textm.Length - 1)
 | |
| 				rotxt.Append(textm.Substring(beg, textm.Length - beg));
 | |
| 			
 | |
| 			ds.Dispose();
 | |
| 			da.Dispose();
 | |
| 			return rotxt.ToString();
 | |
| 		}
 | |
| 	}
 | |
| 		 
 | |
| } |