2006-11-14 15:58:03 +00:00

92 lines
2.8 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.CSLA.Library;
namespace DataLoader
{
public partial class frmLoader : Form
{
private void AddRoUsage(int structId, string ROID)
{
RoUsage ro = RoUsage.MakeRoUsage(structId, ROID);
ro.StructureID = structId;
ro.ROID = ROID;
}
private string MigrateRos(OleDbConnection cn, string textm, string seqcvt, int structId)
{
StringBuilder rotxt = new StringBuilder();
int instance = 0;
int beg = 0;
DataTable dt = null;
DataSet ds = null;
OleDbDataAdapter da = null;
//TODO: ZSteps
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)
{
log.Error("Error getting RO Usages");
log.ErrorFormat("proc number = {0}, oldstepsequence = {1}",ProcNumber, seqcvt);
log.ErrorFormat("{0}\r\n\r\n{1}", ex.Message, ex.InnerException);
return textm;
}
int tok = textm.IndexOf('\x15');
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));
DataRow dr = dt.Rows[instance];
string ROID = dr["ROID"].ToString();
AddRoUsage(structId, ROID);
rotxt.Append("\x15{{");
rotxt.Append(ROID);
rotxt.Append("}{");
string val = rofst.GetRoValue(ROID.Substring(0, 12));
rotxt.Append(val);
rotxt.Append("}}");
instance++;
beg = tok + 1;
if (beg > textm.Length)
{
tok = -1;
da.Dispose();
}
else
tok = textm.IndexOf('\x15', beg);
}
if (beg < textm.Length - 1)
rotxt.Append(textm.Substring(beg, textm.Length - beg));
return rotxt.ToString();
}
}
}