This commit is contained in:
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;
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user