This commit is contained in:
parent
4caceedd65
commit
ad3f77a360
71
PROMS/DataLoader/App.config
Normal file
71
PROMS/DataLoader/App.config
Normal file
@ -0,0 +1,71 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8" ?>
|
||||||
|
<configuration>
|
||||||
|
<configSections>
|
||||||
|
<section name="log4net" type="log4net.Config.Log4NetConfigurationSectionHandler, log4net" />
|
||||||
|
</configSections>
|
||||||
|
<log4net>
|
||||||
|
<appender name="LogFileAppender" type="log4net.Appender.FileAppender">
|
||||||
|
<param name="File" value="Log4Net.txt" />
|
||||||
|
<param name="AppendToFile" value="false" />
|
||||||
|
<layout type="log4net.Layout.PatternLayout">
|
||||||
|
<param name="Header" value="[Header]\r\n" />
|
||||||
|
<param name="Footer" value="[Footer]\r\n" />
|
||||||
|
<param name="ConversionPattern" value="%d [%t] %-5p %c - %m%n" />
|
||||||
|
</layout>
|
||||||
|
</appender>
|
||||||
|
<appender name="ConsoleAppender" type="log4net.Appender.ConsoleAppender" >
|
||||||
|
<layout type="log4net.Layout.PatternLayout">
|
||||||
|
<conversionPattern value="--> %date [%thread] %-5level %logger (%property{log4net:HostName}) [%ndc] - %message%newline" />
|
||||||
|
</layout>
|
||||||
|
</appender>
|
||||||
|
<appender name="EventLogAppender" type="log4net.Appender.EventLogAppender">
|
||||||
|
<threshold value="WARN" />
|
||||||
|
<mapping>
|
||||||
|
<level value="DEBUG" />
|
||||||
|
<eventLogEntryType value="Information" />
|
||||||
|
</mapping>
|
||||||
|
<mapping>
|
||||||
|
<level value="INFO" />
|
||||||
|
<eventLogEntryType value="Information" />
|
||||||
|
</mapping>
|
||||||
|
<mapping>
|
||||||
|
<level value="WARN" />
|
||||||
|
<eventLogEntryType value="Warning" />
|
||||||
|
</mapping>
|
||||||
|
<mapping>
|
||||||
|
<level value="ERROR" />
|
||||||
|
<eventLogEntryType value="Error" />
|
||||||
|
</mapping>
|
||||||
|
<mapping>
|
||||||
|
<level value="FATAL" />
|
||||||
|
<eventLogEntryType value="Error" />
|
||||||
|
</mapping>
|
||||||
|
<layout type="log4net.Layout.PatternLayout">
|
||||||
|
<param name="ConversionPattern" value="---> %d [%t] %-5p %c - %m%n" />
|
||||||
|
</layout>
|
||||||
|
</appender>
|
||||||
|
<root>
|
||||||
|
<level value="ALL" />
|
||||||
|
<appender-ref ref="ConsoleAppender" />
|
||||||
|
<appender-ref ref="LogFileAppender" />
|
||||||
|
<appender-ref ref="EventLogAppender" />
|
||||||
|
</root>
|
||||||
|
<logger name="Volian.CSLA.Library">
|
||||||
|
<level value="WARN" />
|
||||||
|
</logger>
|
||||||
|
</log4net>
|
||||||
|
<appSettings>
|
||||||
|
<add key="CslaAuthentication" value="Windows" />
|
||||||
|
<!-- Active Connection -->
|
||||||
|
<!-- Inactive Connections
|
||||||
|
-->
|
||||||
|
</appSettings>
|
||||||
|
<connectionStrings>
|
||||||
|
<!--<add name="VEPROMS"
|
||||||
|
connectionString="Data Source=rhmdesktop\SQLEXPRESS;AttachDbFilename="C:\VS2005Projects\VEPROMS_USERS\VEPROMS_Users.mdf";Integrated Security=True;User Instance=True"
|
||||||
|
providerName="System.Data.SqlClient" />-->
|
||||||
|
<add name="VEPROMS"
|
||||||
|
connectionString="Data Source=.\SQLEXPRESS;Initial Catalog=VEPROMS;Integrated Security=True"
|
||||||
|
providerName="System.Data.SqlClient" />
|
||||||
|
</connectionStrings>
|
||||||
|
</configuration>
|
1
PROMS/DataLoader/ClassDiagram1.cd
Normal file
1
PROMS/DataLoader/ClassDiagram1.cd
Normal file
@ -0,0 +1 @@
|
|||||||
|
|
79
PROMS/DataLoader/ConfigInfo.cs
Normal file
79
PROMS/DataLoader/ConfigInfo.cs
Normal file
@ -0,0 +1,79 @@
|
|||||||
|
// ========================================================================
|
||||||
|
// 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.Collections.Generic;
|
||||||
|
using System.Text;
|
||||||
|
using System.Xml;
|
||||||
|
|
||||||
|
namespace DataLoader
|
||||||
|
{
|
||||||
|
class ConfigInfo
|
||||||
|
{
|
||||||
|
private XmlDocument xmldoc;
|
||||||
|
public ConfigInfo(string xml)
|
||||||
|
{
|
||||||
|
xmldoc = new XmlDocument();
|
||||||
|
if (xml == null)
|
||||||
|
xmldoc.LoadXml("<config/>");
|
||||||
|
else
|
||||||
|
xmldoc.LoadXml(xml);
|
||||||
|
}
|
||||||
|
|
||||||
|
public ConfigInfo(string xml, string ename, string aname, string avalue)
|
||||||
|
{
|
||||||
|
xmldoc = new XmlDocument();
|
||||||
|
if (xml == null)
|
||||||
|
xmldoc.LoadXml("<config/>");
|
||||||
|
else
|
||||||
|
xmldoc.LoadXml(xml);
|
||||||
|
AddItem(ename, aname.Replace(' ','_'), avalue);
|
||||||
|
}
|
||||||
|
public bool AddItem(string ename, string aname, string avalue)
|
||||||
|
{
|
||||||
|
if (aname != null && aname != "")
|
||||||
|
{
|
||||||
|
//if (xmldoc == null)
|
||||||
|
//{
|
||||||
|
// xmldoc = new XmlDocument();
|
||||||
|
// xmldoc.AppendChild(xmldoc.CreateElement("ConfigInfo"));
|
||||||
|
//}
|
||||||
|
// see if ename element exists, use it to add attributes,
|
||||||
|
// otherwise, create the element.
|
||||||
|
|
||||||
|
XmlNode nxml = null;
|
||||||
|
XmlNodeList xl = xmldoc.DocumentElement.SelectNodes(string.Format("//{0}", ename));
|
||||||
|
switch (xl.Count)
|
||||||
|
{
|
||||||
|
case 0: // No nodes found
|
||||||
|
nxml = xmldoc.DocumentElement.AppendChild(xmldoc.CreateElement(ename));
|
||||||
|
break;
|
||||||
|
default: // Found the node
|
||||||
|
nxml = xl[0];
|
||||||
|
if (nxml.GetType() != typeof(XmlElement))
|
||||||
|
{
|
||||||
|
frmLoader.log.ErrorFormat("Invalid xml element type when migrating config data - element = {0}, name = {1} , value = {2}", ename, aname, avalue);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
XmlAttribute xa = nxml.Attributes.Append(xmldoc.CreateAttribute(aname.Replace(' ', '_')));
|
||||||
|
xa.Value = avalue;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
public override string ToString()
|
||||||
|
{
|
||||||
|
if (xmldoc != null) return xmldoc.InnerXml;
|
||||||
|
else return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
110
PROMS/DataLoader/CurSet.cs
Normal file
110
PROMS/DataLoader/CurSet.cs
Normal file
@ -0,0 +1,110 @@
|
|||||||
|
// ========================================================================
|
||||||
|
// 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.IO;
|
||||||
|
using System.Collections;
|
||||||
|
using System.Text;
|
||||||
|
using System.Windows.Forms;
|
||||||
|
using System.Xml;
|
||||||
|
using System.Xml.Serialization;
|
||||||
|
using Volian.CSLA.Library;
|
||||||
|
|
||||||
|
namespace Utils
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Summary description for CurSet.
|
||||||
|
/// </summary>
|
||||||
|
public class CurSet
|
||||||
|
{
|
||||||
|
private int NUMCBTEXTYPE = 5; // number of changebar text types.
|
||||||
|
public string PathName;
|
||||||
|
|
||||||
|
public CurSet(string pname)
|
||||||
|
{
|
||||||
|
PathName = pname;
|
||||||
|
}
|
||||||
|
|
||||||
|
private string ReadTheString(BinaryReader bw, int maxlen)
|
||||||
|
{
|
||||||
|
StringBuilder retStr = new StringBuilder(maxlen+1);
|
||||||
|
// read a series of characters until a null is found.
|
||||||
|
char ac;
|
||||||
|
bool done = false;
|
||||||
|
while(done==false)
|
||||||
|
{
|
||||||
|
ac = bw.ReadChar();
|
||||||
|
if (ac=='\0')
|
||||||
|
done=true;
|
||||||
|
else
|
||||||
|
retStr.Append(ac);
|
||||||
|
}
|
||||||
|
return retStr.ToString();
|
||||||
|
}
|
||||||
|
|
||||||
|
public FolderConfig Convert(FolderConfig cfg)
|
||||||
|
{
|
||||||
|
BinaryReader br;
|
||||||
|
ArrayList DefaultUserCBMsg = new ArrayList(2);
|
||||||
|
FileStream fs;
|
||||||
|
FileInfo fi = new FileInfo(PathName);
|
||||||
|
try
|
||||||
|
{
|
||||||
|
fs = fi.Open(FileMode.Open, FileAccess.Read, FileShare.ReadWrite );
|
||||||
|
br = new BinaryReader(fs,System.Text.ASCIIEncoding.ASCII);
|
||||||
|
}
|
||||||
|
catch (Exception e)
|
||||||
|
{
|
||||||
|
DataLoader.frmLoader.log.ErrorFormat("Error migrating Curset.dat, error = {0}", e.Message);
|
||||||
|
return cfg;
|
||||||
|
}
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
sbyte tmpsbyte;
|
||||||
|
string tmpstring;
|
||||||
|
tmpsbyte=br.ReadSByte(); // DefaultDestination not used
|
||||||
|
|
||||||
|
// the next byte has three settings embedded in it, the type of change
|
||||||
|
// bar (Print_ChangeBar), the change bar location and its text.
|
||||||
|
tmpsbyte= br.ReadSByte();
|
||||||
|
cfg.Print_ChangeBar = (FolderConfig.PrintChangeBar)((int)tmpsbyte > 2 ? 3 : (int)tmpsbyte);
|
||||||
|
cfg.Print_ChangeBarLoc = (FolderConfig.PrintChangeBarLoc)((tmpsbyte-3)/NUMCBTEXTYPE);
|
||||||
|
int ts = (tmpsbyte-3)%NUMCBTEXTYPE;
|
||||||
|
cfg.Print_ChangeBarText = (FolderConfig.PrintChangeBarText)((tmpsbyte-3)%NUMCBTEXTYPE);
|
||||||
|
cfg.Print_NumCopies=br.ReadSByte();
|
||||||
|
cfg.Print_Pagination=(FolderConfig.PrintPagination) br.ReadSByte();
|
||||||
|
tmpstring = ReadTheString(br,4); // DefaultPrinter not used
|
||||||
|
cfg.Format_Plant = ReadTheString(br,10);
|
||||||
|
tmpstring = ReadTheString(br, 128); // DefaultDestFName not used
|
||||||
|
tmpsbyte = br.ReadSByte(); // DefaultPlotterType not used
|
||||||
|
tmpsbyte = br.ReadSByte(); // DefaultPlotterPort not used
|
||||||
|
tmpsbyte = br.ReadSByte(); // DefaultCIEType not used.
|
||||||
|
for (int i=0;i<8;i++) // DefPenColors[8] not used
|
||||||
|
tmpsbyte = br.ReadSByte();
|
||||||
|
cfg.Print_Watermark = (FolderConfig.PrintWatermark)br.ReadSByte();
|
||||||
|
cfg.Print_UserCBMess1 = ReadTheString(br, 10);
|
||||||
|
cfg.Print_UserCBMess2 = ReadTheString(br, 10);
|
||||||
|
tmpsbyte = br.ReadSByte(); // DontPrintStatusTree not used
|
||||||
|
cfg.Print_UserFormat = ReadTheString(br, 10);
|
||||||
|
tmpsbyte = br.ReadSByte();
|
||||||
|
cfg.Print_DisableDuplex = tmpsbyte == 0 ? false : true;
|
||||||
|
br.Close();
|
||||||
|
}
|
||||||
|
catch(Exception e)
|
||||||
|
{
|
||||||
|
if(br!=null) br.Close();
|
||||||
|
DataLoader.frmLoader.log.ErrorFormat("Error migrating Curset.dat, error = {0}", e.Message);
|
||||||
|
}
|
||||||
|
fs.Close();
|
||||||
|
return cfg;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
166
PROMS/DataLoader/DataLoader.csproj
Normal file
166
PROMS/DataLoader/DataLoader.csproj
Normal file
@ -0,0 +1,166 @@
|
|||||||
|
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||||
|
<PropertyGroup>
|
||||||
|
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
|
||||||
|
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
|
||||||
|
<ProductVersion>8.0.50727</ProductVersion>
|
||||||
|
<SchemaVersion>2.0</SchemaVersion>
|
||||||
|
<ProjectGuid>{8E239A2B-B38C-4CD5-BA0D-A41A88BD2AEE}</ProjectGuid>
|
||||||
|
<OutputType>WinExe</OutputType>
|
||||||
|
<AppDesignerFolder>Properties</AppDesignerFolder>
|
||||||
|
<RootNamespace>DataLoader</RootNamespace>
|
||||||
|
<AssemblyName>DataLoader</AssemblyName>
|
||||||
|
<SccProjectName>SAK</SccProjectName>
|
||||||
|
<SccLocalPath>SAK</SccLocalPath>
|
||||||
|
<SccAuxPath>SAK</SccAuxPath>
|
||||||
|
<SccProvider>SAK</SccProvider>
|
||||||
|
</PropertyGroup>
|
||||||
|
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
|
||||||
|
<DebugSymbols>true</DebugSymbols>
|
||||||
|
<DebugType>full</DebugType>
|
||||||
|
<Optimize>false</Optimize>
|
||||||
|
<OutputPath>..\..\..\..\veproms\bin\</OutputPath>
|
||||||
|
<DefineConstants>DEBUG;TRACE</DefineConstants>
|
||||||
|
<ErrorReport>prompt</ErrorReport>
|
||||||
|
<WarningLevel>4</WarningLevel>
|
||||||
|
</PropertyGroup>
|
||||||
|
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
|
||||||
|
<DebugType>pdbonly</DebugType>
|
||||||
|
<Optimize>true</Optimize>
|
||||||
|
<OutputPath>bin\Release\</OutputPath>
|
||||||
|
<DefineConstants>TRACE</DefineConstants>
|
||||||
|
<ErrorReport>prompt</ErrorReport>
|
||||||
|
<WarningLevel>4</WarningLevel>
|
||||||
|
</PropertyGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<Reference Include="Csla, Version=2.0.3.0, Culture=neutral, PublicKeyToken=93be5fdc093e4c30, processorArchitecture=MSIL">
|
||||||
|
<SpecificVersion>False</SpecificVersion>
|
||||||
|
<HintPath>..\..\..\..\veproms\bin\Csla.dll</HintPath>
|
||||||
|
</Reference>
|
||||||
|
<Reference Include="IniReader, Version=1.0.0.0, Culture=neutral, processorArchitecture=MSIL">
|
||||||
|
<SpecificVersion>False</SpecificVersion>
|
||||||
|
<HintPath>..\..\..\..\veproms\bin\IniReader.dll</HintPath>
|
||||||
|
</Reference>
|
||||||
|
<Reference Include="log4net, Version=1.2.9.0, Culture=neutral, PublicKeyToken=b32731d11ce58905">
|
||||||
|
<SpecificVersion>False</SpecificVersion>
|
||||||
|
<HintPath>..\..\..\..\veproms\bin\log4net.dll</HintPath>
|
||||||
|
</Reference>
|
||||||
|
<Reference Include="MSWord, Version=1.0.0.0, Culture=neutral, processorArchitecture=MSIL">
|
||||||
|
<SpecificVersion>False</SpecificVersion>
|
||||||
|
<HintPath>..\..\..\..\veproms\bin\MSWord.dll</HintPath>
|
||||||
|
</Reference>
|
||||||
|
<Reference Include="System" />
|
||||||
|
<Reference Include="System.Data" />
|
||||||
|
<Reference Include="System.Deployment" />
|
||||||
|
<Reference Include="System.Drawing" />
|
||||||
|
<Reference Include="System.Windows.Forms" />
|
||||||
|
<Reference Include="System.Xml" />
|
||||||
|
<Reference Include="vlnObject, Version=1.0.0.0, Culture=neutral, processorArchitecture=MSIL">
|
||||||
|
<SpecificVersion>False</SpecificVersion>
|
||||||
|
<HintPath>..\..\..\..\veproms\bin\vlnObject.dll</HintPath>
|
||||||
|
</Reference>
|
||||||
|
<Reference Include="vlnServerLibrary, Version=1.0.0.0, Culture=neutral, processorArchitecture=MSIL">
|
||||||
|
<SpecificVersion>False</SpecificVersion>
|
||||||
|
<HintPath>..\..\..\..\veproms\bin\vlnServerLibrary.dll</HintPath>
|
||||||
|
</Reference>
|
||||||
|
<Reference Include="Volian.CSLA.Library, Version=1.0.0.0, Culture=neutral, processorArchitecture=MSIL">
|
||||||
|
<SpecificVersion>False</SpecificVersion>
|
||||||
|
<HintPath>..\..\..\..\veproms\bin\Volian.CSLA.Library.dll</HintPath>
|
||||||
|
</Reference>
|
||||||
|
</ItemGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<Compile Include="ConfigInfo.cs" />
|
||||||
|
<Compile Include="CurSet.cs" />
|
||||||
|
<Compile Include="FolderTreeNode.cs" />
|
||||||
|
<Compile Include="Documents.cs">
|
||||||
|
<SubType>Form</SubType>
|
||||||
|
</Compile>
|
||||||
|
<Compile Include="frmLoader.cs">
|
||||||
|
<SubType>Form</SubType>
|
||||||
|
</Compile>
|
||||||
|
<Compile Include="frmLoader.Designer.cs">
|
||||||
|
<DependentUpon>frmLoader.cs</DependentUpon>
|
||||||
|
</Compile>
|
||||||
|
<Compile Include="GroupProp.cs">
|
||||||
|
<SubType>Form</SubType>
|
||||||
|
</Compile>
|
||||||
|
<Compile Include="GroupProp.Designer.cs">
|
||||||
|
<DependentUpon>GroupProp.cs</DependentUpon>
|
||||||
|
</Compile>
|
||||||
|
<Compile Include="LibDoc.cs">
|
||||||
|
<SubType>Form</SubType>
|
||||||
|
</Compile>
|
||||||
|
<Compile Include="LoadConfig.cs">
|
||||||
|
</Compile>
|
||||||
|
<Compile Include="LoadTreeNh.cs">
|
||||||
|
<SubType>Form</SubType>
|
||||||
|
</Compile>
|
||||||
|
<Compile Include="PrivateProfile.cs" />
|
||||||
|
<Compile Include="Procedures.cs">
|
||||||
|
<SubType>Form</SubType>
|
||||||
|
</Compile>
|
||||||
|
<Compile Include="Program.cs" />
|
||||||
|
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||||
|
<EmbeddedResource Include="frmLoader.resx">
|
||||||
|
<SubType>Designer</SubType>
|
||||||
|
<DependentUpon>frmLoader.cs</DependentUpon>
|
||||||
|
</EmbeddedResource>
|
||||||
|
<EmbeddedResource Include="GroupProp.resx">
|
||||||
|
<SubType>Designer</SubType>
|
||||||
|
<DependentUpon>GroupProp.cs</DependentUpon>
|
||||||
|
</EmbeddedResource>
|
||||||
|
<EmbeddedResource Include="Properties\Resources.resx">
|
||||||
|
<Generator>ResXFileCodeGenerator</Generator>
|
||||||
|
<LastGenOutput>Resources.Designer.cs</LastGenOutput>
|
||||||
|
<SubType>Designer</SubType>
|
||||||
|
</EmbeddedResource>
|
||||||
|
<Compile Include="Properties\Resources.Designer.cs">
|
||||||
|
<AutoGen>True</AutoGen>
|
||||||
|
<DependentUpon>Resources.resx</DependentUpon>
|
||||||
|
<DesignTime>True</DesignTime>
|
||||||
|
</Compile>
|
||||||
|
<None Include="App.config" />
|
||||||
|
<None Include="ClassDiagram1.cd" />
|
||||||
|
<None Include="Properties\Settings.settings">
|
||||||
|
<Generator>SettingsSingleFileGenerator</Generator>
|
||||||
|
<LastGenOutput>Settings.Designer.cs</LastGenOutput>
|
||||||
|
</None>
|
||||||
|
<Compile Include="Properties\Settings.Designer.cs">
|
||||||
|
<AutoGen>True</AutoGen>
|
||||||
|
<DependentUpon>Settings.settings</DependentUpon>
|
||||||
|
<DesignTimeSharedInput>True</DesignTimeSharedInput>
|
||||||
|
</Compile>
|
||||||
|
<Compile Include="RefObjs.cs">
|
||||||
|
<SubType>Form</SubType>
|
||||||
|
</Compile>
|
||||||
|
<Compile Include="ROFST.cs" />
|
||||||
|
<Compile Include="SecObj.cs">
|
||||||
|
</Compile>
|
||||||
|
<Compile Include="Sections.cs">
|
||||||
|
<SubType>Form</SubType>
|
||||||
|
</Compile>
|
||||||
|
<Compile Include="Steps.cs">
|
||||||
|
<SubType>Form</SubType>
|
||||||
|
</Compile>
|
||||||
|
<Compile Include="Structures.cs">
|
||||||
|
<SubType>Form</SubType>
|
||||||
|
</Compile>
|
||||||
|
<Compile Include="TextConvert.cs" />
|
||||||
|
<Compile Include="Transitions.cs">
|
||||||
|
<SubType>Form</SubType>
|
||||||
|
</Compile>
|
||||||
|
<Compile Include="LoadTreeDB.cs">
|
||||||
|
<SubType>Form</SubType>
|
||||||
|
</Compile>
|
||||||
|
<Compile Include="DocVersions.cs">
|
||||||
|
<SubType>Form</SubType>
|
||||||
|
</Compile>
|
||||||
|
</ItemGroup>
|
||||||
|
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
|
||||||
|
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
|
||||||
|
Other similar extension points exist, see Microsoft.Common.targets.
|
||||||
|
<Target Name="BeforeBuild">
|
||||||
|
</Target>
|
||||||
|
<Target Name="AfterBuild">
|
||||||
|
</Target>
|
||||||
|
-->
|
||||||
|
</Project>
|
10
PROMS/DataLoader/DataLoader.csproj.vspscc
Normal file
10
PROMS/DataLoader/DataLoader.csproj.vspscc
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
""
|
||||||
|
{
|
||||||
|
"FILE_VERSION" = "9237"
|
||||||
|
"ENLISTMENT_CHOICE" = "NEVER"
|
||||||
|
"PROJECT_FILE_RELATIVE_PATH" = "relative:DataLoader"
|
||||||
|
"NUMBER_OF_EXCLUDED_FILES" = "0"
|
||||||
|
"ORIGINAL_PROJECT_FILE_PATH" = ""
|
||||||
|
"NUMBER_OF_NESTED_PROJECTS" = "0"
|
||||||
|
"SOURCE_CONTROL_SETTINGS_PROVIDER" = "PROVIDER"
|
||||||
|
}
|
61
PROMS/DataLoader/DocVersions.cs
Normal file
61
PROMS/DataLoader/DocVersions.cs
Normal file
@ -0,0 +1,61 @@
|
|||||||
|
// ========================================================================
|
||||||
|
// 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 Int32 MigrateDocVersion(string pth)
|
||||||
|
{
|
||||||
|
|
||||||
|
Int32 iStructureID = 0;
|
||||||
|
// Open connection
|
||||||
|
OleDbConnection cn = new OleDbConnection(@"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + pth + ";Extended Properties=dBase III;Persist Security Info=False");
|
||||||
|
// load rofst (use it later)....
|
||||||
|
rofst = new ROFST(pth + "\\ro.fst");
|
||||||
|
// Migrate library documents
|
||||||
|
MigrateLibDocs(cn, pth);
|
||||||
|
// Initialize Dictionaries
|
||||||
|
dicTrans_StrDone = new Dictionary<string, int>();
|
||||||
|
dicTrans_StrIds = new Dictionary<string, int>();
|
||||||
|
// Process Procedures
|
||||||
|
iStructureID = MigrateProcedures(cn,pth);
|
||||||
|
// Show any Missing Transtitons (i.e. Transitions which have not been processed)
|
||||||
|
ShowMissingTransitions();
|
||||||
|
log.InfoFormat("Completed Migration of {0}",pth);
|
||||||
|
MessageBox.Show("Completed Migration of " + pth);
|
||||||
|
rofst.Close();
|
||||||
|
cn.Close();
|
||||||
|
dicTrans_StrDone.Clear();
|
||||||
|
dicTrans_StrDone = null;
|
||||||
|
return iStructureID;
|
||||||
|
}
|
||||||
|
private Volian.CSLA.Library.VersionTypeEnum DocVersionType(string s)
|
||||||
|
{
|
||||||
|
if (s.EndsWith("approved")) return Volian.CSLA.Library.VersionTypeEnum.Approved;
|
||||||
|
if (s.EndsWith("chgsht")) return Volian.CSLA.Library.VersionTypeEnum.Revision;
|
||||||
|
if (s.EndsWith("tmpchg")) return Volian.CSLA.Library.VersionTypeEnum.Temporary;
|
||||||
|
return Volian.CSLA.Library.VersionTypeEnum.WorkingDraft;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
114
PROMS/DataLoader/Documents.cs
Normal file
114
PROMS/DataLoader/Documents.cs
Normal file
@ -0,0 +1,114 @@
|
|||||||
|
// ========================================================================
|
||||||
|
// 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 Volian.CSLA.Library;
|
||||||
|
|
||||||
|
namespace DataLoader
|
||||||
|
{
|
||||||
|
public partial class frmLoader : Form
|
||||||
|
{
|
||||||
|
private void SaveSectionDocument(string fname, string stpseq, ref byte ctype, ref int cid)
|
||||||
|
{
|
||||||
|
int docid = SaveWordDoc(fname);
|
||||||
|
switch (docid)
|
||||||
|
{
|
||||||
|
case 0:
|
||||||
|
// could add the following back in - but many of these may be put out in the log, and
|
||||||
|
// don't supply any pertinent info.
|
||||||
|
//log.InfoFormat("Timing problem for save of word document, will retry. oldstepsequence = {0}", stpseq);
|
||||||
|
break;
|
||||||
|
case -1:
|
||||||
|
log.ErrorFormat("Could not complete save of word document, oldstepsequence = {0}", stpseq);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
ctype = 2;
|
||||||
|
cid = docid;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
private int SaveWordDoc(string fname, string title, ConfigInfo ci)
|
||||||
|
{
|
||||||
|
int docid = 0;
|
||||||
|
if (System.IO.File.Exists(fname))
|
||||||
|
{
|
||||||
|
if (cbSaveDoc.Checked)
|
||||||
|
{
|
||||||
|
WordDoc d = new WordDoc(fname);
|
||||||
|
string temppath = Path.GetTempFileName();
|
||||||
|
string s = d.Save(temppath);
|
||||||
|
d.Close();
|
||||||
|
WaitMS(wms);
|
||||||
|
docid = SaveDoc(temppath, title, ci);
|
||||||
|
File.Delete(temppath);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (cbSaveRTF.Checked)
|
||||||
|
docid = SaveDoc(fname, title, ci);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return docid;
|
||||||
|
}
|
||||||
|
private int SaveWordDoc(string temppath)
|
||||||
|
{
|
||||||
|
return SaveWordDoc(temppath, String.Empty, null);
|
||||||
|
}
|
||||||
|
private int SaveTheDoc(string temppath, string title, ConfigInfo ci)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
FileStream fs = File.Open(temppath, FileMode.Open, FileAccess.Read, FileShare.None);
|
||||||
|
long len = fs.Length + 1;
|
||||||
|
byte[] ByteArray = new byte[len];
|
||||||
|
int nBytesRead = fs.Read(ByteArray, 0, (int)len);
|
||||||
|
fs.Close();
|
||||||
|
string t1 = (title == null || title == "") ? "notitle" : title;
|
||||||
|
Document doc = Document.MakeDocument(t1, ByteArray, null, ci == null ? null : ci.ToString());
|
||||||
|
return doc.DocID;
|
||||||
|
}
|
||||||
|
// for an io exception, keep trying
|
||||||
|
catch (IOException)
|
||||||
|
{
|
||||||
|
Wait(2);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
log.Error("Save Word Doc");
|
||||||
|
log.ErrorFormat("{0}\r\n\r\n{1}", ex.Message, ex.InnerException);
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
private int SaveDoc(string temppath, string title, ConfigInfo ci)
|
||||||
|
{
|
||||||
|
int done = 0;
|
||||||
|
int ntry = 0;
|
||||||
|
while (done == 0 && ntry < 4)
|
||||||
|
{
|
||||||
|
ntry++;
|
||||||
|
done = SaveTheDoc(temppath, title, ci);
|
||||||
|
}
|
||||||
|
return done;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
110
PROMS/DataLoader/FolderTreeNode.cs
Normal file
110
PROMS/DataLoader/FolderTreeNode.cs
Normal file
@ -0,0 +1,110 @@
|
|||||||
|
// ========================================================================
|
||||||
|
// 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.Collections.Generic;
|
||||||
|
using System.Text;
|
||||||
|
using Volian.CSLA.Library;
|
||||||
|
using Csla;
|
||||||
|
using System.Windows.Forms;
|
||||||
|
|
||||||
|
namespace DataLoader
|
||||||
|
{
|
||||||
|
public class FolderTreeNode : TreeNode
|
||||||
|
{
|
||||||
|
FolderTreeNode(string s) : base(s)
|
||||||
|
{
|
||||||
|
this.Name="ID:" + s;
|
||||||
|
}
|
||||||
|
FolderTreeNode(FolderInfo folderinfo)
|
||||||
|
: base(folderinfo.Name)
|
||||||
|
{
|
||||||
|
_folderinfo = folderinfo;
|
||||||
|
this.Name = "ID:" + folderinfo.FolderID.ToString();
|
||||||
|
}
|
||||||
|
private FolderInfo _folderinfo;
|
||||||
|
public FolderInfo FolderInfo
|
||||||
|
{
|
||||||
|
get { return _folderinfo; }
|
||||||
|
set
|
||||||
|
{
|
||||||
|
_folderinfo = value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
private Dictionary<int, FolderTreeNode> _findTree = null;
|
||||||
|
private Dictionary<int, FolderTreeNode> FindTree
|
||||||
|
{
|
||||||
|
get { return _findTree; }
|
||||||
|
set { _findTree = value; }
|
||||||
|
}
|
||||||
|
public FolderTreeNode FindTreeNode(int folderID)
|
||||||
|
{
|
||||||
|
if (_findTree != null) return _findTree[folderID];
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
public static FolderTreeNode BuildTreeList()
|
||||||
|
{
|
||||||
|
FolderTreeNode root = null;
|
||||||
|
FolderInfoList fil = FolderInfoList.Get();
|
||||||
|
Dictionary<int, FolderTreeNode> dicMissing = new Dictionary<int, FolderTreeNode>();
|
||||||
|
Dictionary<int, FolderTreeNode> dicExists = new Dictionary<int, FolderTreeNode>();
|
||||||
|
foreach (FolderInfo fi in fil)
|
||||||
|
{
|
||||||
|
FolderTreeNode ftp = null;
|
||||||
|
if (dicExists.ContainsKey(fi.ParentID))
|
||||||
|
{
|
||||||
|
ftp = dicExists[fi.ParentID];
|
||||||
|
// dicNeedToLoad.Remove(ftp);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (fi.ParentID != 0)
|
||||||
|
{
|
||||||
|
ftp = new FolderTreeNode(fi.ParentID.ToString());
|
||||||
|
dicMissing.Add(fi.ParentID, ftp);
|
||||||
|
dicExists.Add(fi.ParentID, ftp);
|
||||||
|
if (fi.DocVersionCount > 0)
|
||||||
|
{
|
||||||
|
TreeNode tn = new TreeNode("dummy");
|
||||||
|
tn.Tag = "dummy";
|
||||||
|
ftp.Nodes.Add(tn);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
FolderTreeNode ft = null;
|
||||||
|
if (dicMissing.ContainsKey(fi.FolderID))
|
||||||
|
{
|
||||||
|
ft = dicMissing[fi.FolderID];
|
||||||
|
ft.FolderInfo = fi;
|
||||||
|
dicMissing.Remove(fi.FolderID);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
ft = new FolderTreeNode(fi);
|
||||||
|
if (fi.DocVersionCount > 0)
|
||||||
|
{
|
||||||
|
TreeNode tn = new TreeNode("dummy");
|
||||||
|
tn.Tag = "dummy";
|
||||||
|
ft.Nodes.Add(tn);
|
||||||
|
}
|
||||||
|
dicExists.Add(fi.FolderID, ft);
|
||||||
|
//dicNeedToLoad.Add(ft);
|
||||||
|
}
|
||||||
|
ft.Tag = fi;
|
||||||
|
if (fi.ParentID == 0)
|
||||||
|
root = ft;
|
||||||
|
else
|
||||||
|
ftp.Nodes.Add(ft);
|
||||||
|
}
|
||||||
|
root.FindTree = dicExists;
|
||||||
|
return root;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
110
PROMS/DataLoader/GroupProp.Designer.cs
generated
Normal file
110
PROMS/DataLoader/GroupProp.Designer.cs
generated
Normal file
@ -0,0 +1,110 @@
|
|||||||
|
namespace DataLoader
|
||||||
|
{
|
||||||
|
partial class GroupProp
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Required designer variable.
|
||||||
|
/// </summary>
|
||||||
|
private System.ComponentModel.IContainer components = null;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Clean up any resources being used.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
|
||||||
|
protected override void Dispose(bool disposing)
|
||||||
|
{
|
||||||
|
if (disposing && (components != null))
|
||||||
|
{
|
||||||
|
components.Dispose();
|
||||||
|
}
|
||||||
|
base.Dispose(disposing);
|
||||||
|
}
|
||||||
|
|
||||||
|
#region Windows Form Designer generated code
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Required method for Designer support - do not modify
|
||||||
|
/// the contents of this method with the code editor.
|
||||||
|
/// </summary>
|
||||||
|
private void InitializeComponent()
|
||||||
|
{
|
||||||
|
this.splitContainer1 = new System.Windows.Forms.SplitContainer();
|
||||||
|
this.lbGroups = new System.Windows.Forms.ListBox();
|
||||||
|
this.pg = new System.Windows.Forms.PropertyGrid();
|
||||||
|
this.btnSave = new System.Windows.Forms.Button();
|
||||||
|
this.splitContainer1.Panel1.SuspendLayout();
|
||||||
|
this.splitContainer1.Panel2.SuspendLayout();
|
||||||
|
this.splitContainer1.SuspendLayout();
|
||||||
|
this.SuspendLayout();
|
||||||
|
//
|
||||||
|
// splitContainer1
|
||||||
|
//
|
||||||
|
this.splitContainer1.Dock = System.Windows.Forms.DockStyle.Fill;
|
||||||
|
this.splitContainer1.Location = new System.Drawing.Point(0, 0);
|
||||||
|
this.splitContainer1.Name = "splitContainer1";
|
||||||
|
//
|
||||||
|
// splitContainer1.Panel1
|
||||||
|
//
|
||||||
|
this.splitContainer1.Panel1.Controls.Add(this.lbGroups);
|
||||||
|
//
|
||||||
|
// splitContainer1.Panel2
|
||||||
|
//
|
||||||
|
this.splitContainer1.Panel2.Controls.Add(this.pg);
|
||||||
|
this.splitContainer1.Panel2.Controls.Add(this.btnSave);
|
||||||
|
this.splitContainer1.Size = new System.Drawing.Size(629, 290);
|
||||||
|
this.splitContainer1.SplitterDistance = 209;
|
||||||
|
this.splitContainer1.TabIndex = 0;
|
||||||
|
//
|
||||||
|
// lbGroups
|
||||||
|
//
|
||||||
|
this.lbGroups.Dock = System.Windows.Forms.DockStyle.Fill;
|
||||||
|
this.lbGroups.FormattingEnabled = true;
|
||||||
|
this.lbGroups.Location = new System.Drawing.Point(0, 0);
|
||||||
|
this.lbGroups.Name = "lbGroups";
|
||||||
|
this.lbGroups.Size = new System.Drawing.Size(209, 290);
|
||||||
|
this.lbGroups.TabIndex = 0;
|
||||||
|
this.lbGroups.Click += new System.EventHandler(this.lbGroups_Click);
|
||||||
|
//
|
||||||
|
// pg
|
||||||
|
//
|
||||||
|
this.pg.Dock = System.Windows.Forms.DockStyle.Fill;
|
||||||
|
this.pg.Location = new System.Drawing.Point(0, 23);
|
||||||
|
this.pg.Name = "pg";
|
||||||
|
this.pg.Size = new System.Drawing.Size(416, 267);
|
||||||
|
this.pg.TabIndex = 0;
|
||||||
|
//
|
||||||
|
// btnSave
|
||||||
|
//
|
||||||
|
this.btnSave.Dock = System.Windows.Forms.DockStyle.Top;
|
||||||
|
this.btnSave.Location = new System.Drawing.Point(0, 0);
|
||||||
|
this.btnSave.Name = "btnSave";
|
||||||
|
this.btnSave.Size = new System.Drawing.Size(416, 23);
|
||||||
|
this.btnSave.TabIndex = 1;
|
||||||
|
this.btnSave.Text = "Save";
|
||||||
|
this.btnSave.UseVisualStyleBackColor = true;
|
||||||
|
this.btnSave.Click += new System.EventHandler(this.btnSave_Click);
|
||||||
|
//
|
||||||
|
// GroupProp
|
||||||
|
//
|
||||||
|
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
|
||||||
|
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||||
|
this.ClientSize = new System.Drawing.Size(629, 290);
|
||||||
|
this.Controls.Add(this.splitContainer1);
|
||||||
|
this.Name = "GroupProp";
|
||||||
|
this.Text = "GroupProp";
|
||||||
|
this.Load += new System.EventHandler(this.GroupProp_Load);
|
||||||
|
this.splitContainer1.Panel1.ResumeLayout(false);
|
||||||
|
this.splitContainer1.Panel2.ResumeLayout(false);
|
||||||
|
this.splitContainer1.ResumeLayout(false);
|
||||||
|
this.ResumeLayout(false);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
private System.Windows.Forms.SplitContainer splitContainer1;
|
||||||
|
private System.Windows.Forms.ListBox lbGroups;
|
||||||
|
private System.Windows.Forms.PropertyGrid pg;
|
||||||
|
private System.Windows.Forms.Button btnSave;
|
||||||
|
}
|
||||||
|
}
|
45
PROMS/DataLoader/GroupProp.cs
Normal file
45
PROMS/DataLoader/GroupProp.cs
Normal file
@ -0,0 +1,45 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.ComponentModel;
|
||||||
|
using System.Data;
|
||||||
|
using System.Drawing;
|
||||||
|
using System.Text;
|
||||||
|
using System.Windows.Forms;
|
||||||
|
using Csla;
|
||||||
|
using Volian.CSLA.Library;
|
||||||
|
|
||||||
|
namespace DataLoader
|
||||||
|
{
|
||||||
|
public partial class GroupProp : Form
|
||||||
|
{
|
||||||
|
GroupInfoList glst;
|
||||||
|
Group grp;
|
||||||
|
public GroupProp()
|
||||||
|
{
|
||||||
|
InitializeComponent();
|
||||||
|
}
|
||||||
|
private void GroupProp_Load(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
lbGroups.Dock = DockStyle.Fill;
|
||||||
|
glst = GroupInfoList.Get();
|
||||||
|
lbGroups.DataSource = glst;
|
||||||
|
lbGroups.DisplayMember = "GroupName";
|
||||||
|
lbGroups.ValueMember = "GID";
|
||||||
|
SetGroup();
|
||||||
|
}
|
||||||
|
private void lbGroups_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
SetGroup();
|
||||||
|
Console.WriteLine("Group ID = {0}", lbGroups.SelectedValue);
|
||||||
|
}
|
||||||
|
private void SetGroup()
|
||||||
|
{
|
||||||
|
grp = glst[lbGroups.SelectedIndex].Get();
|
||||||
|
pg.SelectedObject = grp;
|
||||||
|
}
|
||||||
|
private void btnSave_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
grp.Save();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
120
PROMS/DataLoader/GroupProp.resx
Normal file
120
PROMS/DataLoader/GroupProp.resx
Normal file
@ -0,0 +1,120 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<root>
|
||||||
|
<!--
|
||||||
|
Microsoft ResX Schema
|
||||||
|
|
||||||
|
Version 2.0
|
||||||
|
|
||||||
|
The primary goals of this format is to allow a simple XML format
|
||||||
|
that is mostly human readable. The generation and parsing of the
|
||||||
|
various data types are done through the TypeConverter classes
|
||||||
|
associated with the data types.
|
||||||
|
|
||||||
|
Example:
|
||||||
|
|
||||||
|
... ado.net/XML headers & schema ...
|
||||||
|
<resheader name="resmimetype">text/microsoft-resx</resheader>
|
||||||
|
<resheader name="version">2.0</resheader>
|
||||||
|
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
|
||||||
|
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
|
||||||
|
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
|
||||||
|
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
|
||||||
|
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
|
||||||
|
<value>[base64 mime encoded serialized .NET Framework object]</value>
|
||||||
|
</data>
|
||||||
|
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
|
||||||
|
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
|
||||||
|
<comment>This is a comment</comment>
|
||||||
|
</data>
|
||||||
|
|
||||||
|
There are any number of "resheader" rows that contain simple
|
||||||
|
name/value pairs.
|
||||||
|
|
||||||
|
Each data row contains a name, and value. The row also contains a
|
||||||
|
type or mimetype. Type corresponds to a .NET class that support
|
||||||
|
text/value conversion through the TypeConverter architecture.
|
||||||
|
Classes that don't support this are serialized and stored with the
|
||||||
|
mimetype set.
|
||||||
|
|
||||||
|
The mimetype is used for serialized objects, and tells the
|
||||||
|
ResXResourceReader how to depersist the object. This is currently not
|
||||||
|
extensible. For a given mimetype the value must be set accordingly:
|
||||||
|
|
||||||
|
Note - application/x-microsoft.net.object.binary.base64 is the format
|
||||||
|
that the ResXResourceWriter will generate, however the reader can
|
||||||
|
read any of the formats listed below.
|
||||||
|
|
||||||
|
mimetype: application/x-microsoft.net.object.binary.base64
|
||||||
|
value : The object must be serialized with
|
||||||
|
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
|
||||||
|
: and then encoded with base64 encoding.
|
||||||
|
|
||||||
|
mimetype: application/x-microsoft.net.object.soap.base64
|
||||||
|
value : The object must be serialized with
|
||||||
|
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
|
||||||
|
: and then encoded with base64 encoding.
|
||||||
|
|
||||||
|
mimetype: application/x-microsoft.net.object.bytearray.base64
|
||||||
|
value : The object must be serialized into a byte array
|
||||||
|
: using a System.ComponentModel.TypeConverter
|
||||||
|
: and then encoded with base64 encoding.
|
||||||
|
-->
|
||||||
|
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
|
||||||
|
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
|
||||||
|
<xsd:element name="root" msdata:IsDataSet="true">
|
||||||
|
<xsd:complexType>
|
||||||
|
<xsd:choice maxOccurs="unbounded">
|
||||||
|
<xsd:element name="metadata">
|
||||||
|
<xsd:complexType>
|
||||||
|
<xsd:sequence>
|
||||||
|
<xsd:element name="value" type="xsd:string" minOccurs="0" />
|
||||||
|
</xsd:sequence>
|
||||||
|
<xsd:attribute name="name" use="required" type="xsd:string" />
|
||||||
|
<xsd:attribute name="type" type="xsd:string" />
|
||||||
|
<xsd:attribute name="mimetype" type="xsd:string" />
|
||||||
|
<xsd:attribute ref="xml:space" />
|
||||||
|
</xsd:complexType>
|
||||||
|
</xsd:element>
|
||||||
|
<xsd:element name="assembly">
|
||||||
|
<xsd:complexType>
|
||||||
|
<xsd:attribute name="alias" type="xsd:string" />
|
||||||
|
<xsd:attribute name="name" type="xsd:string" />
|
||||||
|
</xsd:complexType>
|
||||||
|
</xsd:element>
|
||||||
|
<xsd:element name="data">
|
||||||
|
<xsd:complexType>
|
||||||
|
<xsd:sequence>
|
||||||
|
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||||
|
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
|
||||||
|
</xsd:sequence>
|
||||||
|
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
|
||||||
|
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
|
||||||
|
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
|
||||||
|
<xsd:attribute ref="xml:space" />
|
||||||
|
</xsd:complexType>
|
||||||
|
</xsd:element>
|
||||||
|
<xsd:element name="resheader">
|
||||||
|
<xsd:complexType>
|
||||||
|
<xsd:sequence>
|
||||||
|
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||||
|
</xsd:sequence>
|
||||||
|
<xsd:attribute name="name" type="xsd:string" use="required" />
|
||||||
|
</xsd:complexType>
|
||||||
|
</xsd:element>
|
||||||
|
</xsd:choice>
|
||||||
|
</xsd:complexType>
|
||||||
|
</xsd:element>
|
||||||
|
</xsd:schema>
|
||||||
|
<resheader name="resmimetype">
|
||||||
|
<value>text/microsoft-resx</value>
|
||||||
|
</resheader>
|
||||||
|
<resheader name="version">
|
||||||
|
<value>2.0</value>
|
||||||
|
</resheader>
|
||||||
|
<resheader name="reader">
|
||||||
|
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||||
|
</resheader>
|
||||||
|
<resheader name="writer">
|
||||||
|
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||||
|
</resheader>
|
||||||
|
</root>
|
153
PROMS/DataLoader/LibDoc.cs
Normal file
153
PROMS/DataLoader/LibDoc.cs
Normal file
@ -0,0 +1,153 @@
|
|||||||
|
// ========================================================================
|
||||||
|
// 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 Org.Mentalis.Files;
|
||||||
|
|
||||||
|
namespace DataLoader
|
||||||
|
{
|
||||||
|
public partial class frmLoader : Form
|
||||||
|
{
|
||||||
|
private 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 MigrateLibDocs(OleDbConnection cn, string pth)
|
||||||
|
{
|
||||||
|
// Get all of the library documents - the first list has the entire list of files
|
||||||
|
// found within the rtffiles folder, the second list contains usages from the 'tran'
|
||||||
|
// file. During processing for procedures/sections occurs, the used library documents
|
||||||
|
// will be migrated. After that, any remaining library documents will be added to
|
||||||
|
// the section table without a reference from the structuretbl.
|
||||||
|
Dictionary<string, int> dicLibDocSect = new Dictionary<string, int>();
|
||||||
|
UpdateLabelsLibDocs(0, 0);
|
||||||
|
if (Directory.Exists(pth + "\\rtffiles"))
|
||||||
|
{
|
||||||
|
DirectoryInfo di = new DirectoryInfo(pth + "\\RTFFILES");
|
||||||
|
FileInfo[] fis = di.GetFiles("DOC_*.LIB");
|
||||||
|
pbProc.Maximum = fis.Length;
|
||||||
|
foreach (FileInfo fi in fis)
|
||||||
|
{
|
||||||
|
UpdateLabelsLibDocs(1, 0);
|
||||||
|
dicLibDocSect[fi.Name.Substring(0, 8).ToUpper()] = MigrateLibDoc(fi);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
dicLibDocRef = new Dictionary<string, int>();
|
||||||
|
OleDbDataAdapter da_doc = new OleDbDataAdapter("select [FROMNUMBER], [FROMSEQUEN], [TONUMBER] from [tran] where [TONUMBER] LIKE 'doc_%' or [TONUMBER] like 'DOC_%'", cn);
|
||||||
|
DataSet ds_doc = new DataSet();
|
||||||
|
da_doc.Fill(ds_doc);
|
||||||
|
pbSect.Maximum = ds_doc.Tables[0].Rows.Count;
|
||||||
|
foreach (DataRow dr_doc in ds_doc.Tables[0].Rows)
|
||||||
|
{
|
||||||
|
UpdateLabelsLibDocs(0, 1);
|
||||||
|
string key = dr_doc["FROMNUMBER"].ToString().PadRight(20) + dr_doc["FROMSEQUEN"].ToString().PadRight(10);
|
||||||
|
if (!dicLibDocSect.ContainsKey(dr_doc["TONUMBER"].ToString().ToUpper()))
|
||||||
|
log.ErrorFormat("Error setting library document references: {0}", dr_doc["TONUMBER"].ToString().ToUpper());
|
||||||
|
else
|
||||||
|
dicLibDocRef[key] = dicLibDocSect[dr_doc["TONUMBER"].ToString().ToUpper()];
|
||||||
|
}
|
||||||
|
da_doc.Dispose();
|
||||||
|
}
|
||||||
|
private int MigrateLibDoc(FileInfo fi)
|
||||||
|
{
|
||||||
|
ConfigInfo ci = new ConfigInfo(null);
|
||||||
|
string title = null; // for docname, remove the '.lib', i.e. substring(0,8)
|
||||||
|
DateTime dts = DateTime.Now;
|
||||||
|
string tmpRtfFileName = GetLibDocData(fi, ci, ref title);
|
||||||
|
int Docid = SaveWordDoc(tmpRtfFileName, title, ci);
|
||||||
|
File.Delete(tmpRtfFileName);
|
||||||
|
return Docid;
|
||||||
|
}
|
||||||
|
private string LoadFromLib(BinaryReader br)
|
||||||
|
{
|
||||||
|
int nchar = br.ReadInt16();
|
||||||
|
if (nchar > 0)
|
||||||
|
{
|
||||||
|
string tmp = new string(br.ReadChars(nchar));
|
||||||
|
return tmp.Substring(0, tmp.Length - 1); // remove null at end.
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
private string GetLibDocData(FileInfo fi, ConfigInfo ci, ref string title)
|
||||||
|
{
|
||||||
|
title = null;
|
||||||
|
// get the number, title, etc from the file.
|
||||||
|
// use the path to open the file & read the title & comment
|
||||||
|
DateTime dts = fi.LastWriteTime;
|
||||||
|
FileStream fs = fi.Open(FileMode.Open, FileAccess.Read, FileShare.ReadWrite);
|
||||||
|
BinaryReader br = new BinaryReader(fs, System.Text.ASCIIEncoding.ASCII);
|
||||||
|
string tmpRtfFileName = Path.GetTempFileName();
|
||||||
|
FileStream tmpfile = new FileStream(tmpRtfFileName, FileMode.Create);
|
||||||
|
BinaryWriter bw = new BinaryWriter(tmpfile, System.Text.Encoding.ASCII);
|
||||||
|
int cntPage = br.ReadInt16();
|
||||||
|
if (cntPage != -1)
|
||||||
|
{ // Not End of File
|
||||||
|
ci.AddItem("Section", "NumPages", cntPage.ToString());
|
||||||
|
string ldtitle = LoadFromLib(br);
|
||||||
|
if (ldtitle != null && ldtitle != "") title = ldtitle;
|
||||||
|
ci.AddItem("LibDoc", "Comment", LoadFromLib(br));
|
||||||
|
long l = br.BaseStream.Length - br.BaseStream.Position;
|
||||||
|
byte[] buf = new byte[l];
|
||||||
|
br.Read(buf, 0, (int)l);
|
||||||
|
bw.Write(buf, 0, (int)l);
|
||||||
|
// TODO: Check with KBR to see if she needed read/write this way
|
||||||
|
// I can't remember.
|
||||||
|
//byte ac;
|
||||||
|
//bool done = false;
|
||||||
|
//while (done == false)
|
||||||
|
//{
|
||||||
|
// if (br.PeekChar() > 0)
|
||||||
|
// {
|
||||||
|
// ac = br.ReadByte();
|
||||||
|
// bw.Write(ac);
|
||||||
|
// }
|
||||||
|
// else
|
||||||
|
// done = true;
|
||||||
|
//}
|
||||||
|
br.Close();
|
||||||
|
fs.Close();
|
||||||
|
bw.Close();
|
||||||
|
tmpfile.Close();
|
||||||
|
WaitMS(wms); // give it some time to close the tempfile before adding section
|
||||||
|
File.SetLastWriteTime(tmpRtfFileName, dts);
|
||||||
|
}
|
||||||
|
return tmpRtfFileName;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
198
PROMS/DataLoader/LoadConfig.cs
Normal file
198
PROMS/DataLoader/LoadConfig.cs
Normal file
@ -0,0 +1,198 @@
|
|||||||
|
// ========================================================================
|
||||||
|
// 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 Config
|
||||||
|
{
|
||||||
|
public class ConfigFile
|
||||||
|
{
|
||||||
|
#region Log4Net
|
||||||
|
private static readonly log4net.ILog log = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
|
||||||
|
#endregion
|
||||||
|
#region MigrateStrings
|
||||||
|
// the following lists are used for storing the element and attribute names
|
||||||
|
// for migrating of ini & cfg files. The names stored in these lists are
|
||||||
|
// those that should be migrated. If not in this list, the data (either element
|
||||||
|
// or attribute name) is prefaced with a 'z'. At some point in the future, those
|
||||||
|
// names with a 'z' will be removed.
|
||||||
|
public List<string> listIni_EleName = new List<string>();
|
||||||
|
public List<string> listIni_AttrName = new List<string>();
|
||||||
|
private void SetIniEleName()
|
||||||
|
{
|
||||||
|
// veproms.ini
|
||||||
|
listIni_EleName.Add("graphics");
|
||||||
|
listIni_EleName.Add("color");
|
||||||
|
listIni_EleName.Add("print");
|
||||||
|
listIni_EleName.Add("startup");
|
||||||
|
listIni_EleName.Add("data integrity");
|
||||||
|
listIni_EleName.Add("wordprocessor");
|
||||||
|
listIni_EleName.Add("procedurelisttabstops");
|
||||||
|
|
||||||
|
// proc.ini
|
||||||
|
listIni_EleName.Add("rodefaults");
|
||||||
|
listIni_EleName.Add("display");
|
||||||
|
listIni_EleName.Add("backgrounddefaults");
|
||||||
|
|
||||||
|
// <user>.cfg
|
||||||
|
listIni_EleName.Add("spelldictionary");
|
||||||
|
// listIni_EleName.Add("wordprocessor"); - already in here.
|
||||||
|
}
|
||||||
|
|
||||||
|
private void SetIniAttrName()
|
||||||
|
{
|
||||||
|
//veproms.ini
|
||||||
|
listIni_AttrName.Add("defaultext");
|
||||||
|
listIni_AttrName.Add("ro");
|
||||||
|
listIni_AttrName.Add("editbackground");
|
||||||
|
listIni_AttrName.Add("black");
|
||||||
|
listIni_AttrName.Add("blue");
|
||||||
|
listIni_AttrName.Add("green");
|
||||||
|
listIni_AttrName.Add("cyan");
|
||||||
|
listIni_AttrName.Add("red");
|
||||||
|
listIni_AttrName.Add("magenta");
|
||||||
|
listIni_AttrName.Add("brown");
|
||||||
|
listIni_AttrName.Add("lightgray");
|
||||||
|
listIni_AttrName.Add("darkgray");
|
||||||
|
listIni_AttrName.Add("ligthblue");
|
||||||
|
listIni_AttrName.Add("lightgreen");
|
||||||
|
listIni_AttrName.Add("lightcyan");
|
||||||
|
listIni_AttrName.Add("lightred");
|
||||||
|
listIni_AttrName.Add("lightmagenta");
|
||||||
|
listIni_AttrName.Add("yellow");
|
||||||
|
listIni_AttrName.Add("white");
|
||||||
|
listIni_AttrName.Add("underlinewidth");
|
||||||
|
listIni_AttrName.Add("verticalOffset");
|
||||||
|
listIni_AttrName.Add("strokewidth");
|
||||||
|
listIni_AttrName.Add("strokewidthbold");
|
||||||
|
listIni_AttrName.Add("messageboxtitle");
|
||||||
|
listIni_AttrName.Add("messagefile");
|
||||||
|
listIni_AttrName.Add("enableindexcheck");
|
||||||
|
listIni_AttrName.Add("wordwrap");
|
||||||
|
listIni_AttrName.Add("procedurenumbertab");
|
||||||
|
listIni_AttrName.Add("proceduretitletab");
|
||||||
|
|
||||||
|
// proc.ini
|
||||||
|
listIni_AttrName.Add("setpoint");
|
||||||
|
listIni_AttrName.Add("graphics");
|
||||||
|
listIni_AttrName.Add("ropath");
|
||||||
|
listIni_AttrName.Add("display");
|
||||||
|
listIni_AttrName.Add("sectiontitle");
|
||||||
|
listIni_AttrName.Add("sectionnumber");
|
||||||
|
|
||||||
|
// <user>.cfg
|
||||||
|
listIni_AttrName.Add("custom");
|
||||||
|
listIni_AttrName.Add("page");
|
||||||
|
listIni_AttrName.Add("toolbar");
|
||||||
|
listIni_AttrName.Add("paragraph");
|
||||||
|
listIni_AttrName.Add("ruler");
|
||||||
|
listIni_AttrName.Add("userphone1");
|
||||||
|
listIni_AttrName.Add("userphone2");
|
||||||
|
listIni_AttrName.Add("userloc1");
|
||||||
|
listIni_AttrName.Add("userloc2");
|
||||||
|
}
|
||||||
|
#endregion
|
||||||
|
#region LoadDataCode
|
||||||
|
public ConfigFile()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
public void LoadUsrCfg(User user)
|
||||||
|
{
|
||||||
|
string cmdline = System.Environment.CommandLine;
|
||||||
|
string cfgpath = cmdline.Substring(1, cmdline.LastIndexOf("\\") - 1) + "\\config";
|
||||||
|
if (!Directory.Exists(cfgpath))
|
||||||
|
{
|
||||||
|
log.Info("No user cfgs found in config directory - did not migrate any user cfgs");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
DirectoryInfo di = new DirectoryInfo(cfgpath);
|
||||||
|
FileInfo[] fis = di.GetFiles("*.cfg");
|
||||||
|
|
||||||
|
foreach (FileInfo fi in fis)
|
||||||
|
{
|
||||||
|
string cfgname = fi.Name.Substring(0, fi.Name.IndexOf("."));
|
||||||
|
if (cfgname.ToUpper() == user.UserID.ToUpper())
|
||||||
|
{
|
||||||
|
// Get Users table fields by reading the cfg file into a buffer & looking
|
||||||
|
// for the UserNetworkId and UserName fields.
|
||||||
|
StreamReader myReader = new StreamReader(fi.FullName);
|
||||||
|
string sLine;
|
||||||
|
string UserLogin = null;
|
||||||
|
string UserName = null;
|
||||||
|
int indx = -1;
|
||||||
|
while ((sLine = myReader.ReadLine()) != null && (UserLogin == null || UserName == null))
|
||||||
|
{
|
||||||
|
if (sLine.Length > 0 && sLine.Substring(0, 1) != ";")
|
||||||
|
{
|
||||||
|
if ((indx = sLine.ToLower().IndexOf("usernetworkid")) >= 0)
|
||||||
|
{
|
||||||
|
indx = sLine.IndexOf("=", indx + 13);
|
||||||
|
UserLogin = sLine.Substring(indx + 1, sLine.Length - indx - 1).Trim();
|
||||||
|
}
|
||||||
|
else if ((indx = sLine.ToLower().IndexOf("username")) >= 0)
|
||||||
|
{
|
||||||
|
indx = sLine.IndexOf("=", indx + 8);
|
||||||
|
UserName = sLine.Substring(indx + 1, sLine.Length - indx - 1).Trim();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
myReader.Close();
|
||||||
|
|
||||||
|
// get the xml to set the config field
|
||||||
|
XmlDocument d = IniToXml(fi.FullName);
|
||||||
|
user.Config = d == null ? null : d.InnerXml;
|
||||||
|
user.UserLogin = UserLogin;
|
||||||
|
user.UserName = UserName;
|
||||||
|
user.CFGName = cfgname;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public XmlDocument LoadSystemIni()
|
||||||
|
{
|
||||||
|
string cmdline = System.Environment.CommandLine;
|
||||||
|
string inipath = cmdline.Substring(1, cmdline.LastIndexOf("\\") - 1) + "\\veproms.ini";
|
||||||
|
if (!File.Exists(inipath))
|
||||||
|
{
|
||||||
|
log.InfoFormat("Did not migrate {0} - file not found", inipath);
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
XmlDocument d = IniToXml(inipath);
|
||||||
|
return d;
|
||||||
|
}
|
||||||
|
|
||||||
|
public XmlDocument IniToXml(string path)
|
||||||
|
{
|
||||||
|
FileInfo fi = new FileInfo(path);
|
||||||
|
if (fi.Exists)
|
||||||
|
{
|
||||||
|
PrivateProfile ppCfg;
|
||||||
|
if (listIni_AttrName == null || listIni_AttrName.Count == 0) SetIniAttrName();
|
||||||
|
if (listIni_EleName == null || listIni_EleName.Count == 0) SetIniEleName();
|
||||||
|
ppCfg = new PrivateProfile(path, listIni_EleName, listIni_AttrName);
|
||||||
|
return ppCfg.XML();
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
#endregion
|
||||||
|
}
|
||||||
|
}
|
111
PROMS/DataLoader/LoadTreeDB.cs
Normal file
111
PROMS/DataLoader/LoadTreeDB.cs
Normal file
@ -0,0 +1,111 @@
|
|||||||
|
// ========================================================================
|
||||||
|
// 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;
|
||||||
|
using vlnObjectLibrary;
|
||||||
|
using vlnServerLibrary;
|
||||||
|
using Org.Mentalis.Files;
|
||||||
|
using Config;
|
||||||
|
using Utils;
|
||||||
|
|
||||||
|
namespace DataLoader
|
||||||
|
{
|
||||||
|
public partial class frmLoader : Form
|
||||||
|
{
|
||||||
|
private List<Folder> vlnDataPathFolders() // was vlnDataPath
|
||||||
|
{
|
||||||
|
List<Folder> dpf = new List<Folder>();
|
||||||
|
// Get path to config file
|
||||||
|
string sCfg = Environment.GetEnvironmentVariable("veconfig");
|
||||||
|
IniReader cfg = new IniReader(sCfg);
|
||||||
|
// Get DataPath
|
||||||
|
string sDP = cfg.ReadString("menu", "DataPath");
|
||||||
|
// Split DataPath into directories
|
||||||
|
foreach (string s1 in sDP.Split(";".ToCharArray()))
|
||||||
|
{
|
||||||
|
if (s1.Length > 0)
|
||||||
|
{
|
||||||
|
string[] s2 = s1.Split(",".ToCharArray());
|
||||||
|
Folder fld = Folder.MakeFolder(sysFolder.FolderID, dbConn.DBID, s2[1], s2[0], null);
|
||||||
|
dpf.Add(fld);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return dpf;
|
||||||
|
}
|
||||||
|
private int cslaObject(vlnObject vb, int dbid, int parentid, TreeNode tn)
|
||||||
|
{
|
||||||
|
switch (vb.Type)
|
||||||
|
{
|
||||||
|
case "plant":
|
||||||
|
case "set":
|
||||||
|
Folder fld = Folder.MakeFolder(parentid, dbid, vb.Title, vb.Path, string.Empty);
|
||||||
|
tn.Tag = fld;
|
||||||
|
return fld.FolderID;
|
||||||
|
case "version":
|
||||||
|
ConfigFile cfg = new ConfigFile();
|
||||||
|
|
||||||
|
XmlDocument d = cfg.IniToXml(vb.Path + "\\proc.ini");
|
||||||
|
FolderConfig fld_cfg = new FolderConfig(d==null?"":d.InnerXml);
|
||||||
|
// translate curset.dat into xml & add to d (somehow).
|
||||||
|
string csfile = string.Format("{0}\\curset.dat",vb.Path);
|
||||||
|
if (File.Exists(csfile))
|
||||||
|
{
|
||||||
|
CurSet cs = new CurSet(csfile);
|
||||||
|
try
|
||||||
|
{
|
||||||
|
fld_cfg = cs.Convert(fld_cfg);
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
log.ErrorFormat("error in convert curset.dat, ex = {0}", ex.Message);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
string titlepath = vb.Path + "\\" + "Title";
|
||||||
|
FileInfo fi = new FileInfo(titlepath);
|
||||||
|
string thetitle = vb.Title;
|
||||||
|
if (File.Exists(titlepath))
|
||||||
|
{
|
||||||
|
StreamReader myReader = new StreamReader(titlepath);
|
||||||
|
thetitle = myReader.ReadLine();
|
||||||
|
myReader.Close();
|
||||||
|
}
|
||||||
|
DocVersion v = DocVersion.MakeDocVersion(parentid, (int)DocVersionType(vb.Path.ToLower()), thetitle, vb.Path, 0, fld_cfg == null ? null : fld_cfg.ToString());
|
||||||
|
tn.Tag = v;
|
||||||
|
return v.VersionID;
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
private void MigrateChildren(vlnObject vb, vlnServer vs, int dbid, int parentid, TreeNode tn)
|
||||||
|
{
|
||||||
|
if (vb.Type != "version")
|
||||||
|
{
|
||||||
|
vb.LoadChildren(vs.GetChildren(vb.ToString()));
|
||||||
|
List<vlnObject> lv = vb.Children;
|
||||||
|
foreach (vlnObject vbc in lv)
|
||||||
|
{
|
||||||
|
TreeNode tnc = tn.Nodes.Add(vbc.Title);
|
||||||
|
int idc = cslaObject(vbc, dbid, parentid, tnc);
|
||||||
|
MigrateChildren(vbc, vs, dbid, idc, tnc);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
43
PROMS/DataLoader/LoadTreeNh.cs
Normal file
43
PROMS/DataLoader/LoadTreeNh.cs
Normal file
@ -0,0 +1,43 @@
|
|||||||
|
// ========================================================================
|
||||||
|
// 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 bool LoadChildren(FolderInfo fld, TreeNode tn)
|
||||||
|
{
|
||||||
|
tn.Nodes.Clear();
|
||||||
|
bool bLoaded = true;
|
||||||
|
foreach (DocVersionInfo fdv in fld.DocVersions)
|
||||||
|
{
|
||||||
|
TreeNode tnc = tn.Nodes.Add(fdv.Title);
|
||||||
|
tnc.Tag = fdv;
|
||||||
|
tnc.Checked = fdv.StructureID != 0;
|
||||||
|
bLoaded &= tnc.Checked;
|
||||||
|
}
|
||||||
|
return bLoaded;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
274
PROMS/DataLoader/PrivateProfile.cs
Normal file
274
PROMS/DataLoader/PrivateProfile.cs
Normal file
@ -0,0 +1,274 @@
|
|||||||
|
// ========================================================================
|
||||||
|
// 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.IO;
|
||||||
|
using System.Xml;
|
||||||
|
using System.Collections.Specialized;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
|
||||||
|
namespace Config
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// PrivateProfile opens a private profile string and stores it's contents in an xml document.
|
||||||
|
/// </summary>
|
||||||
|
public class PrivateProfile
|
||||||
|
{
|
||||||
|
#region Log4Net
|
||||||
|
private static readonly log4net.ILog log = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
private string ppName;
|
||||||
|
private XmlDocument ppXml;
|
||||||
|
private List<string> attr;
|
||||||
|
private List<string> ele;
|
||||||
|
|
||||||
|
private XmlNode AddNode(XmlNode xParent, string sName, string sValue )
|
||||||
|
{
|
||||||
|
XmlNode nd=AddNode(xParent,sName);
|
||||||
|
nd.Value=sValue;
|
||||||
|
return nd;
|
||||||
|
}
|
||||||
|
private XmlNode AddNode(XmlNode xParent, string sName)
|
||||||
|
{
|
||||||
|
XmlNode nd;
|
||||||
|
// Add a node
|
||||||
|
string tsName = sName.Replace(' ', '_');
|
||||||
|
nd=xParent.OwnerDocument.CreateNode(System.Xml.XmlNodeType.Element,tsName,"");
|
||||||
|
xParent.AppendChild(nd);
|
||||||
|
return nd;
|
||||||
|
}
|
||||||
|
private void AddAttribute(XmlNode xParent, string sName, string sValue )
|
||||||
|
{
|
||||||
|
XmlNode xa=xParent.Attributes.GetNamedItem(sName);
|
||||||
|
// bug fix. 09/15/03
|
||||||
|
// If there was a space after an equal sign, that space character
|
||||||
|
// was becomming part of the value string (reading the user.CFG file).
|
||||||
|
// This was giving us a "Must have semi-colon" error message.
|
||||||
|
// We now strip spaces before and after any Attribute that is written.
|
||||||
|
sValue = sValue.Trim(' ');
|
||||||
|
sName = sName.Replace(' ', '_');
|
||||||
|
|
||||||
|
// Add an attribute
|
||||||
|
if(sValue=="")
|
||||||
|
{
|
||||||
|
if(xa != null)
|
||||||
|
{
|
||||||
|
xParent.Attributes.RemoveNamedItem(sName);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if(xa == null)
|
||||||
|
{
|
||||||
|
xa = xParent.OwnerDocument.CreateNode(System.Xml.XmlNodeType.Attribute ,sName,"");
|
||||||
|
xParent.Attributes.SetNamedItem(xa);
|
||||||
|
}
|
||||||
|
xa.Value=sValue;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
private XmlNode AddSection(XmlNode xParent, string sSection )
|
||||||
|
{
|
||||||
|
// get the name. If it's not in the 'migrated elements' list, then
|
||||||
|
// preface the name with a 'z'.
|
||||||
|
string elename = sSection.Substring(1, sSection.IndexOf("]") - 1);
|
||||||
|
while(elename.IndexOf(' ')>-1) elename = elename.Remove(elename.IndexOf(' '),1);
|
||||||
|
if (!ele.Contains(elename.ToLower())) elename = 'z' + elename;
|
||||||
|
// Add a section [name]
|
||||||
|
XmlNode nd = AddNode(xParent, elename);
|
||||||
|
//AddAttribute(nd,"name",sSection.Substring(1,sSection.IndexOf("]")-1));
|
||||||
|
return nd;
|
||||||
|
}
|
||||||
|
private XmlNode AddSection_UC(XmlNode xParent, string sSection )
|
||||||
|
{
|
||||||
|
// Add a section [name]
|
||||||
|
string name_uc = sSection.Substring(1,sSection.IndexOf("]")-1).ToUpper() + "__UC";
|
||||||
|
XmlNode nd =AddNode(xParent,name_uc);
|
||||||
|
// AddAttribute(nd,"name",name_uc);
|
||||||
|
return nd;
|
||||||
|
}
|
||||||
|
private void AddComment(XmlNode xParent, string sComment)
|
||||||
|
{
|
||||||
|
|
||||||
|
if(xParent.ChildNodes.Count > 0)
|
||||||
|
{
|
||||||
|
XmlNode ndlast=xParent.ChildNodes.Item(xParent.ChildNodes.Count-1);
|
||||||
|
if(ndlast.Name=="comment")
|
||||||
|
{
|
||||||
|
XmlNode xa = ndlast.Attributes.GetNamedItem("text");
|
||||||
|
xa.Value=xa.Value + "\r\n" + sComment;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// Add a comment text
|
||||||
|
XmlNode nd =AddNode(xParent,"comment");
|
||||||
|
AddAttribute(nd,"text",sComment);
|
||||||
|
}
|
||||||
|
private void AddLine(XmlNode xParent, string sLine)
|
||||||
|
{
|
||||||
|
// Add a comment text
|
||||||
|
XmlNode nd =AddNode(xParent,"line");
|
||||||
|
AddAttribute(nd,"text",sLine);
|
||||||
|
}
|
||||||
|
private void AddParam(XmlNode xParent, string sParam)
|
||||||
|
{
|
||||||
|
int i = sParam.IndexOf("=");
|
||||||
|
// get the name. If it's not in the 'migrated attribute' list, then
|
||||||
|
// preface the name with a 'z'.
|
||||||
|
string attrname = sParam.Substring(0, i);
|
||||||
|
while (attrname.IndexOf(' ') > -1) attrname = attrname.Remove(attrname.IndexOf(' '), 1);
|
||||||
|
if (!attr.Contains(attrname.ToLower())) attrname = 'z' + attrname;
|
||||||
|
string sValue=sParam.Substring(i+1);
|
||||||
|
string sName = attrname.Trim(' ');
|
||||||
|
AddAttribute(xParent, sName, sValue);
|
||||||
|
}
|
||||||
|
private void AddParam_UC(XmlNode xParent, string sParam)
|
||||||
|
{
|
||||||
|
int i = sParam.IndexOf("=");
|
||||||
|
// add a param name=value
|
||||||
|
string sName=sParam.Substring(0,i);
|
||||||
|
string sValue=sParam.Substring(i+1);
|
||||||
|
//XmlNode nd =AddNode(xParent,"paramUC");
|
||||||
|
sName = sName.Trim(' ');
|
||||||
|
AddAttribute(xParent, sName, sValue);
|
||||||
|
//AddAttribute(nd,"name",sName.ToUpper()+"__UC");
|
||||||
|
//AddAttribute(nd,"value",sValue);
|
||||||
|
}
|
||||||
|
private void LoadXML()
|
||||||
|
{
|
||||||
|
string sLine;
|
||||||
|
ppXml.LoadXml("<ConfigInfo/>");// initialize ppXml
|
||||||
|
XmlNode xmlTop=ppXml.DocumentElement;
|
||||||
|
XmlNode xmlNd=ppXml.DocumentElement;
|
||||||
|
//XmlNode xmlNd_UC=ppXml.DocumentElement;
|
||||||
|
StreamReader myReader = new StreamReader(ppName);// Open file
|
||||||
|
while( (sLine = myReader.ReadLine())!= null)// read line-by-line
|
||||||
|
{
|
||||||
|
// add structure
|
||||||
|
try
|
||||||
|
{
|
||||||
|
if (sLine.Length > 0)
|
||||||
|
{
|
||||||
|
switch (sLine.Substring(0, 1))
|
||||||
|
{
|
||||||
|
case "[":
|
||||||
|
xmlNd = AddSection(xmlTop, sLine);
|
||||||
|
//xmlNd_UC=AddSection_UC(xmlTop, sLine);
|
||||||
|
break;
|
||||||
|
case ";":
|
||||||
|
//AddComment(xmlNd, sLine);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
if (sLine.IndexOf("=") >= 0)
|
||||||
|
{
|
||||||
|
AddParam(xmlNd, sLine);
|
||||||
|
//AddParam_UC(xmlNd_UC, sLine);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
//AddLine(xmlNd, sLine);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
log.ErrorFormat("error parsing .INI file: {0} - Directory: {1}", ex.Message,ppName);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
myReader.Close();
|
||||||
|
}
|
||||||
|
public PrivateProfile(string sFileName, List<string> listIni_EleName, List<string> listIni_AttrName)
|
||||||
|
{
|
||||||
|
ppName=sFileName;
|
||||||
|
ppXml= new XmlDocument();
|
||||||
|
attr = listIni_AttrName;
|
||||||
|
ele = listIni_EleName;
|
||||||
|
LoadXML();
|
||||||
|
}
|
||||||
|
~PrivateProfile()
|
||||||
|
{
|
||||||
|
// Clean-up
|
||||||
|
//
|
||||||
|
}
|
||||||
|
public string PrettyNode(XmlNode nd,int level)
|
||||||
|
{
|
||||||
|
string retval="";
|
||||||
|
string prefix=new string(' ',level*2);
|
||||||
|
if(nd.ChildNodes.Count > 0)
|
||||||
|
{
|
||||||
|
retval = prefix + "<" + nd.Name;
|
||||||
|
for(int i=0;i<nd.Attributes.Count;i++)
|
||||||
|
{
|
||||||
|
retval=retval + " " + nd.Attributes.Item(i).Name + "='" + nd.Attributes.Item(i).Value + "'";
|
||||||
|
}
|
||||||
|
retval=retval+">";
|
||||||
|
for(int i=0;i<nd.ChildNodes.Count;i++)
|
||||||
|
{
|
||||||
|
retval=retval+"\r\n"+PrettyNode(nd.ChildNodes.Item(i),level+1);
|
||||||
|
}
|
||||||
|
retval=retval+"\r\n" + prefix + "</" + nd.Name + ">";
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
retval = prefix + "<" + nd.Name;
|
||||||
|
for(int i=0;i<nd.Attributes.Count;i++)
|
||||||
|
{
|
||||||
|
retval=retval + " " + nd.Attributes.Item(i).Name + "='" + nd.Attributes.Item(i).Value + "'";
|
||||||
|
}
|
||||||
|
retval=retval+"/>";
|
||||||
|
}
|
||||||
|
return retval;
|
||||||
|
}
|
||||||
|
public string PrettyXML()
|
||||||
|
{
|
||||||
|
return PrettyNode(ppXml.DocumentElement,0);
|
||||||
|
}
|
||||||
|
public XmlDocument XML()
|
||||||
|
{
|
||||||
|
// return XML Document
|
||||||
|
return ppXml;
|
||||||
|
}
|
||||||
|
public override string ToString()
|
||||||
|
{
|
||||||
|
// return string
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
public void Save()
|
||||||
|
{
|
||||||
|
SaveAs(ppName);
|
||||||
|
}
|
||||||
|
public void SaveAs(string sName)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
public string Attr(string sPath)
|
||||||
|
{
|
||||||
|
string retval="";
|
||||||
|
XmlNode xn = ppXml.SelectSingleNode(sPath);
|
||||||
|
if(xn != null)
|
||||||
|
{
|
||||||
|
string quots = xn.Value;
|
||||||
|
if (quots.Substring(0,1)=="\"" && quots.Substring(quots.Length-1,1)=="\"")
|
||||||
|
retval = quots.Substring(1,quots.Length-2);
|
||||||
|
else
|
||||||
|
retval=xn.Value;
|
||||||
|
}
|
||||||
|
return retval;
|
||||||
|
}
|
||||||
|
|
||||||
|
public string Attr(string sSection, string sParameter)
|
||||||
|
{
|
||||||
|
string findstr = "/ini/sectionUC[@name='" + sSection.ToUpper() + "__UC']/paramUC[@name='" + sParameter.ToUpper() + "__UC']/@value";
|
||||||
|
return Attr(findstr);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
189
PROMS/DataLoader/Procedures.cs
Normal file
189
PROMS/DataLoader/Procedures.cs
Normal file
@ -0,0 +1,189 @@
|
|||||||
|
// ========================================================================
|
||||||
|
// 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 Int32 MigrateProcedure(OleDbConnection cn, DataRow dr, Byte FromType, Int32 FromID, string pth)
|
||||||
|
{
|
||||||
|
dicOldStepSequence = new Dictionary<object, string>();
|
||||||
|
Stack<int> SubSectLevels = new Stack<int>(); // levels of subsections
|
||||||
|
ProcFileName = dr["Entry"].ToString();
|
||||||
|
ProcNumber = dr["Number"].ToString();
|
||||||
|
DateTime dts = GetDTS(dr["Date"].ToString(), dr["Time"].ToString());
|
||||||
|
string userid = dr["initials"].ToString().Trim();
|
||||||
|
|
||||||
|
ConfigInfo ci = null;
|
||||||
|
string tstr = dr["Proccode"].ToString();
|
||||||
|
if (tstr != null && tstr != "")
|
||||||
|
{
|
||||||
|
ci = new ConfigInfo(null);
|
||||||
|
ci.AddItem("Procedure", "ProcCode", tstr);
|
||||||
|
}
|
||||||
|
tstr = dr["Series"].ToString();
|
||||||
|
if (tstr != null && tstr != "")
|
||||||
|
{
|
||||||
|
if (ci == null) ci = new ConfigInfo(null);
|
||||||
|
ci.AddItem("Procedure", "Series", tstr);
|
||||||
|
}
|
||||||
|
|
||||||
|
DataSet ds = new DataSet();
|
||||||
|
DataTable dt = null;
|
||||||
|
|
||||||
|
// See if there is PSI and if so, add it to the xml.
|
||||||
|
OleDbDataAdapter dapsi = new OleDbDataAdapter("select * from [" + dr["entry"] + "] where [STEP] is null", cn);
|
||||||
|
dapsi.Fill(ds);
|
||||||
|
dt = ds.Tables[0];
|
||||||
|
|
||||||
|
if (dt.Rows.Count > 0)
|
||||||
|
{
|
||||||
|
DataRow drpsi = dt.Rows[0];
|
||||||
|
string psistr = drpsi["TEXTM"].ToString();
|
||||||
|
if (psistr != null && psistr != "")
|
||||||
|
{
|
||||||
|
StringReader strrd = new StringReader(psistr);
|
||||||
|
|
||||||
|
string sLine;
|
||||||
|
if (ci == null) ci = new ConfigInfo(null);
|
||||||
|
while ((sLine = strrd.ReadLine()) != null)
|
||||||
|
{
|
||||||
|
int indx = sLine.IndexOf(' ');
|
||||||
|
string nm = null;
|
||||||
|
string vl = null;
|
||||||
|
if (indx < 0)
|
||||||
|
nm = sLine;
|
||||||
|
else
|
||||||
|
{
|
||||||
|
nm = sLine.Substring(0, indx);
|
||||||
|
vl = sLine.Substring(indx+1, sLine.Length-indx-1);
|
||||||
|
}
|
||||||
|
ci.AddItem("PSI", nm, vl==null?null:vl);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
dapsi.Dispose();
|
||||||
|
|
||||||
|
// Note, for now the data from the format field will be saved. Later, xpath, ??
|
||||||
|
EditSectId = 0;
|
||||||
|
|
||||||
|
Byte FrType = 2;
|
||||||
|
Int32 FrID = 0;// str.Structureid;
|
||||||
|
Procedure prc = Procedure.MakeProcedure(TextConvert.ConvertText(dr["Number"].ToString()), TextConvert.ConvertText(dr["Title"].ToString()), ci==null?null:ci.ToString(), null, 0, 0, dts, userid);
|
||||||
|
Structure str = Structure.MakeStructure(FromType, FromID, 1, prc.ProcID, dts, userid);
|
||||||
|
UpdateLabels(1, 0, 0);
|
||||||
|
//OleDbDataAdapter da = new OleDbDataAdapter("select * from (select asc(mid(sequence,2,1)) as locb,* from [" + dr["entry"] + "] where sequence like ' %') order by locb asc", cn);
|
||||||
|
OleDbDataAdapter da = new OleDbDataAdapter("select * from [" + dr["entry"] + "] where sequence like ' %'", cn);
|
||||||
|
try
|
||||||
|
{
|
||||||
|
LoadSection(ds, da, dr["entry"].ToString());
|
||||||
|
da.SelectCommand.CommandText = "select * from [" + dr["entry"] + "] where step not like ' '";
|
||||||
|
da.Fill(ds, "Steps");
|
||||||
|
dt = ds.Tables["Steps"];
|
||||||
|
dt.CaseSensitive = true;
|
||||||
|
ds.Tables["Steps"].CaseSensitive = true;
|
||||||
|
dt.Columns.Add("CStep", System.Type.GetType("System.String"));
|
||||||
|
dt.Columns.Add("CSequence", System.Type.GetType("System.String"));
|
||||||
|
// set the cstep & csequence - couldn't do it in the add because it needed a sql function
|
||||||
|
foreach (DataRow drw in ds.Tables["Steps"].Rows)
|
||||||
|
{
|
||||||
|
drw["CStep"] = TextConvert.ConvertSeq(drw["Step"].ToString());
|
||||||
|
drw["CSequence"] = TextConvert.ConvertSeq(drw["Sequence"].ToString());
|
||||||
|
}
|
||||||
|
dt.Columns.Add("StepNo", System.Type.GetType("System.Int32"), "Convert(Convert(Substring(CStep,2,1),'System.Char'),'System.Int32')-48");
|
||||||
|
dt.Columns.Add("Level", System.Type.GetType("System.Int32"), "Len(CSequence)");
|
||||||
|
dt.Columns.Add("SubStepNo", System.Type.GetType("System.Int32"), "Convert(Convert(Substring(CSequence,Len(CSequence),1),'System.Char'),'System.Int32')-48");
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
log.ErrorFormat("{0}\r\n\r\n{1}", ex.Message, ex.InnerException);
|
||||||
|
log.Error(ex.StackTrace);
|
||||||
|
}
|
||||||
|
|
||||||
|
Dictionary<int, int> dicSecCount = new Dictionary<int, int>();
|
||||||
|
Dictionary<int, int> dicSecID = new Dictionary<int, int>();
|
||||||
|
pbSect.Maximum = ds.Tables["Sections"].Rows.Count;
|
||||||
|
pbSect.Value = 0;
|
||||||
|
|
||||||
|
DataTable dtsect = ds.Tables["Sections"];
|
||||||
|
dtsect.CaseSensitive = true;
|
||||||
|
DataView dv = new DataView(dtsect, "", "locb", DataViewRowState.CurrentRows);
|
||||||
|
foreach (DataRowView drw in dv)
|
||||||
|
{
|
||||||
|
FrID = MigrateSection(prc, cn, drw, ds.Tables["Steps"], FrType, FrID, dicSecCount.Count > 0 ? true : false, pth);
|
||||||
|
if (prc.StructureID == 0)
|
||||||
|
{
|
||||||
|
prc.StructureID = FrID;
|
||||||
|
prc.Save(true); //force update
|
||||||
|
}
|
||||||
|
FrType = 0;
|
||||||
|
dicSecID[dicSecCount.Count] = FrID;
|
||||||
|
if (dicSecCount.Count > 0)
|
||||||
|
{
|
||||||
|
if ((dicSecCount[dicSecCount.Count]) == 1)
|
||||||
|
{
|
||||||
|
dicSecCount.Remove(dicSecCount.Count);
|
||||||
|
FrID = dicSecID[dicSecCount.Count];
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
dicSecCount[dicSecCount.Count] = dicSecCount[dicSecCount.Count] - 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
int subSecs = drw["Sequence"].ToString().PadRight(12, ' ')[5] - 48;
|
||||||
|
if (subSecs > 0)
|
||||||
|
{
|
||||||
|
dicSecCount[dicSecCount.Count + 1] = subSecs;
|
||||||
|
FrType = 2;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (EditSectId != 0)
|
||||||
|
{
|
||||||
|
prc.StructureStart = EditSectId;
|
||||||
|
EditSectId = 0;
|
||||||
|
prc.Save(true); // force update
|
||||||
|
}
|
||||||
|
return str.StructureID;
|
||||||
|
}
|
||||||
|
private Int32 MigrateProcedures(OleDbConnection cn, string pth)
|
||||||
|
{
|
||||||
|
// Loop through Set File for each Procedure
|
||||||
|
OleDbDataAdapter da = new OleDbDataAdapter("Select * from [set] where entry is not null", cn);
|
||||||
|
DataSet ds = new DataSet();
|
||||||
|
da.Fill(ds);
|
||||||
|
Byte FrType = 1;
|
||||||
|
Int32 FrID = 0;
|
||||||
|
Int32 FirstID = 0;
|
||||||
|
pbProc.Maximum = ds.Tables[0].Rows.Count;
|
||||||
|
UpdateLabels(0, 0, 0);
|
||||||
|
foreach (DataRow dr in ds.Tables[0].Rows)
|
||||||
|
{
|
||||||
|
FrID = MigrateProcedure(cn, dr, FrType, FrID, pth);
|
||||||
|
if (FirstID == 0) FirstID = FrID;
|
||||||
|
FrType = 0;
|
||||||
|
}
|
||||||
|
da.Dispose();
|
||||||
|
return FirstID;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
21
PROMS/DataLoader/Program.cs
Normal file
21
PROMS/DataLoader/Program.cs
Normal file
@ -0,0 +1,21 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Windows.Forms;
|
||||||
|
|
||||||
|
|
||||||
|
namespace DataLoader
|
||||||
|
{
|
||||||
|
static class Program
|
||||||
|
{
|
||||||
|
//<summary>
|
||||||
|
//The main entry point for the application.
|
||||||
|
//</summary>
|
||||||
|
[STAThread]
|
||||||
|
static void Main()
|
||||||
|
{
|
||||||
|
Application.EnableVisualStyles();
|
||||||
|
Application.SetCompatibleTextRenderingDefault(false);
|
||||||
|
Application.Run(new frmLoader());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
251
PROMS/DataLoader/ROFST.cs
Normal file
251
PROMS/DataLoader/ROFST.cs
Normal file
@ -0,0 +1,251 @@
|
|||||||
|
// ========================================================================
|
||||||
|
// 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.Collections.Generic;
|
||||||
|
using System.Collections.Specialized;
|
||||||
|
using System.Text;
|
||||||
|
using System.IO;
|
||||||
|
using System.Xml.Serialization;
|
||||||
|
using System.Xml;
|
||||||
|
using System.Xml.XPath;
|
||||||
|
|
||||||
|
namespace DataLoader
|
||||||
|
{
|
||||||
|
public class ROFST
|
||||||
|
{
|
||||||
|
#region Log4Net
|
||||||
|
private static readonly log4net.ILog log = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
|
||||||
|
#endregion
|
||||||
|
[Serializable]
|
||||||
|
public struct roHdr
|
||||||
|
{
|
||||||
|
public int hSize;
|
||||||
|
public int hYear;
|
||||||
|
public byte hMonth;
|
||||||
|
public byte hDay;
|
||||||
|
public int hcYear;
|
||||||
|
public byte hcMonth;
|
||||||
|
public byte hcDay;
|
||||||
|
public byte hcHour;
|
||||||
|
public byte hcMin;
|
||||||
|
public byte hcSec;
|
||||||
|
public byte hcHund;
|
||||||
|
public rodbi[] myDbs;
|
||||||
|
};
|
||||||
|
[Serializable]
|
||||||
|
public struct rodbi
|
||||||
|
{
|
||||||
|
public int dbiID;
|
||||||
|
public int dbiType;
|
||||||
|
public int dbiAW;
|
||||||
|
public string dbiTitle;
|
||||||
|
public string dbiAP;
|
||||||
|
public int ID;
|
||||||
|
public int ParentID;
|
||||||
|
public rochild[] children;
|
||||||
|
};
|
||||||
|
public struct rogrp
|
||||||
|
{
|
||||||
|
public int ID;
|
||||||
|
public int ParentID;
|
||||||
|
public rochild[] children;
|
||||||
|
public string value;
|
||||||
|
public string appid;
|
||||||
|
};
|
||||||
|
public struct rochild
|
||||||
|
{
|
||||||
|
public int ID;
|
||||||
|
public int ParentID;
|
||||||
|
public int type;
|
||||||
|
public string title;
|
||||||
|
public string roid;
|
||||||
|
public string appid;
|
||||||
|
public string value;
|
||||||
|
public rochild[] children;
|
||||||
|
};
|
||||||
|
private roHdr myHdr;
|
||||||
|
private int TableID;
|
||||||
|
private string fstPath;
|
||||||
|
private HybridDictionary dicRos;
|
||||||
|
|
||||||
|
public ROFST(string path)
|
||||||
|
{
|
||||||
|
fstPath = path;
|
||||||
|
if (!File.Exists(fstPath))
|
||||||
|
{
|
||||||
|
log.ErrorFormat("RO FST Does not exist: {0}", path);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
dicRos = new HybridDictionary();
|
||||||
|
ParseIntoDictionary();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void Close()
|
||||||
|
{
|
||||||
|
// remove the dictionary
|
||||||
|
dicRos.Clear();
|
||||||
|
dicRos = null;
|
||||||
|
}
|
||||||
|
|
||||||
|
// this only gets rochild values. Later we may want another
|
||||||
|
// dictionary to get groups.
|
||||||
|
public string GetRoValue(string ROID)
|
||||||
|
{
|
||||||
|
// Use the ROID to get the value from the dictionary
|
||||||
|
if (dicRos.Contains(ROID))
|
||||||
|
{
|
||||||
|
rochild rochld = (rochild)dicRos[ROID];
|
||||||
|
return rochld.value;
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
private int StringLength(byte[] ab, int offset)
|
||||||
|
{
|
||||||
|
int i = 0;
|
||||||
|
while (ab[i + offset] != 0) i++;
|
||||||
|
return i;
|
||||||
|
}
|
||||||
|
private rogrp LoadGroup(byte[] ab, int offset)
|
||||||
|
{
|
||||||
|
rogrp myGrp = new rogrp();
|
||||||
|
myGrp.ID = BitConverter.ToInt32(ab, offset);
|
||||||
|
myGrp.ParentID = BitConverter.ToInt32(ab, offset + 4);
|
||||||
|
int howmany = BitConverter.ToInt16(ab, offset + 8);
|
||||||
|
if (howmany > 0)
|
||||||
|
{
|
||||||
|
myGrp.children = new rochild[howmany];
|
||||||
|
int myOffset = offset + 10;
|
||||||
|
for (int i = 0; i < myGrp.children.Length; i++)
|
||||||
|
{
|
||||||
|
int childOffset = BitConverter.ToInt32(ab, myOffset);
|
||||||
|
rochild tmp = new rochild();
|
||||||
|
//tmp.offset=BitConverter.ToInt32(ab,myOffset);
|
||||||
|
tmp.type = BitConverter.ToInt16(ab, myOffset + 4);
|
||||||
|
int slen = StringLength(ab, myOffset + 6);
|
||||||
|
tmp.title = Encoding.Default.GetString(ab, myOffset + 6, slen);
|
||||||
|
myOffset += (7 + slen);
|
||||||
|
rogrp tmpg = LoadGroup(ab, childOffset);
|
||||||
|
tmp.ID = tmpg.ID;
|
||||||
|
tmp.ParentID = tmpg.ParentID;
|
||||||
|
tmp.children = tmpg.children;
|
||||||
|
tmp.value = tmpg.value;
|
||||||
|
tmp.appid = tmpg.appid;
|
||||||
|
tmp.roid = TableID.ToString("X4") + tmp.ID.ToString("X8");
|
||||||
|
dicRos.Add(tmp.roid, tmp);
|
||||||
|
int j;
|
||||||
|
for (j = i - 1; j >= 0 && tmp.ID < myGrp.children[j].ID; j--)
|
||||||
|
{
|
||||||
|
myGrp.children[j + 1] = myGrp.children[j];
|
||||||
|
}
|
||||||
|
myGrp.children[j + 1] = tmp;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
int slen = StringLength(ab, offset + 12);
|
||||||
|
myGrp.value = Encoding.Default.GetString(ab, offset + 12, slen);
|
||||||
|
int slen2 = StringLength(ab, offset + 13 + slen);
|
||||||
|
myGrp.appid = Encoding.Default.GetString(ab, offset + 13 + slen, slen2);
|
||||||
|
}
|
||||||
|
return myGrp;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void ParseIntoDictionary()
|
||||||
|
{
|
||||||
|
FileStream fsIn = new FileStream(fstPath, FileMode.Open,FileAccess.Read, FileShare.Read);
|
||||||
|
// Create an instance of StreamReader that can read
|
||||||
|
// characters from the FileStream.
|
||||||
|
BinaryReader r = new BinaryReader(fsIn);
|
||||||
|
byte[] ab = r.ReadBytes((int)fsIn.Length);
|
||||||
|
r.Close();
|
||||||
|
|
||||||
|
myHdr.hSize = BitConverter.ToInt32(ab, 0);
|
||||||
|
myHdr.hYear = BitConverter.ToInt16(ab, 4);
|
||||||
|
myHdr.hMonth = ab[6];
|
||||||
|
myHdr.hDay = ab[7];
|
||||||
|
myHdr.hcYear = BitConverter.ToInt16(ab, 8);
|
||||||
|
myHdr.hcMonth = ab[10];
|
||||||
|
myHdr.hcDay = ab[11];
|
||||||
|
myHdr.hcHour = ab[12];
|
||||||
|
myHdr.hcMin = ab[13];
|
||||||
|
myHdr.hcSec = ab[14];
|
||||||
|
myHdr.hcHund = ab[15];
|
||||||
|
int hdrOffset = BitConverter.ToInt32(ab, 16);
|
||||||
|
int howbig = BitConverter.ToInt32(ab, hdrOffset);
|
||||||
|
int dbs = BitConverter.ToInt16(ab, hdrOffset + 4);
|
||||||
|
myHdr.myDbs = new rodbi[dbs];
|
||||||
|
for (int i = 0; i < dbs; i++)
|
||||||
|
{
|
||||||
|
int offset = hdrOffset + 6 + (i * 30);
|
||||||
|
myHdr.myDbs[i].dbiID = BitConverter.ToInt16(ab, offset + 0);
|
||||||
|
TableID = myHdr.myDbs[i].dbiID;
|
||||||
|
myHdr.myDbs[i].dbiType = BitConverter.ToInt16(ab, offset + 2);
|
||||||
|
myHdr.myDbs[i].dbiAW = BitConverter.ToInt16(ab, offset + 4);
|
||||||
|
rogrp tmp = LoadGroup(ab, BitConverter.ToInt32(ab, offset + 6));
|
||||||
|
myHdr.myDbs[i].ID = tmp.ID;
|
||||||
|
myHdr.myDbs[i].children = tmp.children;
|
||||||
|
int iPtr = BitConverter.ToInt32(ab, offset + 22) + hdrOffset + 6;
|
||||||
|
myHdr.myDbs[i].dbiTitle = Encoding.Default.GetString(ab, iPtr, StringLength(ab, iPtr));
|
||||||
|
iPtr = BitConverter.ToInt32(ab, offset + 26) + hdrOffset + 6;
|
||||||
|
myHdr.myDbs[i].dbiAP = Encoding.Default.GetString(ab, iPtr, StringLength(ab, iPtr));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public bool SaveToXml(string fname)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
StreamWriter swxml = new StreamWriter(fname);
|
||||||
|
XmlSerializer mySer = new XmlSerializer(typeof(roHdr));
|
||||||
|
mySer.Serialize(swxml, myHdr);
|
||||||
|
swxml.Close();
|
||||||
|
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
log.ErrorFormat("Error writing to file: {0}", ex.Message);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public XmlDocument GetXmlFromFile(string fname)
|
||||||
|
{
|
||||||
|
FileStream xmlIn = new FileStream(fname, FileMode.Open, FileAccess.Read, FileShare.Read);
|
||||||
|
XmlDocument xmlDoc = new XmlDocument();
|
||||||
|
xmlDoc.Load(xmlIn);
|
||||||
|
xmlIn.Close();
|
||||||
|
return xmlDoc;
|
||||||
|
}
|
||||||
|
|
||||||
|
public string GetValueFromXml(XmlDocument xmlDoc, string ROID)
|
||||||
|
{
|
||||||
|
// use roid as xpath to get data.
|
||||||
|
try
|
||||||
|
{
|
||||||
|
string xpath_roid = "//rochild[roid = \"" + ROID.Substring(0, 12) + "\"]/value";
|
||||||
|
XmlNode valnd = xmlDoc.SelectSingleNode(xpath_roid);
|
||||||
|
if (valnd == null) return null;
|
||||||
|
return valnd.InnerText;
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
log.ErrorFormat("Cannot find ro in XmlDocument ");
|
||||||
|
log.ErrorFormat("roid = {0}", ROID);
|
||||||
|
log.ErrorFormat("{0}\r\n\r\n{1}", ex.Message, ex.InnerException);
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
92
PROMS/DataLoader/RefObjs.cs
Normal file
92
PROMS/DataLoader/RefObjs.cs
Normal file
@ -0,0 +1,92 @@
|
|||||||
|
// ========================================================================
|
||||||
|
// 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();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
913
PROMS/DataLoader/SecObj.cs
Normal file
913
PROMS/DataLoader/SecObj.cs
Normal file
@ -0,0 +1,913 @@
|
|||||||
|
// ========================================================================
|
||||||
|
// 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.IO;
|
||||||
|
using System.Collections;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Collections.Specialized;
|
||||||
|
using System.Windows.Forms;
|
||||||
|
using System.Text;
|
||||||
|
using Volian.CSLA.Library;
|
||||||
|
using Config;
|
||||||
|
|
||||||
|
namespace DataLoader
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Summary description for Security.
|
||||||
|
/// </summary>
|
||||||
|
///
|
||||||
|
#region OldVeSamClasses
|
||||||
|
// do a temp plant - we may keep this for loading in data. It will be migrated
|
||||||
|
// to a folders record.
|
||||||
|
#region Options
|
||||||
|
public class PlantOptions
|
||||||
|
{
|
||||||
|
private UInt16 _id;
|
||||||
|
private UInt32 _plopts;
|
||||||
|
public List<ProcOptions> poList = new List<ProcOptions>();
|
||||||
|
|
||||||
|
public UInt16 Id
|
||||||
|
{
|
||||||
|
get {return _id;}
|
||||||
|
set {if (_id != value) _id = value;}
|
||||||
|
}
|
||||||
|
|
||||||
|
public UInt32 Options
|
||||||
|
{
|
||||||
|
get {return _plopts;}
|
||||||
|
set {if (_plopts != value) _plopts = value;}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
public class ProcOptions
|
||||||
|
{
|
||||||
|
private UInt16 _id;
|
||||||
|
private UInt16 _selected;
|
||||||
|
public UInt32 [] Options = new UInt32[4];
|
||||||
|
|
||||||
|
public UInt16 Id
|
||||||
|
{
|
||||||
|
get {return _id;}
|
||||||
|
set {if (_id != value)_id = value;}
|
||||||
|
}
|
||||||
|
public UInt16 Selected
|
||||||
|
{
|
||||||
|
get {return _selected;}
|
||||||
|
set {if (_selected != value)_selected = value;}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endregion
|
||||||
|
#region OldFolders
|
||||||
|
public class Plant
|
||||||
|
{
|
||||||
|
private string _name;
|
||||||
|
private string _path;
|
||||||
|
private UInt16 _id;
|
||||||
|
public Dictionary<ushort, ProcSet> psDic = new Dictionary<ushort,ProcSet>();
|
||||||
|
|
||||||
|
public string Name
|
||||||
|
{
|
||||||
|
get {return _name;}
|
||||||
|
set
|
||||||
|
{
|
||||||
|
if (value == null) value = string.Empty;
|
||||||
|
if (_name != value) _name = value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
public string Path
|
||||||
|
{
|
||||||
|
get {return _path;}
|
||||||
|
set
|
||||||
|
{
|
||||||
|
if (value == null) value = string.Empty;
|
||||||
|
if (_path != value)_path = value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
public UInt16 Id
|
||||||
|
{
|
||||||
|
get {return _id;}
|
||||||
|
set {if (_id != value) _id = value;}
|
||||||
|
}
|
||||||
|
|
||||||
|
public Plant() { }
|
||||||
|
public Plant(string nm, string pth, UInt16 idn)
|
||||||
|
{
|
||||||
|
_name = nm;
|
||||||
|
_path = pth;
|
||||||
|
_id = idn;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public class ProcSet
|
||||||
|
{
|
||||||
|
private string _name;
|
||||||
|
private string _path;
|
||||||
|
private UInt16 _id;
|
||||||
|
public string Name
|
||||||
|
{
|
||||||
|
get {return _name;}
|
||||||
|
set
|
||||||
|
{
|
||||||
|
if (value == null) value = string.Empty;
|
||||||
|
if (_name != value)_name = value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
public string Path
|
||||||
|
{
|
||||||
|
get {return _path;}
|
||||||
|
set
|
||||||
|
{
|
||||||
|
if (value == null) value = string.Empty;
|
||||||
|
if (_path != value)_path = value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
public UInt16 Id
|
||||||
|
{
|
||||||
|
get {return _id;}
|
||||||
|
set {if (_id != value) _id = value;}
|
||||||
|
}
|
||||||
|
public ProcSet() { }
|
||||||
|
|
||||||
|
public ProcSet(string nm, string pth, UInt16 idn)
|
||||||
|
{
|
||||||
|
_name = nm;
|
||||||
|
_path = pth;
|
||||||
|
_id = idn;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endregion
|
||||||
|
#region OldUser
|
||||||
|
// The OldUser class stores data from the vesam input. The User class migrates
|
||||||
|
// and saves data to the new sql database.
|
||||||
|
public class OldUser
|
||||||
|
{
|
||||||
|
private UInt32 _systemopts;
|
||||||
|
private string _username;
|
||||||
|
private bool _blockaccessflag = false;
|
||||||
|
public List<PlantOptions> PlantOpts = new List<PlantOptions>();
|
||||||
|
|
||||||
|
public UInt32 SystemOpts
|
||||||
|
{
|
||||||
|
get { return _systemopts; }
|
||||||
|
set { if (_systemopts != value) _systemopts = value; }
|
||||||
|
}
|
||||||
|
public string UserName
|
||||||
|
{
|
||||||
|
get { return _username; }
|
||||||
|
set
|
||||||
|
{
|
||||||
|
if (value == null) value = string.Empty;
|
||||||
|
if (_username != value) _username = value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public bool BlockAccessFlag
|
||||||
|
{
|
||||||
|
get { return _blockaccessflag; }
|
||||||
|
set { if (_blockaccessflag != value) _blockaccessflag = value; }
|
||||||
|
}
|
||||||
|
|
||||||
|
public bool PermissionToManageFlag
|
||||||
|
{
|
||||||
|
get { return (_systemopts & VESamOpt.DOCMAINT)==0?false:true; }
|
||||||
|
//set { if (_permissiontomanageflag != value) _permissiontomanageflag = value; }
|
||||||
|
}
|
||||||
|
|
||||||
|
public bool SystemAdminFlag
|
||||||
|
{
|
||||||
|
get { return (_systemopts & VESamOpt.SYSADMIN)==0 ? false:true; }
|
||||||
|
//set { if (_systemadminflag != value) _systemadminflag = value; }
|
||||||
|
}
|
||||||
|
|
||||||
|
public bool PermissionToLockFlag
|
||||||
|
{
|
||||||
|
get { return (_systemopts & VESamOpt.LOCKSYSTEM)==0 ? false:true; }
|
||||||
|
//set { if (_permissiontolockflag != value) _permissiontolockflag = value; }
|
||||||
|
}
|
||||||
|
|
||||||
|
public bool RoEditorFlag
|
||||||
|
{
|
||||||
|
get { return (_systemopts & VESamOpt.ROEDITOR) == 0 ? false : true; }
|
||||||
|
}
|
||||||
|
|
||||||
|
public OldUser(string nm)
|
||||||
|
{
|
||||||
|
_username = nm;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endregion
|
||||||
|
#region VESam
|
||||||
|
public class VESamOpt
|
||||||
|
{
|
||||||
|
#region Log4Net
|
||||||
|
private static readonly log4net.ILog log = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
|
||||||
|
#endregion
|
||||||
|
public const long VIEW = 0x00000001L;
|
||||||
|
public const long PRINT = 0x00000002L;
|
||||||
|
public const long PRINTDRAFT = 0x00000004L;
|
||||||
|
public const long PRINTCHANGES = 0x00000008L;
|
||||||
|
public const long EDIT = 0x00000010L;
|
||||||
|
public const long SEARCH = 0x00000020L;
|
||||||
|
public const long STANDARDSTEPS = 0x00000040L;
|
||||||
|
public const long APPROVE = 0x00000080L;
|
||||||
|
public const long APPROVESINGLE = 0x00000100L;
|
||||||
|
public const long LIBRARYDOCS = 0x00000200L;
|
||||||
|
public const long ADDMODDEL = 0x00000400L;
|
||||||
|
public const long CLEAN = 0x00000800L;
|
||||||
|
public const long LOCKPROC = 0x00001000L;
|
||||||
|
public const long LOCKSET = 0x00000001L;
|
||||||
|
public const long UCF = 0x00000002L;
|
||||||
|
public const long LOCKSYSTEM = 0x00000001L;
|
||||||
|
public const long DOCMAINT = 0x00000002L;
|
||||||
|
public const long ROEDITOR = 0x00000004L;
|
||||||
|
public const long SYSADMIN = 0x00000008L;
|
||||||
|
|
||||||
|
public const int SUPERUSER = 1000;
|
||||||
|
public const long SUPERACCESS = 0xFFFFFFFFL;
|
||||||
|
|
||||||
|
private bool _blockAccess;
|
||||||
|
public int userid = -1;
|
||||||
|
public string initials;
|
||||||
|
private const string samoptname = "vesam.opt";
|
||||||
|
public FileStream fs;
|
||||||
|
public BinaryReader bw;
|
||||||
|
public bool isDemoMode = false;
|
||||||
|
List<Plant> plntList = new List<Plant>();
|
||||||
|
List<OldUser> userList = new List<OldUser>();
|
||||||
|
Dictionary<ushort, Plant> plntDic = new Dictionary<ushort, Plant>();
|
||||||
|
|
||||||
|
public bool BlockAccess
|
||||||
|
{
|
||||||
|
get { return _blockAccess; }
|
||||||
|
set { if (_blockAccess != value) _blockAccess = value; }
|
||||||
|
}
|
||||||
|
|
||||||
|
public bool OpenFile(string oname)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
fs = new FileStream(oname, FileMode.Open, FileAccess.Read, FileShare.Read, 1, false);
|
||||||
|
bw = new BinaryReader(fs);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
catch (Exception e)
|
||||||
|
{
|
||||||
|
MessageBox.Show(e.Message, "Security File");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void CloseFile()
|
||||||
|
{
|
||||||
|
bw.Close();
|
||||||
|
fs.Close();
|
||||||
|
bw = null;
|
||||||
|
fs = null;
|
||||||
|
}
|
||||||
|
public Dictionary<ushort, Plant> LoadPlants()
|
||||||
|
{
|
||||||
|
UInt16 ui16;
|
||||||
|
UInt32 ui32;
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
byte x;
|
||||||
|
|
||||||
|
// read past some header stuff.
|
||||||
|
for (int jj = 0; jj < 8; jj++) x = bw.ReadByte();
|
||||||
|
|
||||||
|
long nxtPl = bw.ReadUInt32();
|
||||||
|
uint nmPlant = bw.ReadUInt16();
|
||||||
|
ui16 = bw.ReadUInt16();
|
||||||
|
|
||||||
|
// not needed here, but need to read past this...
|
||||||
|
long nxtUs = bw.ReadUInt32();
|
||||||
|
uint nmUser = bw.ReadUInt16();
|
||||||
|
ui16 = bw.ReadUInt16();
|
||||||
|
long nxtGr = bw.ReadUInt32();
|
||||||
|
uint nmGrp = bw.ReadUInt16();
|
||||||
|
ui16 = bw.ReadUInt16();
|
||||||
|
|
||||||
|
BlockAccess = bw.ReadUInt16()==0?false:true;
|
||||||
|
|
||||||
|
string pname, ppth;
|
||||||
|
for (int i = 0; i < nmPlant; i++)
|
||||||
|
{
|
||||||
|
if (nxtPl == 0xFFFFFFFEL)
|
||||||
|
{
|
||||||
|
log.Error("Reading in VESAM options file - cannot find next plant in list");
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
fs.Seek(nxtPl, SeekOrigin.Begin);
|
||||||
|
nxtPl = bw.ReadUInt32();
|
||||||
|
|
||||||
|
Plant pl = new Plant();
|
||||||
|
pl.Id = bw.ReadUInt16();
|
||||||
|
ui16 = bw.ReadUInt16();
|
||||||
|
|
||||||
|
byte[] stmp = new byte[256];
|
||||||
|
stmp = bw.ReadBytes(ui16);
|
||||||
|
pname = Encoding.ASCII.GetString(stmp, 0, ui16);
|
||||||
|
pl.Name = pname;
|
||||||
|
ui16 = bw.ReadUInt16();
|
||||||
|
stmp = bw.ReadBytes(ui16);
|
||||||
|
ppth = Encoding.ASCII.GetString(stmp, 0, ui16);
|
||||||
|
pl.Path = ppth;
|
||||||
|
|
||||||
|
// read in any sets within this plant.
|
||||||
|
UInt16 nmPrcDr = bw.ReadUInt16();
|
||||||
|
ui32 = bw.ReadUInt32();
|
||||||
|
UInt32 nxtPr = bw.ReadUInt32();
|
||||||
|
|
||||||
|
for (int j = 0; j < nmPrcDr; j++)
|
||||||
|
{
|
||||||
|
ProcSet ps = new ProcSet();
|
||||||
|
ps.Id = bw.ReadUInt16();
|
||||||
|
ui16 = bw.ReadUInt16();
|
||||||
|
stmp = bw.ReadBytes(ui16);
|
||||||
|
pname = Encoding.ASCII.GetString(stmp, 0, ui16);
|
||||||
|
ps.Name = pname;
|
||||||
|
ui16 = bw.ReadUInt16();
|
||||||
|
stmp = bw.ReadBytes(ui16);
|
||||||
|
ppth = Encoding.ASCII.GetString(stmp, 0, ui16);
|
||||||
|
ps.Path = ppth;
|
||||||
|
ui32 = bw.ReadUInt32();
|
||||||
|
if (nxtPr == 0xFFFFFFFDL && j + 1 < nmPrcDr)
|
||||||
|
{
|
||||||
|
log.ErrorFormat("Loading vesam.opt - procedure sets for {0}", ps.Name);
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
try
|
||||||
|
{
|
||||||
|
pl.psDic.Add(ps.Id, ps);
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
log.ErrorFormat("Adding to set dictionary - {0}. Error: {1}" + ps.Path, ex.Message);
|
||||||
|
}
|
||||||
|
if (nxtPr != 0xFFFFFFFDL)
|
||||||
|
{
|
||||||
|
fs.Seek(nxtPr, SeekOrigin.Begin);
|
||||||
|
nxtPr = bw.ReadUInt32();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
try
|
||||||
|
{
|
||||||
|
if (!plntDic.ContainsKey(pl.Id))plntDic.Add(pl.Id, pl);
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
log.ErrorFormat("Adding to plant dictionary - {0}. Error: {1}", pl.Path, ex.Message);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
log.ErrorFormat("Loading plants from vesam.opt: {0}", ex.Message);
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
return plntDic;
|
||||||
|
}
|
||||||
|
public List<OldUser> LoadUserList()
|
||||||
|
{
|
||||||
|
UInt16 ui16;
|
||||||
|
UInt32 ui32;
|
||||||
|
try
|
||||||
|
{
|
||||||
|
byte x;
|
||||||
|
|
||||||
|
fs.Seek(0, SeekOrigin.Begin);
|
||||||
|
// read past some header stuff.
|
||||||
|
for (int jj = 0; jj < 8; jj++) x = bw.ReadByte();
|
||||||
|
long nxtPl = bw.ReadUInt32();
|
||||||
|
uint nmPlant = bw.ReadUInt16();
|
||||||
|
ui16 = bw.ReadUInt16();
|
||||||
|
|
||||||
|
// get info in header for users
|
||||||
|
long nxtUs = bw.ReadUInt32();
|
||||||
|
uint nmUser = bw.ReadUInt16();
|
||||||
|
ui16 = bw.ReadUInt16();
|
||||||
|
long nxtGr = bw.ReadUInt32();
|
||||||
|
uint nmGrp = bw.ReadUInt16();
|
||||||
|
ui16 = bw.ReadUInt16();
|
||||||
|
|
||||||
|
bool localblockAccess = bw.ReadUInt16()==0?false:true;
|
||||||
|
// Now read in all of the user information
|
||||||
|
UInt16 uid;
|
||||||
|
string fName, fPass;
|
||||||
|
for (int i = 0; i < nmUser; i++)
|
||||||
|
{
|
||||||
|
if (nxtUs == 0xFFFFFFFCL && i + 1 < nmUser)
|
||||||
|
{
|
||||||
|
log.Error("Loading vesam.opt - reading in user list.");
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
fs.Seek((long)nxtUs, SeekOrigin.Begin);
|
||||||
|
nxtUs = bw.ReadUInt32();
|
||||||
|
uid = bw.ReadUInt16();
|
||||||
|
ui16 = bw.ReadUInt16(); // user's group?
|
||||||
|
|
||||||
|
byte[] test = new byte[10];
|
||||||
|
test = bw.ReadBytes(10);
|
||||||
|
|
||||||
|
// get ve-proms (vesam) username & password
|
||||||
|
fName = Encoding.ASCII.GetString(test, 0, 10);
|
||||||
|
int indx = fName.IndexOf("\0");
|
||||||
|
string fNameTrim = fName.Substring(0, indx);
|
||||||
|
test = bw.ReadBytes(10);
|
||||||
|
fPass = Encoding.ASCII.GetString(test, 0, 10);
|
||||||
|
indx = fPass.IndexOf("\0");
|
||||||
|
string fPassTrim = fPass.Substring(0, indx);
|
||||||
|
OldUser usr = new OldUser(fNameTrim);
|
||||||
|
usr.SystemOpts = bw.ReadUInt32();
|
||||||
|
usr.BlockAccessFlag = localblockAccess;
|
||||||
|
ui32 = bw.ReadUInt32();
|
||||||
|
|
||||||
|
// now get plant & proc set options.
|
||||||
|
nmPlant = bw.ReadUInt16();
|
||||||
|
for (int j = 0; j < nmPlant; j++)
|
||||||
|
{
|
||||||
|
PlantOptions plO = new PlantOptions();
|
||||||
|
plO.Id = bw.ReadUInt16();
|
||||||
|
plO.Options = bw.ReadUInt32();
|
||||||
|
ui32 = bw.ReadUInt32();
|
||||||
|
UInt16 nmPrcDr = bw.ReadUInt16();
|
||||||
|
for (int k = 0; k < nmPrcDr; k++)
|
||||||
|
{
|
||||||
|
ProcOptions prO = new ProcOptions();
|
||||||
|
prO.Id = bw.ReadUInt16();
|
||||||
|
prO.Selected = bw.ReadUInt16();
|
||||||
|
for (int kk = 0; kk < 4; kk++) prO.Options[kk] = bw.ReadUInt32();
|
||||||
|
plO.poList.Add(prO);
|
||||||
|
}
|
||||||
|
usr.PlantOpts.Add(plO);
|
||||||
|
}
|
||||||
|
userList.Add(usr);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
log.ErrorFormat("Error Loading (old) User info from vesam.opt: {0}", ex.Message);
|
||||||
|
return null ;
|
||||||
|
}
|
||||||
|
return userList;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endregion
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region SecurityMigration
|
||||||
|
public class Security
|
||||||
|
{
|
||||||
|
#region Log4Net
|
||||||
|
private static readonly log4net.ILog log = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
|
||||||
|
#endregion
|
||||||
|
Dictionary<ushort, Plant> plntDic = new Dictionary<ushort, Plant>();
|
||||||
|
List<OldUser> userList = new List<OldUser>();
|
||||||
|
private string optfilename;
|
||||||
|
private string[] prflags ={ "Vfw", "Prnt", "Prnt Drft", "Prnt Chgs", "Edit", "Srch", "St Stp", "App", "App Sel", "Lib", "AMD", "Clean", "Lock" };
|
||||||
|
private string[] sysflags ={ "NetworkLock", "SysMaint", "ROEditor", "SysAdmin" };
|
||||||
|
#region NewMig
|
||||||
|
public Security(string pathname)
|
||||||
|
{
|
||||||
|
if (File.Exists(pathname) == false)
|
||||||
|
{
|
||||||
|
MessageBox.Show("Could not locate the Security Options file:\n\n" + pathname, "Security Access Error");
|
||||||
|
optfilename = null;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
optfilename = pathname;
|
||||||
|
}
|
||||||
|
public bool Migrate()
|
||||||
|
{
|
||||||
|
VESamOpt vso = new VESamOpt();
|
||||||
|
bool suc = vso.OpenFile(optfilename);
|
||||||
|
if (!suc) return false;
|
||||||
|
plntDic = vso.LoadPlants();
|
||||||
|
if (plntDic == null) return false;
|
||||||
|
suc = VerifyFolders(plntDic);
|
||||||
|
if (!suc) return suc;
|
||||||
|
userList = vso.LoadUserList();
|
||||||
|
if (userList == null) return false;
|
||||||
|
vso.CloseFile();
|
||||||
|
vso = null;
|
||||||
|
log.Info("Original vesam.opt loaded successfully - next step is to migrate security information to new database");
|
||||||
|
//WriteOutSummary(plntDic, userList);
|
||||||
|
suc = TranslateToNew(vso, plntDic, userList);
|
||||||
|
log.Info("Migrated vesam successfully");
|
||||||
|
return suc ;
|
||||||
|
}
|
||||||
|
#endregion
|
||||||
|
#region WriteVESamSummary
|
||||||
|
private void WriteOutSummary(Dictionary<ushort, Plant> plntDic, List<OldUser> userList)
|
||||||
|
{
|
||||||
|
foreach (OldUser usr in userList)
|
||||||
|
{
|
||||||
|
log.InfoFormat("User = {0}", usr.UserName);
|
||||||
|
|
||||||
|
StringBuilder sb = new StringBuilder();
|
||||||
|
for (int i = 0; i < 4; i++)
|
||||||
|
{
|
||||||
|
if ((usr.SystemOpts & (1L << i)) != 0) sb.Append(sysflags[i] + " ");
|
||||||
|
}
|
||||||
|
if (sb.Length > 0) log.InfoFormat(" System Options = {0}", sb.ToString());
|
||||||
|
|
||||||
|
// for now, don't worry about system options.
|
||||||
|
// for each plant, list any permissions of the plant or its proc sets. If
|
||||||
|
// none set, nothing will be listed.
|
||||||
|
foreach (PlantOptions po in usr.PlantOpts)
|
||||||
|
{
|
||||||
|
bool plntout = false;
|
||||||
|
Plant pl = (Plant)plntDic[po.Id];
|
||||||
|
if (po.Options != 0)
|
||||||
|
{
|
||||||
|
plntout = true;
|
||||||
|
log.InfoFormat(" Plant = {0}. Options = {1}", pl.Name, po.Options);
|
||||||
|
}
|
||||||
|
foreach (ProcOptions psO in po.poList)
|
||||||
|
{
|
||||||
|
ProcSet ps = (ProcSet)pl.psDic[psO.Id];
|
||||||
|
if (psO.Options[0] != 0 || psO.Options[1] != 0 || psO.Options[2] != 0 || psO.Options[3] != 0)
|
||||||
|
{
|
||||||
|
if (!plntout) log.InfoFormat(" Plant = {0}.", pl.Name);
|
||||||
|
log.InfoFormat(" Procedure Set = {0}", ps.Name);
|
||||||
|
sb.Length = 0;
|
||||||
|
int nm = 0;
|
||||||
|
for (int i1 = 0; i1 < 4; i1++)
|
||||||
|
{
|
||||||
|
for (int j1 = 0; j1 < 16; j1++)
|
||||||
|
{
|
||||||
|
if ((psO.Options[i1] & (1L << j1)) != 0) sb.Append(prflags[nm] + " ");
|
||||||
|
nm++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (sb.Length > 0) log.InfoFormat(" {0}", sb.ToString());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
#endregion
|
||||||
|
#region MigrateCode
|
||||||
|
private string[] defaultRole ={ "Administrator", "User Administrator", "RO Manager", "Writer", "Reviewer", "Guest" };
|
||||||
|
private string[] defaultRoleTitle = { "Manages Data - Backups, Approval etc.", "Maintains User Security", "Maintains Referenced Objects", "Can Edit", "Can potentially add comments", "Read-Only access to approved procedures" };
|
||||||
|
// defaultPermData sets the permission data (Permissions table) - columns are
|
||||||
|
// PermLevel, VersionType, PermValue (Note for vesam migration, PermAD is always allow, i.e. 0)
|
||||||
|
private int[,] defaultPermData = {
|
||||||
|
{2, 3, 15}, // Administrator
|
||||||
|
{1, 3, 15}, // User Administrator
|
||||||
|
{3, 3, 15}, // RO Manager
|
||||||
|
{5, 1, 15}, // Writer
|
||||||
|
{7, 3, 15}, // Reviewer
|
||||||
|
{2, 2, 1}}; // Guest
|
||||||
|
|
||||||
|
private int[] accessLevelSetup = { -1, 5, 4, 3, 0, 0, 2, 1 };
|
||||||
|
private int[] accessLevelTrans;
|
||||||
|
|
||||||
|
private Dictionary<int, Role> AddDefaultRoles()
|
||||||
|
{
|
||||||
|
Dictionary<int, Role> rdic = new Dictionary<int, Role>();
|
||||||
|
try
|
||||||
|
{
|
||||||
|
accessLevelTrans = new int[accessLevelSetup.Length];
|
||||||
|
for (int i = 0; i < 6; i++)
|
||||||
|
{
|
||||||
|
Role role = Role.New();
|
||||||
|
role.Name = defaultRole[i];
|
||||||
|
role.Title = defaultRoleTitle[i];
|
||||||
|
role.Save();
|
||||||
|
Permission perm = Permission.New();
|
||||||
|
perm.RID = role.RID;
|
||||||
|
perm.PermLevel = defaultPermData[i, 0];
|
||||||
|
perm.VersionType = defaultPermData[i, 1];
|
||||||
|
perm.PermValue = defaultPermData[i, 2];
|
||||||
|
perm.Save();
|
||||||
|
rdic.Add(role.RID, role);
|
||||||
|
for (int j = 1; j < accessLevelSetup.Length; j++)
|
||||||
|
{
|
||||||
|
if (accessLevelSetup[j] == i) accessLevelTrans[j] = role.RID;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
log.ErrorFormat("Error setting default roles & permissions: {0}", ex.Message);
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
return rdic;
|
||||||
|
}
|
||||||
|
|
||||||
|
public bool VerifyFolders(Dictionary<ushort, Plant> dicPlants)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
// For each folder from vesam, see if there is a matching folder already
|
||||||
|
// migrated...
|
||||||
|
|
||||||
|
FolderInfoList fil = FolderInfoList.Get();
|
||||||
|
// add the titles to a dictionary for quick checking
|
||||||
|
List<string> folderlist = new List<string>();
|
||||||
|
foreach (FolderInfo fi in fil)
|
||||||
|
{
|
||||||
|
folderlist.Add(fi.Title.ToUpper());
|
||||||
|
}
|
||||||
|
|
||||||
|
foreach (ushort u in dicPlants.Keys)
|
||||||
|
{
|
||||||
|
Plant pl = dicPlants[u];
|
||||||
|
bool foundplant = false;
|
||||||
|
if (folderlist.Contains(pl.Path.ToUpper())) foundplant=true;
|
||||||
|
|
||||||
|
if (!foundplant)
|
||||||
|
log.InfoFormat("Plant from vesam.opt not found in folder data: {0}", pl.Path);
|
||||||
|
else // if found, check for sets
|
||||||
|
{
|
||||||
|
foreach (ushort uu in pl.psDic.Keys)
|
||||||
|
{
|
||||||
|
ProcSet pr = pl.psDic[uu];
|
||||||
|
bool foundprocset = false;
|
||||||
|
foreach (FolderInfo fi in fil)
|
||||||
|
{
|
||||||
|
string tstpath = pl.Path.ToUpper() + "\\" + pr.Path.ToUpper();
|
||||||
|
if (tstpath == fi.Title.ToUpper())
|
||||||
|
{
|
||||||
|
foundprocset = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (!foundprocset) log.InfoFormat("Procedure Set from vesam.opt not found in folder data: {0}\\{1}", pl.Path, pr.Path);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
log.ErrorFormat("error mapping vesam directories to data directories, error = {0}", ex.Message);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
private Dictionary<string, int> LoadFolders()
|
||||||
|
{
|
||||||
|
FolderInfoList fldlist = FolderInfoList.Get();
|
||||||
|
Dictionary<string, int> fdic = new Dictionary<string, int>();
|
||||||
|
foreach (FolderInfo fi in fldlist)
|
||||||
|
{
|
||||||
|
fdic.Add(fi.Title.ToUpper(), fi.FolderID);
|
||||||
|
}
|
||||||
|
return fdic;
|
||||||
|
}
|
||||||
|
|
||||||
|
private bool TranslateToNew(VESamOpt vso, Dictionary<ushort, Plant> plntDic, List<OldUser> userList)
|
||||||
|
{
|
||||||
|
Dictionary<int, Role> rlpdic = AddDefaultRoles();
|
||||||
|
AddUsrGrpAsgnRecs(plntDic, userList);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
private string VersionName(string s)
|
||||||
|
{
|
||||||
|
return s.Substring(s.LastIndexOf(" - ") + 3);
|
||||||
|
}
|
||||||
|
private string SetName(string s)
|
||||||
|
{
|
||||||
|
return s.Substring(0, s.LastIndexOf(" - "));
|
||||||
|
}
|
||||||
|
private string FixName(string s)
|
||||||
|
{
|
||||||
|
s = s.Replace(" - Working Draft (Unit 1)", " (Unit 1) - Working Draft");
|
||||||
|
s = s.Replace(" - Working Draft (Unit 2)", " (Unit 2) - Working Draft");
|
||||||
|
s = s.Replace(" - Current Approved Version", " - Approved Version");
|
||||||
|
return s.Replace(" - Working Draft", " - Working Draft");
|
||||||
|
}
|
||||||
|
private int CalcAccessLevel(int iBase, uint options, string sVersion)
|
||||||
|
{
|
||||||
|
if (sVersion == "Working Draft")
|
||||||
|
{
|
||||||
|
if (options == 0) return 0;
|
||||||
|
if ((options & 6528) != 0) return 5;
|
||||||
|
if ((options & 1024) != 0) return 4;
|
||||||
|
if ((options & 528) != 0) return 3;
|
||||||
|
return 2;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (iBase != 0) return iBase;
|
||||||
|
else if (options != 0) return 1;
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
private string SystemOption(uint options)
|
||||||
|
{
|
||||||
|
if ((options & 11) != 0) return "\"Admin\"";
|
||||||
|
if (options == 4) return "\"RO\"";
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
private void AddAccessRights(Dictionary<int, List<int>> dic, int folderId, int roleId)
|
||||||
|
{
|
||||||
|
if (!dic.ContainsKey(folderId)) dic[folderId] = new List<int>();
|
||||||
|
dic[folderId].Add(roleId);
|
||||||
|
}
|
||||||
|
private void AddUsrGrpAsgnRecs(Dictionary<ushort, Plant> plntDic, List<OldUser> userList)
|
||||||
|
{
|
||||||
|
Dictionary<string, List<string>> dicGroups = new Dictionary<string, List<string>>();
|
||||||
|
Dictionary<string, int> dicGroupIds = new Dictionary<string, int>();
|
||||||
|
Dictionary<string, int> dicOldFolders = new Dictionary<string, int>();
|
||||||
|
int oldFolderCount = 1;
|
||||||
|
dicOldFolders.Add("system", oldFolderCount++);
|
||||||
|
Dictionary<string, int> dicNewFolders = LoadFolders();
|
||||||
|
List<string> lstVersions = new List<string>();
|
||||||
|
StringBuilder sb;
|
||||||
|
OldUser frst = userList[0];
|
||||||
|
|
||||||
|
string[] accessLevel = { "", "\"Guest\"", "\"Reviewer\"", "\"Writer\"", "\"Admin\"", "\"Admin\"" };
|
||||||
|
foreach (OldUser usr in userList)
|
||||||
|
{
|
||||||
|
int sysAccess = 5;
|
||||||
|
Dictionary<PlantOptions, int> plantAccess = new Dictionary<PlantOptions, int>();
|
||||||
|
|
||||||
|
if ((usr.SystemOpts & 11) == 0)
|
||||||
|
{
|
||||||
|
foreach (PlantOptions po in usr.PlantOpts)
|
||||||
|
{
|
||||||
|
plantAccess[po] = 5;
|
||||||
|
Plant pl = (Plant)plntDic[po.Id];
|
||||||
|
if (!dicOldFolders.ContainsKey(pl.Path.ToUpper()))dicOldFolders.Add(pl.Path.ToUpper(), oldFolderCount++);
|
||||||
|
string sSetLast = "";
|
||||||
|
int iAccessLevel = 0;
|
||||||
|
|
||||||
|
foreach (ProcOptions psO in po.poList)
|
||||||
|
{
|
||||||
|
ProcSet ps = null;
|
||||||
|
try
|
||||||
|
{
|
||||||
|
ps = (ProcSet)pl.psDic[psO.Id];
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
MessageBox.Show("here");
|
||||||
|
}
|
||||||
|
if (!dicOldFolders.ContainsKey(pl.Path.ToUpper()+"\\"+ps.Path.ToUpper()))dicOldFolders.Add(pl.Path.ToUpper()+"\\"+ps.Path.ToUpper(), oldFolderCount++);
|
||||||
|
string sName = FixName(ps.Name);
|
||||||
|
string sVersion = VersionName(sName);
|
||||||
|
string sSet = SetName(sName);
|
||||||
|
if (sSet != sSetLast)
|
||||||
|
{
|
||||||
|
if (sSetLast != "")
|
||||||
|
{
|
||||||
|
// if the proc access is lower than the plant, reset plant level.
|
||||||
|
if (iAccessLevel < plantAccess[po]) plantAccess[po] = iAccessLevel;
|
||||||
|
iAccessLevel = 0;
|
||||||
|
}
|
||||||
|
sSetLast = sSet;
|
||||||
|
}
|
||||||
|
iAccessLevel = CalcAccessLevel(iAccessLevel, psO.Options[0], sVersion);
|
||||||
|
}
|
||||||
|
// do one last check to see if plant level should be lowered. Also
|
||||||
|
// check if the system level should be lowered.
|
||||||
|
if (iAccessLevel < plantAccess[po]) plantAccess[po] = iAccessLevel;
|
||||||
|
if (plantAccess[po] < sysAccess) sysAccess = plantAccess[po];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// set the system level access, i.e. User Admin, System Admin & RO Editor roles if
|
||||||
|
// necessary.
|
||||||
|
int systemid = dicOldFolders["system"];
|
||||||
|
|
||||||
|
Dictionary<int, List<int>> accessRights = new Dictionary<int, List<int>>();
|
||||||
|
if (usr.SystemOpts != 0) AddAccessRights(accessRights, systemid, accessLevelTrans[6]); // add ro editor
|
||||||
|
if ((usr.SystemOpts & 11) != 0)
|
||||||
|
{
|
||||||
|
AddAccessRights(accessRights, systemid, accessLevelTrans[5]); // add sys admin rights
|
||||||
|
AddAccessRights(accessRights, systemid, accessLevelTrans[7]); // and add user admin rights
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// the user has a role at the system level that is not an admin,
|
||||||
|
// such as reviewer or guest - add it in.
|
||||||
|
if (sysAccess > 0) AddAccessRights(accessRights, systemid, accessLevelTrans[sysAccess]);
|
||||||
|
}
|
||||||
|
|
||||||
|
sb = new StringBuilder(string.Format("{0},{1}", (usr.SystemOpts == 0 ? "" : "Admin"), accessLevel[sysAccess]));
|
||||||
|
|
||||||
|
if ((usr.SystemOpts & 11) == 0)
|
||||||
|
{
|
||||||
|
foreach (PlantOptions po in usr.PlantOpts)
|
||||||
|
{
|
||||||
|
Plant pl = plntDic[po.Id];
|
||||||
|
// Need logic for po.Options in combination with PlantAccess[po]
|
||||||
|
//sb.Append(string.Format(",{0}", po.Options));
|
||||||
|
|
||||||
|
if (plantAccess[po] > sysAccess)
|
||||||
|
{
|
||||||
|
AddAccessRights(accessRights, dicOldFolders[pl.Path.ToUpper()], accessLevelTrans[plantAccess[po]]);
|
||||||
|
sb.Append(string.Format(",{0}", accessLevel[plantAccess[po]]));
|
||||||
|
}
|
||||||
|
else
|
||||||
|
sb.Append(",");
|
||||||
|
string sSetLast = "";
|
||||||
|
string sPathLast = "";
|
||||||
|
int iAccessLevel = 0;
|
||||||
|
string sPath = "";
|
||||||
|
foreach (ProcOptions psO in po.poList)
|
||||||
|
{
|
||||||
|
ProcSet ps = pl.psDic[psO.Id];
|
||||||
|
string sName = FixName(ps.Name);
|
||||||
|
string sVersion = VersionName(sName);
|
||||||
|
if (sVersion == "Working Draft") sPath = pl.Path + "\\" + ps.Path;
|
||||||
|
string sSet = SetName(sName);
|
||||||
|
|
||||||
|
if (sSet != sSetLast)
|
||||||
|
{
|
||||||
|
if (sSetLast != "")
|
||||||
|
{
|
||||||
|
if (iAccessLevel > plantAccess[po])
|
||||||
|
{
|
||||||
|
AddAccessRights(accessRights, dicOldFolders[sPathLast.ToUpper()], accessLevelTrans[iAccessLevel]);
|
||||||
|
sb.Append(string.Format(",{0}", accessLevel[iAccessLevel]));
|
||||||
|
}
|
||||||
|
else
|
||||||
|
sb.Append(",");
|
||||||
|
iAccessLevel = 0;
|
||||||
|
}
|
||||||
|
sSetLast = sSet;
|
||||||
|
sPathLast = sPath;
|
||||||
|
}
|
||||||
|
iAccessLevel = CalcAccessLevel(iAccessLevel, psO.Options[0], sVersion);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (iAccessLevel > plantAccess[po])
|
||||||
|
{
|
||||||
|
AddAccessRights(accessRights, dicOldFolders[sPathLast.ToUpper()], accessLevelTrans[iAccessLevel]);
|
||||||
|
sb.Append(string.Format(",{0}", accessLevel[iAccessLevel]));
|
||||||
|
}
|
||||||
|
else
|
||||||
|
sb.Append(",");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
string s = sb.ToString();
|
||||||
|
|
||||||
|
if (!dicGroups.ContainsKey(s))
|
||||||
|
{
|
||||||
|
dicGroups[s] = new List<string>();
|
||||||
|
Group grp = Group.New();
|
||||||
|
grp.GroupName = "Group " + dicGroups.Count.ToString();
|
||||||
|
int pathInData = -1;
|
||||||
|
foreach (int folderId in accessRights.Keys)
|
||||||
|
{
|
||||||
|
// see if this folderId exists in the data (rather
|
||||||
|
// than the list from vesam). If not, don't do an
|
||||||
|
// assignments record
|
||||||
|
pathInData = 0;
|
||||||
|
foreach (KeyValuePair<string, int> kvp in dicOldFolders)
|
||||||
|
{
|
||||||
|
if (kvp.Value == folderId)
|
||||||
|
{
|
||||||
|
string path = kvp.Key;
|
||||||
|
if (dicNewFolders.ContainsKey(path.ToUpper()))
|
||||||
|
pathInData = dicNewFolders[path.ToUpper()];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (pathInData>0)
|
||||||
|
{
|
||||||
|
foreach (int roleId in accessRights[folderId])
|
||||||
|
{
|
||||||
|
grp.GroupAssignments.Add(roleId, pathInData);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
grp.Save();
|
||||||
|
dicGroupIds[s] = grp.GID;
|
||||||
|
}
|
||||||
|
dicGroups[s].Add(usr.UserName);
|
||||||
|
}
|
||||||
|
|
||||||
|
foreach (string s in dicGroups.Keys)
|
||||||
|
{
|
||||||
|
foreach (string sUser in dicGroups[s])
|
||||||
|
{
|
||||||
|
// add user record & membership record.
|
||||||
|
User newusr = User.New();
|
||||||
|
newusr.UserID = sUser;
|
||||||
|
ConfigFile cfg = new ConfigFile();
|
||||||
|
cfg.LoadUsrCfg(newusr);
|
||||||
|
newusr.UserMemberships.Add(dicGroupIds[s]);
|
||||||
|
newusr.Save();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endregion
|
||||||
|
}
|
||||||
|
#endregion
|
||||||
|
}
|
383
PROMS/DataLoader/Sections.cs
Normal file
383
PROMS/DataLoader/Sections.cs
Normal file
@ -0,0 +1,383 @@
|
|||||||
|
// ========================================================================
|
||||||
|
// 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 Section AddSection(string Number, string Title, DateTime Dts, string Userid, ConfigInfo ci, string stpseq, string fmt, int libdocid, string pth)
|
||||||
|
{
|
||||||
|
UpdateLabels(0, 1, 0);
|
||||||
|
try
|
||||||
|
{
|
||||||
|
string Format = null;
|
||||||
|
|
||||||
|
// do the format field, an xpath for the format & last part is column
|
||||||
|
// mode if a step section.
|
||||||
|
try
|
||||||
|
{
|
||||||
|
if (fmt != null && fmt != "")
|
||||||
|
{
|
||||||
|
if (fmt.IndexOf(' ') > -1) // will have spaces if it's a user format
|
||||||
|
{
|
||||||
|
string part1 = "/" + fmt.Substring(0, fmt.IndexOf(' ')) + "/";
|
||||||
|
string part2 = "USER=" + fmt.Substring(fmt.LastIndexOf(' ') + 1, 2);
|
||||||
|
Format = part1 + part2;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
Format = "/" + fmt;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
log.ErrorFormat("Error getting format {0}", ex.Message);
|
||||||
|
}
|
||||||
|
// tack on the column mode:
|
||||||
|
if (stpseq != null && stpseq.Substring(1, 1) == "0" && stpseq.Substring(5, 1) != " ") Format = Format + "/COL=" + stpseq.Substring(5, 1);
|
||||||
|
|
||||||
|
// find rtf file (or use the library document temp file) & read it into the field
|
||||||
|
// acccontent
|
||||||
|
int Contentid=0;
|
||||||
|
byte ContentType=0;
|
||||||
|
if (libdocid != 0 || stpseq.Substring(1, 1) != "0")
|
||||||
|
{
|
||||||
|
string fname = null;
|
||||||
|
if (libdocid != 0)
|
||||||
|
{
|
||||||
|
Contentid = libdocid;
|
||||||
|
ContentType = 2;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
int num = Convert.ToInt32(stpseq[0]) - 64;
|
||||||
|
string thenum = num.ToString("d2");
|
||||||
|
fname = string.Format("{0}\\rtffiles\\{1}.A{2}", pth, ProcFileName, thenum);
|
||||||
|
Application.DoEvents();
|
||||||
|
SaveSectionDocument(fname, stpseq, ref ContentType, ref Contentid);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Section sec = Section.MakeSection(Number, Title,ContentType, Contentid, Format, ci.ToString(), Dts, Userid);
|
||||||
|
dicOldStepSequence[sec] = stpseq;
|
||||||
|
return sec;
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
log.Error("Save Section");
|
||||||
|
log.ErrorFormat("oldstepsequence = {0}", stpseq);
|
||||||
|
log.ErrorFormat("{0}\r\n\r\n{1}", ex.Message, ex.InnerException);
|
||||||
|
log.ErrorFormat(ex.StackTrace);
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
private string SectTitle(OleDbConnection cn, DataRowView dr)
|
||||||
|
{
|
||||||
|
string tbuff = null;
|
||||||
|
string menustr = null;
|
||||||
|
bool UseMultiLineSectionTitle = false; // TODO KBR: format flag
|
||||||
|
if (UseMultiLineSectionTitle)
|
||||||
|
{
|
||||||
|
bool titleInMemo = false;
|
||||||
|
// for accessory pages...
|
||||||
|
if (dr["Step"].ToString().Substring(1, 1) != "0")
|
||||||
|
{
|
||||||
|
// The long section title is stored on a record with the "~" character.
|
||||||
|
// This was done since originally the actual accessory page data was stored in the memo
|
||||||
|
// field, so the long title could not be stored there, another record had to be used.
|
||||||
|
OleDbDataAdapter da = new OleDbDataAdapter("select * from " + ProcFileName + " where [Step] like '" + dr["Step"].ToString().Substring(0, 1) + "~';", cn);
|
||||||
|
DataSet ds = new DataSet();
|
||||||
|
try
|
||||||
|
{
|
||||||
|
da.Fill(ds);
|
||||||
|
if (ds.Tables[0].Rows.Count == 1)
|
||||||
|
{
|
||||||
|
DataRow row = ds.Tables[0].Rows[0];
|
||||||
|
tbuff = TextConvert.ConvertText(row["Textm"].ToString());
|
||||||
|
if (tbuff != null || tbuff[0] != '\0') titleInMemo = true;
|
||||||
|
}
|
||||||
|
else // no long section title existed for this accessory page
|
||||||
|
tbuff = TextConvert.ConvertText(dr["Text"].ToString().PadRight(130, ' ').Substring(0, 75).TrimEnd());
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
log.ErrorFormat("Error getting long section title {0}", ex.Message);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// For step sections, the long section title is stored on the section record
|
||||||
|
// (see above comment for accessory pages to see the difference)
|
||||||
|
else
|
||||||
|
{
|
||||||
|
tbuff = TextConvert.ConvertText(dr["TextM"].ToString().Trim());
|
||||||
|
}
|
||||||
|
|
||||||
|
//// TESTS were run & it looked like that whitespace was removed before saving,
|
||||||
|
//// so, put up a message box if find out otherwise....
|
||||||
|
int nl = tbuff.IndexOf("\n");
|
||||||
|
if (nl > -1)
|
||||||
|
MessageBox.Show("multiline text for section title, fix this!!");
|
||||||
|
|
||||||
|
//// remove newlines & any other escape/whitespace chars.
|
||||||
|
//int nl = tbuff.IndexOf("\n");
|
||||||
|
//if (nl > -1 || titleInMemo)
|
||||||
|
//{
|
||||||
|
|
||||||
|
// string tmpstr = tbuff.Replace("\r", "");
|
||||||
|
// tmpstr = tmpstr.Replace("\t", "");
|
||||||
|
// tmpstr = tmpstr.Replace("\n", " ");
|
||||||
|
// // get rid of multiple spaces
|
||||||
|
// while (tmpstr.IndexOf(" ") > -1) tmpstr = tmpstr.Replace(" ", " ");
|
||||||
|
// tbuff = tmpstr;
|
||||||
|
// if (tbuff.Substring(tbuff.Length-1, 1) == " ") tbuff = tbuff.Substring(0, tbuff.Length - 1);
|
||||||
|
//}
|
||||||
|
//menustr = tbuff;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{ // format does not include long section title
|
||||||
|
menustr = TextConvert.ConvertText(dr["Text"].ToString().PadRight(80, ' ').Substring(0, 75).TrimEnd());
|
||||||
|
}
|
||||||
|
return menustr;
|
||||||
|
}
|
||||||
|
private Int32 MigrateSection(Procedure prc, OleDbConnection cn, DataRowView dr, DataTable dt, Byte FromType, Int32 FromID, bool isSubSection, string pth)
|
||||||
|
{
|
||||||
|
Int32 thesectid = 0;
|
||||||
|
bool islibdoc = false;
|
||||||
|
//bool hasxml = false;
|
||||||
|
string s = dr["text"].ToString().PadRight(130, ' ');
|
||||||
|
string num = s.Substring(85, 20).TrimEnd();
|
||||||
|
string fmt = s.Substring(75, 10).TrimEnd();
|
||||||
|
string title = SectTitle(cn, dr);
|
||||||
|
string init = dr["initials"].ToString().Trim();
|
||||||
|
string sequence = dr["CSequence"].ToString().PadRight(10);
|
||||||
|
string step = dr["CStep"].ToString();
|
||||||
|
int libDocid = 0;
|
||||||
|
|
||||||
|
DateTime dts = GetDTS(dr["Date"].ToString(), dr["Time"].ToString());
|
||||||
|
|
||||||
|
ConfigInfo ci = new ConfigInfo(null);
|
||||||
|
// for steps sections...
|
||||||
|
// Step Section Header Format:
|
||||||
|
// A0 1X2S51 &Y
|
||||||
|
// ^^^^^^^^^^^^
|
||||||
|
// |||||||||||||
|
||||||
|
// ||||||||||||`- 'Y','N', or blank signals to print section header - lib/section/addsec.c
|
||||||
|
// |||||||||||`-- (bits) Auto Indent, Editable Data, Checkoff Header Type - lib/section/addsec.c
|
||||||
|
// ||||||||||`--- blank
|
||||||
|
// ||||||||`----- Link With Enhanced Document ' '-Default(not determined) 0-NO 1-YES
|
||||||
|
// |||||||`------ MetaSection - number of subsections is given
|
||||||
|
// ||||||`------- S-Separate(PageBreak); T-Continuous; ' '-Default
|
||||||
|
// |||||`-------- Column mode (1,2,3,' '-default)
|
||||||
|
// ||||`--------- X -only proc section; x -orig. proc; ' ' -other
|
||||||
|
// |||`---------- Position within the procedure
|
||||||
|
// ||`----------- ALWAYS leave blank
|
||||||
|
// |`------------ Step Section Header marker
|
||||||
|
// `------------- Internal section number (starts at A)
|
||||||
|
|
||||||
|
if (step.Substring(1, 1) == "0")
|
||||||
|
{
|
||||||
|
// if this section has the original edit section flag (sequence[2]) save the id.
|
||||||
|
|
||||||
|
// set pagination, continuous, separate. If blank, don't create attribute - uses format default.
|
||||||
|
if (sequence.Substring(4, 1) == "T")
|
||||||
|
{
|
||||||
|
ci.AddItem("Section", "Pagination", "C");
|
||||||
|
//hasxml = SetXml(xmldoc, topElement, "Section", "Pagination", "C");
|
||||||
|
}
|
||||||
|
else if (sequence.Substring(4, 1) == "S")
|
||||||
|
{
|
||||||
|
ci.AddItem("Section", "Pagination", "S");
|
||||||
|
//hasxml = SetXml(xmldoc, topElement, "Section", "Pagination", "S");
|
||||||
|
}
|
||||||
|
|
||||||
|
// Step: linked to enhanced (!exist = N)
|
||||||
|
if (sequence.Substring(7, 1) == "1")
|
||||||
|
{
|
||||||
|
ci.AddItem("Step", "LnkEnh", "Y");
|
||||||
|
//hasxml = SetXml(xmldoc, topElement, "Step", "LnkEnh", "Y");
|
||||||
|
}
|
||||||
|
char cbittst = sequence.PadRight(10)[8];
|
||||||
|
if (cbittst == ' ') cbittst = '\0';
|
||||||
|
|
||||||
|
// determine if TOC element (!exist = N)
|
||||||
|
if ((cbittst & TOC) > 1)
|
||||||
|
{
|
||||||
|
ci.AddItem("Section", "TOC", "Y");
|
||||||
|
//hasxml = SetXml(xmldoc, topElement, "Section", "TOC", "Y");
|
||||||
|
}
|
||||||
|
// determine if autogenerated section (!exist = N)
|
||||||
|
if ((cbittst & AUTOGEN) > 1)
|
||||||
|
{
|
||||||
|
ci.AddItem("Section", "AutoGen", "Y");
|
||||||
|
//hasxml = SetXml(xmldoc, topElement, "Section", "AutoGen", "Y");
|
||||||
|
}
|
||||||
|
|
||||||
|
// Here are subsection flags, i.e. the following are only set if this
|
||||||
|
// is a subsection.
|
||||||
|
bool didsub = false;
|
||||||
|
if (isSubSection)
|
||||||
|
{
|
||||||
|
// Subsection: editable (!exist = Y)
|
||||||
|
if ((cbittst & EDDATA) > 0)
|
||||||
|
{
|
||||||
|
ci.AddItem("SubSection", "Edit", "N");
|
||||||
|
//SetXml(xmldoc, topElement, "SubSection", "Edit", "N");
|
||||||
|
}
|
||||||
|
|
||||||
|
// Subsection: print section headers (!exist = Y)
|
||||||
|
if ((cbittst & PH) > 0)
|
||||||
|
{
|
||||||
|
didsub = true;
|
||||||
|
ci.AddItem("SubSection", "PH", "N");
|
||||||
|
//SetXml(xmldoc, topElement, "SubSection", "PH", "N");
|
||||||
|
}
|
||||||
|
|
||||||
|
// Subsection: autoindent (!exist = Y)
|
||||||
|
if ((cbittst & AUTOIND) > 0)
|
||||||
|
{
|
||||||
|
ci.AddItem("SubSection", "AutoIndent", "N");
|
||||||
|
//SetXml(xmldoc, topElement, "SubSection", "AutoIndent", "N");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (!didsub && sequence.Substring(4, 1) == "N")
|
||||||
|
{
|
||||||
|
ci.AddItem("SubSection", "PH", "N");
|
||||||
|
//SetXml(xmldoc, topElement, "SubSection", "PH", "N");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// Accessory Section Format:
|
||||||
|
// AI 1 2
|
||||||
|
// ^^ ^ ^
|
||||||
|
// || | |
|
||||||
|
// || | `- # of pages (ASCII value minus 48)
|
||||||
|
// || `--- Position within the procedure
|
||||||
|
// |`----- Acc. page type (A,I, or F)
|
||||||
|
// `------ Internal section number (starts at A)
|
||||||
|
ci.AddItem("Section", "NumPages", sequence.Substring(3, 1));
|
||||||
|
//hasxml = SetXml(xmldoc, topElement, "Section", "NumPages", sequence.Substring(3, 1));
|
||||||
|
|
||||||
|
// see if it's a libdoc too.0
|
||||||
|
string thekey = prc.Number.PadRight(20) + step.Substring(0, 1).PadRight(10);
|
||||||
|
if (dicLibDocRef.ContainsKey(thekey))
|
||||||
|
{
|
||||||
|
// if it is a library document, see if the section record has already been
|
||||||
|
// saved. If it has, just use this section id, otherwise, create the
|
||||||
|
// section record with info from the library document file.
|
||||||
|
libDocid = dicLibDocRef[thekey];
|
||||||
|
islibdoc = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Section sec = AddSection(num, title, dts, init, ci, step + sequence, fmt, libDocid, pth);
|
||||||
|
thesectid = sec.SectID;
|
||||||
|
|
||||||
|
// if this section has the original edit section flag (sequence[2]) save the id.
|
||||||
|
if (!islibdoc && step[1] == '0' && (sequence[2] == 'x' || sequence[2] == 'X'))
|
||||||
|
EditSectId = thesectid;
|
||||||
|
// ContentType (2 in the following call) are:
|
||||||
|
// 0 = structure,
|
||||||
|
// 1 = procedure,
|
||||||
|
// 2 = section,
|
||||||
|
// 3 = step
|
||||||
|
// 4 = branch
|
||||||
|
|
||||||
|
// fromtype values are (see steps.cs too)
|
||||||
|
// 0 = next of same type
|
||||||
|
// 1 = procedure,
|
||||||
|
// 2 = section,
|
||||||
|
// 3 = caution
|
||||||
|
// 4 = note
|
||||||
|
// 5 = RNO
|
||||||
|
// 6 = substep
|
||||||
|
// 7 = table
|
||||||
|
|
||||||
|
Structure str = AddStructure(FromType, FromID, 2, thesectid, step + sequence, dts, init);
|
||||||
|
// Process the Data Table - First look for High Level Steps
|
||||||
|
string sQry = string.Format("Step like '[{0}]%' and Sequence='S'", dr["Step"].ToString().Substring(0, 1));
|
||||||
|
DataView dv = new DataView(dt, sQry, "StepNo", DataViewRowState.CurrentRows);
|
||||||
|
Byte FrType = 6;
|
||||||
|
Int32 FrID = 0;
|
||||||
|
pbStep.Maximum = dt.Rows.Count;
|
||||||
|
pbStep.Value = 0;
|
||||||
|
foreach (DataRowView drv in dv)
|
||||||
|
{
|
||||||
|
FrID = MigrateStep(cn, dt, drv, FrType, FrID);
|
||||||
|
if (sec.ContentID == 0)
|
||||||
|
{
|
||||||
|
sec.ContentID = FrID;
|
||||||
|
sec.ContentType = 1;
|
||||||
|
sec.Save(true);
|
||||||
|
}
|
||||||
|
FrType = 0;
|
||||||
|
}
|
||||||
|
return str.StructureID;
|
||||||
|
}
|
||||||
|
private void LoadSection(DataSet ds, OleDbDataAdapter da, string FileName)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
da.Fill(ds, "Sections");
|
||||||
|
DataTable dt = ds.Tables["Sections"];
|
||||||
|
dt.CaseSensitive = true;
|
||||||
|
dt.Columns.Add("CStep", System.Type.GetType("System.String"));
|
||||||
|
dt.Columns.Add("CSequence", System.Type.GetType("System.String"));
|
||||||
|
// set the cstep & csequence - couldn't do it in the add because it needed a sql function
|
||||||
|
foreach (DataRow drw in ds.Tables["Sections"].Rows)
|
||||||
|
{
|
||||||
|
drw["CStep"] = TextConvert.ConvertSeq(drw["Step"].ToString());
|
||||||
|
drw["CSequence"] = TextConvert.ConvertSeq(drw["Sequence"].ToString());
|
||||||
|
}
|
||||||
|
dt.Columns.Add("StepNo", System.Type.GetType("System.Int32"), "Convert(Convert(Substring(CStep,2,1),'System.Char'),'System.Int32')-48");
|
||||||
|
dt.Columns.Add("Level", System.Type.GetType("System.Int32"), "Len(CSequence)");
|
||||||
|
dt.Columns.Add("SubStepNo", System.Type.GetType("System.Int32"), "Convert(Convert(Substring(CSequence,Len(CSequence),1),'System.Char'),'System.Int32')-48");
|
||||||
|
dt.Columns.Add("locb", System.Type.GetType("System.Int32"), "Convert(Convert(Substring(CSequence,2,1),'System.Char'),'System.Int32')-48");
|
||||||
|
}
|
||||||
|
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
FileInfo fi;
|
||||||
|
switch (ex.Message)
|
||||||
|
{
|
||||||
|
case "Index file not found.":// then delete inf file
|
||||||
|
fi = new FileInfo(tbSource.Text + "\\" + FileName + ".inf");
|
||||||
|
fi.Delete();
|
||||||
|
LoadSection(ds, da, FileName);// Try Again
|
||||||
|
break;
|
||||||
|
case "External table is not in the expected format.": // then pad dbt file with 128 zeros.
|
||||||
|
fi = new FileInfo(tbSource.Text + "\\" + FileName + ".dbt");
|
||||||
|
FileStream fs = fi.OpenWrite();
|
||||||
|
fs.Position = fs.Length;
|
||||||
|
byte[] buf = new byte[128];
|
||||||
|
for (int i = 0; i < 128; i++) buf[i] = 0;
|
||||||
|
fs.Write(buf, 0, 128);
|
||||||
|
fs.Close();
|
||||||
|
LoadSection(ds, da, FileName);// Try Again
|
||||||
|
break;
|
||||||
|
default: // Unrecognized error
|
||||||
|
log.ErrorFormat("File - {0}.DBF\r\n\r\n{1}\r\n\r\n{2}", FileName, ex.Message, ex.InnerException);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
307
PROMS/DataLoader/Steps.cs
Normal file
307
PROMS/DataLoader/Steps.cs
Normal file
@ -0,0 +1,307 @@
|
|||||||
|
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 Step AddStep(OleDbConnection cn, string StepType, string Textm, string Recid, string stpseq, string structtype, int structid, DateTime dts, string userid)
|
||||||
|
{
|
||||||
|
Step stp = null;
|
||||||
|
UpdateLabels(0, 0, 1);
|
||||||
|
bool hasxml = false;
|
||||||
|
ConfigInfo ci = new ConfigInfo(null);
|
||||||
|
string stptext = null;
|
||||||
|
int tok = -1;
|
||||||
|
char[] chrarr = { '\x1', '\x2', '\x3', '\x5' };
|
||||||
|
try
|
||||||
|
{
|
||||||
|
// the textm field has step text, but also may have other text stored
|
||||||
|
// with it with a 'token' as a separator (see below).
|
||||||
|
tok = Textm.IndexOfAny(chrarr);
|
||||||
|
if (tok < 0)
|
||||||
|
stptext = TextConvert.ConvertText(Textm);
|
||||||
|
else
|
||||||
|
stptext = TextConvert.ConvertText(Textm.Substring(0, tok));
|
||||||
|
|
||||||
|
string seqcvt = TextConvert.ConvertSeq(stpseq);
|
||||||
|
|
||||||
|
// Figure marker - it should NEVER get here!!!
|
||||||
|
int tokfig = Textm.IndexOf('\xE8');
|
||||||
|
if (tokfig > -1)
|
||||||
|
{
|
||||||
|
log.Error("Found a old style figure!");
|
||||||
|
log.ErrorFormat("oldstepsequence = {0}", stpseq);
|
||||||
|
}
|
||||||
|
// Before we save it, handle RO & Transitions tokens.
|
||||||
|
int tokrt = Textm.IndexOf('\x15');
|
||||||
|
if (tokrt > -1) stptext = MigrateRos(cn, stptext, seqcvt, structid);
|
||||||
|
|
||||||
|
// 16-bit code has the following two defines.
|
||||||
|
// #define TransitionMarker 0xC2
|
||||||
|
// #define ReferenceMarker 0xCB
|
||||||
|
// these two characters get converted (to unicode) from ado.net
|
||||||
|
// use the unicode chars.
|
||||||
|
char[] chrrotrn = { '\x252C', '\x2566' };
|
||||||
|
tokrt = Textm.IndexOfAny(chrrotrn);
|
||||||
|
if (tokrt > -1) stptext = MigrateTrans(cn, stptext, seqcvt, structid);
|
||||||
|
TextM tm = TextM.MakeTextM(stptext);
|
||||||
|
stp = Step.MakeStep(StepType, tm.TextMID, null, dts, userid);
|
||||||
|
dicOldStepSequence[stp] = seqcvt;
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
log.Error("Save Step");
|
||||||
|
log.ErrorFormat("oldstepsequence = {0}", stpseq);
|
||||||
|
log.ErrorFormat("{0}\r\n\r\n{1}", ex.Message, ex.InnerException);
|
||||||
|
log.ErrorFormat(ex.StackTrace);
|
||||||
|
stp = null;
|
||||||
|
}
|
||||||
|
|
||||||
|
// now add on any support pieces of text associated with the step.
|
||||||
|
// These include:
|
||||||
|
// '\1' comment
|
||||||
|
// '\2' multiple change ids and/or change message
|
||||||
|
// '\3' linked sequence
|
||||||
|
// '\3\3'override tab
|
||||||
|
// '\5' continuous action summary flag
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
while (tok >= 0 && tok != Textm.Length)
|
||||||
|
{
|
||||||
|
int nxttok = Textm.IndexOfAny(chrarr, tok + 1);
|
||||||
|
char chr = Textm[tok];
|
||||||
|
int typ = 0;
|
||||||
|
if (chr == '\x1')
|
||||||
|
typ = STP_COMMENT;
|
||||||
|
else if (chr == '\x2')
|
||||||
|
typ = STP_MULT_CHGID;
|
||||||
|
else if (chr == '\x3')
|
||||||
|
{
|
||||||
|
typ = STP_LNK_SEQ;
|
||||||
|
// check for a double \3 - override tab.
|
||||||
|
if (tok + 1 < Textm.Length)
|
||||||
|
{
|
||||||
|
char nxttokchr = Textm[tok + 1];
|
||||||
|
if (nxttokchr == '\x3')
|
||||||
|
{
|
||||||
|
typ = STP_OVR_TAB;
|
||||||
|
tok++; // this was a double \3, get past 1st one.
|
||||||
|
nxttok = Textm.IndexOfAny(chrarr, tok + 1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (chr == '\x5')
|
||||||
|
{
|
||||||
|
ci.AddItem("Step", "ContActSum", "True");
|
||||||
|
//hasxml = SetXml(xmldoc, topElement, "Step", "ContActSum", "True");
|
||||||
|
if (nxttok < 0) nxttok = Textm.Length;
|
||||||
|
}
|
||||||
|
|
||||||
|
// if not xml, i.e. chr=='\x5', make a textm element
|
||||||
|
if (chr != '\x5')
|
||||||
|
{
|
||||||
|
if (nxttok < 0) nxttok = Textm.Length;
|
||||||
|
// if this is a sequence number - may need to convert hi-end chars
|
||||||
|
string str = null;
|
||||||
|
if (typ == STP_LNK_SEQ)
|
||||||
|
str = TextConvert.ConvertSeq(Textm.Substring(tok + 1, nxttok - tok - 1));
|
||||||
|
else
|
||||||
|
str = Textm.Substring(tok + 1, nxttok - tok - 1);
|
||||||
|
//StepText stptxt = StepText.MakeStepText(typ, str, true);
|
||||||
|
//stptxt.ItemType = typ;
|
||||||
|
//stptxt.Textm = str;
|
||||||
|
//stp.StepStepTexts.Add(
|
||||||
|
}
|
||||||
|
tok = nxttok;
|
||||||
|
}
|
||||||
|
|
||||||
|
// also see if a check-off needs added.
|
||||||
|
if (Recid[0] != '0')
|
||||||
|
{
|
||||||
|
string chkindx = Recid[0].ToString();
|
||||||
|
ci.AddItem("Step", "CheckOffIndex", chkindx);
|
||||||
|
//hasxml = SetXml(xmldoc, topElement, "Step", "CheckOffIndex", chkindx);
|
||||||
|
}
|
||||||
|
|
||||||
|
// here's where it knows if it's a linked step (or in processstep)
|
||||||
|
if (Recid[1] != '0')
|
||||||
|
{
|
||||||
|
// do linked step stuff.
|
||||||
|
}
|
||||||
|
|
||||||
|
// if checkoffs or the continuous action summary flag, save the xml.
|
||||||
|
if (hasxml)
|
||||||
|
{
|
||||||
|
stp.Config = ci.ToString();
|
||||||
|
stp.Save(true);
|
||||||
|
}
|
||||||
|
// if this has associated steptext, such as tab override or comment,
|
||||||
|
// save it.
|
||||||
|
//else if (stp.StepStepTexts.Count > 0)
|
||||||
|
// stp.Save(true);
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
log.Error("Save Step part 2");
|
||||||
|
log.ErrorFormat("oldstepsequence = {0}", stpseq);
|
||||||
|
log.ErrorFormat("{0}\r\n\r\n{1}", ex.Message, ex.InnerException);
|
||||||
|
log.ErrorFormat(ex.StackTrace);
|
||||||
|
}
|
||||||
|
return stp;
|
||||||
|
}
|
||||||
|
|
||||||
|
// private void ProcessSubStep(DataTable dt,DataRowView drv,StepTbl stpP)
|
||||||
|
// {
|
||||||
|
// // TODO: Need logic for TextM Support
|
||||||
|
// StepTbl stp = AddStep(stpP,drv["Type"].ToString(),drv["Text"].ToString(),drv["Step"].ToString()+drv["sequence"].ToString());
|
||||||
|
// // TODO: Logic to add Sub-steps
|
||||||
|
// string sPre = drv["Sequence"].ToString();
|
||||||
|
// ProcessSubSteps(dt,drv["Step"].ToString(),sPre+"[*!]?",stp);// Cautions and Notes
|
||||||
|
// ProcessSubSteps(dt,drv["Step"].ToString(),sPre+"$",stp);// RNOs
|
||||||
|
// ProcessSubSteps(dt,drv["Step"].ToString(),sPre+"?",stp);// Substeps
|
||||||
|
// //ProcessSubSteps(dt,drv["Step"],"S_",stp);// Tables
|
||||||
|
// }
|
||||||
|
// private void ProcessSubSteps(DataTable dt,string step,string lookfor,StepTbl stp)
|
||||||
|
// {
|
||||||
|
// DataView dv = new DataView(dt,"Step='" + step + "' and Sequence like'" + lookfor + "'",
|
||||||
|
// "sequence",DataViewRowState.OriginalRows);
|
||||||
|
// foreach(DataRowView drv in dv)
|
||||||
|
// {
|
||||||
|
// ProcessSubStep(dt,drv,stp);
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
private string GetParent(string s)
|
||||||
|
{
|
||||||
|
string retval = "S";
|
||||||
|
if (s.Length > 1)
|
||||||
|
{
|
||||||
|
int l = s.Length;
|
||||||
|
if ("!*".IndexOf(s[l - 2]) > -1)
|
||||||
|
{
|
||||||
|
if (l > 2) retval = s.Substring(0, l - 2);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
retval = s.Substring(0, l - 1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return retval;
|
||||||
|
}
|
||||||
|
private string GetStructType(string s)
|
||||||
|
{
|
||||||
|
string retval = "S";
|
||||||
|
if (s.Length > 1)
|
||||||
|
{
|
||||||
|
int l = s.Length;
|
||||||
|
if ("!*".IndexOf(s[l - 2]) > -1)
|
||||||
|
{
|
||||||
|
if (s[l - 2] == '!') retval = "C";
|
||||||
|
else retval = "N";
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (s[l - 1] == '$') retval = "R";
|
||||||
|
if (s[l - 1] == '#') retval = "T";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return retval;
|
||||||
|
}
|
||||||
|
private Int32 MigrateStep(OleDbConnection cn, DataTable dt, DataRowView drv, Byte FromType, Int32 FromID)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
int tmpid = 1;
|
||||||
|
|
||||||
|
// Do the structure record first because usages from the step require a structure
|
||||||
|
// id.
|
||||||
|
string sType = GetStructType(drv["CSequence"].ToString());
|
||||||
|
// Structures str = AddStructure(FromType, FromID, (byte)(3 + ("CNRST".IndexOf(sType))), tmpid, drv["CStep"].ToString() + drv["CSequence"].ToString(),
|
||||||
|
Structure str = AddStructure(FromType, FromID, 3, tmpid, drv["CStep"].ToString() + drv["CSequence"].ToString(),
|
||||||
|
GetDTS(drv["Date"].ToString(), drv["Time"].ToString()), drv["Initials"].ToString());
|
||||||
|
Step stp = AddStep(cn, drv["Type"].ToString()
|
||||||
|
, (drv["textm"] == DBNull.Value ? drv["Text"].ToString() : drv["Textm"].ToString())
|
||||||
|
, drv["Recid"].ToString(), drv["CStep"].ToString() + drv["CSequence"].ToString(), "S", str.StructureID
|
||||||
|
, GetDTS(drv["Date"].ToString(), drv["Time"].ToString()), drv["Initials"].ToString());
|
||||||
|
str.ContentID = stp.StepID;
|
||||||
|
str.Save(true);
|
||||||
|
Dictionary<string, Step> dicStep = new Dictionary<string, Step>();
|
||||||
|
dicStep[drv["CSequence"].ToString()] = stp;
|
||||||
|
Dictionary<string, Dictionary<string, int>> dicStruct = new Dictionary<string, Dictionary<string, int>>();
|
||||||
|
Dictionary<string, int> dicBase = new Dictionary<string, int>();
|
||||||
|
dicStruct[drv["CSequence"].ToString()] = dicBase;
|
||||||
|
dicBase[""] = str.StructureID;
|
||||||
|
// Logic to add Sub-steps
|
||||||
|
string sQry = "CStep = '" + drv["CStep"].ToString() + "' and CSequence <> 'S'";
|
||||||
|
// sort order - for sections use currentrows.
|
||||||
|
DataView dv = new DataView(dt, sQry, "StepNo,Level,SubStepNo", DataViewRowState.CurrentRows);
|
||||||
|
//dataGrid1.DataSource=dv;
|
||||||
|
//Loop through DataView and add Steps one at a time
|
||||||
|
//Console.WriteLine("={0}",drv["Step"]);
|
||||||
|
Byte FrType = 0;
|
||||||
|
Int32 FrID = str.StructureID;
|
||||||
|
foreach (DataRowView drvs in dv)
|
||||||
|
{
|
||||||
|
//Console.WriteLine(">{0}",drvs["CStep"]);
|
||||||
|
|
||||||
|
string sParent = GetParent(drvs["CSequence"].ToString());
|
||||||
|
if (dicStep.ContainsKey(sParent))
|
||||||
|
{
|
||||||
|
Step stpp = dicStep[sParent];
|
||||||
|
sType = GetStructType(drvs["CSequence"].ToString());
|
||||||
|
Dictionary<string,int> dicStr = dicStruct[sParent];
|
||||||
|
if (dicStr.ContainsKey(sType))
|
||||||
|
{
|
||||||
|
FrID = (Int32)dicStr[sType];
|
||||||
|
FrType = 0;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
FrID = (Int32)dicStr[""];
|
||||||
|
FrType = (byte)(3 + ("CNRST".IndexOf(sType)));
|
||||||
|
}
|
||||||
|
Structure str1 = AddStructure(FrType, FrID, 3, tmpid++, drvs["CStep"].ToString() + drvs["CSequence"].ToString(),
|
||||||
|
GetDTS(drvs["Date"].ToString(), drvs["Time"].ToString()), drvs["Initials"].ToString());
|
||||||
|
Step stpc = AddStep(cn, drvs["Type"].ToString()
|
||||||
|
, (drvs["textm"] == DBNull.Value ? drvs["Text"].ToString() : drvs["Textm"].ToString())
|
||||||
|
, drv["Recid"].ToString(), drvs["CStep"].ToString() + drvs["CSequence"].ToString(), GetStructType(drvs["sequence"].ToString()), str1.StructureID
|
||||||
|
, GetDTS(drvs["Date"].ToString(), drvs["Time"].ToString()), drvs["Initials"].ToString());
|
||||||
|
str1.ContentID = stpc.StepID;
|
||||||
|
str1.Save(true);
|
||||||
|
dicStep[drvs["CSequence"].ToString()] = stpc;
|
||||||
|
|
||||||
|
dicBase = new Dictionary<string, int>();
|
||||||
|
dicStruct[drvs["CSequence"].ToString()] = dicBase;
|
||||||
|
dicBase[""] = str1.StructureID;
|
||||||
|
dicStr[sType] = str1.StructureID;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
log.ErrorFormat("Parent {0} Could not be found for {1}", sParent, drvs["sequence"].ToString());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return str.StructureID;
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
log.Error("PROCESS STEP");
|
||||||
|
log.ErrorFormat("{0}\r\n\r\n{1}", ex.Message, ex.InnerException);
|
||||||
|
log.ErrorFormat(ex.StackTrace);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
//return 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
70
PROMS/DataLoader/Structures.cs
Normal file
70
PROMS/DataLoader/Structures.cs
Normal file
@ -0,0 +1,70 @@
|
|||||||
|
// ========================================================================
|
||||||
|
// 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 Structure AddStructure(byte FromType, int FromID, byte ContentType, int ContentID, string stpseq,
|
||||||
|
DateTime dts, string userid)
|
||||||
|
{
|
||||||
|
Structure str = null;
|
||||||
|
string str_key = ProcNumber + "|";
|
||||||
|
switch (ContentType)
|
||||||
|
{
|
||||||
|
case 1:
|
||||||
|
str_key += stpseq;
|
||||||
|
break;
|
||||||
|
case 2:
|
||||||
|
str_key += stpseq.Substring(0, 1)+"0";
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
str_key += stpseq;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
if (dicTrans_StrIds.ContainsKey(str_key))
|
||||||
|
{
|
||||||
|
str = Structure.Get(dicTrans_StrIds[str_key]);
|
||||||
|
str.FromID = FromID;
|
||||||
|
str.FromType = FromType;
|
||||||
|
str.ContentID = ContentID;
|
||||||
|
str.ContentType = ContentType;
|
||||||
|
str.DTS = dts;
|
||||||
|
str.UserID = (userid==null||userid=="")?"empty":userid;
|
||||||
|
str.Save(true); ;
|
||||||
|
dicTrans_StrIds.Remove(str_key);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
str = Structure.MakeStructure(FromType, FromID, ContentType, ContentID, dts, userid);
|
||||||
|
}
|
||||||
|
if (dicTrans_StrDone.ContainsKey(str_key))
|
||||||
|
log.ErrorFormat("Duplicate proc/sequence number during structure migration: {0}", str_key);
|
||||||
|
else
|
||||||
|
dicTrans_StrDone.Add(str_key, str.StructureID);
|
||||||
|
|
||||||
|
return str;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
120
PROMS/DataLoader/TextConvert.cs
Normal file
120
PROMS/DataLoader/TextConvert.cs
Normal file
@ -0,0 +1,120 @@
|
|||||||
|
// ========================================================================
|
||||||
|
// 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.Collections.Generic;
|
||||||
|
using System.Text;
|
||||||
|
using System.Text.RegularExpressions;
|
||||||
|
|
||||||
|
namespace DataLoader
|
||||||
|
{
|
||||||
|
public static class TextConvert
|
||||||
|
{
|
||||||
|
static TextConvert()
|
||||||
|
{
|
||||||
|
BuildDictionarySeq();
|
||||||
|
BuildDictionaryText();
|
||||||
|
}
|
||||||
|
|
||||||
|
private static Dictionary<int, int> dicChar;
|
||||||
|
public static void BuildDictionarySeq()
|
||||||
|
{
|
||||||
|
dicChar = new Dictionary<int, int>();
|
||||||
|
for (int i = 0; i < 128; i++) dicChar[i] = i;
|
||||||
|
dicChar[199] = 128; dicChar[252] = 129; dicChar[233] = 130; dicChar[226] = 131;
|
||||||
|
dicChar[228] = 132; dicChar[224] = 133; dicChar[229] = 134; dicChar[231] = 135;
|
||||||
|
dicChar[234] = 136; dicChar[235] = 137; dicChar[232] = 138; dicChar[239] = 139;
|
||||||
|
dicChar[238] = 140; dicChar[236] = 141; dicChar[196] = 142; dicChar[197] = 143;
|
||||||
|
dicChar[201] = 144; dicChar[230] = 145; dicChar[198] = 146; dicChar[244] = 147;
|
||||||
|
dicChar[246] = 148; dicChar[242] = 149; dicChar[251] = 150; dicChar[249] = 151;
|
||||||
|
dicChar[255] = 152; dicChar[214] = 153; dicChar[220] = 154; dicChar[162] = 155;
|
||||||
|
dicChar[163] = 156; dicChar[165] = 157; dicChar[8359] = 158; dicChar[402] = 159;
|
||||||
|
dicChar[225] = 160; dicChar[237] = 161; dicChar[243] = 162; dicChar[250] = 163;
|
||||||
|
dicChar[241] = 164; dicChar[209] = 165; dicChar[170] = 166; dicChar[186] = 167;
|
||||||
|
dicChar[191] = 168; dicChar[8976] = 169; dicChar[172] = 170; dicChar[189] = 171;
|
||||||
|
dicChar[188] = 172; dicChar[161] = 173; dicChar[171] = 174; dicChar[187] = 175;
|
||||||
|
dicChar[9617] = 176; dicChar[9618] = 177; dicChar[9619] = 178; dicChar[9474] = 179;
|
||||||
|
dicChar[9508] = 180; dicChar[9569] = 181; dicChar[9570] = 182; dicChar[9558] = 183;
|
||||||
|
dicChar[9557] = 184; dicChar[9571] = 185; dicChar[9553] = 186; dicChar[9559] = 187;
|
||||||
|
dicChar[9565] = 188; dicChar[9564] = 189; dicChar[9563] = 190; dicChar[9488] = 191;
|
||||||
|
dicChar[9492] = 192; dicChar[9524] = 193; dicChar[9516] = 194; dicChar[9500] = 195;
|
||||||
|
dicChar[9472] = 196; dicChar[9532] = 197; dicChar[9566] = 198; dicChar[9567] = 199;
|
||||||
|
dicChar[9562] = 200; dicChar[9556] = 201; dicChar[9577] = 202; dicChar[9574] = 203;
|
||||||
|
dicChar[9568] = 204; dicChar[9552] = 205; dicChar[9580] = 206; dicChar[9575] = 207;
|
||||||
|
dicChar[9576] = 208; dicChar[9572] = 209; dicChar[9573] = 210; dicChar[9561] = 211;
|
||||||
|
dicChar[9560] = 212; dicChar[9554] = 213; dicChar[9555] = 214; dicChar[9579] = 215;
|
||||||
|
dicChar[9578] = 216; dicChar[9496] = 217; dicChar[9484] = 218; dicChar[9608] = 219;
|
||||||
|
dicChar[9604] = 220; dicChar[9612] = 221; dicChar[9616] = 222; dicChar[9600] = 223;
|
||||||
|
dicChar[945] = 224; dicChar[223] = 225; dicChar[915] = 226; dicChar[960] = 227;
|
||||||
|
dicChar[931] = 228; dicChar[963] = 229; dicChar[181] = 230; dicChar[964] = 231;
|
||||||
|
dicChar[934] = 232; dicChar[920] = 233; dicChar[937] = 234; dicChar[948] = 235;
|
||||||
|
dicChar[8734] = 236; dicChar[966] = 237; dicChar[949] = 238; dicChar[8745] = 239;
|
||||||
|
dicChar[8801] = 240; dicChar[177] = 241; dicChar[8805] = 242; dicChar[8804] = 243;
|
||||||
|
dicChar[8992] = 244; dicChar[8993] = 245; dicChar[247] = 246; dicChar[8776] = 247;
|
||||||
|
dicChar[176] = 248; dicChar[8729] = 249; dicChar[183] = 250; dicChar[8730] = 251;
|
||||||
|
dicChar[8319] = 252; dicChar[178] = 253; dicChar[9632] = 254; dicChar[160] = 255;
|
||||||
|
}
|
||||||
|
public static string ConvertSeq(string s1)
|
||||||
|
{
|
||||||
|
Encoding Eibm437 = Encoding.GetEncoding(437);
|
||||||
|
Encoding Eunicode = Encoding.Unicode;
|
||||||
|
Decoder d = Eibm437.GetDecoder();
|
||||||
|
Byte[] bs1 = Eunicode.GetBytes(s1);
|
||||||
|
Byte[] bs2 = Encoding.Convert(Eunicode, Eibm437, bs1);
|
||||||
|
char[] cs2 = new char[Eibm437.GetCharCount(bs2)];
|
||||||
|
for (int i = 0; i < cs2.Length; i++) cs2[i] = (char)bs2[i];
|
||||||
|
return new string(cs2);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static Regex Reg2;
|
||||||
|
public static void BuildDictionaryText()
|
||||||
|
{
|
||||||
|
dicChar = new Dictionary<int, int>();
|
||||||
|
dicChar[966] = 216;
|
||||||
|
dicChar[201] = 274;
|
||||||
|
dicChar[127] = 916;
|
||||||
|
dicChar[964] = 947;
|
||||||
|
dicChar[920] = 952;
|
||||||
|
dicChar[915] = 961;
|
||||||
|
dicChar[191] = 964;
|
||||||
|
dicChar[8801] = 8773;
|
||||||
|
dicChar[8734] = 8857;
|
||||||
|
dicChar[7] = 9679;
|
||||||
|
dicChar[8976] = 9830;
|
||||||
|
char[] creg = new char[dicChar.Count];
|
||||||
|
int i = 0;
|
||||||
|
foreach (int ic in dicChar.Keys)
|
||||||
|
{
|
||||||
|
creg[i] = (char)ic;
|
||||||
|
i++;
|
||||||
|
}
|
||||||
|
Reg2 = new Regex("[" + new string(creg) + "]");
|
||||||
|
}
|
||||||
|
public static string ReplaceChars(Match m)
|
||||||
|
{
|
||||||
|
char[] cs = m.Value.ToCharArray();
|
||||||
|
for (int i = 0; i < cs.Length; i++)
|
||||||
|
{
|
||||||
|
if (dicChar.ContainsKey((int)(cs[i])))
|
||||||
|
{
|
||||||
|
int iKey = (int)cs[i];
|
||||||
|
int iValue = dicChar[iKey];
|
||||||
|
cs[i] = (char)iValue;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return new string(cs);
|
||||||
|
}
|
||||||
|
public static string ConvertText(string s1)
|
||||||
|
{
|
||||||
|
string s2 = Reg2.Replace(s1, new MatchEvaluator(ReplaceChars));
|
||||||
|
return s2;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
139
PROMS/DataLoader/Transitions.cs
Normal file
139
PROMS/DataLoader/Transitions.cs
Normal file
@ -0,0 +1,139 @@
|
|||||||
|
// ========================================================================
|
||||||
|
// 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 int AddTrans(int fromId, DataRow dr)
|
||||||
|
{
|
||||||
|
//TODO: ZTransitions tr.Oldto = dr["OLDTO"].ToString();
|
||||||
|
string thekey = dr["TONUMBER"].ToString() + "|" + dr["TOSEQUENCE"].ToString();
|
||||||
|
string dti = dr["DTI"].ToString().PadRight(18, ' ');
|
||||||
|
string userid = dti.Substring(13, 5).Trim();
|
||||||
|
DateTime dts = GetDTS(MakeDate(dti.Substring(0, 8).Trim()), dti.Substring(8, 5).Trim());
|
||||||
|
// if it's in the dictionary of structure elements already migrated, just use this
|
||||||
|
// structure id, or if it's in the dictionary of structure elements that have
|
||||||
|
// not been migrated but a record was created from this code, use it. Otherwise
|
||||||
|
// create a new structure record and use its id, its data will be updated later.
|
||||||
|
// a structure record.
|
||||||
|
int toid;
|
||||||
|
if (dicTrans_StrDone.ContainsKey(thekey))
|
||||||
|
toid = dicTrans_StrDone[thekey];
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (dicTrans_StrIds.ContainsKey(thekey))
|
||||||
|
toid = dicTrans_StrIds[thekey];
|
||||||
|
else
|
||||||
|
{
|
||||||
|
Structure str = Structure.MakeStructure(0, 0, 0, 0);
|
||||||
|
toid = str.StructureID;
|
||||||
|
dicTrans_StrIds.Add(thekey, toid);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Transition tr = Transition.MakeTransition(fromId, toid, System.Convert.ToInt32(dr["TYPE"].ToString()),0,0,0,0,dts,userid);
|
||||||
|
return tr.TransitionId;
|
||||||
|
}
|
||||||
|
|
||||||
|
private string MigrateTrans(OleDbConnection cn, string textm, string seqcvt, int structId)
|
||||||
|
{
|
||||||
|
StringBuilder trtxt = new StringBuilder();
|
||||||
|
int instance = 0;
|
||||||
|
int beg = 0;
|
||||||
|
DataTable dt = null;
|
||||||
|
DataSet ds = null;
|
||||||
|
OleDbDataAdapter da = null;
|
||||||
|
|
||||||
|
char[] chrtrn = { '\x252C', '\x2566' };
|
||||||
|
int tok = textm.IndexOfAny(chrtrn);
|
||||||
|
if (tok > -1)
|
||||||
|
{
|
||||||
|
string cmd = "SELECT * FROM [tran] WHERE [FROMNUMBER]='" + ProcNumber.Replace("'", "''") + "' AND [FROMSEQUEN] ='" + seqcvt + "' ORDER BY [FROMINSTAN]";
|
||||||
|
da = new OleDbDataAdapter(cmd, cn);
|
||||||
|
// get transition records for this step.
|
||||||
|
ds = new DataSet();
|
||||||
|
try
|
||||||
|
{
|
||||||
|
da.Fill(ds);
|
||||||
|
dt = ds.Tables[0];
|
||||||
|
dt.CaseSensitive = true;
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
log.Error("Error getting transitions");
|
||||||
|
log.ErrorFormat("from number = {0} oldstepsequence = {1}", ProcNumber, seqcvt);
|
||||||
|
log.ErrorFormat("{0}\r\n\r\n{1}", ex.Message, ex.InnerException);
|
||||||
|
return textm;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
while (tok > -1)
|
||||||
|
{
|
||||||
|
// found a transition token, add the token and transition id into the string and
|
||||||
|
// add an transition record for it. Later there may be text added.
|
||||||
|
trtxt.Append(textm.Substring(beg, tok - beg));
|
||||||
|
// we have too many tokens and not enough usage records - report an error...
|
||||||
|
if (instance >= dt.Rows.Count)
|
||||||
|
{
|
||||||
|
log.ErrorFormat("Error - ran out of usage records for step, check data ");
|
||||||
|
log.ErrorFormat("from number = {0} oldstepsequence = {1}", ProcNumber, seqcvt);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
DataRow dr = dt.Rows[instance];
|
||||||
|
int trid = AddTrans(structId, dr);
|
||||||
|
trtxt.Append(textm[tok]);
|
||||||
|
trtxt.Append("{{");
|
||||||
|
trtxt.Append(trid.ToString());
|
||||||
|
trtxt.Append("}}");
|
||||||
|
}
|
||||||
|
instance++;
|
||||||
|
beg = tok + 1;
|
||||||
|
if (beg > textm.Length)
|
||||||
|
{
|
||||||
|
tok = -1;
|
||||||
|
da.Dispose();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
tok = textm.IndexOfAny(chrtrn, beg);
|
||||||
|
}
|
||||||
|
if (beg < textm.Length - 1)
|
||||||
|
trtxt.Append(textm.Substring(beg, textm.Length - beg));
|
||||||
|
if (dt.Rows.Count > instance + 1)
|
||||||
|
{
|
||||||
|
log.ErrorFormat("Error - extra usage records for step, check data ");
|
||||||
|
log.ErrorFormat("from number = {0} oldstepsequence = {1}", ProcNumber, seqcvt);
|
||||||
|
}
|
||||||
|
return trtxt.ToString();
|
||||||
|
}
|
||||||
|
private void ShowMissingTransitions()
|
||||||
|
{
|
||||||
|
log.Info("Missing Transitions");
|
||||||
|
foreach (string s in dicTrans_StrIds.Keys)
|
||||||
|
{
|
||||||
|
log.InfoFormat("{0} - {1}", s, dicTrans_StrIds[s]);
|
||||||
|
}
|
||||||
|
log.Info("End of Missing Transitions");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
382
PROMS/DataLoader/frmLoader.Designer.cs
generated
Normal file
382
PROMS/DataLoader/frmLoader.Designer.cs
generated
Normal file
@ -0,0 +1,382 @@
|
|||||||
|
namespace DataLoader
|
||||||
|
{
|
||||||
|
partial class frmLoader
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Required designer variable.
|
||||||
|
/// </summary>
|
||||||
|
private System.ComponentModel.IContainer components = null;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Clean up any resources being used.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
|
||||||
|
protected override void Dispose(bool disposing)
|
||||||
|
{
|
||||||
|
if (disposing && (components != null))
|
||||||
|
{
|
||||||
|
components.Dispose();
|
||||||
|
}
|
||||||
|
base.Dispose(disposing);
|
||||||
|
}
|
||||||
|
|
||||||
|
#region Windows Form Designer generated code
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Required method for Designer support - do not modify
|
||||||
|
/// the contents of this method with the code editor.
|
||||||
|
/// </summary>
|
||||||
|
private void InitializeComponent()
|
||||||
|
{
|
||||||
|
this.sc = new System.Windows.Forms.SplitContainer();
|
||||||
|
this.btnVETree_CSLA = new System.Windows.Forms.Button();
|
||||||
|
this.btnBrowseVesam = new System.Windows.Forms.Button();
|
||||||
|
this.tbVesamPath = new System.Windows.Forms.TextBox();
|
||||||
|
this.btnVesam = new System.Windows.Forms.Button();
|
||||||
|
this.btnLoadTreeCSLA = new System.Windows.Forms.Button();
|
||||||
|
this.cbLazy = new System.Windows.Forms.CheckBox();
|
||||||
|
this.btnConvertSelected = new System.Windows.Forms.Button();
|
||||||
|
this.btnLoadTreeDB = new System.Windows.Forms.Button();
|
||||||
|
this.cbPurgeData = new System.Windows.Forms.CheckBox();
|
||||||
|
this.lblTime = new System.Windows.Forms.Label();
|
||||||
|
this.pbStep = new System.Windows.Forms.ProgressBar();
|
||||||
|
this.pbSect = new System.Windows.Forms.ProgressBar();
|
||||||
|
this.pbProc = new System.Windows.Forms.ProgressBar();
|
||||||
|
this.cbSaveDoc = new System.Windows.Forms.CheckBox();
|
||||||
|
this.cbSaveRTF = new System.Windows.Forms.CheckBox();
|
||||||
|
this.btnBrowse = new System.Windows.Forms.Button();
|
||||||
|
this.tbSource = new System.Windows.Forms.TextBox();
|
||||||
|
this.lblStep = new System.Windows.Forms.Label();
|
||||||
|
this.lblSection = new System.Windows.Forms.Label();
|
||||||
|
this.lblProc = new System.Windows.Forms.Label();
|
||||||
|
this.btnConvert = new System.Windows.Forms.Button();
|
||||||
|
this.tv = new System.Windows.Forms.TreeView();
|
||||||
|
this.fbd = new System.Windows.Forms.FolderBrowserDialog();
|
||||||
|
this.btnGroup = new System.Windows.Forms.Button();
|
||||||
|
this.sc.Panel1.SuspendLayout();
|
||||||
|
this.sc.Panel2.SuspendLayout();
|
||||||
|
this.sc.SuspendLayout();
|
||||||
|
this.SuspendLayout();
|
||||||
|
//
|
||||||
|
// sc
|
||||||
|
//
|
||||||
|
this.sc.Dock = System.Windows.Forms.DockStyle.Fill;
|
||||||
|
this.sc.Location = new System.Drawing.Point(0, 0);
|
||||||
|
this.sc.Margin = new System.Windows.Forms.Padding(2);
|
||||||
|
this.sc.Name = "sc";
|
||||||
|
this.sc.Orientation = System.Windows.Forms.Orientation.Horizontal;
|
||||||
|
//
|
||||||
|
// sc.Panel1
|
||||||
|
//
|
||||||
|
this.sc.Panel1.Controls.Add(this.btnGroup);
|
||||||
|
this.sc.Panel1.Controls.Add(this.btnVETree_CSLA);
|
||||||
|
this.sc.Panel1.Controls.Add(this.btnBrowseVesam);
|
||||||
|
this.sc.Panel1.Controls.Add(this.tbVesamPath);
|
||||||
|
this.sc.Panel1.Controls.Add(this.btnVesam);
|
||||||
|
this.sc.Panel1.Controls.Add(this.btnLoadTreeCSLA);
|
||||||
|
this.sc.Panel1.Controls.Add(this.cbLazy);
|
||||||
|
this.sc.Panel1.Controls.Add(this.btnConvertSelected);
|
||||||
|
this.sc.Panel1.Controls.Add(this.btnLoadTreeDB);
|
||||||
|
this.sc.Panel1.Controls.Add(this.cbPurgeData);
|
||||||
|
this.sc.Panel1.Controls.Add(this.lblTime);
|
||||||
|
this.sc.Panel1.Controls.Add(this.pbStep);
|
||||||
|
this.sc.Panel1.Controls.Add(this.pbSect);
|
||||||
|
this.sc.Panel1.Controls.Add(this.pbProc);
|
||||||
|
this.sc.Panel1.Controls.Add(this.cbSaveDoc);
|
||||||
|
this.sc.Panel1.Controls.Add(this.cbSaveRTF);
|
||||||
|
this.sc.Panel1.Controls.Add(this.btnBrowse);
|
||||||
|
this.sc.Panel1.Controls.Add(this.tbSource);
|
||||||
|
this.sc.Panel1.Controls.Add(this.lblStep);
|
||||||
|
this.sc.Panel1.Controls.Add(this.lblSection);
|
||||||
|
this.sc.Panel1.Controls.Add(this.lblProc);
|
||||||
|
this.sc.Panel1.Controls.Add(this.btnConvert);
|
||||||
|
//
|
||||||
|
// sc.Panel2
|
||||||
|
//
|
||||||
|
this.sc.Panel2.Controls.Add(this.tv);
|
||||||
|
this.sc.Size = new System.Drawing.Size(623, 413);
|
||||||
|
this.sc.SplitterDistance = 172;
|
||||||
|
this.sc.SplitterWidth = 3;
|
||||||
|
this.sc.TabIndex = 46;
|
||||||
|
//
|
||||||
|
// btnVETree_CSLA
|
||||||
|
//
|
||||||
|
this.btnVETree_CSLA.Location = new System.Drawing.Point(293, 121);
|
||||||
|
this.btnVETree_CSLA.Name = "btnVETree_CSLA";
|
||||||
|
this.btnVETree_CSLA.Size = new System.Drawing.Size(145, 21);
|
||||||
|
this.btnVETree_CSLA.TabIndex = 68;
|
||||||
|
this.btnVETree_CSLA.Text = "Load VETree from CSLA";
|
||||||
|
this.btnVETree_CSLA.UseVisualStyleBackColor = true;
|
||||||
|
this.btnVETree_CSLA.Click += new System.EventHandler(this.btnVETree_CSLA_Click);
|
||||||
|
//
|
||||||
|
// btnBrowseVesam
|
||||||
|
//
|
||||||
|
this.btnBrowseVesam.Location = new System.Drawing.Point(479, 150);
|
||||||
|
this.btnBrowseVesam.Margin = new System.Windows.Forms.Padding(2);
|
||||||
|
this.btnBrowseVesam.Name = "btnBrowseVesam";
|
||||||
|
this.btnBrowseVesam.Size = new System.Drawing.Size(119, 19);
|
||||||
|
this.btnBrowseVesam.TabIndex = 67;
|
||||||
|
this.btnBrowseVesam.Text = "Browse for Vesam...";
|
||||||
|
this.btnBrowseVesam.UseVisualStyleBackColor = true;
|
||||||
|
this.btnBrowseVesam.Click += new System.EventHandler(this.btnBrowseVesam_Click);
|
||||||
|
//
|
||||||
|
// tbVesamPath
|
||||||
|
//
|
||||||
|
this.tbVesamPath.Location = new System.Drawing.Point(114, 150);
|
||||||
|
this.tbVesamPath.Name = "tbVesamPath";
|
||||||
|
this.tbVesamPath.Size = new System.Drawing.Size(353, 20);
|
||||||
|
this.tbVesamPath.TabIndex = 66;
|
||||||
|
this.tbVesamPath.Text = "e:\\ve-proms\\vesam.opt";
|
||||||
|
//
|
||||||
|
// btnVesam
|
||||||
|
//
|
||||||
|
this.btnVesam.Location = new System.Drawing.Point(2, 148);
|
||||||
|
this.btnVesam.Name = "btnVesam";
|
||||||
|
this.btnVesam.Size = new System.Drawing.Size(108, 21);
|
||||||
|
this.btnVesam.TabIndex = 65;
|
||||||
|
this.btnVesam.Text = "Convert Security";
|
||||||
|
this.btnVesam.UseVisualStyleBackColor = true;
|
||||||
|
this.btnVesam.Click += new System.EventHandler(this.btnVesam_Click);
|
||||||
|
//
|
||||||
|
// btnLoadTreeCSLA
|
||||||
|
//
|
||||||
|
this.btnLoadTreeCSLA.Location = new System.Drawing.Point(295, 96);
|
||||||
|
this.btnLoadTreeCSLA.Name = "btnLoadTreeCSLA";
|
||||||
|
this.btnLoadTreeCSLA.Size = new System.Drawing.Size(144, 20);
|
||||||
|
this.btnLoadTreeCSLA.TabIndex = 64;
|
||||||
|
this.btnLoadTreeCSLA.Text = "Load Tree from CSLA";
|
||||||
|
this.btnLoadTreeCSLA.UseVisualStyleBackColor = true;
|
||||||
|
this.btnLoadTreeCSLA.Click += new System.EventHandler(this.btnLoadTreeCSLA_Click);
|
||||||
|
//
|
||||||
|
// cbLazy
|
||||||
|
//
|
||||||
|
this.cbLazy.AutoSize = true;
|
||||||
|
this.cbLazy.Checked = true;
|
||||||
|
this.cbLazy.CheckState = System.Windows.Forms.CheckState.Checked;
|
||||||
|
this.cbLazy.Location = new System.Drawing.Point(11, 126);
|
||||||
|
this.cbLazy.Margin = new System.Windows.Forms.Padding(2);
|
||||||
|
this.cbLazy.Name = "cbLazy";
|
||||||
|
this.cbLazy.Size = new System.Drawing.Size(75, 17);
|
||||||
|
this.cbLazy.TabIndex = 63;
|
||||||
|
this.cbLazy.Text = "Lazy Load";
|
||||||
|
this.cbLazy.UseVisualStyleBackColor = true;
|
||||||
|
//
|
||||||
|
// btnConvertSelected
|
||||||
|
//
|
||||||
|
this.btnConvertSelected.Location = new System.Drawing.Point(170, 97);
|
||||||
|
this.btnConvertSelected.Margin = new System.Windows.Forms.Padding(2);
|
||||||
|
this.btnConvertSelected.Name = "btnConvertSelected";
|
||||||
|
this.btnConvertSelected.Size = new System.Drawing.Size(108, 19);
|
||||||
|
this.btnConvertSelected.TabIndex = 62;
|
||||||
|
this.btnConvertSelected.Text = "Convert Selected";
|
||||||
|
this.btnConvertSelected.UseVisualStyleBackColor = true;
|
||||||
|
this.btnConvertSelected.Click += new System.EventHandler(this.btnConvertSelected_Click);
|
||||||
|
//
|
||||||
|
// btnLoadTreeDB
|
||||||
|
//
|
||||||
|
this.btnLoadTreeDB.Location = new System.Drawing.Point(450, 97);
|
||||||
|
this.btnLoadTreeDB.Margin = new System.Windows.Forms.Padding(2);
|
||||||
|
this.btnLoadTreeDB.Name = "btnLoadTreeDB";
|
||||||
|
this.btnLoadTreeDB.Size = new System.Drawing.Size(124, 19);
|
||||||
|
this.btnLoadTreeDB.TabIndex = 60;
|
||||||
|
this.btnLoadTreeDB.Text = "Load Tree from dBase";
|
||||||
|
this.btnLoadTreeDB.UseVisualStyleBackColor = true;
|
||||||
|
this.btnLoadTreeDB.Click += new System.EventHandler(this.btnLoadTreeDB_Click);
|
||||||
|
//
|
||||||
|
// cbPurgeData
|
||||||
|
//
|
||||||
|
this.cbPurgeData.AutoSize = true;
|
||||||
|
this.cbPurgeData.Checked = true;
|
||||||
|
this.cbPurgeData.CheckState = System.Windows.Forms.CheckState.Checked;
|
||||||
|
this.cbPurgeData.Location = new System.Drawing.Point(479, 75);
|
||||||
|
this.cbPurgeData.Margin = new System.Windows.Forms.Padding(2);
|
||||||
|
this.cbPurgeData.Name = "cbPurgeData";
|
||||||
|
this.cbPurgeData.Size = new System.Drawing.Size(119, 17);
|
||||||
|
this.cbPurgeData.TabIndex = 59;
|
||||||
|
this.cbPurgeData.Text = "Purge Existing Data";
|
||||||
|
this.cbPurgeData.UseVisualStyleBackColor = true;
|
||||||
|
//
|
||||||
|
// lblTime
|
||||||
|
//
|
||||||
|
this.lblTime.BackColor = System.Drawing.SystemColors.ButtonShadow;
|
||||||
|
this.lblTime.Location = new System.Drawing.Point(70, 92);
|
||||||
|
this.lblTime.Margin = new System.Windows.Forms.Padding(2, 0, 2, 0);
|
||||||
|
this.lblTime.Name = "lblTime";
|
||||||
|
this.lblTime.Size = new System.Drawing.Size(84, 20);
|
||||||
|
this.lblTime.TabIndex = 58;
|
||||||
|
//
|
||||||
|
// pbStep
|
||||||
|
//
|
||||||
|
this.pbStep.Location = new System.Drawing.Point(160, 76);
|
||||||
|
this.pbStep.Margin = new System.Windows.Forms.Padding(2);
|
||||||
|
this.pbStep.Name = "pbStep";
|
||||||
|
this.pbStep.Size = new System.Drawing.Size(308, 15);
|
||||||
|
this.pbStep.TabIndex = 57;
|
||||||
|
//
|
||||||
|
// pbSect
|
||||||
|
//
|
||||||
|
this.pbSect.Location = new System.Drawing.Point(160, 56);
|
||||||
|
this.pbSect.Margin = new System.Windows.Forms.Padding(2);
|
||||||
|
this.pbSect.Name = "pbSect";
|
||||||
|
this.pbSect.Size = new System.Drawing.Size(307, 15);
|
||||||
|
this.pbSect.TabIndex = 56;
|
||||||
|
//
|
||||||
|
// pbProc
|
||||||
|
//
|
||||||
|
this.pbProc.Location = new System.Drawing.Point(160, 37);
|
||||||
|
this.pbProc.Margin = new System.Windows.Forms.Padding(2);
|
||||||
|
this.pbProc.Name = "pbProc";
|
||||||
|
this.pbProc.Size = new System.Drawing.Size(308, 15);
|
||||||
|
this.pbProc.TabIndex = 55;
|
||||||
|
//
|
||||||
|
// cbSaveDoc
|
||||||
|
//
|
||||||
|
this.cbSaveDoc.AutoSize = true;
|
||||||
|
this.cbSaveDoc.Checked = true;
|
||||||
|
this.cbSaveDoc.CheckState = System.Windows.Forms.CheckState.Checked;
|
||||||
|
this.cbSaveDoc.Location = new System.Drawing.Point(480, 34);
|
||||||
|
this.cbSaveDoc.Margin = new System.Windows.Forms.Padding(2);
|
||||||
|
this.cbSaveDoc.Name = "cbSaveDoc";
|
||||||
|
this.cbSaveDoc.Size = new System.Drawing.Size(77, 17);
|
||||||
|
this.cbSaveDoc.TabIndex = 54;
|
||||||
|
this.cbSaveDoc.Text = "Save DOC";
|
||||||
|
this.cbSaveDoc.UseVisualStyleBackColor = true;
|
||||||
|
this.cbSaveDoc.Click += new System.EventHandler(this.cbSaveDoc_Click);
|
||||||
|
//
|
||||||
|
// cbSaveRTF
|
||||||
|
//
|
||||||
|
this.cbSaveRTF.AutoSize = true;
|
||||||
|
this.cbSaveRTF.Location = new System.Drawing.Point(480, 54);
|
||||||
|
this.cbSaveRTF.Margin = new System.Windows.Forms.Padding(2);
|
||||||
|
this.cbSaveRTF.Name = "cbSaveRTF";
|
||||||
|
this.cbSaveRTF.Size = new System.Drawing.Size(75, 17);
|
||||||
|
this.cbSaveRTF.TabIndex = 53;
|
||||||
|
this.cbSaveRTF.Text = "Save RTF";
|
||||||
|
this.cbSaveRTF.UseVisualStyleBackColor = true;
|
||||||
|
this.cbSaveRTF.Click += new System.EventHandler(this.cbSaveRTF_Click);
|
||||||
|
//
|
||||||
|
// btnBrowse
|
||||||
|
//
|
||||||
|
this.btnBrowse.Location = new System.Drawing.Point(479, 10);
|
||||||
|
this.btnBrowse.Margin = new System.Windows.Forms.Padding(2);
|
||||||
|
this.btnBrowse.Name = "btnBrowse";
|
||||||
|
this.btnBrowse.Size = new System.Drawing.Size(56, 19);
|
||||||
|
this.btnBrowse.TabIndex = 52;
|
||||||
|
this.btnBrowse.Text = "Browse...";
|
||||||
|
this.btnBrowse.UseVisualStyleBackColor = true;
|
||||||
|
this.btnBrowse.Click += new System.EventHandler(this.btnBrowse_Click);
|
||||||
|
//
|
||||||
|
// tbSource
|
||||||
|
//
|
||||||
|
this.tbSource.Location = new System.Drawing.Point(71, 10);
|
||||||
|
this.tbSource.Margin = new System.Windows.Forms.Padding(2);
|
||||||
|
this.tbSource.Name = "tbSource";
|
||||||
|
this.tbSource.Size = new System.Drawing.Size(397, 20);
|
||||||
|
this.tbSource.TabIndex = 51;
|
||||||
|
this.tbSource.Text = "i:\\vedata\\vewcnfp\\fp.prc";
|
||||||
|
//
|
||||||
|
// lblStep
|
||||||
|
//
|
||||||
|
this.lblStep.BackColor = System.Drawing.SystemColors.ButtonShadow;
|
||||||
|
this.lblStep.Location = new System.Drawing.Point(70, 72);
|
||||||
|
this.lblStep.Margin = new System.Windows.Forms.Padding(2, 0, 2, 0);
|
||||||
|
this.lblStep.Name = "lblStep";
|
||||||
|
this.lblStep.Size = new System.Drawing.Size(84, 20);
|
||||||
|
this.lblStep.TabIndex = 49;
|
||||||
|
//
|
||||||
|
// lblSection
|
||||||
|
//
|
||||||
|
this.lblSection.BackColor = System.Drawing.SystemColors.ButtonShadow;
|
||||||
|
this.lblSection.Location = new System.Drawing.Point(70, 53);
|
||||||
|
this.lblSection.Margin = new System.Windows.Forms.Padding(2, 0, 2, 0);
|
||||||
|
this.lblSection.Name = "lblSection";
|
||||||
|
this.lblSection.Size = new System.Drawing.Size(84, 19);
|
||||||
|
this.lblSection.TabIndex = 48;
|
||||||
|
//
|
||||||
|
// lblProc
|
||||||
|
//
|
||||||
|
this.lblProc.BackColor = System.Drawing.SystemColors.ButtonShadow;
|
||||||
|
this.lblProc.Location = new System.Drawing.Point(70, 34);
|
||||||
|
this.lblProc.Margin = new System.Windows.Forms.Padding(2, 0, 2, 0);
|
||||||
|
this.lblProc.Name = "lblProc";
|
||||||
|
this.lblProc.Size = new System.Drawing.Size(84, 19);
|
||||||
|
this.lblProc.TabIndex = 47;
|
||||||
|
//
|
||||||
|
// btnConvert
|
||||||
|
//
|
||||||
|
this.btnConvert.Location = new System.Drawing.Point(2, 9);
|
||||||
|
this.btnConvert.Margin = new System.Windows.Forms.Padding(2);
|
||||||
|
this.btnConvert.Name = "btnConvert";
|
||||||
|
this.btnConvert.Size = new System.Drawing.Size(56, 19);
|
||||||
|
this.btnConvert.TabIndex = 46;
|
||||||
|
this.btnConvert.Text = "Convert";
|
||||||
|
this.btnConvert.Click += new System.EventHandler(this.btnConvert_Click);
|
||||||
|
//
|
||||||
|
// tv
|
||||||
|
//
|
||||||
|
this.tv.CheckBoxes = true;
|
||||||
|
this.tv.Dock = System.Windows.Forms.DockStyle.Bottom;
|
||||||
|
this.tv.Location = new System.Drawing.Point(0, 1);
|
||||||
|
this.tv.Margin = new System.Windows.Forms.Padding(2);
|
||||||
|
this.tv.Name = "tv";
|
||||||
|
this.tv.Size = new System.Drawing.Size(623, 237);
|
||||||
|
this.tv.TabIndex = 24;
|
||||||
|
this.tv.BeforeExpand += new System.Windows.Forms.TreeViewCancelEventHandler(this.tv_BeforeExpand);
|
||||||
|
this.tv.AfterSelect += new System.Windows.Forms.TreeViewEventHandler(this.tv_AfterSelect);
|
||||||
|
//
|
||||||
|
// btnGroup
|
||||||
|
//
|
||||||
|
this.btnGroup.Location = new System.Drawing.Point(505, 118);
|
||||||
|
this.btnGroup.Name = "btnGroup";
|
||||||
|
this.btnGroup.Size = new System.Drawing.Size(75, 23);
|
||||||
|
this.btnGroup.TabIndex = 69;
|
||||||
|
this.btnGroup.Text = "Group";
|
||||||
|
this.btnGroup.UseVisualStyleBackColor = true;
|
||||||
|
this.btnGroup.Click += new System.EventHandler(this.btnGroup_Click);
|
||||||
|
//
|
||||||
|
// frmLoader
|
||||||
|
//
|
||||||
|
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
|
||||||
|
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||||
|
this.ClientSize = new System.Drawing.Size(623, 413);
|
||||||
|
this.Controls.Add(this.sc);
|
||||||
|
this.Margin = new System.Windows.Forms.Padding(2);
|
||||||
|
this.Name = "frmLoader";
|
||||||
|
this.Text = "frmLoader";
|
||||||
|
this.sc.Panel1.ResumeLayout(false);
|
||||||
|
this.sc.Panel1.PerformLayout();
|
||||||
|
this.sc.Panel2.ResumeLayout(false);
|
||||||
|
this.sc.ResumeLayout(false);
|
||||||
|
this.ResumeLayout(false);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
private System.Windows.Forms.SplitContainer sc;
|
||||||
|
private System.Windows.Forms.CheckBox cbLazy;
|
||||||
|
private System.Windows.Forms.Button btnConvertSelected;
|
||||||
|
private System.Windows.Forms.Button btnLoadTreeDB;
|
||||||
|
private System.Windows.Forms.CheckBox cbPurgeData;
|
||||||
|
private System.Windows.Forms.Label lblTime;
|
||||||
|
private System.Windows.Forms.ProgressBar pbStep;
|
||||||
|
private System.Windows.Forms.ProgressBar pbSect;
|
||||||
|
private System.Windows.Forms.ProgressBar pbProc;
|
||||||
|
private System.Windows.Forms.CheckBox cbSaveDoc;
|
||||||
|
private System.Windows.Forms.CheckBox cbSaveRTF;
|
||||||
|
private System.Windows.Forms.Button btnBrowse;
|
||||||
|
private System.Windows.Forms.TextBox tbSource;
|
||||||
|
private System.Windows.Forms.Label lblStep;
|
||||||
|
private System.Windows.Forms.Label lblSection;
|
||||||
|
private System.Windows.Forms.Label lblProc;
|
||||||
|
private System.Windows.Forms.Button btnConvert;
|
||||||
|
private System.Windows.Forms.TreeView tv;
|
||||||
|
private System.Windows.Forms.FolderBrowserDialog fbd;
|
||||||
|
private System.Windows.Forms.Button btnLoadTreeCSLA;
|
||||||
|
private System.Windows.Forms.TextBox tbVesamPath;
|
||||||
|
private System.Windows.Forms.Button btnVesam;
|
||||||
|
private System.Windows.Forms.Button btnBrowseVesam;
|
||||||
|
private System.Windows.Forms.Button btnVETree_CSLA;
|
||||||
|
private System.Windows.Forms.Button btnGroup;
|
||||||
|
}
|
||||||
|
}
|
416
PROMS/DataLoader/frmLoader.cs
Normal file
416
PROMS/DataLoader/frmLoader.cs
Normal file
@ -0,0 +1,416 @@
|
|||||||
|
// ========================================================================
|
||||||
|
// 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 Volian.CSLA.Library;
|
||||||
|
using Config;
|
||||||
|
|
||||||
|
[assembly: log4net.Config.XmlConfigurator(Watch = true)]
|
||||||
|
|
||||||
|
namespace DataLoader
|
||||||
|
{
|
||||||
|
public partial class frmLoader : Form
|
||||||
|
{
|
||||||
|
|
||||||
|
#region Log4Net
|
||||||
|
public static readonly log4net.ILog log = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
|
||||||
|
#endregion
|
||||||
|
#region ClassProperties
|
||||||
|
private int wms = 500;
|
||||||
|
private static int EDDATA = 0x01;
|
||||||
|
private static int PH = 0x02;
|
||||||
|
private static int TOC = 0x04;
|
||||||
|
private static int AUTOIND = 0x08;
|
||||||
|
private static int AUTOGEN = 0x40;
|
||||||
|
|
||||||
|
private static int STP_COMMENT = 0;
|
||||||
|
private static int STP_MULT_CHGID = 1;
|
||||||
|
private static int STP_LNK_SEQ = 2;
|
||||||
|
private static int STP_OVR_TAB = 3;
|
||||||
|
|
||||||
|
private string ProcFileName;
|
||||||
|
private string ProcNumber;
|
||||||
|
private ROFST rofst;
|
||||||
|
private int EditSectId;
|
||||||
|
private Dictionary<string, int> dicLibDocRef;
|
||||||
|
|
||||||
|
// have a few variables for storing the database id record & the system record.
|
||||||
|
private Connection dbConn;
|
||||||
|
private Folder sysFolder;
|
||||||
|
FolderTreeNode _topnode;
|
||||||
|
|
||||||
|
// the following two dictionaries are used to handle migration of the
|
||||||
|
// transitions... dicTrans_StrDone gets an entry for procnumber, sequence
|
||||||
|
// number and the new structure id as a step or section is created (transitions
|
||||||
|
// can go to steps or sections). When a transition is encountered, check this
|
||||||
|
// dictionary to see if the step or section was migrated & use the structureid
|
||||||
|
// for the step or section if it was migrated. When a transition is migrated where
|
||||||
|
// the 'to' has not been migrated yet, check if an entry exists in dicTrans_StrIds,
|
||||||
|
// if so, use the id listed here. If no entry exists in dicTrans_StrIds, create
|
||||||
|
// a structure table record and use the id as part of the 'to', and add an entry to
|
||||||
|
// dicTrans_StpIds to flag that the record was already created. As migrating sections
|
||||||
|
// and steps, check this dicTrans_StrIds to see if the structure record has already
|
||||||
|
// been create, if so use it and remove it from the dicTrans_StrIds dictionary,
|
||||||
|
// otherwise, create a new structure record.
|
||||||
|
private Dictionary<string, int> dicTrans_StrDone;
|
||||||
|
private Dictionary<string, int> dicTrans_StrIds;
|
||||||
|
private Dictionary<object, string> dicOldStepSequence;
|
||||||
|
private Dictionary<TreeNode, TreeNode> dicNeedToLoad;
|
||||||
|
private bool UseVeTree = false;
|
||||||
|
#endregion
|
||||||
|
public frmLoader()
|
||||||
|
{
|
||||||
|
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";// 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;
|
||||||
|
default:
|
||||||
|
throw new Exception("Not configured for " + SystemInformation.ComputerName);
|
||||||
|
}
|
||||||
|
dicNeedToLoad = new Dictionary<TreeNode, TreeNode>();
|
||||||
|
}
|
||||||
|
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;
|
||||||
|
//object o = tn.Tag;
|
||||||
|
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();
|
||||||
|
int istr = MigrateDocVersion(v.Title);
|
||||||
|
if (istr > 0)
|
||||||
|
{
|
||||||
|
|
||||||
|
v.StructureID = istr;
|
||||||
|
v.Title = "";
|
||||||
|
v.Save(true); // true forces save.
|
||||||
|
tn.Checked = true;
|
||||||
|
//TODO: Walk up structure and set check boxes appropriately.
|
||||||
|
}
|
||||||
|
}
|
||||||
|
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;
|
||||||
|
int istr = MigrateDocVersion(v.Title);
|
||||||
|
if (istr > 0)
|
||||||
|
{
|
||||||
|
|
||||||
|
v.StructureID = istr;
|
||||||
|
v.Title = "";
|
||||||
|
v.Save(true); // true forces save.
|
||||||
|
tn.Checked = true;
|
||||||
|
//TODO: Walk up structure and set check boxes appropriately.
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
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.DocVersionCount>0)
|
||||||
|
tn.Checked = 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 bool LoadFolders()
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
// make the initial database connection record
|
||||||
|
dbConn = Connection.MakeConnection("Default", "Default", "Data Source=.\\SQLEXPRESS;Initial Catalog=VEPROMS;Integrated Security=True", 1, null);
|
||||||
|
ConfigFile cfg = new ConfigFile();
|
||||||
|
|
||||||
|
|
||||||
|
XmlDocument d = cfg.LoadSystemIni();
|
||||||
|
sysFolder = Folder.MakeFolder(0, dbConn.DBID, "system", "system", d.InnerXml);
|
||||||
|
|
||||||
|
// This is to test the vln Libraries
|
||||||
|
List<Folder> lfldr = vlnDataPathFolders();
|
||||||
|
|
||||||
|
List<vlnObject> dp2 = new List<vlnObject>();
|
||||||
|
foreach (Folder fldr in lfldr)
|
||||||
|
{
|
||||||
|
TreeNode tn = tv.Nodes.Add(fldr.Name);
|
||||||
|
tn.Tag = fldr;
|
||||||
|
vlnObject vb = new vlnObject(null, "datapath", fldr.Name, fldr.Title);
|
||||||
|
dp2.Add(vb);
|
||||||
|
vlnServer vs = new vlnServer();
|
||||||
|
MigrateChildren(vb, vs, fldr.DBID, fldr.FolderID, tn);
|
||||||
|
tn.Expand();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
log.ErrorFormat("Could not load data, error = {0}", ex.Message);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
private void btnLoadTreeDB_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
// When loading folders, i.e. the tree from dBase (old 16-bit)
|
||||||
|
// always clear the data
|
||||||
|
ClearData();
|
||||||
|
bool suc = LoadFolders();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void btnConvert_Click(object sender, System.EventArgs e)
|
||||||
|
{
|
||||||
|
bool success = true;
|
||||||
|
// if purge data, purge it all & reload folders & security.
|
||||||
|
if (cbPurgeData.Checked)
|
||||||
|
{
|
||||||
|
ClearData();
|
||||||
|
success=LoadFolders();
|
||||||
|
if (success)success=LoadSecurity();
|
||||||
|
}
|
||||||
|
if (success) MigrateDocVersion(tbSource.Text);
|
||||||
|
}
|
||||||
|
private 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)
|
||||||
|
{
|
||||||
|
log.ErrorFormat("{0}\r\n\r\n{1}", ex.Message, ex.InnerException);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
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 Wait(int n)
|
||||||
|
{
|
||||||
|
DateTime dtw = DateTime.Now.AddSeconds(n);
|
||||||
|
while (DateTime.Now < dtw)
|
||||||
|
{
|
||||||
|
Application.DoEvents();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
private void WaitMS(int n)
|
||||||
|
{
|
||||||
|
DateTime dtw = DateTime.Now.AddMilliseconds(n);
|
||||||
|
while (DateTime.Now < dtw)
|
||||||
|
{
|
||||||
|
Application.DoEvents();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
private void ClearData()
|
||||||
|
{
|
||||||
|
Database.PurgeData();
|
||||||
|
}
|
||||||
|
public static string MakeDate(string src)
|
||||||
|
{
|
||||||
|
if (src.Trim() == "") return null;
|
||||||
|
int[] DateOffset ={ 4, 5, 47, 6, 7, 47, 0, 1, 2, 3 }; // 47 = '/'
|
||||||
|
StringBuilder datebuff = new StringBuilder(10);
|
||||||
|
for (int i = 0; i < DateOffset.Length; i++)
|
||||||
|
{
|
||||||
|
if (DateOffset[i] < 9)
|
||||||
|
datebuff.Append(src[DateOffset[i]]);
|
||||||
|
else
|
||||||
|
datebuff.Append(System.Convert.ToChar(DateOffset[i]));
|
||||||
|
}
|
||||||
|
return datebuff.ToString();
|
||||||
|
}
|
||||||
|
private DateTime GetDTS(string date, string time)
|
||||||
|
{
|
||||||
|
// Set the date/time stamp. If there is no 'date', set the date
|
||||||
|
// to 1/1/2000 (this can be changed!). If there is not 'time',
|
||||||
|
// set the time to 0:0:0 (midnight).
|
||||||
|
|
||||||
|
DateTime dts = DateTime.Now;
|
||||||
|
string month = "01";
|
||||||
|
string day = "01";
|
||||||
|
string year = "2000";
|
||||||
|
string hour = "";
|
||||||
|
string minute = "";
|
||||||
|
try
|
||||||
|
{
|
||||||
|
if (date != null && date != "")
|
||||||
|
{
|
||||||
|
int indx1 = date.IndexOf("/");
|
||||||
|
month = date.Substring(0, indx1);
|
||||||
|
int indx2 = date.IndexOf("/", indx1 + 1);
|
||||||
|
day = date.Substring(indx1 + 1, indx2 - indx1 - 1);
|
||||||
|
year = date.Substring(indx2 + 1, 4);
|
||||||
|
}
|
||||||
|
if (time == null || time == "")
|
||||||
|
{
|
||||||
|
hour = "0";
|
||||||
|
minute = "0";
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
|
||||||
|
hour = time.Substring(0, 2);
|
||||||
|
int indxc = time.IndexOfAny(":A-".ToCharArray());
|
||||||
|
if (indxc == time.Length - 1)
|
||||||
|
minute = time.Substring(2, 2);
|
||||||
|
else
|
||||||
|
minute = time.Substring(indxc + 1, time.Length - indxc - 1);
|
||||||
|
}
|
||||||
|
dts = new DateTime(System.Convert.ToInt32(year), System.Convert.ToInt32(month), System.Convert.ToInt32(day),
|
||||||
|
System.Convert.ToInt32(hour), System.Convert.ToInt32(minute), 0);
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
log.ErrorFormat("DATE/TIME {0} {1}", date, time);
|
||||||
|
log.ErrorFormat("{0}\r\n\r\n{1}", ex.Message, ex.InnerException);
|
||||||
|
log.ErrorFormat(ex.StackTrace);
|
||||||
|
return dts;
|
||||||
|
}
|
||||||
|
return dts;
|
||||||
|
}
|
||||||
|
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 bool LoadSecurity()
|
||||||
|
{
|
||||||
|
Security sec = new Security(tbVesamPath.Text);
|
||||||
|
return sec.Migrate();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void btnVesam_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
// if purge data, purge it all & reload folders.
|
||||||
|
if (cbPurgeData.Checked)
|
||||||
|
{
|
||||||
|
ClearData();
|
||||||
|
LoadFolders();
|
||||||
|
}
|
||||||
|
bool sec = LoadSecurity();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void btnVETree_CSLA_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
tv.Nodes.Add(VEFolder.LoadTree());
|
||||||
|
UseVeTree = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void btnGroup_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
GroupProp f = new GroupProp();
|
||||||
|
f.ShowDialog();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
123
PROMS/DataLoader/frmLoader.resx
Normal file
123
PROMS/DataLoader/frmLoader.resx
Normal file
@ -0,0 +1,123 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<root>
|
||||||
|
<!--
|
||||||
|
Microsoft ResX Schema
|
||||||
|
|
||||||
|
Version 2.0
|
||||||
|
|
||||||
|
The primary goals of this format is to allow a simple XML format
|
||||||
|
that is mostly human readable. The generation and parsing of the
|
||||||
|
various data types are done through the TypeConverter classes
|
||||||
|
associated with the data types.
|
||||||
|
|
||||||
|
Example:
|
||||||
|
|
||||||
|
... ado.net/XML headers & schema ...
|
||||||
|
<resheader name="resmimetype">text/microsoft-resx</resheader>
|
||||||
|
<resheader name="version">2.0</resheader>
|
||||||
|
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
|
||||||
|
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
|
||||||
|
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
|
||||||
|
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
|
||||||
|
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
|
||||||
|
<value>[base64 mime encoded serialized .NET Framework object]</value>
|
||||||
|
</data>
|
||||||
|
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
|
||||||
|
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
|
||||||
|
<comment>This is a comment</comment>
|
||||||
|
</data>
|
||||||
|
|
||||||
|
There are any number of "resheader" rows that contain simple
|
||||||
|
name/value pairs.
|
||||||
|
|
||||||
|
Each data row contains a name, and value. The row also contains a
|
||||||
|
type or mimetype. Type corresponds to a .NET class that support
|
||||||
|
text/value conversion through the TypeConverter architecture.
|
||||||
|
Classes that don't support this are serialized and stored with the
|
||||||
|
mimetype set.
|
||||||
|
|
||||||
|
The mimetype is used for serialized objects, and tells the
|
||||||
|
ResXResourceReader how to depersist the object. This is currently not
|
||||||
|
extensible. For a given mimetype the value must be set accordingly:
|
||||||
|
|
||||||
|
Note - application/x-microsoft.net.object.binary.base64 is the format
|
||||||
|
that the ResXResourceWriter will generate, however the reader can
|
||||||
|
read any of the formats listed below.
|
||||||
|
|
||||||
|
mimetype: application/x-microsoft.net.object.binary.base64
|
||||||
|
value : The object must be serialized with
|
||||||
|
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
|
||||||
|
: and then encoded with base64 encoding.
|
||||||
|
|
||||||
|
mimetype: application/x-microsoft.net.object.soap.base64
|
||||||
|
value : The object must be serialized with
|
||||||
|
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
|
||||||
|
: and then encoded with base64 encoding.
|
||||||
|
|
||||||
|
mimetype: application/x-microsoft.net.object.bytearray.base64
|
||||||
|
value : The object must be serialized into a byte array
|
||||||
|
: using a System.ComponentModel.TypeConverter
|
||||||
|
: and then encoded with base64 encoding.
|
||||||
|
-->
|
||||||
|
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
|
||||||
|
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
|
||||||
|
<xsd:element name="root" msdata:IsDataSet="true">
|
||||||
|
<xsd:complexType>
|
||||||
|
<xsd:choice maxOccurs="unbounded">
|
||||||
|
<xsd:element name="metadata">
|
||||||
|
<xsd:complexType>
|
||||||
|
<xsd:sequence>
|
||||||
|
<xsd:element name="value" type="xsd:string" minOccurs="0" />
|
||||||
|
</xsd:sequence>
|
||||||
|
<xsd:attribute name="name" use="required" type="xsd:string" />
|
||||||
|
<xsd:attribute name="type" type="xsd:string" />
|
||||||
|
<xsd:attribute name="mimetype" type="xsd:string" />
|
||||||
|
<xsd:attribute ref="xml:space" />
|
||||||
|
</xsd:complexType>
|
||||||
|
</xsd:element>
|
||||||
|
<xsd:element name="assembly">
|
||||||
|
<xsd:complexType>
|
||||||
|
<xsd:attribute name="alias" type="xsd:string" />
|
||||||
|
<xsd:attribute name="name" type="xsd:string" />
|
||||||
|
</xsd:complexType>
|
||||||
|
</xsd:element>
|
||||||
|
<xsd:element name="data">
|
||||||
|
<xsd:complexType>
|
||||||
|
<xsd:sequence>
|
||||||
|
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||||
|
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
|
||||||
|
</xsd:sequence>
|
||||||
|
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
|
||||||
|
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
|
||||||
|
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
|
||||||
|
<xsd:attribute ref="xml:space" />
|
||||||
|
</xsd:complexType>
|
||||||
|
</xsd:element>
|
||||||
|
<xsd:element name="resheader">
|
||||||
|
<xsd:complexType>
|
||||||
|
<xsd:sequence>
|
||||||
|
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||||
|
</xsd:sequence>
|
||||||
|
<xsd:attribute name="name" type="xsd:string" use="required" />
|
||||||
|
</xsd:complexType>
|
||||||
|
</xsd:element>
|
||||||
|
</xsd:choice>
|
||||||
|
</xsd:complexType>
|
||||||
|
</xsd:element>
|
||||||
|
</xsd:schema>
|
||||||
|
<resheader name="resmimetype">
|
||||||
|
<value>text/microsoft-resx</value>
|
||||||
|
</resheader>
|
||||||
|
<resheader name="version">
|
||||||
|
<value>2.0</value>
|
||||||
|
</resheader>
|
||||||
|
<resheader name="reader">
|
||||||
|
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||||
|
</resheader>
|
||||||
|
<resheader name="writer">
|
||||||
|
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||||
|
</resheader>
|
||||||
|
<metadata name="fbd.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
|
||||||
|
<value>17, 17</value>
|
||||||
|
</metadata>
|
||||||
|
</root>
|
Loading…
x
Reference in New Issue
Block a user