132 lines
		
	
	
		
			5.2 KiB
		
	
	
	
		
			C#
		
	
	
	
	
	
			
		
		
	
	
			132 lines
		
	
	
		
			5.2 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 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
 | 
						|
					{
 | 
						|
						string rov = rofstinfo.ROFSTLookup.GetRoValue(ROID.ToUpper());
 | 
						|
						ROFSTLookup.rochild myro = rofstinfo.ROFSTLookup.GetRoChild12(ROID.ToUpper());
 | 
						|
						rotype = Math.Max(rotype, myro.type);
 | 
						|
						//jsj string rov = TextConvert.ConvertText(rofstinfo.ROFSTLookup.GetRoValue(ROID.Substring(0, 12).ToUpper()));
 | 
						|
						//string results = string.Format(@"{0}{1}\v #Link:ReferencedObject:{2} {3} {4}\v0",
 | 
						|
						//    '\x15', rofstinfo.ROFSTLookup.GetRoValue(ROID.Substring(0, 12).ToUpper()), ro.ROUsageID, ROID, rodb.RODbID);
 | 
						|
 | 
						|
						// TODO: NEED TO PASS IN ConvertCaret FORMAT FLAG
 | 
						|
						string roval = TextConvert.ConvertDOSSuperAndSubScripts(rofstinfo.ROFSTLookup.GetRoValue(ROID.ToUpper()));
 | 
						|
						roval = TextConvert.ReplaceUnicode(roval, conv_caret);
 | 
						|
						if (textm[tok] == '\x3a6' && roval.IndexOf('\n')>-1)  // figure - just get image name
 | 
						|
						{
 | 
						|
							roval = roval.Substring(0, roval.IndexOf('\n'));
 | 
						|
						}
 | 
						|
 | 
						|
						//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
 | 
						|
                {
 | 
						|
                    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();
 | 
						|
		}
 | 
						|
	}
 | 
						|
		 
 | 
						|
} |