473,739 Members | 3,381 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Xml Serialization Error

ron
Hi,
I have class object that i serialize using the
System.Xml.Seri alization class.

Intermittently the object is not getting serialized
correctly, using System.Xml.Seri alization classes.
Therefore the application errors out when deserializing
the xml data.

It places the some part of the child element

<MyRootElemen t>
<SomeOtherEleme nt>
</SomeOtherElemen t>
</MyRootElement>e ment> --- This gets added to the end of
the root element name.

What would be causing this.

Ron Good
Nov 15 '05 #1
4 2328
Ron,

Without seeing some code, it would be difficult to tell. Generally
speaking, I can't imagine that it would do this on it's own, and if it does,
it needs to be reported as a bug.

Can you post your code that is serializing this, as well as the code for
the class that is being serialized?
--
- Nicholas Paldino [.NET/C# MVP]
- ni************* *@exisconsultin g.com

"ron" <goodr@no_spam4 me_mddm.panason ic.com> wrote in message
news:57******** *************** *****@phx.gbl.. .
Hi,
I have class object that i serialize using the
System.Xml.Seri alization class.

Intermittently the object is not getting serialized
correctly, using System.Xml.Seri alization classes.
Therefore the application errors out when deserializing
the xml data.

It places the some part of the child element

<MyRootElemen t>
<SomeOtherEleme nt>
</SomeOtherElemen t>
</MyRootElement>e ment> --- This gets added to the end of
the root element name.

What would be causing this.

Ron Good

Nov 15 '05 #2
ron
Nicholas,

The first part is the Base class
The second part is the one calling the Serializer from
the base.

using System;
using System.Data;
using System.Data.Sql Client;
using System.Configur ation;
using System.IO;
using System.Text;
using FDS.SmartCalend ar;
using FDS.Data.Core;
using System.Diagnost ics;
using System.Xml.Seri alization;

namespace FDS.DataCollect ionServer.DataP rocessing
{
/// <summary>
/// Summary description for DataProcess.
/// </summary>
public abstract class DataProcess : DbObject
{
private int lineId;
private static string fileName = null;
private static DateTime
previousProduct ionDate;
private static bool newcycle;
private static int tubeNumber;
private static int totRejects;

protected static ShiftCalendar.C alendar
cal = new ShiftCalendar.C alendar();

/// <summary>
///
/// </summary>
/// <param
name="newConnec tionString"></param>
public DataProcess(str ing
newConnectionSt ring) : base(newConnect ionString)
{
previousProduct ionDate =
DateTime.Now;
}

/// <summary>
/// Set the public fields to supply
settings to DataProcess.
/// </summary>
[Serializable]
public class ProcessedSettin gs
{
public int LastTubeNumber =
tubeNumber;
public string RawDataFile =
fileName;
public DateTime
LastProductionD ate = previousProduct ionDate;

/// <summary>
/// Save the object in XML format
to a stream
/// </summary>
/// <param name="s">Stream to
save the object to</param>
public void SaveAsXML(Strea m s)
{
XmlSerializer sr = new
XmlSerializer(t his.GetType());
sr.Serialize(s, this);
}

/// <summary>
/// Create a new
ProcessedSettin gs object initialised from XML data
/// </summary>
/// <param name="s">Stream to
load the XML from</param>
/// <returns>Proces sedSettings
object</returns>
public static ProcessedSettin gs
LoadFromXML(Str eam s)
{
return LoadFromXML(s,
typeof(Processe dSettings));
}

/// <summary>
/// Create a new object loading
members from the stream in XML format.
/// Derived class should call
this from a static method i.e.:
/// return
(ProcessedDeriv edSettings)Load FromXML(s, typeof
(ProcessedDeriv edSettings));
/// </summary>
/// <param name="s">Stream to
load the object from</param>
/// <param name="t">Type of the
derived object</param>
/// <returns></returns>
protected static
ProcessedSettin gs LoadFromXML(Str eam s, Type t)
{
XmlSerializer sr = new
XmlSerializer(t );
try
{
return
(ProcessedSetti ngs)sr.Deserial ize(s);
}
catch(Exception e)
{
string
errorMessage = "";

errorMessage
= "Message: " + e.Message + "\n";
EventLog log =
new EventLog();
log.Source
= "DCServer";
log.WriteEntry
(errorMessage);
return null;
}
}

}

#region "Properties ..."

public int TubeNumber{get{ return
tubeNumber;}set {tubeNumber = value;}}

public int TotalRejects{ge t{return
totRejects;}set {totRejects = value;}}

public string FileName{get{re turn
fileName;}set{f ileName = value;}}

public int LineId{get{retu rn lineId;}set
{lineId = value;}}

public DateTime PreviousProduct ionDate{get
{return previousProduct ionDate;}set
{previousProduc tionDate = value;}}

public bool IsNewProduction Cycle{get
{return newcycle;}set{n ewcycle = value;}}

#endregion

public void GetShift()
{
cal.CurrentShif t(LineId);
}

public void GetNewFileName( )
{
// The name uses day,month,year
conjoined to establish the file name.
// example file
name="raw_01172 003.txt
fileName = "raw_";
// strip slashes
string[] dateValues =
cal.ProductionD ate.Split('/');
for(int i = 0; i <
dateValues.Leng th; i++)
{
fileName += dateValues[i];
}
fileName += ".txt";

}

protected void CheckShiftStatu s()
{
// End of current shift get new
shift
if(DateTime.Now > cal.EndShift)
{
GetShift();
// Look for new
prodcution cycle if 2 or 4 shift type configuration
if((cal.ShiftTy pe != "3-
Shift") & (cal.Shift == "A" | cal.Shift == "C"))
ProductionCycle Reset();
// Look for new
prodcution cycle if 3 shift type configuration
if((cal.ShiftTy pe == "3-
Shift") & (cal.Shift == "A"))Production CycleReset();
}
else
{
// System may have been
shut down for more than 24 hr
// Look to see if system
was shut down
if(DateTime.Par se
(cal.Production Date) > PreviousProduct ionDate)
ProductionCycle Reset();
// Look for no file name
if(fileName == null)
ProductionCycle Reset();
}

// increment tube after checking
shift status
tubeNumber++;
TubeNumber = tubeNumber;
}

private void ProductionCycle Reset()
{
GetNewFileName( );
FileName = fileName;
PreviousProduct ionDate =
DateTime.Parse( cal.ProductionD ate);
tubeNumber = 0;
totRejects = 0;
newcycle = true;
}

public abstract void Process(string[]
dmData, string[] frameCheckSum);

public abstract void LoadSettings();

public abstract void SaveSettings();
}

}

+++++++++++++++ +++++++++++++++ +++++++++++++++ ++++++++
Second Part
+++++++++++++++ +++++++++++++++ +++++++++++++++ ++++++++

using System;
using System.Data;
using System.Data.Sql Client;
using System.Configur ation;
using System.IO;
using System.Text;
using FDS.SmartCalend ar;
using System.Globaliz ation;
using System.Diagnost ics;
using System.Xml.Seri alization;

namespace FDS.DataCollect ionServer.DataP rocessing
{
/// <summary>
/// Summary description for DataProcessTest ing.
/// </summary>
public class DataProcessTest ing : DataProcess
{
// Internal fields
DateTime testDate;
string[] fcs = new string[2];
string[] dmArray;
int[] judgements = new int[7];
bool[] online = new bool[7];
bool[] decisions = new bool[144];
static int[] defects = new int[36];
static int[][] palletdefect = new int[21]
[];
static int[] palletrevolutio n = new int
[21];
static int[][] hourlyCount = new int[24]
[];
string testResult = null;
string troubleFlag = null;
bool isTestPiece;
bool isReject;
bool isNoTest;
bool isGO;
bool nowork;
int testType;
int records;
int palletnumber;
string[] tallyItem =
{"Virgin", "Reage", "Respark", "Gross", "No Test",

"Screen", "Mask", "Ba", "Purity", "Gun Rotation",

"Insulation ", "Vkco", "Igas", "Ki", "Emission", "S
lump",

"Ig2", "Ig3", "Stray", "Visual G3", "Visual
G2", "Others",
"Test
Piece", "Total"};

public static DataProcessTest ingSettings
settings;
string fSettings = @"settings.xml" ;

#region Properties ...

protected bool IsNoWork{get{re turn
nowork;}set{now ork = value;}}

protected bool DecisionIsNoTes t{get
{return isNoTest;}set{i sNoTest = value;}}

protected bool DecisionIsRejec t{get
{return isReject;}set{i sReject = value;}}

protected bool DecisionIsGo{ge t{return
isGO;}set{isGO = value;}}

protected string TestResult{get{ return
testResult;}}

protected bool IsTestPiece{get {return
isTestPiece;}}

protected string TroubleFlag{get {return
troubleFlag;}se t{troubleFlag = value;}}

protected int TestType{get{re turn
testType;}set{t estType = value;}}

protected int[] Judgements{get{ return
judgements;}}

protected bool[] TestOnline{get{ return
online;}}

protected bool[] Decisions{get{r eturn
decisions;}}

protected int PalletNumber{ge t{return
palletnumber;}s et{palletnumber = value;}}

#endregion

protected enum DecimalLocation
{
Tenths,
Hundredths,
None
}

protected enum HexToBinType
{
Decision,
Flag
}

protected enum Type
{
Virgin = 0,
Reage = 1,
Respark = 2,
};

public DataProcessTest ing(string
newConnectionSt ring) : base(newConnect ionString)
{
for(int i=0;
i<palletdefect. Length; i++)
{
palletdefect[i] = new int
[16];
}

for(int i=0;
i<hourlyCount.L ength; i++)
{
hourlyCount[i] = new int
[24];
}
}
/// <summary>
/// Extends ProcessedSettin gs to add the
settings used by DataProcessTest ingSettings.
/// </summary>
[Serializable]
public class DataProcessTest ingSettings :
DataProcess.Pro cessedSettings
{
public int[] PalletRevolutio ns =
palletrevolutio n;
public int[][] PalletDefects =
palletdefect;
public int[][] HourlyCounts =
hourlyCount;
public int[] Defects = defects;

public static new
DataProcessTest ingSettings LoadFromXML(Str eam s)
{
return
(DataProcessTes tingSettings)Lo adFromXML(s, typeof
(DataProcessTes tingSettings));
}
}

public override void LoadSettings()
{

FileInfo f = new FileInfo
(fSettings);
if(f.Exists)
{
Stream fs = f.OpenRead();
try
{
settings =
DataProcessTest ingSettings.Loa dFromXML(fs);
}
catch(Exception e)
{
string
errorMessage = "";

errorMessage
= "Message: " + e.Message + "\n";
EventLog log =
new EventLog();
log.Source
= "DCServer";
log.WriteEntry
(errorMessage);
}
fs.Close();
base.TubeNumber =
settings.LastTu beNumber;
base.FileName =
settings.RawDat aFile;

base.PreviousPr oductionDate =
settings.LastPr oductionDate;
}
else
{
// File dose not exist
use default settings
settings = new
DataProcessTest ingSettings();
}
}
public override void SaveSettings()
{

settings = new
DataProcessTest ingSettings();

settings.LastTu beNumber =
base.TubeNumber ;
settings.RawDat aFile =
base.FileName;
settings.LastPr oductionDate =
base.PreviousPr oductionDate;
settings.Pallet Revolutions =
palletrevolutio n;
settings.Pallet Defects =
palletdefect;
settings.Hourly Counts =
hourlyCount;
settings.Defect s = defects;

FileInfo f = new FileInfo
(fSettings);
Stream fs = f.OpenWrite();
settings.SaveAs XML(fs);
fs.Close();

}
public override void Process(string[]
dmData, string[] frameCheckSum)
{
// Create defualt values before
processing data string
testDate = DateTime.Now;
int hr = testDate.Hour;
string rawData = null;
// DecisionIsNoTes t = false;
// DecisionIsRejec t = false;
// DecisionIsGo = false;

// Create a string array of the
PLC DM data to work with
dmArray = new string
[dmData.Length];
dmArray = dmData;
fcs = frameCheckSum;

// Look for work status
IsNoWork = GetWorkStatus() ;

// Check to see if we need to
process for work,
// terminate execution of the
method and return control to the calling method.
if(IsNoWork)
{
//return control to the
calling method
return;
}
else
{
// OK Pallet has work so
lets get to work.
// Check the shift status.
base.CheckShift Status();
// Check for new
production cycle and reset count's
if
(base.IsNewProd uctionCycle)Res et();

// Get the pallet number
PalletNumber =
GetPalletNumber (dmArray[120]);
// Check the Pallet
Number and make sure it is not "0"
// if it is then return
control to the calling method recived incorrect pallet
number
if(PalletNumber == 0)
return;
palletrevolutio n
[PalletNumber]++;

// Get all test
position's on-line status
CheckOnlineStat us();

// Convert all decision
bit's from hex to binary
dmArray[0] =
ConvertHexToBin (dmArray[0], HexToBinType.De cision);
dmArray[20] =
ConvertHexToBin (dmArray[20], HexToBinType.De cision);
dmArray[40] =
ConvertHexToBin (dmArray[40], HexToBinType.De cision);
dmArray[60] =
ConvertHexToBin (dmArray[60], HexToBinType.De cision);
dmArray[80] =
ConvertHexToBin (dmArray[80], HexToBinType.De cision);
dmArray[100] =
ConvertHexToBin (dmArray[100], HexToBinType.De cision);
dmArray[101] =
ConvertHexToBin (dmArray[101], HexToBinType.De cision);
dmArray[112] =
ConvertHexToBin (dmArray[112], HexToBinType.De cision);
dmArray[113] =
ConvertHexToBin (dmArray[113], HexToBinType.De cision);
// Concatenate all the
test positions decision bits
string decisionbits =
dmArray[0] + dmArray[20] + dmArray[40] + dmArray[60] +
dmArray[80] + dmArray[100] + dmArray[101] + dmArray[112]
+ dmArray[113];

// Check all test
position's decision bits
CheckDecisions
(decisionbits);

// Convert the test and
tracking flags
dmArray[121] =
ConvertHexToBin (dmArray[121], HexToBinType.Fl ag);
dmArray[122] =
ConvertHexToBin (dmArray[122], HexToBinType.Fl ag);

// Get all test position
judgement's
GetJudgements() ;

// Set Trouble Flag
TroubleFlag =
GetTroubleFlag( );

// Get the test type
(virgin,reage,r espark) and count for each type
TestType = GetTestType();

// Get the final test
decision
GetFinalDecisio n();

// Calculate defects only
if test is a reject and virgin.
if(this.Decisio nIsReject
& this.TestType == 0)
{

base.TotalRejec ts++;
CalculateDefect s
();
}

// Calculate pallet
defects only if test is virgin.
if(this.TestTyp e == 0)
CalculatePallet Defects();

// Calculate hourly counts

CalculateHourly Counts();

// Calculate all test
values that need signed value's and decimal location's.
CalculateTestVa lues();

// Create a csv file
format to save as the raw data file
rawData =
TubeNumber.ToSt ring() + "," + cal.Shift + "," +
cal.ShiftType + ",";
rawData +=
testDate.ToStri ng("HH:mm:ss") + "," + cal.ProductionD ate
+ ",";
rawData +=
testDate.Hour.T oString() + "," + this.TestResult + ",";
for(int i = 0; i<
dmArray.Length; i++)
{
rawData += dmArray
[i] + ",";
}
rawData += fcs[0] + "," +
fcs[1];

Console.WriteLi ne
(rawData);
Console.WriteLi ne();

// Save raw data to text
file on local machine.
//SaveRawDataFile
(rawData);

// Insert new DM data to
the database
//records = InsertDMData
();
//records = InsertDefects
();
//records =
InsertPalletDet ails();
//records =
InsertHourlyCou nts();
}

}
protected void Reset()
{
base.IsNewProdu ctionCycle = false;
// Sets all elements in the
Array's to zero, to false,
// or to a null reference,
depending on the element type.
Array.Clear(pal letrevolution, 0,
palletrevolutio n.Length);
Array.Clear(def ects, 0,
defects.Length) ;

foreach(int[] subArray in
palletdefect)
{
Array.Clear(sub Array, 0,
subArray.Length );
}

foreach(int[] subArray in
hourlyCount)
{
Array.Clear (subArray, 0,
subArray.Length );
}
}

// Check the online status of all test
positions to see if the pallet has work.
protected bool GetWorkStatus()
{
return (((dmArray[3] == "0000") &
(dmArray[23] == "0000") & (dmArray[43] == "0000") &
(dmArray[63] == "0000") & (dmArray[83] == "0000") &
(dmArray[103] == "0000")) == true)? true : false;
}
protected void CheckOnlineStat us()
{
int j = 0;
try
{
for(int i=3; i<=103;
i+=20)
{
online[j] = (0x1
== int.Parse(dmArr ay[i].Substring(3,1) ,
NumberStyles.He xNumber))? true : false;
j++;
}
// Establish test sevens
status by looking at the test flag and tracking flag bits
online[6] = ((0x8 ==
int.Parse(dmArr ay[121].Substring
(3,1),NumberSty les.HexNumber)) ||
(0x8 == int.Parse
(dmArray[122].Substring(3,1) ,NumberStyles.H exNumber)))?
true : false;
}
catch(Exception e)
{
string errorMessage = "";

errorMessage
= "Message: " + e.Message + "\n";
EventLog log = new
EventLog();
log.Source = "DCServer";
log.WriteEntry
(errorMessage);
}
}
protected void GetJudgements()
{
int j = 0;
try
{
// Check test position's
1-5 judgement.
for(int i=4; i<84; i+=20)
{
judgements[j] =
int.Parse(dmArr ay[i]);
j++;
}

// Check on-line status
of test positions 6 and 7
// preform judgement
logic accordingly.
if((TestOnline[5]) &
(TestOnline[6]))
{
// Look at
tracking and test flags for no-test condition.
if(dmArray
[121].Substring(5,1) == "1" & dmArray[122].Substring(5,1)
== "0") // no-test condition
{
judgements
[5] = 2;
}
else if(dmArray
[121].Substring(5,1) == "1" & dmArray[122].Substring(5,1)
== "1") // tested condition
{
// Check
test position 6 judgement.
judgements
[5] = (0 != Convert.ToInt32 (dmArray[113], 2))? 1 : 0;
}
else
{
// Gets
the defualt test condition
judgements
[5] = int.Parse(dmArr ay[104]);
}

// Check test
position 7 judgement
// Look at
tracking and test flags for no-test condition.
if(dmArray
[121].Substring(6,1) == "1" & dmArray[122].Substring(6,1)
== "0")
{
// Test
flags indicate no-test condition
judgements
[6] = 2;
}
else
{
// Gets
the defualt test condition
judgements
[6] = int.Parse(dmArr ay[104]);
}
}
else if((TestOnline[5] ==
true) & (TestOnline[6] == false))
{
// Test 7 is off
line get the defualt test condition
judgements[5] =
int.Parse(dmArr ay[104]);
}
else if((TestOnline[5] ==
false) & (TestOnline[6] == true))
{
// Test 6 is off
line get the defualt test condition
judgements[6] =
int.Parse(dmArr ay[104]);
}
}
catch(Exception e)
{
string errorMessage = "";

errorMessage
= "Message: " + e.Message + "\n";
EventLog log = new
EventLog();
log.Source = "DCServer";
log.WriteEntry
(errorMessage);
}
}
protected int GetTestType()
{
// Set default type to virgin
int type = 0;
try
{
if((dmArray[148]
== "0000") & (dmArray[149] == "0000")) // virgin
{
type = (int)
Type.Virgin;
}
else if(dmArray[148]
== "0001")
// reage
{
type = (int)
Type.Reage;
}
else if(dmArray[149]
== "0001")
// respark
{
type = (int)
Type.Respark;
}
}
catch(Exception e)
{
string errorMessage = "";

errorMessage
= "Message: " + e.Message + "\n";
EventLog log = new
EventLog();
log.Source = "DCServer";
log.WriteEntry
(errorMessage);
}
return type;
}
protected void GetFinalDecisio n()
{
DecisionIsGo = (int.Parse(dmAr ray
[124]) == 0 & int.Parse(dmArr ay[123]) == 0)? true : false;
DecisionIsRejec t = (int.Parse
(dmArray[124]) == 1 & int.Parse(dmArr ay[123]) == 0)?
true : false;
DecisionIsNoTes t = (int.Parse
(dmArray[124]) != 0 & int.Parse(dmArr ay[123]) != 0)?
true : false;
}
protected string GetTroubleFlag( )
{
string tflag = null;
try
{
for(int i = 2; i < 102; i
+= 20)
{
tflag += dmArray
[i].Substring(3,1) ;
}
}
catch(Exception e)
{
string errorMessage = "";

errorMessage
= "Message: " + e.Message + "\n";
EventLog log = new
EventLog();
log.Source = "DCServer";
log.WriteEntry
(errorMessage);
}

return tflag.PadRight( 10, '0');
}
protected int GetPalletNumber (string dm)
{
int palNumber = 0;
try
{
palNumber =
Convert.ToInt32 (dm, 16);
if(palNumber > 32)
palNumber -= 32;
}
catch(Exception e)
{
string errorMessage = "";

errorMessage
= "Message: " + e.Message + "\n";
EventLog log = new
EventLog();
log.Source = "DCServer";
log.WriteEntry
(errorMessage);
}

return palNumber;
}
protected void CheckDecisions( string bits)
{
try
{
for(int i=0; i <
bits.Length; i++)
{
decisions[i] =
(bits.Substring (i,1) == "1")? true : false;
}
}
catch(Exception e)
{
string errorMessage = "";

errorMessage
= "Message: " + e.Message + "\n";
EventLog log = new
EventLog();
log.Source = "DCServer";
log.WriteEntry
(errorMessage);
}
}
protected string ConvertHexToBin (string
dm, HexToBinType type)
{
try
{

switch(type)
{
case
HexToBinType.De cision:
dm =
Convert.ToStrin g(Convert.ToInt 32(dm, 16), 2).PadLeft
(16, '0');
break;
case
HexToBinType.Fl ag:
dm =
Convert.ToStrin g(Convert.ToInt 32(dm, 16), 2).PadRight
(10, '0');
break;
}
}
catch(Exception e)
{
string errorMessage = "";

errorMessage
= "Message: " + e.Message + "\n";
EventLog log = new
EventLog();
log.Source = "DCServer";
log.WriteEntry
(errorMessage);
}

return dm;
}
protected string CalculateSlump( string
dm, int ik1, int ik2)
{
// Initial string value will be 4
chars insert decimal at tenths location
// If 'ik2 > ik1' then slump is
negitive calculate slump value
string slump = dm.Insert(3,"." );
try
{
slump = (ik2 > ik1)? (0 -
double.Parse(sl ump)).ToString( "##0.0") : double.Parse
(slump).ToStrin g("##0.0");
}
catch(Exception e)
{
string errorMessage = "";

errorMessage
= "Message: " + e.Message + "\n";
EventLog log = new
EventLog();
log.Source = "DCServer";
log.WriteEntry
(errorMessage);
}

return slump;
}
protected string CalculatePosNeg (string
dm, DecimalLocation location)
{
// Initial string value will be 4
chars.
// The value of "8" from the PLC
is a BCD value for
// negative, all other values
less than 8000 are positive.
// Tenths will modify to "##0.0"
or "-##0.0"
// Hundredths will modify
to "#0.00" or "-#0.00"
// None will modify to "###0"
or "-###0"
try
{
switch(location )
{
case
DecimalLocation .Tenths:
dm =
(double.Parse(d m) > 7999)? ((8000 - double.Parse(dm )) /
10).ToString("# #0.0") : (double.Parse(d m) / 10).ToString
("##0.0");
break;
case
DecimalLocation .Hundredths:
dm =
(double.Parse(d m) > 7999)? ((8000 - double.Parse(dm )) /
100).ToString(" #0.00") : (double.Parse(d m) / 100).ToString
("#0.00");
break;
case
DecimalLocation .None:
dm =
(int.Parse(dm) > 7999)? (8000 - int.Parse(dm)). ToString
("###0") : int.Parse(dm).T oString("###0") ;
break;
}
}
catch(Exception e)
{
string errorMessage = "";

errorMessage
= "Message: " + e.Message + "\n";
EventLog log = new
EventLog();
log.Source = "DCServer";
log.WriteEntry
(errorMessage);
}

return dm;
}
protected void CalculateTestVa lues()
{
// Test position 1
dmArray[5] = CalculatePosNeg
(dmArray[5], DecimalLocation .Tenths);
// ins1
dmArray[6] = CalculatePosNeg
(dmArray[6], DecimalLocation .Tenths);
// ins2
dmArray[7] = CalculatePosNeg
(dmArray[7], DecimalLocation .Tenths);
// ins3
dmArray[8] = CalculatePosNeg
(dmArray[8], DecimalLocation .Tenths);
// ins4

dmArray[9] = CalculatePosNeg
(dmArray[9], DecimalLocation .Tenths);
// ins5
// Test postion 2
dmArray[25] = CalculatePosNeg
(dmArray[25], DecimalLocation .Hundredths);
// ig3-1
dmArray[26] = CalculatePosNeg
(dmArray[26], DecimalLocation .Hundredths);
// ig3-2
dmArray[27] = CalculatePosNeg
(dmArray[27], DecimalLocation .Hundredths);
// stray low
dmArray[28] = CalculatePosNeg
(dmArray[28], DecimalLocation .Hundredths);
// ig2
dmArray[29] = CalculatePosNeg
(dmArray[29], DecimalLocation .None);
// spark
dmArray[30] = CalculatePosNeg
(dmArray[30], DecimalLocation .Hundredths);
// stray high
// Test position 3
dmArray[45] = CalculatePosNeg
(dmArray[45], DecimalLocation .None);
// ikr
dmArray[46] = CalculatePosNeg
(dmArray[46], DecimalLocation .None);
// ikg
dmArray[47] = CalculatePosNeg
(dmArray[47], DecimalLocation .None);
// ikb
dmArray[48] = CalculatePosNeg
(dmArray[48], DecimalLocation .None);
// spark
// Test position 4
dmArray[65] = CalculatePosNeg
(dmArray[65], DecimalLocation .Tenths);
// vkcor
dmArray[66] = CalculatePosNeg
(dmArray[66], DecimalLocation .Tenths);
// vkcog
dmArray[67] = CalculatePosNeg
(dmArray[67], DecimalLocation .Tenths);
// vkcob
dmArray[68] = CalculatePosNeg
(dmArray[68], DecimalLocation .None);
// dvk
// Emission calculations red
dmArray[72] = CalculatePosNeg
(dmArray[72], DecimalLocation .None);
// ik1r
dmArray[69] = CalculatePosNeg
(dmArray[69], DecimalLocation .None);
// ik2r
dmArray[74] = CalculateSlump
(dmArray[74],int.Parse(dmAr ray[72]), int.Parse(dmArr ay
[69])); // srr
// Emission calculations green
dmArray[73] = CalculatePosNeg
(dmArray[73], DecimalLocation .None);
// ik1g
dmArray[70] = CalculatePosNeg
(dmArray[70], DecimalLocation .None);
// ik2g
dmArray[75] = CalculateSlump
(dmArray[75],int.Parse(dmAr ray[73]), int.Parse(dmArr ay
[70])); // srg
// Emission calculations blue
dmArray[79] = CalculatePosNeg
(dmArray[79], DecimalLocation .None);
// ik1b
dmArray[71] = CalculatePosNeg
(dmArray[71], DecimalLocation .None);
// ik2b
dmArray[76] = CalculateSlump
(dmArray[76],int.Parse(dmAr ray[79]), int.Parse(dmArr ay
[71])); // srb

dmArray[77] = CalculatePosNeg
(dmArray[77], DecimalLocation .None);
// ih
dmArray[78] = CalculatePosNeg
(dmArray[78], DecimalLocation .None);
// spark
// Test position 5
dmArray[85] = CalculatePosNeg
(dmArray[85], DecimalLocation .None);
// igas
dmArray[86] = CalculatePosNeg
(dmArray[86], DecimalLocation .None);
// i1
dmArray[87] = CalculatePosNeg
(dmArray[87], DecimalLocation .None);
// i2
dmArray[88] = CalculatePosNeg
(dmArray[88], DecimalLocation .None);
// ikgas
// Test position 6/7 (visual's)
dmArray[105] = CalculatePosNeg
(dmArray[105], DecimalLocation .None);
// 2px
dmArray[106] = CalculatePosNeg
(dmArray[106], DecimalLocation .None);
// 2py
dmArray[107] = CalculatePosNeg
(dmArray[107], DecimalLocation .None);
// 4px
dmArray[108] = CalculatePosNeg
(dmArray[108], DecimalLocation .None);
// 4py
dmArray[109] = CalculatePosNeg
(dmArray[109], DecimalLocation .None);
// 6px
dmArray[110] = CalculatePosNeg
(dmArray[110], DecimalLocation .None);
// 6py
dmArray[111] = CalculatePosNeg
(dmArray[111], DecimalLocation .None);
// spark

}
protected void CalculateDefect s()
{
// Check the decision bit for
ture state
// increament the correspoding
defect counter
if(decisions[15])defects[0]++;
// ins1
if(decisions[14])defects[1]++;
// ins2
if(decisions[13])defects[2]++;
// ins3
if(decisions[12])defects[3]++;
// ins4
if(decisions[11])defects[4]++;
// ins5
if(decisions[31])defects[5]++;
// test2 spark
if(decisions[30])defects[6]++;
// test2 spark pass
if(decisions[29])defects[7]++;
// ig3-1
if(decisions[28])defects[8]++;
// ig3-2
if(decisions[26])defects[9]++;
// ig2
if(decisions[25])defects[10]++;
// stray
if(decisions[63])defects[11]++;
// test4 spark
if(decisions[62])defects[12]++;
// ik-auto
if(decisions[61])defects[13]++;
// vkr
if(decisions[60])defects[14]++;
// vkg
if(decisions[59])defects[15]++;
// vkb
if(decisions[58])defects[16]++;
// dvk
if(decisions[57])defects[17]++;
// ik1r
if(decisions[56])defects[18]++;
// ik1g
if(decisions[55])defects[19]++;
// ik1b
if(decisions[54])defects[20]++;
// ik2r
if(decisions[53])defects[21]++;
// ik2g
if(decisions[52])defects[22]++;
// ik2b
if(decisions[51])defects[23]++;
// srr
if(decisions[50])defects[24]++;
// srg
if(decisions[49])defects[25]++;
// srb
if(decisions[48])defects[26]++;
// ih
if(decisions[79])defects[27]++;
// igas
if(decisions[78])defects[28]++;
// ikgas

// g3 stray visual
if((decisions[94] || decisions
[142]))defects[29]++;
// g2 stray visual
if((decisions[93] || decisions
[141]))defects[30]++;
// purity
if(decisions[111])defects[31]++;
// gun rotation
if((decisions[92] || decisions
[140]))defects[32]++;
// ki
if(decisions[81] || decisions[82]
|| decisions[83] ||
decisions[129] ||
decisions[130] || decisions[131])defects[33]++;

// visual defect's focus(r,g,b),
raster(r,g,b), white quality and landing(4,6) pole.
if(decisions[84] || decisions[85]
|| decisions[86] ||
decisions[87] || decisions
[88] || decisions[89] ||
decisions[90] || decisions
[91] || decisions[109] ||
decisions[110])defects[34]
++;

// 2nd (others)
if(decisions[80] || decisions
[128])defects[35]++;
}
protected void CalculatePallet Defects()
{
try
{

// insulation
if((decisions[11] ||
decisions[12] || decisions[13] || decisions[14] ||
decisions[15]))
{
palletdefect
[PalletNumber][0]++;
palletdefect[0][0]
++;
}
// vk cut-off
if((decisions[58] ||
decisions[59] || decisions[60] || decisions[61]))
{
palletdefect
[PalletNumber][1]++;
palletdefect[0][1]
++;
}
// igas
if(decisions[79])
{
palletdefect
[PalletNumber][2]++;
palletdefect[0][2]
++;
}
// igas equal to zero
if(int.Parse(dm Array[85])
== 0)
{
palletdefect
[PalletNumber][3]++;
palletdefect[0][3]
++;
}
// ikgas
if(decisions[78])
{
palletdefect
[PalletNumber][4]++;
palletdefect[0][4]
++;
}
// ki
if((decisions[81] ||
decisions[82] || decisions[83] || decisions[129] ||
decisions[130] || decisions[131]))
{
palletdefect
[PalletNumber][5]++;
palletdefect[0][5]
++;
}
// emission
if((decisions[52] ||
decisions[53] || decisions[54] || decisions[55] ||
decisions[56] || decisions[57]))
{
palletdefect
[PalletNumber][6]++;
palletdefect[0][6]
++;
}
// slump
if((decisions[49] ||
decisions[50] || decisions[51]))
{
palletdefect
[PalletNumber][7]++;
palletdefect[0][7]
++;
}
// ih
if(decisions[48])
{
palletdefect
[PalletNumber][8]++;
palletdefect[0][8]
++;
}
// ig2
if(decisions[26])
{
palletdefect
[PalletNumber][9]++;
palletdefect[0][9]
++;
}
// ig3
if((decisions[28] ||
decisions[29]))
{
palletdefect
[PalletNumber][10]++;
palletdefect[0]
[10]++;
}
// stray
if(decisions[25])
{
palletdefect
[PalletNumber][11]++;
palletdefect[0]
[11]++;
}
// spark
if(decisions[31])
{
palletdefect
[PalletNumber][12]++;
palletdefect[0]
[12]++;
}
// 2 pole x (purity)
if(decisions[111])
{
palletdefect
[PalletNumber][13]++;
palletdefect[0]
[13]++;
}
// gun rotation
if((decisions[92] ||
decisions[140]))
{
palletdefect
[PalletNumber][14]++;
palletdefect[0]
[14]++;
}
// no-test (measurement
trouble)
if(int.Parse(dm Array
[123]) != 0)
{
palletdefect
[PalletNumber][15]++;
palletdefect[0]
[15]++;
}
}
catch(Exception e)
{
string errorMessage = "";

errorMessage
= "Message: " + e.Message + "\n";
EventLog log = new
EventLog();
log.Source = "DCServer";
log.WriteEntry
(errorMessage);
}

}
protected void CalculateHourly Counts()
{
int hr = testDate.Hour;
isTestPiece = false;

// Calculate totals
switch(TestType )
{
case 0:
hourlyCount[0][hr]
++; // Total hourly virign product
break;
case 1:
hourlyCount[1][hr]
++; // Total hourly reage product

break;
case 2:
hourlyCount[2][hr]
++; // Total hourly respark product

break;
}

// Calculate the hourly gross.
hourlyCount[3][hr]++;
// Calculate the hourly No-Test.
if(DecisionIsNo Test)hourlyCoun t[4]
[hr]++;

// test piece
if(decisions[125])
{
hourlyCount[22][hr]++;
hourlyCount[23][hr]++;
// Hourly summation
isTestPiece = true;
}

// Calculate hourly counts only
if test is a reject and virign
if((DecisionIsR eject) & TestType
== 0)
{
// screen
if((decisions[88] ||
decisions[89] || decisions[90] || decisions[91]) & ((!
decisions[126]) & (!decisions[127])))
{
hourlyCount[5][hr]
++;
hourlyCount[23]
[hr]++; // Hourly summation
testResult
= "SCREEN";
return;
}
// mask
if(decisions[127])
{
hourlyCount[6][hr]
++;
hourlyCount[23]
[hr]++; // Hourly summation
testResult
= "MASK";
return;
}
// ba
if(decisions[126])
{
hourlyCount[7][hr]
++;
hourlyCount[23]
[hr]++; // Hourly summation
testResult = "BA";
return;
}
// purity
if(decisions[111])
{
hourlyCount[8][hr]
++;
hourlyCount[23]
[hr]++; // Hourly summation
testResult
= "PURITY";
return;
}
// gunrotation
if((decisions[92] ||
decisions[140]))
{
hourlyCount[9][hr]
++;
hourlyCount[23]
[hr]++; // Hourly summation
testResult
= "GUNROT";
return;
}
// insulation
if(decisions[11] ||
decisions[12] || decisions[13] || decisions[14]
||decisions[15])
{
hourlyCount[10]
[hr]++;
hourlyCount[23]
[hr]++; // Hourly summation
testResult
= "INS";
return;
}

// vk cut-off
if(decisions[58] ||
decisions[59] || decisions[60] || decisions[61])
{
hourlyCount[11]
[hr]++;
hourlyCount[23]
[hr]++; // Hourly summation
testResult
= "VKCO";
return;
}
// igas
if(decisions[78] ||
decisions[79])
{
hourlyCount[12]
[hr]++;
hourlyCount[23]
[hr]++; // Hourly summation
testResult
= "IGAS";
return;
}
// ki
if(decisions[81] ||
decisions[82] || decisions[83] || decisions[129] ||
decisions[130] || decisions[131])
{
hourlyCount[13]
[hr]++;
hourlyCount[23]
[hr]++; // Hourly summation
testResult = "KI";
return;
}
// emission
if(decisions[52] ||
decisions[53] || decisions[54] || decisions[55] ||
decisions[56] || decisions[57])
{
hourlyCount[14]
[hr]++;
hourlyCount[23]
[hr]++; // Hourly summation
testResult
= "EMISSION";
return;
}
// slump
if(decisions[49] ||
decisions[50] || decisions[51])
{
hourlyCount[15]
[hr]++;
hourlyCount[23]
[hr]++; // Hourly summation
testResult
= "SLUMP";
return;
}
// ig2
if(decisions[26])
{
hourlyCount[16]
[hr]++;
hourlyCount[23]
[hr]++; // Hourly summation
testResult
= "IG2";
return;
}
// ig3
if(decisions[28] ||
decisions[29])
{
hourlyCount[17]
[hr]++;
hourlyCount[23]
[hr]++; // Hourly summation
testResult
= "IG3";
return;
}
// stray
if(decisions[25])
{
hourlyCount[18]
[hr]++;
hourlyCount[23]
[hr]++; // Hourly summation
testResult
= "STRAY";
return;
}
// visual g3 stray
if(decisions[94] ||
decisions[142])
{
hourlyCount[19]
[hr]++;
hourlyCount[23]
[hr]++; // Hourly summation
testResult
= "G3STARY";
return;
}
// visual g2 stray
if(decisions[93] ||
decisions[141])
{
hourlyCount[20]
[hr]++;
hourlyCount[23]
[hr]++; // Hourly summation
testResult
= "G2STRAY";
return;
}
// others
if(decisions[31] ||
decisions[48] || decisions[63] || decisions[80] ||
decisions[81] ||
decisions[82] || decisions[83] || decisions[84] ||
decisions[85] ||
decisions[86] || decisions[92] || decisions[87] ||
decisions[128] ||
decisions[129] || decisions[130] || decisions[131] ||
decisions[132] ||
decisions[133] || decisions[134] || decisions[135] ||
decisions[140])
{
hourlyCount[21]
[hr]++;
hourlyCount[23]
[hr]++; // Hourly summation
testResult
= "OTHERS";
return;
}

}
else
{
if(DecisionIsNo Test)
{
testResult = "NT";
}
else if(DecisionIsRe ject)
{
testResult = "NG";
}
else if(DecisionIsGo )
{
testResult = "GO";

}
}
}
#region DataInsert Methods ...

protected int InsertDMData()
{

int numAffected;

// create the parameters
SqlParameter[] parameters = {
new SqlParameter
("@tube_number" , SqlDbType.Int, 4),
new SqlParameter
("@shift", SqlDbType.NChar , 1),
new SqlParameter
("@shift_typ e", SqlDbType.NChar , 7),
new SqlParameter
("@production_d ate", SqlDbType.NChar , 10),
new SqlParameter
("@test_hour ", SqlDbType.Int, 4),
new SqlParameter("@ item",
SqlDbType.NVarC har, 25),
new SqlParameter
("@pal_num", SqlDbType.Int, 4),
new SqlParameter
("@tot_jg", SqlDbType.Int, 4),
new SqlParameter
("@tot_trbl" , SqlDbType.Int, 4),
new SqlParameter
("@trbl_flag ", SqlDbType.NChar , 10),
new SqlParameter
("@test_flag ", SqlDbType.NChar , 10),
new SqlParameter
("@track_fla g", SqlDbType.NChar , 10),
new SqlParameter
("@tc5_data" , SqlDbType.Int, 4),
new SqlParameter
("@test1_dec ", SqlDbType.NChar , 16),
new SqlParameter
("@test1_trb l", SqlDbType.Int, 4),
new SqlParameter
("@test1_onl ", SqlDbType.Int, 4),
new SqlParameter
("@test1_jg" , SqlDbType.Int, 4),
new SqlParameter("@ ins1",
SqlDbType.Decim al, 9),
new SqlParameter("@ ins2",
SqlDbType.Decim al, 9),
new SqlParameter("@ ins3",
SqlDbType.Decim al, 9),
new SqlParameter("@ ins4",
SqlDbType.Decim al, 9),
new SqlParameter("@ ins5",
SqlDbType.Decim al, 9),
new SqlParameter
("@test2_dec ", SqlDbType.NChar , 16),
new SqlParameter
("@test2_trb l", SqlDbType.Int, 4),
new SqlParameter
("@test2_onl ", SqlDbType.Int, 4),
new SqlParameter
("@test2_jg" , SqlDbType.Int, 4),
new SqlParameter
("@ig3_1", SqlDbType.Decim al, 9),
new SqlParameter
("@ig3_2", SqlDbType.Decim al, 9),
new SqlParameter("@ ig2",
SqlDbType.Decim al, 9),
new SqlParameter
("@stray_hig h", SqlDbType.Decim al, 9),
new SqlParameter
("@stray_low ", SqlDbType.Decim al, 9),
new SqlParameter
("@test2_spark" , SqlDbType.Int, 4),
new SqlParameter
("@test3_dec ", SqlDbType.NChar , 16),
new SqlParameter
("@test3_trb l", SqlDbType.Int, 4),
new SqlParameter
("@test3_onl ", SqlDbType.Int, 4),
new SqlParameter
("@test3_jg" , SqlDbType.Int, 4),
new SqlParameter("@ ikr",
SqlDbType.Int, 4),
new SqlParameter("@ ikg",
SqlDbType.Int, 4),
new SqlParameter("@ ikb",
SqlDbType.Int, 4),
new SqlParameter
("@test3_spark" , SqlDbType.Int, 4),
new SqlParameter
("@test4_dec ", SqlDbType.NChar , 16),
new SqlParameter
("@test4_trb l", SqlDbType.Int, 4),
new SqlParameter
("@test4_onl ", SqlDbType.Int, 4),
new SqlParameter
("@test4_jg" , SqlDbType.Int, 4),
new SqlParameter("@ vkr",
SqlDbType.Decim al, 9),
new SqlParameter("@ vkg",
SqlDbType.Decim al, 9),
new SqlParameter("@ vkb",
SqlDbType.Decim al, 9),
new SqlParameter("@ dvk",
SqlDbType.Int, 4),
new SqlParameter("@ ik1r",
SqlDbType.Int, 4),
new SqlParameter("@ ik2r",
SqlDbType.Int, 4),
new SqlParameter("@ ik1g",
SqlDbType.Int, 4),
new SqlParameter("@ ik2g",
SqlDbType.Int, 4),
new SqlParameter("@ ik1b",
SqlDbType.Int, 4),
new SqlParameter("@ ik2b",
SqlDbType.Int, 4),
new SqlParameter("@ srr",
SqlDbType.Decim al, 9),
new SqlParameter("@ srg",
SqlDbType.Decim al, 9),
new SqlParameter("@ srb",
SqlDbType.Decim al, 9),
new SqlParameter("@ ih",
SqlDbType.Int, 4),
new SqlParameter
("@test4_spark" , SqlDbType.Int, 4),
new SqlParameter
("@test5_dec ", SqlDbType.NChar , 16),
new SqlParameter
("@test5_trb l", SqlDbType.Int, 4),
new SqlParameter
("@test5_onl ", SqlDbType.Int, 4),
new SqlParameter
("@test5_jg" , SqlDbType.Int, 4),
new SqlParameter("@ i1",
SqlDbType.Int, 4),
new SqlParameter("@ i2",
SqlDbType.Int, 4),
new SqlParameter("@ igas",
SqlDbType.Int, 4),
new SqlParameter
("@ikgas", SqlDbType.Int, 4),
new SqlParameter
("@visual1_dec" , SqlDbType.NChar , 16),
new SqlParameter
("@visual2_dec" , SqlDbType.NChar , 16),
new SqlParameter
("@visual_trbl" , SqlDbType.Int, 4),
new SqlParameter
("@visual_on l", SqlDbType.Int, 4),
new SqlParameter
("@visual_jg ", SqlDbType.Int, 4),
new SqlParameter
("@visual_defec t", SqlDbType.Int, 4),
new SqlParameter("@ px2",
SqlDbType.Int, 4),
new SqlParameter("@ py2",
SqlDbType.Int, 4),
new SqlParameter("@ px4",
SqlDbType.Int, 4),
new SqlParameter("@ py4",
SqlDbType.Int, 4),
new SqlParameter("@ px6",
SqlDbType.Int, 4),
new SqlParameter("@ py6",
SqlDbType.Int, 4),
new SqlParameter
("@visual_spark ", SqlDbType.Int, 4),
new SqlParameter
("@visual6_dec" , SqlDbType.NChar , 16),
new SqlParameter
("@is_test", SqlDbType.Int, 4)
};

// set the values
parameters[0].Value =
base.TubeNumber ; // tube
number
parameters[1].Value = cal.Shift;
// shift
parameters[2].Value =
cal.ShiftType; // shift Type
parameters[3].Value =
cal.ProductionD ate; // production date
parameters[4].Value =
testDate.Hour; // test hour
parameters[5].Value =
this.TestResult ; // test
result (sceen,mask,ng, etc...)
parameters[6].Value =
this.PalletNumb er; // pallet number
parameters[7].Value = int.Parse
(dmArray[124]); // total judgement
parameters[8].Value = int.Parse
(dmArray[123]); // total trouble
parameters[9].Value =
this.TroubleFla g; //
trouble flag
parameters[10].Value = dmArray
[122]; // test flag
parameters[11].Value = dmArray
[121]; // tracking flag
parameters[12].Value =
this.TestType; // tc5_data
TestTypes: virgin, reage, respark
parameters[13].Value = dmArray[0];
// test1 decision
parameters[14].Value = int.Parse
(dmArray[2]); // test1 trouble
parameters[15].Value = int.Parse
(dmArray[3]); // test1 online
parameters[16].Value = int.Parse
(dmArray[4]); // test1 judgement
parameters[17].Value =
double.Parse(dm Array[5]); // ins1
parameters[18].Value =
double.Parse(dm Array[6]); // ins2
parameters[19].Value =
double.Parse(dm Array[7]); // ins3
parameters[20].Value =
double.Parse(dm Array[8]); // ins4
parameters[21].Value =
double.Parse(dm Array[9]); // ins5
parameters[22].Value = dmArray
[20]; // test2 decision
parameters[23].Value = int.Parse
(dmArray[22]); // test2 trouble
parameters[24].Value = int.Parse
(dmArray[23]); // test2 online
parameters[25].Value = int.Parse
(dmArray[24]); // test2 judgement
parameters[26].Value =
double.Parse(dm Array[25]); // ig3-1
parameters[27].Value =
double.Parse(dm Array[26]); // ig3-2
parameters[28].Value =
double.Parse(dm Array[28]); // ig2
parameters[29].Value =
double.Parse(dm Array[30]); // stray high
parameters[30].Value =
double.Parse(dm Array[27]); // stray low
parameters[31].Value = int.Parse
(dmArray[29]); // test2 spark
parameters[32].Value = dmArray
[40]; // test3 decision
parameters[33].Value = int.Parse
(dmArray[42]); // test3 trouble
parameters[34].Value = int.Parse
(dmArray[43]); // test3 online
parameters[35].Value = int.Parse
(dmArray[44]); // test3 judgement
parameters[36].Value = int.Parse
(dmArray[45]); // ikr
parameters[37].Value = int.Parse
(dmArray[46]); // ikg
parameters[38].Value = int.Parse
(dmArray[47]); // ikb
parameters[39].Value = int.Parse
(dmArray[48]); // test3 spark
parameters[40].Value = dmArray
[60]; // test4 decision
parameters[41].Value = int.Parse
(dmArray[62]); // test4 trouble
parameters[42].Value = int.Parse
(dmArray[63]); // test4 online
parameters[43].Value = int.Parse
(dmArray[64]); // test4 judgement
parameters[44].Value =
double.Parse(dm Array[65]); // vkr
parameters[45].Value =
double.Parse(dm Array[66]); // vkg
parameters[46].Value =
double.Parse(dm Array[67]); // vkb
parameters[47].Value = int.Parse
(dmArray[68]); // dvk
parameters[48].Value = int.Parse
(dmArray[72]); // ik1r
parameters[49].Value = int.Parse
(dmArray[69]); // ik2r
parameters[50].Value = int.Parse
(dmArray[73]); // ik1g
parameters[51].Value = int.Parse
(dmArray[70]); // ik2g
parameters[52].Value = int.Parse
(dmArray[79]); // ik1b
parameters[53].Value = int.Parse
(dmArray[71]); // ik2b
parameters[54].Value =
double.Parse(dm Array[74]); // srr
parameters[55].Value =
double.Parse(dm Array[75]); // srg
parameters[56].Value =
double.Parse(dm Array[76]); // srb
parameters[57].Value = int.Parse
(dmArray[77]); // ih
parameters[58].Value = int.Parse
(dmArray[78]); // test4 spark
parameters[59].Value = dmArray
[80]; // test5 decision
parameters[60].Value = int.Parse
(dmArray[82]); // test5 trouble
parameters[61].Value = int.Parse
(dmArray[83]); // test5 online
parameters[62].Value = int.Parse
(dmArray[84]); // test5 judgement
parameters[63].Value = int.Parse
(dmArray[86]); // i1
parameters[64].Value = int.Parse
(dmArray[87]); // i2
parameters[65].Value = int.Parse
(dmArray[85]); // igas
parameters[66].Value = int.Parse
(dmArray[88]); // ikgas
parameters[67].Value = dmArray
[100]; // visual1 decision
parameters[68].Value = dmArray
[101]; // visual2 decision
parameters[69].Value = int.Parse
(dmArray[102]); // visual trouble
parameters[70].Value = int.Parse
(dmArray[103]); // visual online
parameters[71].Value = int.Parse
(dmArray[104]); // visual judgement
parameters[72].Value = int.Parse
(dmArray[112]); // visual defect
parameters[73].Value = int.Parse
(dmArray[105]); // 2px
parameters[74].Value = int.Parse
(dmArray[106]); // 2py
parameters[75].Value = int.Parse
(dmArray[107]); // 4px
parameters[76].Value = int.Parse
(dmArray[108]); // 4py
parameters[77].Value = int.Parse
(dmArray[109]); // 6px
parameters[78].Value = int.Parse
(dmArray[110]); // 6py
parameters[79].Value = int.Parse
(dmArray[111]); // visual spark
parameters[80].Value = dmArray
[113]; // visual6 decision
parameters[81].Value =
(this.IsTestPie ce)? 1 : 0; // is test piece

// run the procedure
RunProcedure
("up_insert_dmd ata_record", parameters, out numAffected);

return numAffected;
}
protected int InsertPalletDet ails()
{
int numAffected;
int rec = 0;
for(int j=0; j<21; j++)
{
SqlParameter[] parameters
= {
new SqlParameter
("@pallet_numbe r", SqlDbType.Int, 4),
new SqlParameter
("@production_d ate", SqlDbType.NChar , 10),
new SqlParameter
("@pallet_revol utions", SqlDbType.Int, 4),
new SqlParameter
("@ins", SqlDbType.Int, 4),
new SqlParameter
("@vkco", SqlDbType.Int, 4),
new SqlParameter
("@igas", SqlDbType.Int, 4),
new SqlParameter
("@zero_igas ", SqlDbType.Int, 4),
new SqlParameter
("@ikgas", SqlDbType.Int, 4),
new SqlParameter
("@ki", SqlDbType.Int, 4),
new SqlParameter
("@emission" , SqlDbType.Int, 4),
new SqlParameter
("@slump", SqlDbType.Int, 4),
new SqlParameter
("@ih", SqlDbType.Int, 4),
new SqlParameter
("@ig2", SqlDbType.Int, 4),
new SqlParameter
("@ig3", SqlDbType.Int, 4),
new SqlParameter
("@stray", SqlDbType.Int, 4),
new SqlParameter
("@spark", SqlDbType.Int, 4),
new SqlParameter
("@purity", SqlDbType.Int, 4),
new SqlParameter
("@gunrotation" , SqlDbType.Int, 4),
new SqlParameter
("@notest", SqlDbType.Int, 4)
};

parameters[0].Value = j;
// pallet
number
parameters[1].Value =
cal.ProductionD ate; // production date
parameters[2].Value =
palletrevolutio n[j]; // pallet revolution total

for(int i=0; i<16; i++)
{
parameters
[i+3].Value = palletdefect[j][i]; // pallet defect
item
}

// run the procedure
RunProcedure
("up_insert_pal letdetails", parameters, out numAffected);
rec += numAffected;
}

return rec;

}
protected int InsertDefects()
{
int numAffected;

// create the parameters
SqlParameter[] parameters = {

new SqlParameter
("@production_d ate", SqlDbType.NChar , 10),
new SqlParameter("@ ins1",
SqlDbType.Int, 4),
new SqlParameter("@ ins2",
SqlDbType.Int, 4),
new SqlParameter("@ ins3",
SqlDbType.Int, 4),
new SqlParameter("@ ins4",
SqlDbType.Int, 4),
new SqlParameter("@ ins5",
SqlDbType.Int, 4),
new SqlParameter
("@test2_spark" , SqlDbType.Int, 4),
new SqlParameter
("@spark_pas s", SqlDbType.Int, 4),
new SqlParameter
("@ig3_1", SqlDbType.Int, 4),
new SqlParameter
("@ig3_2", SqlDbType.Int, 4),
new SqlParameter("@ ig2",
SqlDbType.Int, 4),
new SqlParameter
("@stray", SqlDbType.Int, 4),
new SqlParameter
("@test4_spark" , SqlDbType.Int, 4),
new SqlParameter
("@ikauto", SqlDbType.Int, 4),
new SqlParameter("@ vkr",
SqlDbType.Int, 4),
new SqlParameter("@ vkg",
SqlDbType.Int, 4),
new SqlParameter("@ vkb",
SqlDbType.Int, 4),
new SqlParameter("@ dvk",
SqlDbType.Int, 4),
new SqlParameter("@ ik1r",
SqlDbType.Int, 4),
new SqlParameter("@ ik1g",
SqlDbType.Int, 4),
new SqlParameter("@ ik1b",
SqlDbType.Int, 4),
new SqlParameter("@ ik2r",
SqlDbType.Int, 4),
new SqlParameter("@ ik2g",
SqlDbType.Int, 4),
new SqlParameter("@ ik2b",
SqlDbType.Int, 4),
new SqlParameter("@ srr",
SqlDbType.Int, 4),
new SqlParameter("@ srg",
SqlDbType.Int, 4),
new SqlParameter("@ srb",
SqlDbType.Int, 4),
new SqlParameter("@ ih",
SqlDbType.Int, 4),
new SqlParameter("@ igas",
SqlDbType.Int, 4),
new SqlParameter
("@ikgas", SqlDbType.Int, 4),
new SqlParameter
("@g3stray", SqlDbType.Int, 4),
new SqlParameter
("@g2stray", SqlDbType.Int, 4),
new SqlParameter
("@purity", SqlDbType.Int, 4),
new SqlParameter
("@gun_rotation ", SqlDbType.Int, 4),
new SqlParameter("@ ki",
SqlDbType.Int, 4),
new SqlParameter
("@visual", SqlDbType.Int, 4),
new SqlParameter
("@others", SqlDbType.Int, 4),
new SqlParameter
("@total", SqlDbType.Int, 4)
};

// set the values
parameters[0].Value =
cal.ProductionD ate;
for(int i=0; i < defects.Length;
i++)
{
parameters[i+1].Value =
defects[i];
}
parameters[37].Value =
base.TotalRejec ts;

// run the procedure
RunProcedure
("up_insert_def ect_record", parameters, out numAffected);

return numAffected;
}
protected int InsertHourlyCou nts()
{
int numAffected;
int rec = 0;

for(int i=0; i<tallyItem.Len gth;
i++)
{
SqlParameter[] parameters
= {
new SqlParameter
("@item", SqlDbType.NVarC har, 25),
new SqlParameter
("@production_d ate", SqlDbType.NChar , 10),
new SqlParameter
("@hr_00", SqlDbType.Int, 4),
new SqlParameter
("@hr_01", SqlDbType.Int, 4),
new SqlParameter
("@hr_02", SqlDbType.Int, 4),
new SqlParameter
("@hr_03", SqlDbType.Int, 4),
new SqlParameter
("@hr_04", SqlDbType.Int, 4),
new SqlParameter
("@hr_05", SqlDbType.Int, 4),
new SqlParameter
("@hr_06", SqlDbType.Int, 4),
new SqlParameter
("@hr_07", SqlDbType.Int, 4),
new SqlParameter
("@hr_08", SqlDbType.Int, 4),
new SqlParameter
("@hr_09", SqlDbType.Int, 4),
new SqlParameter
("@hr_10", SqlDbType.Int, 4),
new SqlParameter
("@hr_11", SqlDbType.Int, 4),
new SqlParameter
("@hr_12", SqlDbType.Int, 4),
new SqlParameter
("@hr_13", SqlDbType.Int, 4),
new SqlParameter
("@hr_14", SqlDbType.Int, 4),
new SqlParameter
("@hr_15", SqlDbType.Int, 4),
new SqlParameter
("@hr_16", SqlDbType.Int, 4),
new SqlParameter
("@hr_17", SqlDbType.Int, 4),
new SqlParameter
("@hr_18", SqlDbType.Int, 4),
new SqlParameter
("@hr_19", SqlDbType.Int, 4),
new SqlParameter
("@hr_20", SqlDbType.Int, 4),
new SqlParameter
("@hr_21", SqlDbType.Int, 4),
new SqlParameter
("@hr_22", SqlDbType.Int, 4),
new SqlParameter
("@hr_23", SqlDbType.Int, 4)

};

parameters[0].Value =
tallyItem[i];
parameters[1].Value =
cal.ProductionD ate;

for(int j=0; j<24; j++)
{
parameters
[j+2].Value = hourlyCount[i][j];
}

// Run the procedure
RunProcedure
("up_insert_hou rlycount_record ", parameters, out
numAffected);
rec += numAffected;
}

return rec;

}

#endregion

protected void SaveRawDataFile (string
fileData)
{
FileInfo fi = new FileInfo
(@"C:\RawData \" + FileName);
if(fi.Exists)
{
// This text will always
be added, making the file longer over time
// if it is not deleted.
using (StreamWriter sw =
fi.AppendText() )
{
sw.WriteLine
(fileData);
sw.Flush();
sw.Close();
}
}
else
{
//Create a file to write
to.
using (StreamWriter sw =
fi.CreateText() )
{
sw.WriteLine
(fileData);
sw.Flush();
sw.Close();
}
}
}
}
}
-----Original Message-----
Ron,

Without seeing some code, it would be difficult to tell. Generallyspeaking, I can't imagine that it would do this on it's own, and if it does,it needs to be reported as a bug.

Can you post your code that is serializing this, as well as the code forthe class that is being serialized?
--
- Nicholas Paldino [.NET/C# MVP]
- ni************* *@exisconsultin g.com

"ron" <goodr@no_spam4 me_mddm.panason ic.com> wrote in messagenews:57******* *************** ******@phx.gbl. ..
Hi,
I have class object that i serialize using the
System.Xml.Seri alization class.

Intermittently the object is not getting serialized
correctly, using System.Xml.Seri alization classes.
Therefore the application errors out when deserializing
the xml data.

It places the some part of the child element

<MyRootElemen t>
<SomeOtherEleme nt>
</SomeOtherElemen t>
</MyRootElement>e ment> --- This gets added to the end of the root element name.

What would be causing this.

Ron Good

.

Nov 15 '05 #3
ron
Nicholas,
This is what the serialized file with the error looks
like.

<?xml version="1.0"?>
<DataProcessTes tingSettings
xmlns:xsd="http ://www.w3.org/2001/XMLSchema"
xmlns:xsi="http ://www.w3.org/2001/XMLSchema-instance">
<LastTubeNumber >362</LastTubeNumber>
<RawDataFile>ra w_09042003.txt</RawDataFile>
<LastProduction Date>2003-09-04T00:00:00.000 0000-
04:00</LastProductionD ate>
<PalletRevoluti ons>
<int>0</int>
<int>0</int>
<int>0</int>
<int>0</int>
<int>0</int>
<int>0</int>
<int>0</int>
<int>0</int>
<int>0</int>
<int>0</int>
<int>0</int>
<int>1</int>
<int>1</int>
<int>0</int>
<int>0</int>
<int>0</int>
<int>0</int>
<int>0</int>
<int>0</int>
<int>0</int>
<int>0</int>
</PalletRevolutio ns>
<PalletDefect s>
<ArrayOfInt>
<int>0</int>
<int>0</int>
<int>0</int>
<int>0</int>
<int>0</int>
<int>0</int>
<int>0</int>
<int>0</int>
<int>0</int>
<int>0</int>
<int>0</int>
<int>0</int>
<int>0</int>
<int>0</int>
<int>0</int>
<int>0</int>
</ArrayOfInt>
<ArrayOfInt>
<int>0</int>
<int>0</int>
<int>0</int>
<int>0</int>
<int>0</int>
<int>0</int>
<int>0</int>
<int>0</int>
<int>0</int>
<int>0</int>
<int>0</int>
<int>0</int>
<int>0</int>
<int>0</int>
<int>0</int>
<int>0</int>
</ArrayOfInt>
<ArrayOfInt>
<int>0</int>
<int>0</int>
<int>0</int>
<int>0</int>
<int>0</int>
<int>0</int>
<int>0</int>
<int>0</int>
<int>0</int>
<int>0</int>
<int>0</int>
<int>0</int>
<int>0</int>
<int>0</int>
<int>0</int>
<int>0</int>
</ArrayOfInt>
<ArrayOfInt>
<int>0</int>
<int>0</int>
<int>0</int>
<int>0</int>
<int>0</int>
<int>0</int>
<int>0</int>
<int>0</int>
<int>0</int>
<int>0</int>
<int>0</int>
<int>0</int>
<int>0</int>
<int>0</int>
<int>0</int>
<int>0</int>
</ArrayOfInt>
<ArrayOfInt>
<int>0</int>
<int>0</int>
<int>0</int>
<int>0</int>
<int>0</int>
<int>0</int>
<int>0</int>
<int>0</int>
<int>0</int>
<int>0</int>
<int>0</int>
<int>0</int>
<int>0</int>
<int>0</int>
<int>0</int>
<int>0</int>
</ArrayOfInt>
<ArrayOfInt>
<int>0</int>
<int>0</int>
<int>0</int>
<int>0</int>
<int>0</int>
<int>0</int>
<int>0</int>
<int>0</int>
<int>0</int>
<int>0</int>
<int>0</int>
<int>0</int>
<int>0</int>
<int>0</int>
<int>0</int>
<int>0</int>
</ArrayOfInt>
<ArrayOfInt>
<int>0</int>
<int>0</int>
<int>0</int>
<int>0</int>
<int>0</int>
<int>0</int>
<int>0</int>
<int>0</int>
<int>0</int>
<int>0</int>
<int>0</int>
<int>0</int>
<int>0</int>
<int>0</int>
<int>0</int>
<int>0</int>
</ArrayOfInt>
<ArrayOfInt>
<int>0</int>
<int>0</int>
<int>0</int>
<int>0</int>
<int>0</int>
<int>0</int>
<int>0</int>
<int>0</int>
<int>0</int>
<int>0</int>
<int>0</int>
<int>0</int>
<int>0</int>
<int>0</int>
<int>0</int>
<int>0</int>
</ArrayOfInt>
<ArrayOfInt>
<int>0</int>
<int>0</int>
<int>0</int>
<int>0</int>
<int>0</int>
<int>0</int>
<int>0</int>
<int>0</int>
<int>0</int>
<int>0</int>
<int>0</int>
<int>0</int>
<int>0</int>
<int>0</int>
<int>0</int>
<int>0</int>
</ArrayOfInt>
<ArrayOfInt>
<int>0</int>
<int>0</int>
<int>0</int>
<int>0</int>
<int>0</int>
<int>0</int>
<int>0</int>
<int>0</int>
<int>0</int>
<int>0</int>
<int>0</int>
<int>0</int>
<int>0</int>
<int>0</int>
<int>0</int>
<int>0</int>
</ArrayOfInt>
<ArrayOfInt>
<int>0</int>
<int>0</int>
<int>0</int>
<int>0</int>
<int>0</int>
<int>0</int>
<int>0</int>
<int>0</int>
<int>0</int>
<int>0</int>
<int>0</int>
<int>0</int>
<int>0</int>
<int>0</int>
<int>0</int>
<int>0</int>
</ArrayOfInt>
<ArrayOfInt>
<int>0</int>
<int>0</int>
<int>0</int>
<int>0</int>
<int>0</int>
<int>0</int>
<int>0</int>
<int>0</int>
<int>0</int>
<int>0</int>
<int>0</int>
<int>0</int>
<int>0</int>
<int>0</int>
<int>0</int>
<int>0</int>
</ArrayOfInt>
<ArrayOfInt>
<int>0</int>
<int>0</int>
<int>0</int>
<int>0</int>
<int>0</int>
<int>0</int>
<int>0</int>
<int>0</int>
<int>0</int>
<int>0</int>
<int>0</int>
<int>0</int>
<int>0</int>
<int>0</int>
<int>0</int>
<int>0</int>
</ArrayOfInt>
<ArrayOfInt>
<int>0</int>
<int>0</int>
<int>0</int>
<int>0</int>
<int>0</int>
<int>0</int>
<int>0</int>
<int>0</int>
<int>0</int>
<int>0</int>
<int>0</int>
<int>0</int>
<int>0</int>
<int>0</int>
<int>0</int>
<int>0</int>
</ArrayOfInt>
<ArrayOfInt>
<int>0</int>
<int>0</int>
<int>0</int>
<int>0</int>
<int>0</int>
<int>0</int>
<int>0</int>
<int>0</int>
<int>0</int>
<int>0</int>
<int>0</int>
<int>0</int>
<int>0</int>
<int>0</int>
<int>0</int>
<int>0</int>
</ArrayOfInt>
<ArrayOfInt>
<int>0</int>
<int>0</int>
<int>0</int>
<int>0</int>
<int>0</int>
<int>0</int>
<int>0</int>
<int>0</int>
<int>0</int>
<int>0</int>
<int>0</int>
<int>0</int>
<int>0</int>
<int>0</int>
<int>0</int>
<int>0</int>
</ArrayOfInt>
<ArrayOfInt>
<int>0</int>
<int>0</int>
<int>0</int>
<int>0</int>
<int>0</int>
<int>0</int>
<int>0</int>
<int>0</int>
<int>0</int>
<int>0</int>
<int>0</int>
<int>0</int>
<int>0</int>
<int>0</int>
<int>0</int>
<int>0</int>
</ArrayOfInt>
<ArrayOfInt>
<int>0</int>
<int>0</int>
<int>0</int>
<int>0</int>
<int>0</int>
<int>0</int>
<int>0</int>
<int>0</int>
<int>0</int>
<int>0</int>
<int>0</int>
<int>0</int>
<int>0</int>
<int>0</int>
<int>0</int>
<int>0</int>
</ArrayOfInt>
<ArrayOfInt>
<int>0</int>
<int>0</int>
<int>0</int>
<int>0</int>
<int>0</int>
<int>0</int>
<int>0</int>
<int>0</int>
<int>0</int>
<int>0</int>
<int>0</int>
<int>0</int>
<int>0</int>
<int>0</int>
<int>0</int>
<int>0</int>
</ArrayOfInt>
<ArrayOfInt>
<int>0</int>
<int>0</int>
<int>0</int>
<int>0</int>
<int>0</int>
<int>0</int>
<int>0</int>
<int>0</int>
<int>0</int>
<int>0</int>
<int>0</int>
<int>0</int>
<int>0</int>
<int>0</int>
<int>0</int>
<int>0</int>
</ArrayOfInt>
<ArrayOfInt>
<int>0</int>
<int>0</int>
<int>0</int>
<int>0</int>
<int>0</int>
<int>0</int>
<int>0</int>
<int>0</int>
<int>0</int>
<int>0</int>
<int>0</int>
<int>0</int>
<int>0</int>
<int>0</int>
<int>0</int>
<int>0</int>
</ArrayOfInt>
</PalletDefects>
<HourlyCounts >
<ArrayOfInt>
<int>0</int>
<int>0</int>
<int>0</int>
<int>0</int>
<int>0</int>
<int>0</int>
<int>0</int>
<int>0</int>
<int>0</int>
<int>0</int>
<int>2</int>
<int>0</int>
<int>0</int>
<int>0</int>
<int>0</int>
<int>0</int>
<int>0</int>
<int>0</int>
<int>0</int>
<int>0</int>
<int>0</int>
<int>0</int>
<int>0</int>
<int>0</int>
</ArrayOfInt>
<ArrayOfInt>
<int>0</int>
<int>0</int>
<int>0</int>
<int>0</int>
<int>0</int>
<int>0</int>
<int>0</int>
<int>0</int>
<int>0</int>
<int>0</int>
<int>0</int>
<int>0</int>
<int>0</int>
<int>0</int>
<int>0</int>
<int>0</int>
<int>0</int>
<int>0</int>
<int>0</int>
<int>0</int>
<int>0</int>
<int>0</int>
<int>0</int>
<int>0</int>
</ArrayOfInt>
<ArrayOfInt>
<int>0</int>
<int>0</int>
<int>0</int>
<int>0</int>
<int>0</int>
<int>0</int>
<int>0</int>
<int>0</int>
<int>0</int>
<int>0</int>
<int>0</int>
<int>0</int>
<int>0</int>
<int>0</int>
<int>0</int>
<int>0</int>
<int>0</int>
<int>0</int>
<int>0</int>
<int>0</int>
<int>0</int>
<int>0</int>
<int>0</int>
<int>0</int>
</ArrayOfInt>
<ArrayOfInt>
<int>0</int>
<int>0</int>
<int>0</int>
<int>0</int>
<int>0</int>
<int>0</int>
<int>0</int>
<int>0</int>
<int>0</int>
<int>0</int>
<int>2</int>
<int>0</int>
<int>0</int>
<int>0</int>
<int>0</int>
<int>0</int>
<int>0</int>
<int>0</int>
<int>0</int>
<int>0</int>
<int>0</int>
<int>0</int>
<int>0</int>
<int>0</int>
</ArrayOfInt>
<ArrayOfInt>
<int>0</int>
<int>0</int>
<int>0</int>
<int>0</int>
<int>0</int>
<int>0</int>
<int>0</int>
<int>0</int>
<int>0</int>
<int>0</int>
<int>0</int>
<int>0</int>
<int>0</int>
<int>0</int>
<int>0</int>
<int>0</int>
<int>0</int>
<int>0</int>
<int>0</int>
<int>0</int>
<int>0</int>
<int>0</int>
<int>0</int>
<int>0</int>
</ArrayOfInt>
<ArrayOfInt>
<int>0</int>
<int>0</int>
<int>0</int>
<int>0</int>
<int>0</int>
<int>0</int>
<int>0</int>
<int>0</int>
<int>0</int>
<int>0</int>
<int>0</int>
<int>0</int>
<int>0</int>
<int>0</int>
<int>0</int>
<int>0</int>
<int>0</int>
<int>0</int>
<int>0</int>
<int>0</int>
<int>0</int>
<int>0</int>
<int>0</int>
<int>0</int>
</ArrayOfInt>
<ArrayOfInt>
<int>0</int>
<int>0</int>
<int>0</int>
<int>0</int>
<int>0</int>
<int>0</int>
<int>0</int>
<int>0</int>
<int>0</int>
<int>0</int>
<int>0</int>
<int>0</int>
<int>0</int>
<int>0</int>
<int>0</int>
<int>0</int>
<int>0</int>
<int>0</int>
<int>0</int>
<int>0</int>
<int>0</int>
<int>0</int>
<int>0</int>
<int>0</int>
</ArrayOfInt>
<ArrayOfInt>
<int>0</int>
<int>0</int>
<int>0</int>
<int>0</int>
<int>0</int>
<int>0</int>
<int>0</int>
<int>0</int>
<int>0</int>
<int>0</int>
<int>0</int>
<int>0</int>
<int>0</int>
<int>0</int>
<int>0</int>
<int>0</int>
<int>0</int>
<int>0</int>
<int>0</int>
<int>0</int>
<int>0</int>
<int>0</int>
<int>0</int>
<int>0</int>
</ArrayOfInt>
<ArrayOfInt>
<int>0</int>
<int>0</int>
<int>0</int>
<int>0</int>
<int>0</int>
<int>0</int>
<int>0</int>
<int>0</int>
<int>0</int>
<int>0</int>
<int>0</int>
<int>0</int>
<int>0</int>
<int>0</int>
<int>0</int>
<int>0</int>
<int>0</int>
<int>0</int>
<int>0</int>
<int>0</int>
<int>0</int>
<int>0</int>
<int>0</int>
<int>0</int>
</ArrayOfInt>
<ArrayOfInt>
<int>0</int>
<int>0</int>
<int>0</int>
<int>0</int>
<int>0</int>
<int>0</int>
<int>0</int>
<int>0</int>
<int>0</int>
<int>0</int>
<int>0</int>
<int>0</int>
<int>0</int>
<int>0</int>
<int>0</int>
<int>0</int>
<int>0</int>
<int>0</int>
<int>0</int>
<int>0</int>
<int>0</int>
<int>0</int>
<int>0</int>
<int>0</int>
</ArrayOfInt>
<ArrayOfInt>
<int>0</int>
<int>0</int>
<int>0</int>
<int>0</int>
<int>0</int>
<int>0</int>
<int>0</int>
<int>0</int>
<int>0</int>
<int>0</int>
<int>0</int>
<int>0</int>
<int>0</int>
<int>0</int>
<int>0</int>
<int>0</int>
<int>0</int>
<int>0</int>
<int>0</int>
<int>0</int>
<int>0</int>
<int>0</int>
<int>0</int>
<int>0</int>
</ArrayOfInt>
<ArrayOfInt>
<int>0</int>
<int>0</int>
<int>0</int>
<int>0</int>
<int>0</int>
<int>0</int>
<int>0</int>
<int>0</int>
<int>0</int>
<int>0</int>
<int>0</int>
<int>0</int>
<int>0</int>
<int>0</int>
<int>0</int>
<int>0</int>
<int>0</int>
<int>0</int>
<int>0</int>
<int>0</int>
<int>0</int>
<int>0</int>
<int>0</int>
<int>0</int>
</ArrayOfInt>
<ArrayOfInt>
<int>0</int>
<int>0</int>
<int>0</int>
<int>0</int>
<int>0</int>
<int>0</int>
<int>0</int>
<int>0</int>
<int>0</int>
<int>0</int>
<int>0</int>
<int>0</int>
<int>0</int>
<int>0</int>
<int>0</int>
<int>0</int>
<int>0</int>
<int>0</int>
<int>0</int>
<int>0</int>
<int>0</int>
<int>0</int>
<int>0</int>
<int>0</int>
</ArrayOfInt>
<ArrayOfInt>
<int>0</int>
<int>0</int>
<int>0</int>
<int>0</int>
<int>0</int>
<int>0</int>
<int>0</int>
<int>0</int>
<int>0</int>
<int>0</int>
<int>0</int>
<int>0</int>
<int>0</int>
<int>0</int>
<int>0</int>
<int>0</int>
<int>0</int>
<int>0</int>
<int>0</int>
<int>0</int>
<int>0</int>
<int>0</int>
<int>0</int>
<int>0</int>
</ArrayOfInt>
<ArrayOfInt>
<int>0</int>
<int>0</int>
<int>0</int>
<int>0</int>
<int>0</int>
<int>0</int>
<int>0</int>
<int>0</int>
<int>0</int>
<int>0</int>
<int>0</int>
<int>0</int>
<int>0</int>
<int>0</int>
<int>0</int>
<int>0</int>
<int>0</int>
<int>0</int>
<int>0</int>
<int>0</int>
<int>0</int>
<int>0</int>
<int>0</int>
<int>0</int>
</ArrayOfInt>
<ArrayOfInt>
<int>0</int>
<int>0</int>
<int>0</int>
<int>0</int>
<int>0</int>
<int>0</int>
<int>0</int>
<int>0</int>
<int>0</int>
<int>0</int>
<int>0</int>
<int>0</int>
<int>0</int>
<int>0</int>
<int>0</int>
<int>0</int>
<int>0</int>
<int>0</int>
<int>0</int>
<int>0</int>
<int>0</int>
<int>0</int>
<int>0</int>
<int>0</int>
</ArrayOfInt>
<ArrayOfInt>
<int>0</int>
<int>0</int>
<int>0</int>
<int>0</int>
<int>0</int>
<int>0</int>
<int>0</int>
<int>0</int>
<int>0</int>
<int>0</int>
<int>0</int>
<int>0</int>
<int>0</int>
<int>0</int>
<int>0</int>
<int>0</int>
<int>0</int>
<int>0</int>
<int>0</int>
<int>0</int>
<int>0</int>
<int>0</int>
<int>0</int>
<int>0</int>
</ArrayOfInt>
<ArrayOfInt>
<int>0</int>
<int>0</int>
<int>0</int>
<int>0</int>
<int>0</int>
<int>0</int>
<int>0</int>
<int>0</int>
<int>0</int>
<int>0</int>
<int>0</int>
<int>0</int>
<int>0</int>
<int>0</int>
<int>0</int>
<int>0</int>
<int>0</int>
<int>0</int>
<int>0</int>
<int>0</int>
<int>0</int>
<int>0</int>
<int>0</int>
<int>0</int>
</ArrayOfInt>
<ArrayOfInt>
<int>0</int>
<int>0</int>
<int>0</int>
<int>0</int>
<int>0</int>
<int>0</int>
<int>0</int>
<int>0</int>
<int>0</int>
<int>0</int>
<int>0</int>
<int>0</int>
<int>0</int>
<int>0</int>
<int>0</int>
<int>0</int>
<int>0</int>
<int>0</int>
<int>0</int>
<int>0</int>
<int>0</int>
<int>0</int>
<int>0</int>
<int>0</int>
</ArrayOfInt>
<ArrayOfInt>
<int>0</int>
<int>0</int>
<int>0</int>
<int>0</int>
<int>0</int>
<int>0</int>
<int>0</int>
<int>0</int>
<int>0</int>
<int>0</int>
<int>0</int>
<int>0</int>
<int>0</int>
<int>0</int>
<int>0</int>
<int>0</int>
<int>0</int>
<int>0</int>
<int>0</int>
<int>0</int>
<int>0</int>
<int>0</int>
<int>0</int>
<int>0</int>
</ArrayOfInt>
<ArrayOfInt>
<int>0</int>
<int>0</int>
<int>0</int>
<int>0</int>
<int>0</int>
<int>0</int>
<int>0</int>
<int>0</int>
<int>0</int>
<int>0</int>
<int>0</int>
<int>0</int>
<int>0</int>
<int>0</int>
<int>0</int>
<int>0</int>
<int>0</int>
<int>0</int>
<int>0</int>
<int>0</int>
<int>0</int>
<int>0</int>
<int>0</int>
<int>0</int>
</ArrayOfInt>
<ArrayOfInt>
<int>0</int>
<int>0</int>
<int>0</int>
<int>0</int>
<int>0</int>
<int>0</int>
<int>0</int>
<int>0</int>
<int>0</int>
<int>0</int>
<int>0</int>
<int>0</int>
<int>0</int>
<int>0</int>
<int>0</int>
<int>0</int>
<int>0</int>
<int>0</int>
<int>0</int>
<int>0</int>
<int>0</int>
<int>0</int>
<int>0</int>
<int>0</int>
</ArrayOfInt>
<ArrayOfInt>
<int>0</int>
<int>0</int>
<int>0</int>
<int>0</int>
<int>0</int>
<int>0</int>
<int>0</int>
<int>0</int>
<int>0</int>
<int>0</int>
<int>0</int>
<int>0</int>
<int>0</int>
<int>0</int>
<int>0</int>
<int>0</int>
<int>0</int>
<int>0</int>
<int>0</int>
<int>0</int>
<int>0</int>
<int>0</int>
<int>0</int>
<int>0</int>
</ArrayOfInt>
<ArrayOfInt>
<int>0</int>
<int>0</int>
<int>0</int>
<int>0</int>
<int>0</int>
<int>0</int>
<int>0</int>
<int>0</int>
<int>0</int>
<int>0</int>
<int>0</int>
<int>0</int>
<int>0</int>
<int>0</int>
<int>0</int>
<int>0</int>
<int>0</int>
<int>0</int>
<int>0</int>
<int>0</int>
<int>0</int>
<int>0</int>
<int>0</int>
<int>0</int>
</ArrayOfInt>
</HourlyCounts>
<Defects>
<int>0</int>
<int>0</int>
<int>0</int>
<int>0</int>
<int>0</int>
<int>0</int>
<int>0</int>
<int>0</int>
<int>0</int>
<int>0</int>
<int>0</int>
<int>0</int>
<int>0</int>
<int>0</int>
<int>0</int>
<int>0</int>
<int>0</int>
<int>0</int>
<int>0</int>
<int>0</int>
<int>0</int>
<int>0</int>
<int>0</int>
<int>0</int>
<int>0</int>
<int>0</int>
<int>0</int>
<int>0</int>
<int>0</int>
<int>0</int>
<int>0</int>
<int>0</int>
<int>0</int>
<int>0</int>
<int>0</int>
<int>0</int>
</Defects>
</DataProcessTest ingSettings>fec ts> --- This what happens
itermittently.
</DataProcessTest ingSettings>

Thanks Ron

-----Original Message-----
Ron,

Without seeing some code, it would be difficult to tell. Generallyspeaking, I can't imagine that it would do this on it's own, and if it does,it needs to be reported as a bug.

Can you post your code that is serializing this, as well as the code forthe class that is being serialized?
--
- Nicholas Paldino [.NET/C# MVP]
- ni************* *@exisconsultin g.com

"ron" <goodr@no_spam4 me_mddm.panason ic.com> wrote in messagenews:57******* *************** ******@phx.gbl. ..
Hi,
I have class object that i serialize using the
System.Xml.Seri alization class.

Intermittently the object is not getting serialized
correctly, using System.Xml.Seri alization classes.
Therefore the application errors out when deserializing
the xml data.

It places the some part of the child element

<MyRootElemen t>
<SomeOtherEleme nt>
</SomeOtherElemen t>
</MyRootElement>e ment> --- This gets added to the end of the root element name.

What would be causing this.

Ron Good

.

Nov 15 '05 #4
Ron,

Can you trim this down a little bit so that only the relevant sections
are shown?
--
- Nicholas Paldino [.NET/C# MVP]
- ni************* *@exisconsultin g.com

"ron" <goodr@no_spam4 me_mdda.panason ic.com> wrote in message
news:54******** *************** *****@phx.gbl.. .
Nicholas,

The first part is the Base class
The second part is the one calling the Serializer from
the base.

using System;
using System.Data;
using System.Data.Sql Client;
using System.Configur ation;
using System.IO;
using System.Text;
using FDS.SmartCalend ar;
using FDS.Data.Core;
using System.Diagnost ics;
using System.Xml.Seri alization;

namespace FDS.DataCollect ionServer.DataP rocessing
{
/// <summary>
/// Summary description for DataProcess.
/// </summary>
public abstract class DataProcess : DbObject
{
private int lineId;
private static string fileName = null;
private static DateTime
previousProduct ionDate;
private static bool newcycle;
private static int tubeNumber;
private static int totRejects;

protected static ShiftCalendar.C alendar
cal = new ShiftCalendar.C alendar();

/// <summary>
///
/// </summary>
/// <param
name="newConnec tionString"></param>
public DataProcess(str ing
newConnectionSt ring) : base(newConnect ionString)
{
previousProduct ionDate =
DateTime.Now;
}

/// <summary>
/// Set the public fields to supply
settings to DataProcess.
/// </summary>
[Serializable]
public class ProcessedSettin gs
{
public int LastTubeNumber =
tubeNumber;
public string RawDataFile =
fileName;
public DateTime
LastProductionD ate = previousProduct ionDate;

/// <summary>
/// Save the object in XML format
to a stream
/// </summary>
/// <param name="s">Stream to
save the object to</param>
public void SaveAsXML(Strea m s)
{
XmlSerializer sr = new
XmlSerializer(t his.GetType());
sr.Serialize(s, this);
}

/// <summary>
/// Create a new
ProcessedSettin gs object initialised from XML data
/// </summary>
/// <param name="s">Stream to
load the XML from</param>
/// <returns>Proces sedSettings
object</returns>
public static ProcessedSettin gs
LoadFromXML(Str eam s)
{
return LoadFromXML(s,
typeof(Processe dSettings));
}

/// <summary>
/// Create a new object loading
members from the stream in XML format.
/// Derived class should call
this from a static method i.e.:
/// return
(ProcessedDeriv edSettings)Load FromXML(s, typeof
(ProcessedDeriv edSettings));
/// </summary>
/// <param name="s">Stream to
load the object from</param>
/// <param name="t">Type of the
derived object</param>
/// <returns></returns>
protected static
ProcessedSettin gs LoadFromXML(Str eam s, Type t)
{
XmlSerializer sr = new
XmlSerializer(t );
try
{
return
(ProcessedSetti ngs)sr.Deserial ize(s);
}
catch(Exception e)
{
string
errorMessage = "";

errorMessage
= "Message: " + e.Message + "\n";
EventLog log =
new EventLog();
log.Source
= "DCServer";
log.WriteEntry
(errorMessage);
return null;
}
}

}

#region "Properties ..."

public int TubeNumber{get{ return
tubeNumber;}set {tubeNumber = value;}}

public int TotalRejects{ge t{return
totRejects;}set {totRejects = value;}}

public string FileName{get{re turn
fileName;}set{f ileName = value;}}

public int LineId{get{retu rn lineId;}set
{lineId = value;}}

public DateTime PreviousProduct ionDate{get
{return previousProduct ionDate;}set
{previousProduc tionDate = value;}}

public bool IsNewProduction Cycle{get
{return newcycle;}set{n ewcycle = value;}}

#endregion

public void GetShift()
{
cal.CurrentShif t(LineId);
}

public void GetNewFileName( )
{
// The name uses day,month,year
conjoined to establish the file name.
// example file
name="raw_01172 003.txt
fileName = "raw_";
// strip slashes
string[] dateValues =
cal.ProductionD ate.Split('/');
for(int i = 0; i <
dateValues.Leng th; i++)
{
fileName += dateValues[i];
}
fileName += ".txt";

}

protected void CheckShiftStatu s()
{
// End of current shift get new
shift
if(DateTime.Now > cal.EndShift)
{
GetShift();
// Look for new
prodcution cycle if 2 or 4 shift type configuration
if((cal.ShiftTy pe != "3-
Shift") & (cal.Shift == "A" | cal.Shift == "C"))
ProductionCycle Reset();
// Look for new
prodcution cycle if 3 shift type configuration
if((cal.ShiftTy pe == "3-
Shift") & (cal.Shift == "A"))Production CycleReset();
}
else
{
// System may have been
shut down for more than 24 hr
// Look to see if system
was shut down
if(DateTime.Par se
(cal.Production Date) > PreviousProduct ionDate)
ProductionCycle Reset();
// Look for no file name
if(fileName == null)
ProductionCycle Reset();
}

// increment tube after checking
shift status
tubeNumber++;
TubeNumber = tubeNumber;
}

private void ProductionCycle Reset()
{
GetNewFileName( );
FileName = fileName;
PreviousProduct ionDate =
DateTime.Parse( cal.ProductionD ate);
tubeNumber = 0;
totRejects = 0;
newcycle = true;
}

public abstract void Process(string[]
dmData, string[] frameCheckSum);

public abstract void LoadSettings();

public abstract void SaveSettings();
}

}

+++++++++++++++ +++++++++++++++ +++++++++++++++ ++++++++
Second Part
+++++++++++++++ +++++++++++++++ +++++++++++++++ ++++++++

using System;
using System.Data;
using System.Data.Sql Client;
using System.Configur ation;
using System.IO;
using System.Text;
using FDS.SmartCalend ar;
using System.Globaliz ation;
using System.Diagnost ics;
using System.Xml.Seri alization;

namespace FDS.DataCollect ionServer.DataP rocessing
{
/// <summary>
/// Summary description for DataProcessTest ing.
/// </summary>
public class DataProcessTest ing : DataProcess
{
// Internal fields
DateTime testDate;
string[] fcs = new string[2];
string[] dmArray;
int[] judgements = new int[7];
bool[] online = new bool[7];
bool[] decisions = new bool[144];
static int[] defects = new int[36];
static int[][] palletdefect = new int[21]
[];
static int[] palletrevolutio n = new int
[21];
static int[][] hourlyCount = new int[24]
[];
string testResult = null;
string troubleFlag = null;
bool isTestPiece;
bool isReject;
bool isNoTest;
bool isGO;
bool nowork;
int testType;
int records;
int palletnumber;
string[] tallyItem =
{"Virgin", "Reage", "Respark", "Gross", "No Test",

"Screen", "Mask", "Ba", "Purity", "Gun Rotation",

"Insulation ", "Vkco", "Igas", "Ki", "Emission", "S
lump",

"Ig2", "Ig3", "Stray", "Visual G3", "Visual
G2", "Others",
"Test
Piece", "Total"};

public static DataProcessTest ingSettings
settings;
string fSettings = @"settings.xml" ;

#region Properties ...

protected bool IsNoWork{get{re turn
nowork;}set{now ork = value;}}

protected bool DecisionIsNoTes t{get
{return isNoTest;}set{i sNoTest = value;}}

protected bool DecisionIsRejec t{get
{return isReject;}set{i sReject = value;}}

protected bool DecisionIsGo{ge t{return
isGO;}set{isGO = value;}}

protected string TestResult{get{ return
testResult;}}

protected bool IsTestPiece{get {return
isTestPiece;}}

protected string TroubleFlag{get {return
troubleFlag;}se t{troubleFlag = value;}}

protected int TestType{get{re turn
testType;}set{t estType = value;}}

protected int[] Judgements{get{ return
judgements;}}

protected bool[] TestOnline{get{ return
online;}}

protected bool[] Decisions{get{r eturn
decisions;}}

protected int PalletNumber{ge t{return
palletnumber;}s et{palletnumber = value;}}

#endregion

protected enum DecimalLocation
{
Tenths,
Hundredths,
None
}

protected enum HexToBinType
{
Decision,
Flag
}

protected enum Type
{
Virgin = 0,
Reage = 1,
Respark = 2,
};

public DataProcessTest ing(string
newConnectionSt ring) : base(newConnect ionString)
{
for(int i=0;
i<palletdefect. Length; i++)
{
palletdefect[i] = new int
[16];
}

for(int i=0;
i<hourlyCount.L ength; i++)
{
hourlyCount[i] = new int
[24];
}
}
/// <summary>
/// Extends ProcessedSettin gs to add the
settings used by DataProcessTest ingSettings.
/// </summary>
[Serializable]
public class DataProcessTest ingSettings :
DataProcess.Pro cessedSettings
{
public int[] PalletRevolutio ns =
palletrevolutio n;
public int[][] PalletDefects =
palletdefect;
public int[][] HourlyCounts =
hourlyCount;
public int[] Defects = defects;

public static new
DataProcessTest ingSettings LoadFromXML(Str eam s)
{
return
(DataProcessTes tingSettings)Lo adFromXML(s, typeof
(DataProcessTes tingSettings));
}
}

public override void LoadSettings()
{

FileInfo f = new FileInfo
(fSettings);
if(f.Exists)
{
Stream fs = f.OpenRead();
try
{
settings =
DataProcessTest ingSettings.Loa dFromXML(fs);
}
catch(Exception e)
{
string
errorMessage = "";

errorMessage
= "Message: " + e.Message + "\n";
EventLog log =
new EventLog();
log.Source
= "DCServer";
log.WriteEntry
(errorMessage);
}
fs.Close();
base.TubeNumber =
settings.LastTu beNumber;
base.FileName =
settings.RawDat aFile;

base.PreviousPr oductionDate =
settings.LastPr oductionDate;
}
else
{
// File dose not exist
use default settings
settings = new
DataProcessTest ingSettings();
}
}
public override void SaveSettings()
{

settings = new
DataProcessTest ingSettings();

settings.LastTu beNumber =
base.TubeNumber ;
settings.RawDat aFile =
base.FileName;
settings.LastPr oductionDate =
base.PreviousPr oductionDate;
settings.Pallet Revolutions =
palletrevolutio n;
settings.Pallet Defects =
palletdefect;
settings.Hourly Counts =
hourlyCount;
settings.Defect s = defects;

FileInfo f = new FileInfo
(fSettings);
Stream fs = f.OpenWrite();
settings.SaveAs XML(fs);
fs.Close();

}
public override void Process(string[]
dmData, string[] frameCheckSum)
{
// Create defualt values before
processing data string
testDate = DateTime.Now;
int hr = testDate.Hour;
string rawData = null;
// DecisionIsNoTes t = false;
// DecisionIsRejec t = false;
// DecisionIsGo = false;

// Create a string array of the
PLC DM data to work with
dmArray = new string
[dmData.Length];
dmArray = dmData;
fcs = frameCheckSum;

// Look for work status
IsNoWork = GetWorkStatus() ;

// Check to see if we need to
process for work,
// terminate execution of the
method and return control to the calling method.
if(IsNoWork)
{
//return control to the
calling method
return;
}
else
{
// OK Pallet has work so
lets get to work.
// Check the shift status.
base.CheckShift Status();
// Check for new
production cycle and reset count's
if
(base.IsNewProd uctionCycle)Res et();

// Get the pallet number
PalletNumber =
GetPalletNumber (dmArray[120]);
// Check the Pallet
Number and make sure it is not "0"
// if it is then return
control to the calling method recived incorrect pallet
number
if(PalletNumber == 0)
return;
palletrevolutio n
[PalletNumber]++;

// Get all test
position's on-line status
CheckOnlineStat us();

// Convert all decision
bit's from hex to binary
dmArray[0] =
ConvertHexToBin (dmArray[0], HexToBinType.De cision);
dmArray[20] =
ConvertHexToBin (dmArray[20], HexToBinType.De cision);
dmArray[40] =
ConvertHexToBin (dmArray[40], HexToBinType.De cision);
dmArray[60] =
ConvertHexToBin (dmArray[60], HexToBinType.De cision);
dmArray[80] =
ConvertHexToBin (dmArray[80], HexToBinType.De cision);
dmArray[100] =
ConvertHexToBin (dmArray[100], HexToBinType.De cision);
dmArray[101] =
ConvertHexToBin (dmArray[101], HexToBinType.De cision);
dmArray[112] =
ConvertHexToBin (dmArray[112], HexToBinType.De cision);
dmArray[113] =
ConvertHexToBin (dmArray[113], HexToBinType.De cision);
// Concatenate all the
test positions decision bits
string decisionbits =
dmArray[0] + dmArray[20] + dmArray[40] + dmArray[60] +
dmArray[80] + dmArray[100] + dmArray[101] + dmArray[112]
+ dmArray[113];

// Check all test
position's decision bits
CheckDecisions
(decisionbits);

// Convert the test and
tracking flags
dmArray[121] =
ConvertHexToBin (dmArray[121], HexToBinType.Fl ag);
dmArray[122] =
ConvertHexToBin (dmArray[122], HexToBinType.Fl ag);

// Get all test position
judgement's
GetJudgements() ;

// Set Trouble Flag
TroubleFlag =
GetTroubleFlag( );

// Get the test type
(virgin,reage,r espark) and count for each type
TestType = GetTestType();

// Get the final test
decision
GetFinalDecisio n();

// Calculate defects only
if test is a reject and virgin.
if(this.Decisio nIsReject
& this.TestType == 0)
{

base.TotalRejec ts++;
CalculateDefect s
();
}

// Calculate pallet
defects only if test is virgin.
if(this.TestTyp e == 0)
CalculatePallet Defects();

// Calculate hourly counts

CalculateHourly Counts();

// Calculate all test
values that need signed value's and decimal location's.
CalculateTestVa lues();

// Create a csv file
format to save as the raw data file
rawData =
TubeNumber.ToSt ring() + "," + cal.Shift + "," +
cal.ShiftType + ",";
rawData +=
testDate.ToStri ng("HH:mm:ss") + "," + cal.ProductionD ate
+ ",";
rawData +=
testDate.Hour.T oString() + "," + this.TestResult + ",";
for(int i = 0; i<
dmArray.Length; i++)
{
rawData += dmArray
[i] + ",";
}
rawData += fcs[0] + "," +
fcs[1];

Console.WriteLi ne
(rawData);
Console.WriteLi ne();

// Save raw data to text
file on local machine.
//SaveRawDataFile
(rawData);

// Insert new DM data to
the database
//records = InsertDMData
();
//records = InsertDefects
();
//records =
InsertPalletDet ails();
//records =
InsertHourlyCou nts();
}

}
protected void Reset()
{
base.IsNewProdu ctionCycle = false;
// Sets all elements in the
Array's to zero, to false,
// or to a null reference,
depending on the element type.
Array.Clear(pal letrevolution, 0,
palletrevolutio n.Length);
Array.Clear(def ects, 0,
defects.Length) ;

foreach(int[] subArray in
palletdefect)
{
Array.Clear(sub Array, 0,
subArray.Length );
}

foreach(int[] subArray in
hourlyCount)
{
Array.Clear (subArray, 0,
subArray.Length );
}
}

// Check the online status of all test
positions to see if the pallet has work.
protected bool GetWorkStatus()
{
return (((dmArray[3] == "0000") &
(dmArray[23] == "0000") & (dmArray[43] == "0000") &
(dmArray[63] == "0000") & (dmArray[83] == "0000") &
(dmArray[103] == "0000")) == true)? true : false;
}
protected void CheckOnlineStat us()
{
int j = 0;
try
{
for(int i=3; i<=103;
i+=20)
{
online[j] = (0x1
== int.Parse(dmArr ay[i].Substring(3,1) ,
NumberStyles.He xNumber))? true : false;
j++;
}
// Establish test sevens
status by looking at the test flag and tracking flag bits
online[6] = ((0x8 ==
int.Parse(dmArr ay[121].Substring
(3,1),NumberSty les.HexNumber)) ||
(0x8 == int.Parse
(dmArray[122].Substring(3,1) ,NumberStyles.H exNumber)))?
true : false;
}
catch(Exception e)
{
string errorMessage = "";

errorMessage
= "Message: " + e.Message + "\n";
EventLog log = new
EventLog();
log.Source = "DCServer";
log.WriteEntry
(errorMessage);
}
}
protected void GetJudgements()
{
int j = 0;
try
{
// Check test position's
1-5 judgement.
for(int i=4; i<84; i+=20)
{
judgements[j] =
int.Parse(dmArr ay[i]);
j++;
}

// Check on-line status
of test positions 6 and 7
// preform judgement
logic accordingly.
if((TestOnline[5]) &
(TestOnline[6]))
{
// Look at
tracking and test flags for no-test condition.
if(dmArray
[121].Substring(5,1) == "1" & dmArray[122].Substring(5,1)
== "0") // no-test condition
{
judgements
[5] = 2;
}
else if(dmArray
[121].Substring(5,1) == "1" & dmArray[122].Substring(5,1)
== "1") // tested condition
{
// Check
test position 6 judgement.
judgements
[5] = (0 != Convert.ToInt32 (dmArray[113], 2))? 1 : 0;
}
else
{
// Gets
the defualt test condition
judgements
[5] = int.Parse(dmArr ay[104]);
}

// Check test
position 7 judgement
// Look at
tracking and test flags for no-test condition.
if(dmArray
[121].Substring(6,1) == "1" & dmArray[122].Substring(6,1)
== "0")
{
// Test
flags indicate no-test condition
judgements
[6] = 2;
}
else
{
// Gets
the defualt test condition
judgements
[6] = int.Parse(dmArr ay[104]);
}
}
else if((TestOnline[5] ==
true) & (TestOnline[6] == false))
{
// Test 7 is off
line get the defualt test condition
judgements[5] =
int.Parse(dmArr ay[104]);
}
else if((TestOnline[5] ==
false) & (TestOnline[6] == true))
{
// Test 6 is off
line get the defualt test condition
judgements[6] =
int.Parse(dmArr ay[104]);
}
}
catch(Exception e)
{
string errorMessage = "";

errorMessage
= "Message: " + e.Message + "\n";
EventLog log = new
EventLog();
log.Source = "DCServer";
log.WriteEntry
(errorMessage);
}
}
protected int GetTestType()
{
// Set default type to virgin
int type = 0;
try
{
if((dmArray[148]
== "0000") & (dmArray[149] == "0000")) // virgin
{
type = (int)
Type.Virgin;
}
else if(dmArray[148]
== "0001")
// reage
{
type = (int)
Type.Reage;
}
else if(dmArray[149]
== "0001")
// respark
{
type = (int)
Type.Respark;
}
}
catch(Exception e)
{
string errorMessage = "";

errorMessage
= "Message: " + e.Message + "\n";
EventLog log = new
EventLog();
log.Source = "DCServer";
log.WriteEntry
(errorMessage);
}
return type;
}
protected void GetFinalDecisio n()
{
DecisionIsGo = (int.Parse(dmAr ray
[124]) == 0 & int.Parse(dmArr ay[123]) == 0)? true : false;
DecisionIsRejec t = (int.Parse
(dmArray[124]) == 1 & int.Parse(dmArr ay[123]) == 0)?
true : false;
DecisionIsNoTes t = (int.Parse
(dmArray[124]) != 0 & int.Parse(dmArr ay[123]) != 0)?
true : false;
}
protected string GetTroubleFlag( )
{
string tflag = null;
try
{
for(int i = 2; i < 102; i
+= 20)
{
tflag += dmArray
[i].Substring(3,1) ;
}
}
catch(Exception e)
{
string errorMessage = "";

errorMessage
= "Message: " + e.Message + "\n";
EventLog log = new
EventLog();
log.Source = "DCServer";
log.WriteEntry
(errorMessage);
}

return tflag.PadRight( 10, '0');
}
protected int GetPalletNumber (string dm)
{
int palNumber = 0;
try
{
palNumber =
Convert.ToInt32 (dm, 16);
if(palNumber > 32)
palNumber -= 32;
}
catch(Exception e)
{
string errorMessage = "";

errorMessage
= "Message: " + e.Message + "\n";
EventLog log = new
EventLog();
log.Source = "DCServer";
log.WriteEntry
(errorMessage);
}

return palNumber;
}
protected void CheckDecisions( string bits)
{
try
{
for(int i=0; i <
bits.Length; i++)
{
decisions[i] =
(bits.Substring (i,1) == "1")? true : false;
}
}
catch(Exception e)
{
string errorMessage = "";

errorMessage
= "Message: " + e.Message + "\n";
EventLog log = new
EventLog();
log.Source = "DCServer";
log.WriteEntry
(errorMessage);
}
}
protected string ConvertHexToBin (string
dm, HexToBinType type)
{
try
{

switch(type)
{
case
HexToBinType.De cision:
dm =
Convert.ToStrin g(Convert.ToInt 32(dm, 16), 2).PadLeft
(16, '0');
break;
case
HexToBinType.Fl ag:
dm =
Convert.ToStrin g(Convert.ToInt 32(dm, 16), 2).PadRight
(10, '0');
break;
}
}
catch(Exception e)
{
string errorMessage = "";

errorMessage
= "Message: " + e.Message + "\n";
EventLog log = new
EventLog();
log.Source = "DCServer";
log.WriteEntry
(errorMessage);
}

return dm;
}
protected string CalculateSlump( string
dm, int ik1, int ik2)
{
// Initial string value will be 4
chars insert decimal at tenths location
// If 'ik2 > ik1' then slump is
negitive calculate slump value
string slump = dm.Insert(3,"." );
try
{
slump = (ik2 > ik1)? (0 -
double.Parse(sl ump)).ToString( "##0.0") : double.Parse
(slump).ToStrin g("##0.0");
}
catch(Exception e)
{
string errorMessage = "";

errorMessage
= "Message: " + e.Message + "\n";
EventLog log = new
EventLog();
log.Source = "DCServer";
log.WriteEntry
(errorMessage);
}

return slump;
}
protected string CalculatePosNeg (string
dm, DecimalLocation location)
{
// Initial string value will be 4
chars.
// The value of "8" from the PLC
is a BCD value for
// negative, all other values
less than 8000 are positive.
// Tenths will modify to "##0.0"
or "-##0.0"
// Hundredths will modify
to "#0.00" or "-#0.00"
// None will modify to "###0"
or "-###0"
try
{
switch(location )
{
case
DecimalLocation .Tenths:
dm =
(double.Parse(d m) > 7999)? ((8000 - double.Parse(dm )) /
10).ToString("# #0.0") : (double.Parse(d m) / 10).ToString
("##0.0");
break;
case
DecimalLocation .Hundredths:
dm =
(double.Parse(d m) > 7999)? ((8000 - double.Parse(dm )) /
100).ToString(" #0.00") : (double.Parse(d m) / 100).ToString
("#0.00");
break;
case
DecimalLocation .None:
dm =
(int.Parse(dm) > 7999)? (8000 - int.Parse(dm)). ToString
("###0") : int.Parse(dm).T oString("###0") ;
break;
}
}
catch(Exception e)
{
string errorMessage = "";

errorMessage
= "Message: " + e.Message + "\n";
EventLog log = new
EventLog();
log.Source = "DCServer";
log.WriteEntry
(errorMessage);
}

return dm;
}
protected void CalculateTestVa lues()
{
// Test position 1
dmArray[5] = CalculatePosNeg
(dmArray[5], DecimalLocation .Tenths);
// ins1
dmArray[6] = CalculatePosNeg
(dmArray[6], DecimalLocation .Tenths);
// ins2
dmArray[7] = CalculatePosNeg
(dmArray[7], DecimalLocation .Tenths);
// ins3
dmArray[8] = CalculatePosNeg
(dmArray[8], DecimalLocation .Tenths);
// ins4

dmArray[9] = CalculatePosNeg
(dmArray[9], DecimalLocation .Tenths);
// ins5
// Test postion 2
dmArray[25] = CalculatePosNeg
(dmArray[25], DecimalLocation .Hundredths);
// ig3-1
dmArray[26] = CalculatePosNeg
(dmArray[26], DecimalLocation .Hundredths);
// ig3-2
dmArray[27] = CalculatePosNeg
(dmArray[27], DecimalLocation .Hundredths);
// stray low
dmArray[28] = CalculatePosNeg
(dmArray[28], DecimalLocation .Hundredths);
// ig2
dmArray[29] = CalculatePosNeg
(dmArray[29], DecimalLocation .None);
// spark
dmArray[30] = CalculatePosNeg
(dmArray[30], DecimalLocation .Hundredths);
// stray high
// Test position 3
dmArray[45] = CalculatePosNeg
(dmArray[45], DecimalLocation .None);
// ikr
dmArray[46] = CalculatePosNeg
(dmArray[46], DecimalLocation .None);
// ikg
dmArray[47] = CalculatePosNeg
(dmArray[47], DecimalLocation .None);
// ikb
dmArray[48] = CalculatePosNeg
(dmArray[48], DecimalLocation .None);
// spark
// Test position 4
dmArray[65] = CalculatePosNeg
(dmArray[65], DecimalLocation .Tenths);
// vkcor
dmArray[66] = CalculatePosNeg
(dmArray[66], DecimalLocation .Tenths);
// vkcog
dmArray[67] = CalculatePosNeg
(dmArray[67], DecimalLocation .Tenths);
// vkcob
dmArray[68] = CalculatePosNeg
(dmArray[68], DecimalLocation .None);
// dvk
// Emission calculations red
dmArray[72] = CalculatePosNeg
(dmArray[72], DecimalLocation .None);
// ik1r
dmArray[69] = CalculatePosNeg
(dmArray[69], DecimalLocation .None);
// ik2r
dmArray[74] = CalculateSlump
(dmArray[74],int.Parse(dmAr ray[72]), int.Parse(dmArr ay
[69])); // srr
// Emission calculations green
dmArray[73] = CalculatePosNeg
(dmArray[73], DecimalLocation .None);
// ik1g
dmArray[70] = CalculatePosNeg
(dmArray[70], DecimalLocation .None);
// ik2g
dmArray[75] = CalculateSlump
(dmArray[75],int.Parse(dmAr ray[73]), int.Parse(dmArr ay
[70])); // srg
// Emission calculations blue
dmArray[79] = CalculatePosNeg
(dmArray[79], DecimalLocation .None);
// ik1b
dmArray[71] = CalculatePosNeg
(dmArray[71], DecimalLocation .None);
// ik2b
dmArray[76] = CalculateSlump
(dmArray[76],int.Parse(dmAr ray[79]), int.Parse(dmArr ay
[71])); // srb

dmArray[77] = CalculatePosNeg
(dmArray[77], DecimalLocation .None);
// ih
dmArray[78] = CalculatePosNeg
(dmArray[78], DecimalLocation .None);
// spark
// Test position 5
dmArray[85] = CalculatePosNeg
(dmArray[85], DecimalLocation .None);
// igas
dmArray[86] = CalculatePosNeg
(dmArray[86], DecimalLocation .None);
// i1
dmArray[87] = CalculatePosNeg
(dmArray[87], DecimalLocation .None);
// i2
dmArray[88] = CalculatePosNeg
(dmArray[88], DecimalLocation .None);
// ikgas
// Test position 6/7 (visual's)
dmArray[105] = CalculatePosNeg
(dmArray[105], DecimalLocation .None);
// 2px
dmArray[106] = CalculatePosNeg
(dmArray[106], DecimalLocation .None);
// 2py
dmArray[107] = CalculatePosNeg
(dmArray[107], DecimalLocation .None);
// 4px
dmArray[108] = CalculatePosNeg
(dmArray[108], DecimalLocation .None);
// 4py
dmArray[109] = CalculatePosNeg
(dmArray[109], DecimalLocation .None);
// 6px
dmArray[110] = CalculatePosNeg
(dmArray[110], DecimalLocation .None);
// 6py
dmArray[111] = CalculatePosNeg
(dmArray[111], DecimalLocation .None);
// spark

}
protected void CalculateDefect s()
{
// Check the decision bit for
ture state
// increament the correspoding
defect counter
if(decisions[15])defects[0]++;
// ins1
if(decisions[14])defects[1]++;
// ins2
if(decisions[13])defects[2]++;
// ins3
if(decisions[12])defects[3]++;
// ins4
if(decisions[11])defects[4]++;
// ins5
if(decisions[31])defects[5]++;
// test2 spark
if(decisions[30])defects[6]++;
// test2 spark pass
if(decisions[29])defects[7]++;
// ig3-1
if(decisions[28])defects[8]++;
// ig3-2
if(decisions[26])defects[9]++;
// ig2
if(decisions[25])defects[10]++;
// stray
if(decisions[63])defects[11]++;
// test4 spark
if(decisions[62])defects[12]++;
// ik-auto
if(decisions[61])defects[13]++;
// vkr
if(decisions[60])defects[14]++;
// vkg
if(decisions[59])defects[15]++;
// vkb
if(decisions[58])defects[16]++;
// dvk
if(decisions[57])defects[17]++;
// ik1r
if(decisions[56])defects[18]++;
// ik1g
if(decisions[55])defects[19]++;
// ik1b
if(decisions[54])defects[20]++;
// ik2r
if(decisions[53])defects[21]++;
// ik2g
if(decisions[52])defects[22]++;
// ik2b
if(decisions[51])defects[23]++;
// srr
if(decisions[50])defects[24]++;
// srg
if(decisions[49])defects[25]++;
// srb
if(decisions[48])defects[26]++;
// ih
if(decisions[79])defects[27]++;
// igas
if(decisions[78])defects[28]++;
// ikgas

// g3 stray visual
if((decisions[94] || decisions
[142]))defects[29]++;
// g2 stray visual
if((decisions[93] || decisions
[141]))defects[30]++;
// purity
if(decisions[111])defects[31]++;
// gun rotation
if((decisions[92] || decisions
[140]))defects[32]++;
// ki
if(decisions[81] || decisions[82]
|| decisions[83] ||
decisions[129] ||
decisions[130] || decisions[131])defects[33]++;

// visual defect's focus(r,g,b),
raster(r,g,b), white quality and landing(4,6) pole.
if(decisions[84] || decisions[85]
|| decisions[86] ||
decisions[87] || decisions
[88] || decisions[89] ||
decisions[90] || decisions
[91] || decisions[109] ||
decisions[110])defects[34]
++;

// 2nd (others)
if(decisions[80] || decisions
[128])defects[35]++;
}
protected void CalculatePallet Defects()
{
try
{

// insulation
if((decisions[11] ||
decisions[12] || decisions[13] || decisions[14] ||
decisions[15]))
{
palletdefect
[PalletNumber][0]++;
palletdefect[0][0]
++;
}
// vk cut-off
if((decisions[58] ||
decisions[59] || decisions[60] || decisions[61]))
{
palletdefect
[PalletNumber][1]++;
palletdefect[0][1]
++;
}
// igas
if(decisions[79])
{
palletdefect
[PalletNumber][2]++;
palletdefect[0][2]
++;
}
// igas equal to zero
if(int.Parse(dm Array[85])
== 0)
{
palletdefect
[PalletNumber][3]++;
palletdefect[0][3]
++;
}
// ikgas
if(decisions[78])
{
palletdefect
[PalletNumber][4]++;
palletdefect[0][4]
++;
}
// ki
if((decisions[81] ||
decisions[82] || decisions[83] || decisions[129] ||
decisions[130] || decisions[131]))
{
palletdefect
[PalletNumber][5]++;
palletdefect[0][5]
++;
}
// emission
if((decisions[52] ||
decisions[53] || decisions[54] || decisions[55] ||
decisions[56] || decisions[57]))
{
palletdefect
[PalletNumber][6]++;
palletdefect[0][6]
++;
}
// slump
if((decisions[49] ||
decisions[50] || decisions[51]))
{
palletdefect
[PalletNumber][7]++;
palletdefect[0][7]
++;
}
// ih
if(decisions[48])
{
palletdefect
[PalletNumber][8]++;
palletdefect[0][8]
++;
}
// ig2
if(decisions[26])
{
palletdefect
[PalletNumber][9]++;
palletdefect[0][9]
++;
}
// ig3
if((decisions[28] ||
decisions[29]))
{
palletdefect
[PalletNumber][10]++;
palletdefect[0]
[10]++;
}
// stray
if(decisions[25])
{
palletdefect
[PalletNumber][11]++;
palletdefect[0]
[11]++;
}
// spark
if(decisions[31])
{
palletdefect
[PalletNumber][12]++;
palletdefect[0]
[12]++;
}
// 2 pole x (purity)
if(decisions[111])
{
palletdefect
[PalletNumber][13]++;
palletdefect[0]
[13]++;
}
// gun rotation
if((decisions[92] ||
decisions[140]))
{
palletdefect
[PalletNumber][14]++;
palletdefect[0]
[14]++;
}
// no-test (measurement
trouble)
if(int.Parse(dm Array
[123]) != 0)
{
palletdefect
[PalletNumber][15]++;
palletdefect[0]
[15]++;
}
}
catch(Exception e)
{
string errorMessage = "";

errorMessage
= "Message: " + e.Message + "\n";
EventLog log = new
EventLog();
log.Source = "DCServer";
log.WriteEntry
(errorMessage);
}

}
protected void CalculateHourly Counts()
{
int hr = testDate.Hour;
isTestPiece = false;

// Calculate totals
switch(TestType )
{
case 0:
hourlyCount[0][hr]
++; // Total hourly virign product
break;
case 1:
hourlyCount[1][hr]
++; // Total hourly reage product

break;
case 2:
hourlyCount[2][hr]
++; // Total hourly respark product

break;
}

// Calculate the hourly gross.
hourlyCount[3][hr]++;
// Calculate the hourly No-Test.
if(DecisionIsNo Test)hourlyCoun t[4]
[hr]++;

// test piece
if(decisions[125])
{
hourlyCount[22][hr]++;
hourlyCount[23][hr]++;
// Hourly summation
isTestPiece = true;
}

// Calculate hourly counts only
if test is a reject and virign
if((DecisionIsR eject) & TestType
== 0)
{
// screen
if((decisions[88] ||
decisions[89] || decisions[90] || decisions[91]) & ((!
decisions[126]) & (!decisions[127])))
{
hourlyCount[5][hr]
++;
hourlyCount[23]
[hr]++; // Hourly summation
testResult
= "SCREEN";
return;
}
// mask
if(decisions[127])
{
hourlyCount[6][hr]
++;
hourlyCount[23]
[hr]++; // Hourly summation
testResult
= "MASK";
return;
}
// ba
if(decisions[126])
{
hourlyCount[7][hr]
++;
hourlyCount[23]
[hr]++; // Hourly summation
testResult = "BA";
return;
}
// purity
if(decisions[111])
{
hourlyCount[8][hr]
++;
hourlyCount[23]
[hr]++; // Hourly summation
testResult
= "PURITY";
return;
}
// gunrotation
if((decisions[92] ||
decisions[140]))
{
hourlyCount[9][hr]
++;
hourlyCount[23]
[hr]++; // Hourly summation
testResult
= "GUNROT";
return;
}
// insulation
if(decisions[11] ||
decisions[12] || decisions[13] || decisions[14]
||decisions[15])
{
hourlyCount[10]
[hr]++;
hourlyCount[23]
[hr]++; // Hourly summation
testResult
= "INS";
return;
}

// vk cut-off
if(decisions[58] ||
decisions[59] || decisions[60] || decisions[61])
{
hourlyCount[11]
[hr]++;
hourlyCount[23]
[hr]++; // Hourly summation
testResult
= "VKCO";
return;
}
// igas
if(decisions[78] ||
decisions[79])
{
hourlyCount[12]
[hr]++;
hourlyCount[23]
[hr]++; // Hourly summation
testResult
= "IGAS";
return;
}
// ki
if(decisions[81] ||
decisions[82] || decisions[83] || decisions[129] ||
decisions[130] || decisions[131])
{
hourlyCount[13]
[hr]++;
hourlyCount[23]
[hr]++; // Hourly summation
testResult = "KI";
return;
}
// emission
if(decisions[52] ||
decisions[53] || decisions[54] || decisions[55] ||
decisions[56] || decisions[57])
{
hourlyCount[14]
[hr]++;
hourlyCount[23]
[hr]++; // Hourly summation
testResult
= "EMISSION";
return;
}
// slump
if(decisions[49] ||
decisions[50] || decisions[51])
{
hourlyCount[15]
[hr]++;
hourlyCount[23]
[hr]++; // Hourly summation
testResult
= "SLUMP";
return;
}
// ig2
if(decisions[26])
{
hourlyCount[16]
[hr]++;
hourlyCount[23]
[hr]++; // Hourly summation
testResult
= "IG2";
return;
}
// ig3
if(decisions[28] ||
decisions[29])
{
hourlyCount[17]
[hr]++;
hourlyCount[23]
[hr]++; // Hourly summation
testResult
= "IG3";
return;
}
// stray
if(decisions[25])
{
hourlyCount[18]
[hr]++;
hourlyCount[23]
[hr]++; // Hourly summation
testResult
= "STRAY";
return;
}
// visual g3 stray
if(decisions[94] ||
decisions[142])
{
hourlyCount[19]
[hr]++;
hourlyCount[23]
[hr]++; // Hourly summation
testResult
= "G3STARY";
return;
}
// visual g2 stray
if(decisions[93] ||
decisions[141])
{
hourlyCount[20]
[hr]++;
hourlyCount[23]
[hr]++; // Hourly summation
testResult
= "G2STRAY";
return;
}
// others
if(decisions[31] ||
decisions[48] || decisions[63] || decisions[80] ||
decisions[81] ||
decisions[82] || decisions[83] || decisions[84] ||
decisions[85] ||
decisions[86] || decisions[92] || decisions[87] ||
decisions[128] ||
decisions[129] || decisions[130] || decisions[131] ||
decisions[132] ||
decisions[133] || decisions[134] || decisions[135] ||
decisions[140])
{
hourlyCount[21]
[hr]++;
hourlyCount[23]
[hr]++; // Hourly summation
testResult
= "OTHERS";
return;
}

}
else
{
if(DecisionIsNo Test)
{
testResult = "NT";
}
else if(DecisionIsRe ject)
{
testResult = "NG";
}
else if(DecisionIsGo )
{
testResult = "GO";

}
}
}
#region DataInsert Methods ...

protected int InsertDMData()
{

int numAffected;

// create the parameters
SqlParameter[] parameters = {
new SqlParameter
("@tube_number" , SqlDbType.Int, 4),
new SqlParameter
("@shift", SqlDbType.NChar , 1),
new SqlParameter
("@shift_typ e", SqlDbType.NChar , 7),
new SqlParameter
("@production_d ate", SqlDbType.NChar , 10),
new SqlParameter
("@test_hour ", SqlDbType.Int, 4),
new SqlParameter("@ item",
SqlDbType.NVarC har, 25),
new SqlParameter
("@pal_num", SqlDbType.Int, 4),
new SqlParameter
("@tot_jg", SqlDbType.Int, 4),
new SqlParameter
("@tot_trbl" , SqlDbType.Int, 4),
new SqlParameter
("@trbl_flag ", SqlDbType.NChar , 10),
new SqlParameter
("@test_flag ", SqlDbType.NChar , 10),
new SqlParameter
("@track_fla g", SqlDbType.NChar , 10),
new SqlParameter
("@tc5_data" , SqlDbType.Int, 4),
new SqlParameter
("@test1_dec ", SqlDbType.NChar , 16),
new SqlParameter
("@test1_trb l", SqlDbType.Int, 4),
new SqlParameter
("@test1_onl ", SqlDbType.Int, 4),
new SqlParameter
("@test1_jg" , SqlDbType.Int, 4),
new SqlParameter("@ ins1",
SqlDbType.Decim al, 9),
new SqlParameter("@ ins2",
SqlDbType.Decim al, 9),
new SqlParameter("@ ins3",
SqlDbType.Decim al, 9),
new SqlParameter("@ ins4",
SqlDbType.Decim al, 9),
new SqlParameter("@ ins5",
SqlDbType.Decim al, 9),
new SqlParameter
("@test2_dec ", SqlDbType.NChar , 16),
new SqlParameter
("@test2_trb l", SqlDbType.Int, 4),
new SqlParameter
("@test2_onl ", SqlDbType.Int, 4),
new SqlParameter
("@test2_jg" , SqlDbType.Int, 4),
new SqlParameter
("@ig3_1", SqlDbType.Decim al, 9),
new SqlParameter
("@ig3_2", SqlDbType.Decim al, 9),
new SqlParameter("@ ig2",
SqlDbType.Decim al, 9),
new SqlParameter
("@stray_hig h", SqlDbType.Decim al, 9),
new SqlParameter
("@stray_low ", SqlDbType.Decim al, 9),
new SqlParameter
("@test2_spark" , SqlDbType.Int, 4),
new SqlParameter
("@test3_dec ", SqlDbType.NChar , 16),
new SqlParameter
("@test3_trb l", SqlDbType.Int, 4),
new SqlParameter
("@test3_onl ", SqlDbType.Int, 4),
new SqlParameter
("@test3_jg" , SqlDbType.Int, 4),
new SqlParameter("@ ikr",
SqlDbType.Int, 4),
new SqlParameter("@ ikg",
SqlDbType.Int, 4),
new SqlParameter("@ ikb",
SqlDbType.Int, 4),
new SqlParameter
("@test3_spark" , SqlDbType.Int, 4),
new SqlParameter
("@test4_dec ", SqlDbType.NChar , 16),
new SqlParameter
("@test4_trb l", SqlDbType.Int, 4),
new SqlParameter
("@test4_onl ", SqlDbType.Int, 4),
new SqlParameter
("@test4_jg" , SqlDbType.Int, 4),
new SqlParameter("@ vkr",
SqlDbType.Decim al, 9),
new SqlParameter("@ vkg",
SqlDbType.Decim al, 9),
new SqlParameter("@ vkb",
SqlDbType.Decim al, 9),
new SqlParameter("@ dvk",
SqlDbType.Int, 4),
new SqlParameter("@ ik1r",
SqlDbType.Int, 4),
new SqlParameter("@ ik2r",
SqlDbType.Int, 4),
new SqlParameter("@ ik1g",
SqlDbType.Int, 4),
new SqlParameter("@ ik2g",
SqlDbType.Int, 4),
new SqlParameter("@ ik1b",
SqlDbType.Int, 4),
new SqlParameter("@ ik2b",
SqlDbType.Int, 4),
new SqlParameter("@ srr",
SqlDbType.Decim al, 9),
new SqlParameter("@ srg",
SqlDbType.Decim al, 9),
new SqlParameter("@ srb",
SqlDbType.Decim al, 9),
new SqlParameter("@ ih",
SqlDbType.Int, 4),
new SqlParameter
("@test4_spark" , SqlDbType.Int, 4),
new SqlParameter
("@test5_dec ", SqlDbType.NChar , 16),
new SqlParameter
("@test5_trb l", SqlDbType.Int, 4),
new SqlParameter
("@test5_onl ", SqlDbType.Int, 4),
new SqlParameter
("@test5_jg" , SqlDbType.Int, 4),
new SqlParameter("@ i1",
SqlDbType.Int, 4),
new SqlParameter("@ i2",
SqlDbType.Int, 4),
new SqlParameter("@ igas",
SqlDbType.Int, 4),
new SqlParameter
("@ikgas", SqlDbType.Int, 4),
new SqlParameter
("@visual1_dec" , SqlDbType.NChar , 16),
new SqlParameter
("@visual2_dec" , SqlDbType.NChar , 16),
new SqlParameter
("@visual_trbl" , SqlDbType.Int, 4),
new SqlParameter
("@visual_on l", SqlDbType.Int, 4),
new SqlParameter
("@visual_jg ", SqlDbType.Int, 4),
new SqlParameter
("@visual_defec t", SqlDbType.Int, 4),
new SqlParameter("@ px2",
SqlDbType.Int, 4),
new SqlParameter("@ py2",
SqlDbType.Int, 4),
new SqlParameter("@ px4",
SqlDbType.Int, 4),
new SqlParameter("@ py4",
SqlDbType.Int, 4),
new SqlParameter("@ px6",
SqlDbType.Int, 4),
new SqlParameter("@ py6",
SqlDbType.Int, 4),
new SqlParameter
("@visual_spark ", SqlDbType.Int, 4),
new SqlParameter
("@visual6_dec" , SqlDbType.NChar , 16),
new SqlParameter
("@is_test", SqlDbType.Int, 4)
};

// set the values
parameters[0].Value =
base.TubeNumber ; // tube
number
parameters[1].Value = cal.Shift;
// shift
parameters[2].Value =
cal.ShiftType; // shift Type
parameters[3].Value =
cal.ProductionD ate; // production date
parameters[4].Value =
testDate.Hour; // test hour
parameters[5].Value =
this.TestResult ; // test
result (sceen,mask,ng, etc...)
parameters[6].Value =
this.PalletNumb er; // pallet number
parameters[7].Value = int.Parse
(dmArray[124]); // total judgement
parameters[8].Value = int.Parse
(dmArray[123]); // total trouble
parameters[9].Value =
this.TroubleFla g; //
trouble flag
parameters[10].Value = dmArray
[122]; // test flag
parameters[11].Value = dmArray
[121]; // tracking flag
parameters[12].Value =
this.TestType; // tc5_data
TestTypes: virgin, reage, respark
parameters[13].Value = dmArray[0];
// test1 decision
parameters[14].Value = int.Parse
(dmArray[2]); // test1 trouble
parameters[15].Value = int.Parse
(dmArray[3]); // test1 online
parameters[16].Value = int.Parse
(dmArray[4]); // test1 judgement
parameters[17].Value =
double.Parse(dm Array[5]); // ins1
parameters[18].Value =
double.Parse(dm Array[6]); // ins2
parameters[19].Value =
double.Parse(dm Array[7]); // ins3
parameters[20].Value =
double.Parse(dm Array[8]); // ins4
parameters[21].Value =
double.Parse(dm Array[9]); // ins5
parameters[22].Value = dmArray
[20]; // test2 decision
parameters[23].Value = int.Parse
(dmArray[22]); // test2 trouble
parameters[24].Value = int.Parse
(dmArray[23]); // test2 online
parameters[25].Value = int.Parse
(dmArray[24]); // test2 judgement
parameters[26].Value =
double.Parse(dm Array[25]); // ig3-1
parameters[27].Value =
double.Parse(dm Array[26]); // ig3-2
parameters[28].Value =
double.Parse(dm Array[28]); // ig2
parameters[29].Value =
double.Parse(dm Array[30]); // stray high
parameters[30].Value =
double.Parse(dm Array[27]); // stray low
parameters[31].Value = int.Parse
(dmArray[29]); // test2 spark
parameters[32].Value = dmArray
[40]; // test3 decision
parameters[33].Value = int.Parse
(dmArray[42]); // test3 trouble
parameters[34].Value = int.Parse
(dmArray[43]); // test3 online
parameters[35].Value = int.Parse
(dmArray[44]); // test3 judgement
parameters[36].Value = int.Parse
(dmArray[45]); // ikr
parameters[37].Value = int.Parse
(dmArray[46]); // ikg
parameters[38].Value = int.Parse
(dmArray[47]); // ikb
parameters[39].Value = int.Parse
(dmArray[48]); // test3 spark
parameters[40].Value = dmArray
[60]; // test4 decision
parameters[41].Value = int.Parse
(dmArray[62]); // test4 trouble
parameters[42].Value = int.Parse
(dmArray[63]); // test4 online
parameters[43].Value = int.Parse
(dmArray[64]); // test4 judgement
parameters[44].Value =
double.Parse(dm Array[65]); // vkr
parameters[45].Value =
double.Parse(dm Array[66]); // vkg
parameters[46].Value =
double.Parse(dm Array[67]); // vkb
parameters[47].Value = int.Parse
(dmArray[68]); // dvk
parameters[48].Value = int.Parse
(dmArray[72]); // ik1r
parameters[49].Value = int.Parse
(dmArray[69]); // ik2r
parameters[50].Value = int.Parse
(dmArray[73]); // ik1g
parameters[51].Value = int.Parse
(dmArray[70]); // ik2g
parameters[52].Value = int.Parse
(dmArray[79]); // ik1b
parameters[53].Value = int.Parse
(dmArray[71]); // ik2b
parameters[54].Value =
double.Parse(dm Array[74]); // srr
parameters[55].Value =
double.Parse(dm Array[75]); // srg
parameters[56].Value =
double.Parse(dm Array[76]); // srb
parameters[57].Value = int.Parse
(dmArray[77]); // ih
parameters[58].Value = int.Parse
(dmArray[78]); // test4 spark
parameters[59].Value = dmArray
[80]; // test5 decision
parameters[60].Value = int.Parse
(dmArray[82]); // test5 trouble
parameters[61].Value = int.Parse
(dmArray[83]); // test5 online
parameters[62].Value = int.Parse
(dmArray[84]); // test5 judgement
parameters[63].Value = int.Parse
(dmArray[86]); // i1
parameters[64].Value = int.Parse
(dmArray[87]); // i2
parameters[65].Value = int.Parse
(dmArray[85]); // igas
parameters[66].Value = int.Parse
(dmArray[88]); // ikgas
parameters[67].Value = dmArray
[100]; // visual1 decision
parameters[68].Value = dmArray
[101]; // visual2 decision
parameters[69].Value = int.Parse
(dmArray[102]); // visual trouble
parameters[70].Value = int.Parse
(dmArray[103]); // visual online
parameters[71].Value = int.Parse
(dmArray[104]); // visual judgement
parameters[72].Value = int.Parse
(dmArray[112]); // visual defect
parameters[73].Value = int.Parse
(dmArray[105]); // 2px
parameters[74].Value = int.Parse
(dmArray[106]); // 2py
parameters[75].Value = int.Parse
(dmArray[107]); // 4px
parameters[76].Value = int.Parse
(dmArray[108]); // 4py
parameters[77].Value = int.Parse
(dmArray[109]); // 6px
parameters[78].Value = int.Parse
(dmArray[110]); // 6py
parameters[79].Value = int.Parse
(dmArray[111]); // visual spark
parameters[80].Value = dmArray
[113]; // visual6 decision
parameters[81].Value =
(this.IsTestPie ce)? 1 : 0; // is test piece

// run the procedure
RunProcedure
("up_insert_dmd ata_record", parameters, out numAffected);

return numAffected;
}
protected int InsertPalletDet ails()
{
int numAffected;
int rec = 0;
for(int j=0; j<21; j++)
{
SqlParameter[] parameters
= {
new SqlParameter
("@pallet_numbe r", SqlDbType.Int, 4),
new SqlParameter
("@production_d ate", SqlDbType.NChar , 10),
new SqlParameter
("@pallet_revol utions", SqlDbType.Int, 4),
new SqlParameter
("@ins", SqlDbType.Int, 4),
new SqlParameter
("@vkco", SqlDbType.Int, 4),
new SqlParameter
("@igas", SqlDbType.Int, 4),
new SqlParameter
("@zero_igas ", SqlDbType.Int, 4),
new SqlParameter
("@ikgas", SqlDbType.Int, 4),
new SqlParameter
("@ki", SqlDbType.Int, 4),
new SqlParameter
("@emission" , SqlDbType.Int, 4),
new SqlParameter
("@slump", SqlDbType.Int, 4),
new SqlParameter
("@ih", SqlDbType.Int, 4),
new SqlParameter
("@ig2", SqlDbType.Int, 4),
new SqlParameter
("@ig3", SqlDbType.Int, 4),
new SqlParameter
("@stray", SqlDbType.Int, 4),
new SqlParameter
("@spark", SqlDbType.Int, 4),
new SqlParameter
("@purity", SqlDbType.Int, 4),
new SqlParameter
("@gunrotation" , SqlDbType.Int, 4),
new SqlParameter
("@notest", SqlDbType.Int, 4)
};

parameters[0].Value = j;
// pallet
number
parameters[1].Value =
cal.ProductionD ate; // production date
parameters[2].Value =
palletrevolutio n[j]; // pallet revolution total

for(int i=0; i<16; i++)
{
parameters
[i+3].Value = palletdefect[j][i]; // pallet defect
item
}

// run the procedure
RunProcedure
("up_insert_pal letdetails", parameters, out numAffected);
rec += numAffected;
}

return rec;

}
protected int InsertDefects()
{
int numAffected;

// create the parameters
SqlParameter[] parameters = {

new SqlParameter
("@production_d ate", SqlDbType.NChar , 10),
new SqlParameter("@ ins1",
SqlDbType.Int, 4),
new SqlParameter("@ ins2",
SqlDbType.Int, 4),
new SqlParameter("@ ins3",
SqlDbType.Int, 4),
new SqlParameter("@ ins4",
SqlDbType.Int, 4),
new SqlParameter("@ ins5",
SqlDbType.Int, 4),
new SqlParameter
("@test2_spark" , SqlDbType.Int, 4),
new SqlParameter
("@spark_pas s", SqlDbType.Int, 4),
new SqlParameter
("@ig3_1", SqlDbType.Int, 4),
new SqlParameter
("@ig3_2", SqlDbType.Int, 4),
new SqlParameter("@ ig2",
SqlDbType.Int, 4),
new SqlParameter
("@stray", SqlDbType.Int, 4),
new SqlParameter
("@test4_spark" , SqlDbType.Int, 4),
new SqlParameter
("@ikauto", SqlDbType.Int, 4),
new SqlParameter("@ vkr",
SqlDbType.Int, 4),
new SqlParameter("@ vkg",
SqlDbType.Int, 4),
new SqlParameter("@ vkb",
SqlDbType.Int, 4),
new SqlParameter("@ dvk",
SqlDbType.Int, 4),
new SqlParameter("@ ik1r",
SqlDbType.Int, 4),
new SqlParameter("@ ik1g",
SqlDbType.Int, 4),
new SqlParameter("@ ik1b",
SqlDbType.Int, 4),
new SqlParameter("@ ik2r",
SqlDbType.Int, 4),
new SqlParameter("@ ik2g",
SqlDbType.Int, 4),
new SqlParameter("@ ik2b",
SqlDbType.Int, 4),
new SqlParameter("@ srr",
SqlDbType.Int, 4),
new SqlParameter("@ srg",
SqlDbType.Int, 4),
new SqlParameter("@ srb",
SqlDbType.Int, 4),
new SqlParameter("@ ih",
SqlDbType.Int, 4),
new SqlParameter("@ igas",
SqlDbType.Int, 4),
new SqlParameter
("@ikgas", SqlDbType.Int, 4),
new SqlParameter
("@g3stray", SqlDbType.Int, 4),
new SqlParameter
("@g2stray", SqlDbType.Int, 4),
new SqlParameter
("@purity", SqlDbType.Int, 4),
new SqlParameter
("@gun_rotation ", SqlDbType.Int, 4),
new SqlParameter("@ ki",
SqlDbType.Int, 4),
new SqlParameter
("@visual", SqlDbType.Int, 4),
new SqlParameter
("@others", SqlDbType.Int, 4),
new SqlParameter
("@total", SqlDbType.Int, 4)
};

// set the values
parameters[0].Value =
cal.ProductionD ate;
for(int i=0; i < defects.Length;
i++)
{
parameters[i+1].Value =
defects[i];
}
parameters[37].Value =
base.TotalRejec ts;

// run the procedure
RunProcedure
("up_insert_def ect_record", parameters, out numAffected);

return numAffected;
}
protected int InsertHourlyCou nts()
{
int numAffected;
int rec = 0;

for(int i=0; i<tallyItem.Len gth;
i++)
{
SqlParameter[] parameters
= {
new SqlParameter
("@item", SqlDbType.NVarC har, 25),
new SqlParameter
("@production_d ate", SqlDbType.NChar , 10),
new SqlParameter
("@hr_00", SqlDbType.Int, 4),
new SqlParameter
("@hr_01", SqlDbType.Int, 4),
new SqlParameter
("@hr_02", SqlDbType.Int, 4),
new SqlParameter
("@hr_03", SqlDbType.Int, 4),
new SqlParameter
("@hr_04", SqlDbType.Int, 4),
new SqlParameter
("@hr_05", SqlDbType.Int, 4),
new SqlParameter
("@hr_06", SqlDbType.Int, 4),
new SqlParameter
("@hr_07", SqlDbType.Int, 4),
new SqlParameter
("@hr_08", SqlDbType.Int, 4),
new SqlParameter
("@hr_09", SqlDbType.Int, 4),
new SqlParameter
("@hr_10", SqlDbType.Int, 4),
new SqlParameter
("@hr_11", SqlDbType.Int, 4),
new SqlParameter
("@hr_12", SqlDbType.Int, 4),
new SqlParameter
("@hr_13", SqlDbType.Int, 4),
new SqlParameter
("@hr_14", SqlDbType.Int, 4),
new SqlParameter
("@hr_15", SqlDbType.Int, 4),
new SqlParameter
("@hr_16", SqlDbType.Int, 4),
new SqlParameter
("@hr_17", SqlDbType.Int, 4),
new SqlParameter
("@hr_18", SqlDbType.Int, 4),
new SqlParameter
("@hr_19", SqlDbType.Int, 4),
new SqlParameter
("@hr_20", SqlDbType.Int, 4),
new SqlParameter
("@hr_21", SqlDbType.Int, 4),
new SqlParameter
("@hr_22", SqlDbType.Int, 4),
new SqlParameter
("@hr_23", SqlDbType.Int, 4)

};

parameters[0].Value =
tallyItem[i];
parameters[1].Value =
cal.ProductionD ate;

for(int j=0; j<24; j++)
{
parameters
[j+2].Value = hourlyCount[i][j];
}

// Run the procedure
RunProcedure
("up_insert_hou rlycount_record ", parameters, out
numAffected);
rec += numAffected;
}

return rec;

}

#endregion

protected void SaveRawDataFile (string
fileData)
{
FileInfo fi = new FileInfo
(@"C:\RawData \" + FileName);
if(fi.Exists)
{
// This text will always
be added, making the file longer over time
// if it is not deleted.
using (StreamWriter sw =
fi.AppendText() )
{
sw.WriteLine
(fileData);
sw.Flush();
sw.Close();
}
}
else
{
//Create a file to write
to.
using (StreamWriter sw =
fi.CreateText() )
{
sw.WriteLine
(fileData);
sw.Flush();
sw.Close();
}
}
}
}
}
-----Original Message-----
Ron,

Without seeing some code, it would be difficult to

tell. Generally
speaking, I can't imagine that it would do this on it's

own, and if it does,
it needs to be reported as a bug.

Can you post your code that is serializing this, as

well as the code for
the class that is being serialized?
--
- Nicholas Paldino [.NET/C# MVP]
- ni************* *@exisconsultin g.com

"ron" <goodr@no_spam4 me_mddm.panason ic.com> wrote in

message
news:57******* *************** ******@phx.gbl. ..
Hi,
I have class object that i serialize using the
System.Xml.Seri alization class.

Intermittently the object is not getting serialized
correctly, using System.Xml.Seri alization classes.
Therefore the application errors out when deserializing
the xml data.

It places the some part of the child element

<MyRootElemen t>
<SomeOtherEleme nt>
</SomeOtherElemen t>
</MyRootElement>e ment> --- This gets added to the end of the root element name.

What would be causing this.

Ron Good

.

Nov 15 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
1236
by: ktn | last post by:
Hi all, I'm a .NET beginner and I've got a problem on a program where I try to do an XML serialization. I get the following error : "An unmanaged exception of type 'System.IO.FileNotFoundException' occured in mscorlib.dll Additonal information : the file or asssembly named n9gu4-bo.dll or one of its dependencies cannot be found"
1
4365
by: andrewcw | last post by:
There is an error in XML document (1, 2). I used XML spy to create the XML and XSD. When I asked to have the XML validated it said it was OK. I used the .net SDK to generate the class. I have done this before but this time I have no idea why I am getting the error. Any ideas ?? THANKS ! <qcsttatus> <manual sourcerootfolder="" manualname="">
3
2458
by: Alexander | last post by:
When i store rule on PC with .NET.SP1 i cant restore them from PC without SP1. An i get this Error: System.Runtime.Serialization.SerializationException: Possible Version mismatch. Type System.Collections.Comparer has 1 members, number of members deserialized is 0. at System.Runtime.Serialization.Formatters.Binary.ReadObjectInfo.GetMemberTypes(String
1
3104
by: Sek | last post by:
Hi Folks, While deserialization in C#, i came across this error: "No assembly ID for object type <MyClassName>". The error is very abstract. Pls find below the stack trace. StackTrace at
2
2589
by: Maximus | last post by:
Hi Everyone, I was using Inprocess session objects, but incase of aspnet process crashes the session objects were lost as a result I decided to shift to out of porocess session objects. For this i had to serialize the objects. While doing that I made the classes serializable whose objects I store in sessions. However, when I run the application I get the following error.
0
348
by: CJ Taylor | last post by:
hey everyone, thought I would ask this here because the web service groups seems pretty light on conversation. I'm buliding a web service, but keep getting this error. I understand the error, read a work around, but don't know if its the best approach. Here is a link to the error... at least a description. http://support.microsoft.com/default.aspx?scid=kb;en-us;814187 i'm confused though. I looked at Icollection, and there is no...
3
15090
by: Paulo Morgado [MVP] | last post by:
Hi all ..NET Framework 1.1 I have created several types that are serailized to XML as strings. Someting like this: public struct MyInt32 : IXmlSerializable { int value;
2
1629
by: Norman Chong | last post by:
Hiddeldi ho, I want to save an object so that I can use its content after I restart my program. I tried to solve this with serialization because someone told me that this is the correct way for this. So I wrote the following code to serialize\deserialize the object, but now I have the problem that the object has a generic list and when I'm trying to deserialize it, I get an error. <System.Serializable()Public Class TestClass
8
12566
by: =?Utf-8?B?UGlnZ3k=?= | last post by:
Hi to all, I am getting this System.OutOfMemoryException calling the Runtime.Serialization.Formatters.Binary.BinaryFormatter.Serialize(<stream>,<Obj>) method. The type of <streamis IO.MemoryStream =====Exception: System.OutOfMemoryException: Exception of type 'System.OutOfMemoryException' was thrown.
0
2478
by: =?Utf-8?B?Y211cmFsaQ==?= | last post by:
I am serializing/deserializing a class (Class1) using the XmlSerializer object in the System.Xml.Serialization namespace in .Net 2.0. Class1 has some strings and ints and two lists of other simple serializable classes (Class2 and Class3) Class1, Class2 and Class3 are defined in an assembly (Assembly1) which is loaded by another assembly (Assembly2). When I statically reference Assembly1 in Assembly2, serialization and deserialization...
0
8969
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8794
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9483
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
9211
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8216
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
4572
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4826
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3282
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
2748
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.