473,407 Members | 2,326 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,407 software developers and data experts.

Xml Serialization Error

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

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

It places the some part of the child element

<MyRootElement>
<SomeOtherElement>
</SomeOtherElement>
</MyRootElement>ement> --- This gets added to the end of
the root element name.

What would be causing this.

Ron Good
Nov 15 '05 #1
4 2299
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**************@exisconsulting.com

"ron" <goodr@no_spam4me_mddm.panasonic.com> wrote in message
news:57****************************@phx.gbl...
Hi,
I have class object that i serialize using the
System.Xml.Serialization class.

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

It places the some part of the child element

<MyRootElement>
<SomeOtherElement>
</SomeOtherElement>
</MyRootElement>ement> --- 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.SqlClient;
using System.Configuration;
using System.IO;
using System.Text;
using FDS.SmartCalendar;
using FDS.Data.Core;
using System.Diagnostics;
using System.Xml.Serialization;

namespace FDS.DataCollectionServer.DataProcessing
{
/// <summary>
/// Summary description for DataProcess.
/// </summary>
public abstract class DataProcess : DbObject
{
private int lineId;
private static string fileName = null;
private static DateTime
previousProductionDate;
private static bool newcycle;
private static int tubeNumber;
private static int totRejects;

protected static ShiftCalendar.Calendar
cal = new ShiftCalendar.Calendar();

/// <summary>
///
/// </summary>
/// <param
name="newConnectionString"></param>
public DataProcess(string
newConnectionString) : base(newConnectionString)
{
previousProductionDate =
DateTime.Now;
}

/// <summary>
/// Set the public fields to supply
settings to DataProcess.
/// </summary>
[Serializable]
public class ProcessedSettings
{
public int LastTubeNumber =
tubeNumber;
public string RawDataFile =
fileName;
public DateTime
LastProductionDate = previousProductionDate;

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

/// <summary>
/// Create a new
ProcessedSettings object initialised from XML data
/// </summary>
/// <param name="s">Stream to
load the XML from</param>
/// <returns>ProcessedSettings
object</returns>
public static ProcessedSettings
LoadFromXML(Stream s)
{
return LoadFromXML(s,
typeof(ProcessedSettings));
}

/// <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
(ProcessedDerivedSettings)LoadFromXML(s, typeof
(ProcessedDerivedSettings));
/// </summary>
/// <param name="s">Stream to
load the object from</param>
/// <param name="t">Type of the
derived object</param>
/// <returns></returns>
protected static
ProcessedSettings LoadFromXML(Stream s, Type t)
{
XmlSerializer sr = new
XmlSerializer(t);
try
{
return
(ProcessedSettings)sr.Deserialize(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{get{return
totRejects;}set{totRejects = value;}}

public string FileName{get{return
fileName;}set{fileName = value;}}

public int LineId{get{return lineId;}set
{lineId = value;}}

public DateTime PreviousProductionDate{get
{return previousProductionDate;}set
{previousProductionDate = value;}}

public bool IsNewProductionCycle{get
{return newcycle;}set{newcycle = value;}}

#endregion

public void GetShift()
{
cal.CurrentShift(LineId);
}

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

}

protected void CheckShiftStatus()
{
// 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.ShiftType != "3-
Shift") & (cal.Shift == "A" | cal.Shift == "C"))
ProductionCycleReset();
// Look for new
prodcution cycle if 3 shift type configuration
if((cal.ShiftType == "3-
Shift") & (cal.Shift == "A"))ProductionCycleReset();
}
else
{
// System may have been
shut down for more than 24 hr
// Look to see if system
was shut down
if(DateTime.Parse
(cal.ProductionDate) > PreviousProductionDate)
ProductionCycleReset();
// Look for no file name
if(fileName == null)
ProductionCycleReset();
}

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

private void ProductionCycleReset()
{
GetNewFileName();
FileName = fileName;
PreviousProductionDate =
DateTime.Parse(cal.ProductionDate);
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.SqlClient;
using System.Configuration;
using System.IO;
using System.Text;
using FDS.SmartCalendar;
using System.Globalization;
using System.Diagnostics;
using System.Xml.Serialization;

namespace FDS.DataCollectionServer.DataProcessing
{
/// <summary>
/// Summary description for DataProcessTesting.
/// </summary>
public class DataProcessTesting : 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[] palletrevolution = 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 DataProcessTestingSettings
settings;
string fSettings = @"settings.xml";

#region Properties ...

protected bool IsNoWork{get{return
nowork;}set{nowork = value;}}

protected bool DecisionIsNoTest{get
{return isNoTest;}set{isNoTest = value;}}

protected bool DecisionIsReject{get
{return isReject;}set{isReject = value;}}

protected bool DecisionIsGo{get{return
isGO;}set{isGO = value;}}

protected string TestResult{get{return
testResult;}}

protected bool IsTestPiece{get{return
isTestPiece;}}

protected string TroubleFlag{get{return
troubleFlag;}set{troubleFlag = value;}}

protected int TestType{get{return
testType;}set{testType = value;}}

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

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

protected bool[] Decisions{get{return
decisions;}}

protected int PalletNumber{get{return
palletnumber;}set{palletnumber = value;}}

#endregion

protected enum DecimalLocation
{
Tenths,
Hundredths,
None
}

protected enum HexToBinType
{
Decision,
Flag
}

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

public DataProcessTesting(string
newConnectionString) : base(newConnectionString)
{
for(int i=0;
i<palletdefect.Length; i++)
{
palletdefect[i] = new int
[16];
}

for(int i=0;
i<hourlyCount.Length; i++)
{
hourlyCount[i] = new int
[24];
}
}
/// <summary>
/// Extends ProcessedSettings to add the
settings used by DataProcessTestingSettings.
/// </summary>
[Serializable]
public class DataProcessTestingSettings :
DataProcess.ProcessedSettings
{
public int[] PalletRevolutions =
palletrevolution;
public int[][] PalletDefects =
palletdefect;
public int[][] HourlyCounts =
hourlyCount;
public int[] Defects = defects;

public static new
DataProcessTestingSettings LoadFromXML(Stream s)
{
return
(DataProcessTestingSettings)LoadFromXML(s, typeof
(DataProcessTestingSettings));
}
}

public override void LoadSettings()
{

FileInfo f = new FileInfo
(fSettings);
if(f.Exists)
{
Stream fs = f.OpenRead();
try
{
settings =
DataProcessTestingSettings.LoadFromXML(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.LastTubeNumber;
base.FileName =
settings.RawDataFile;

base.PreviousProductionDate =
settings.LastProductionDate;
}
else
{
// File dose not exist
use default settings
settings = new
DataProcessTestingSettings();
}
}
public override void SaveSettings()
{

settings = new
DataProcessTestingSettings();

settings.LastTubeNumber =
base.TubeNumber;
settings.RawDataFile =
base.FileName;
settings.LastProductionDate =
base.PreviousProductionDate;
settings.PalletRevolutions =
palletrevolution;
settings.PalletDefects =
palletdefect;
settings.HourlyCounts =
hourlyCount;
settings.Defects = defects;

FileInfo f = new FileInfo
(fSettings);
Stream fs = f.OpenWrite();
settings.SaveAsXML(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;
// DecisionIsNoTest = false;
// DecisionIsReject = 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.CheckShiftStatus();
// Check for new
production cycle and reset count's
if
(base.IsNewProductionCycle)Reset();

// 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;
palletrevolution
[PalletNumber]++;

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

// Convert all decision
bit's from hex to binary
dmArray[0] =
ConvertHexToBin(dmArray[0], HexToBinType.Decision);
dmArray[20] =
ConvertHexToBin(dmArray[20], HexToBinType.Decision);
dmArray[40] =
ConvertHexToBin(dmArray[40], HexToBinType.Decision);
dmArray[60] =
ConvertHexToBin(dmArray[60], HexToBinType.Decision);
dmArray[80] =
ConvertHexToBin(dmArray[80], HexToBinType.Decision);
dmArray[100] =
ConvertHexToBin(dmArray[100], HexToBinType.Decision);
dmArray[101] =
ConvertHexToBin(dmArray[101], HexToBinType.Decision);
dmArray[112] =
ConvertHexToBin(dmArray[112], HexToBinType.Decision);
dmArray[113] =
ConvertHexToBin(dmArray[113], HexToBinType.Decision);
// 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.Flag);
dmArray[122] =
ConvertHexToBin(dmArray[122], HexToBinType.Flag);

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

// Set Trouble Flag
TroubleFlag =
GetTroubleFlag();

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

// Get the final test
decision
GetFinalDecision();

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

base.TotalRejects++;
CalculateDefects
();
}

// Calculate pallet
defects only if test is virgin.
if(this.TestType == 0)
CalculatePalletDefects();

// Calculate hourly counts

CalculateHourlyCounts();

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

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

Console.WriteLine
(rawData);
Console.WriteLine();

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

// Insert new DM data to
the database
//records = InsertDMData
();
//records = InsertDefects
();
//records =
InsertPalletDetails();
//records =
InsertHourlyCounts();
}

}
protected void Reset()
{
base.IsNewProductionCycle = false;
// Sets all elements in the
Array's to zero, to false,
// or to a null reference,
depending on the element type.
Array.Clear(palletrevolution, 0,
palletrevolution.Length);
Array.Clear(defects, 0,
defects.Length);

foreach(int[] subArray in
palletdefect)
{
Array.Clear(subArray, 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 CheckOnlineStatus()
{
int j = 0;
try
{
for(int i=3; i<=103;
i+=20)
{
online[j] = (0x1
== int.Parse(dmArray[i].Substring(3,1),
NumberStyles.HexNumber))? true : false;
j++;
}
// Establish test sevens
status by looking at the test flag and tracking flag bits
online[6] = ((0x8 ==
int.Parse(dmArray[121].Substring
(3,1),NumberStyles.HexNumber)) ||
(0x8 == int.Parse
(dmArray[122].Substring(3,1),NumberStyles.HexNumber)))?
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(dmArray[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(dmArray[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(dmArray[104]);
}
}
else if((TestOnline[5] ==
true) & (TestOnline[6] == false))
{
// Test 7 is off
line get the defualt test condition
judgements[5] =
int.Parse(dmArray[104]);
}
else if((TestOnline[5] ==
false) & (TestOnline[6] == true))
{
// Test 6 is off
line get the defualt test condition
judgements[6] =
int.Parse(dmArray[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 GetFinalDecision()
{
DecisionIsGo = (int.Parse(dmArray
[124]) == 0 & int.Parse(dmArray[123]) == 0)? true : false;
DecisionIsReject = (int.Parse
(dmArray[124]) == 1 & int.Parse(dmArray[123]) == 0)?
true : false;
DecisionIsNoTest = (int.Parse
(dmArray[124]) != 0 & int.Parse(dmArray[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.Decision:
dm =
Convert.ToString(Convert.ToInt32(dm, 16), 2).PadLeft
(16, '0');
break;
case
HexToBinType.Flag:
dm =
Convert.ToString(Convert.ToInt32(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(slump)).ToString("##0.0") : double.Parse
(slump).ToString("##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(dm) > 7999)? ((8000 - double.Parse(dm)) /
10).ToString("##0.0") : (double.Parse(dm) / 10).ToString
("##0.0");
break;
case
DecimalLocation.Hundredths:
dm =
(double.Parse(dm) > 7999)? ((8000 - double.Parse(dm)) /
100).ToString("#0.00") : (double.Parse(dm) / 100).ToString
("#0.00");
break;
case
DecimalLocation.None:
dm =
(int.Parse(dm) > 7999)? (8000 - int.Parse(dm)).ToString
("###0") : int.Parse(dm).ToString("###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 CalculateTestValues()
{
// 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(dmArray[72]), int.Parse(dmArray
[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(dmArray[73]), int.Parse(dmArray
[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(dmArray[79]), int.Parse(dmArray
[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 CalculateDefects()
{
// 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 CalculatePalletDefects()
{
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(dmArray[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(dmArray
[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 CalculateHourlyCounts()
{
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(DecisionIsNoTest)hourlyCount[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((DecisionIsReject) & 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(DecisionIsNoTest)
{
testResult = "NT";
}
else if(DecisionIsReject)
{
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_type", SqlDbType.NChar, 7),
new SqlParameter
("@production_date", SqlDbType.NChar, 10),
new SqlParameter
("@test_hour", SqlDbType.Int, 4),
new SqlParameter("@item",
SqlDbType.NVarChar, 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_flag", SqlDbType.NChar, 10),
new SqlParameter
("@tc5_data", SqlDbType.Int, 4),
new SqlParameter
("@test1_dec", SqlDbType.NChar, 16),
new SqlParameter
("@test1_trbl", SqlDbType.Int, 4),
new SqlParameter
("@test1_onl", SqlDbType.Int, 4),
new SqlParameter
("@test1_jg", SqlDbType.Int, 4),
new SqlParameter("@ins1",
SqlDbType.Decimal, 9),
new SqlParameter("@ins2",
SqlDbType.Decimal, 9),
new SqlParameter("@ins3",
SqlDbType.Decimal, 9),
new SqlParameter("@ins4",
SqlDbType.Decimal, 9),
new SqlParameter("@ins5",
SqlDbType.Decimal, 9),
new SqlParameter
("@test2_dec", SqlDbType.NChar, 16),
new SqlParameter
("@test2_trbl", SqlDbType.Int, 4),
new SqlParameter
("@test2_onl", SqlDbType.Int, 4),
new SqlParameter
("@test2_jg", SqlDbType.Int, 4),
new SqlParameter
("@ig3_1", SqlDbType.Decimal, 9),
new SqlParameter
("@ig3_2", SqlDbType.Decimal, 9),
new SqlParameter("@ig2",
SqlDbType.Decimal, 9),
new SqlParameter
("@stray_high", SqlDbType.Decimal, 9),
new SqlParameter
("@stray_low", SqlDbType.Decimal, 9),
new SqlParameter
("@test2_spark", SqlDbType.Int, 4),
new SqlParameter
("@test3_dec", SqlDbType.NChar, 16),
new SqlParameter
("@test3_trbl", 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_trbl", SqlDbType.Int, 4),
new SqlParameter
("@test4_onl", SqlDbType.Int, 4),
new SqlParameter
("@test4_jg", SqlDbType.Int, 4),
new SqlParameter("@vkr",
SqlDbType.Decimal, 9),
new SqlParameter("@vkg",
SqlDbType.Decimal, 9),
new SqlParameter("@vkb",
SqlDbType.Decimal, 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.Decimal, 9),
new SqlParameter("@srg",
SqlDbType.Decimal, 9),
new SqlParameter("@srb",
SqlDbType.Decimal, 9),
new SqlParameter("@ih",
SqlDbType.Int, 4),
new SqlParameter
("@test4_spark", SqlDbType.Int, 4),
new SqlParameter
("@test5_dec", SqlDbType.NChar, 16),
new SqlParameter
("@test5_trbl", 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_onl", SqlDbType.Int, 4),
new SqlParameter
("@visual_jg", SqlDbType.Int, 4),
new SqlParameter
("@visual_defect", 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.ProductionDate; // production date
parameters[4].Value =
testDate.Hour; // test hour
parameters[5].Value =
this.TestResult; // test
result (sceen,mask,ng, etc...)
parameters[6].Value =
this.PalletNumber; // pallet number
parameters[7].Value = int.Parse
(dmArray[124]); // total judgement
parameters[8].Value = int.Parse
(dmArray[123]); // total trouble
parameters[9].Value =
this.TroubleFlag; //
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(dmArray[5]); // ins1
parameters[18].Value =
double.Parse(dmArray[6]); // ins2
parameters[19].Value =
double.Parse(dmArray[7]); // ins3
parameters[20].Value =
double.Parse(dmArray[8]); // ins4
parameters[21].Value =
double.Parse(dmArray[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(dmArray[25]); // ig3-1
parameters[27].Value =
double.Parse(dmArray[26]); // ig3-2
parameters[28].Value =
double.Parse(dmArray[28]); // ig2
parameters[29].Value =
double.Parse(dmArray[30]); // stray high
parameters[30].Value =
double.Parse(dmArray[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(dmArray[65]); // vkr
parameters[45].Value =
double.Parse(dmArray[66]); // vkg
parameters[46].Value =
double.Parse(dmArray[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(dmArray[74]); // srr
parameters[55].Value =
double.Parse(dmArray[75]); // srg
parameters[56].Value =
double.Parse(dmArray[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.IsTestPiece)? 1 : 0; // is test piece

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

return numAffected;
}
protected int InsertPalletDetails()
{
int numAffected;
int rec = 0;
for(int j=0; j<21; j++)
{
SqlParameter[] parameters
= {
new SqlParameter
("@pallet_number", SqlDbType.Int, 4),
new SqlParameter
("@production_date", SqlDbType.NChar, 10),
new SqlParameter
("@pallet_revolutions", 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.ProductionDate; // production date
parameters[2].Value =
palletrevolution[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_palletdetails", parameters, out numAffected);
rec += numAffected;
}

return rec;

}
protected int InsertDefects()
{
int numAffected;

// create the parameters
SqlParameter[] parameters = {

new SqlParameter
("@production_date", 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_pass", 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.ProductionDate;
for(int i=0; i < defects.Length;
i++)
{
parameters[i+1].Value =
defects[i];
}
parameters[37].Value =
base.TotalRejects;

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

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

for(int i=0; i<tallyItem.Length;
i++)
{
SqlParameter[] parameters
= {
new SqlParameter
("@item", SqlDbType.NVarChar, 25),
new SqlParameter
("@production_date", 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.ProductionDate;

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

// Run the procedure
RunProcedure
("up_insert_hourlycount_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**************@exisconsulting.com

"ron" <goodr@no_spam4me_mddm.panasonic.com> wrote in messagenews:57****************************@phx.gbl...
Hi,
I have class object that i serialize using the
System.Xml.Serialization class.

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

It places the some part of the child element

<MyRootElement>
<SomeOtherElement>
</SomeOtherElement>
</MyRootElement>ement> --- 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"?>
<DataProcessTestingSettings
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<LastTubeNumber>362</LastTubeNumber>
<RawDataFile>raw_09042003.txt</RawDataFile>
<LastProductionDate>2003-09-04T00:00:00.0000000-
04:00</LastProductionDate>
<PalletRevolutions>
<int>0</int>
<int>0</int>
<int>0</int>
<int>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>
</PalletRevolutions>
<PalletDefects>
<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>
</DataProcessTestingSettings>fects> --- This what happens
itermittently.
</DataProcessTestingSettings>

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**************@exisconsulting.com

"ron" <goodr@no_spam4me_mddm.panasonic.com> wrote in messagenews:57****************************@phx.gbl...
Hi,
I have class object that i serialize using the
System.Xml.Serialization class.

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

It places the some part of the child element

<MyRootElement>
<SomeOtherElement>
</SomeOtherElement>
</MyRootElement>ement> --- 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**************@exisconsulting.com

"ron" <goodr@no_spam4me_mdda.panasonic.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.SqlClient;
using System.Configuration;
using System.IO;
using System.Text;
using FDS.SmartCalendar;
using FDS.Data.Core;
using System.Diagnostics;
using System.Xml.Serialization;

namespace FDS.DataCollectionServer.DataProcessing
{
/// <summary>
/// Summary description for DataProcess.
/// </summary>
public abstract class DataProcess : DbObject
{
private int lineId;
private static string fileName = null;
private static DateTime
previousProductionDate;
private static bool newcycle;
private static int tubeNumber;
private static int totRejects;

protected static ShiftCalendar.Calendar
cal = new ShiftCalendar.Calendar();

/// <summary>
///
/// </summary>
/// <param
name="newConnectionString"></param>
public DataProcess(string
newConnectionString) : base(newConnectionString)
{
previousProductionDate =
DateTime.Now;
}

/// <summary>
/// Set the public fields to supply
settings to DataProcess.
/// </summary>
[Serializable]
public class ProcessedSettings
{
public int LastTubeNumber =
tubeNumber;
public string RawDataFile =
fileName;
public DateTime
LastProductionDate = previousProductionDate;

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

/// <summary>
/// Create a new
ProcessedSettings object initialised from XML data
/// </summary>
/// <param name="s">Stream to
load the XML from</param>
/// <returns>ProcessedSettings
object</returns>
public static ProcessedSettings
LoadFromXML(Stream s)
{
return LoadFromXML(s,
typeof(ProcessedSettings));
}

/// <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
(ProcessedDerivedSettings)LoadFromXML(s, typeof
(ProcessedDerivedSettings));
/// </summary>
/// <param name="s">Stream to
load the object from</param>
/// <param name="t">Type of the
derived object</param>
/// <returns></returns>
protected static
ProcessedSettings LoadFromXML(Stream s, Type t)
{
XmlSerializer sr = new
XmlSerializer(t);
try
{
return
(ProcessedSettings)sr.Deserialize(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{get{return
totRejects;}set{totRejects = value;}}

public string FileName{get{return
fileName;}set{fileName = value;}}

public int LineId{get{return lineId;}set
{lineId = value;}}

public DateTime PreviousProductionDate{get
{return previousProductionDate;}set
{previousProductionDate = value;}}

public bool IsNewProductionCycle{get
{return newcycle;}set{newcycle = value;}}

#endregion

public void GetShift()
{
cal.CurrentShift(LineId);
}

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

}

protected void CheckShiftStatus()
{
// 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.ShiftType != "3-
Shift") & (cal.Shift == "A" | cal.Shift == "C"))
ProductionCycleReset();
// Look for new
prodcution cycle if 3 shift type configuration
if((cal.ShiftType == "3-
Shift") & (cal.Shift == "A"))ProductionCycleReset();
}
else
{
// System may have been
shut down for more than 24 hr
// Look to see if system
was shut down
if(DateTime.Parse
(cal.ProductionDate) > PreviousProductionDate)
ProductionCycleReset();
// Look for no file name
if(fileName == null)
ProductionCycleReset();
}

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

private void ProductionCycleReset()
{
GetNewFileName();
FileName = fileName;
PreviousProductionDate =
DateTime.Parse(cal.ProductionDate);
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.SqlClient;
using System.Configuration;
using System.IO;
using System.Text;
using FDS.SmartCalendar;
using System.Globalization;
using System.Diagnostics;
using System.Xml.Serialization;

namespace FDS.DataCollectionServer.DataProcessing
{
/// <summary>
/// Summary description for DataProcessTesting.
/// </summary>
public class DataProcessTesting : 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[] palletrevolution = 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 DataProcessTestingSettings
settings;
string fSettings = @"settings.xml";

#region Properties ...

protected bool IsNoWork{get{return
nowork;}set{nowork = value;}}

protected bool DecisionIsNoTest{get
{return isNoTest;}set{isNoTest = value;}}

protected bool DecisionIsReject{get
{return isReject;}set{isReject = value;}}

protected bool DecisionIsGo{get{return
isGO;}set{isGO = value;}}

protected string TestResult{get{return
testResult;}}

protected bool IsTestPiece{get{return
isTestPiece;}}

protected string TroubleFlag{get{return
troubleFlag;}set{troubleFlag = value;}}

protected int TestType{get{return
testType;}set{testType = value;}}

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

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

protected bool[] Decisions{get{return
decisions;}}

protected int PalletNumber{get{return
palletnumber;}set{palletnumber = value;}}

#endregion

protected enum DecimalLocation
{
Tenths,
Hundredths,
None
}

protected enum HexToBinType
{
Decision,
Flag
}

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

public DataProcessTesting(string
newConnectionString) : base(newConnectionString)
{
for(int i=0;
i<palletdefect.Length; i++)
{
palletdefect[i] = new int
[16];
}

for(int i=0;
i<hourlyCount.Length; i++)
{
hourlyCount[i] = new int
[24];
}
}
/// <summary>
/// Extends ProcessedSettings to add the
settings used by DataProcessTestingSettings.
/// </summary>
[Serializable]
public class DataProcessTestingSettings :
DataProcess.ProcessedSettings
{
public int[] PalletRevolutions =
palletrevolution;
public int[][] PalletDefects =
palletdefect;
public int[][] HourlyCounts =
hourlyCount;
public int[] Defects = defects;

public static new
DataProcessTestingSettings LoadFromXML(Stream s)
{
return
(DataProcessTestingSettings)LoadFromXML(s, typeof
(DataProcessTestingSettings));
}
}

public override void LoadSettings()
{

FileInfo f = new FileInfo
(fSettings);
if(f.Exists)
{
Stream fs = f.OpenRead();
try
{
settings =
DataProcessTestingSettings.LoadFromXML(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.LastTubeNumber;
base.FileName =
settings.RawDataFile;

base.PreviousProductionDate =
settings.LastProductionDate;
}
else
{
// File dose not exist
use default settings
settings = new
DataProcessTestingSettings();
}
}
public override void SaveSettings()
{

settings = new
DataProcessTestingSettings();

settings.LastTubeNumber =
base.TubeNumber;
settings.RawDataFile =
base.FileName;
settings.LastProductionDate =
base.PreviousProductionDate;
settings.PalletRevolutions =
palletrevolution;
settings.PalletDefects =
palletdefect;
settings.HourlyCounts =
hourlyCount;
settings.Defects = defects;

FileInfo f = new FileInfo
(fSettings);
Stream fs = f.OpenWrite();
settings.SaveAsXML(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;
// DecisionIsNoTest = false;
// DecisionIsReject = 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.CheckShiftStatus();
// Check for new
production cycle and reset count's
if
(base.IsNewProductionCycle)Reset();

// 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;
palletrevolution
[PalletNumber]++;

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

// Convert all decision
bit's from hex to binary
dmArray[0] =
ConvertHexToBin(dmArray[0], HexToBinType.Decision);
dmArray[20] =
ConvertHexToBin(dmArray[20], HexToBinType.Decision);
dmArray[40] =
ConvertHexToBin(dmArray[40], HexToBinType.Decision);
dmArray[60] =
ConvertHexToBin(dmArray[60], HexToBinType.Decision);
dmArray[80] =
ConvertHexToBin(dmArray[80], HexToBinType.Decision);
dmArray[100] =
ConvertHexToBin(dmArray[100], HexToBinType.Decision);
dmArray[101] =
ConvertHexToBin(dmArray[101], HexToBinType.Decision);
dmArray[112] =
ConvertHexToBin(dmArray[112], HexToBinType.Decision);
dmArray[113] =
ConvertHexToBin(dmArray[113], HexToBinType.Decision);
// 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.Flag);
dmArray[122] =
ConvertHexToBin(dmArray[122], HexToBinType.Flag);

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

// Set Trouble Flag
TroubleFlag =
GetTroubleFlag();

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

// Get the final test
decision
GetFinalDecision();

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

base.TotalRejects++;
CalculateDefects
();
}

// Calculate pallet
defects only if test is virgin.
if(this.TestType == 0)
CalculatePalletDefects();

// Calculate hourly counts

CalculateHourlyCounts();

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

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

Console.WriteLine
(rawData);
Console.WriteLine();

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

// Insert new DM data to
the database
//records = InsertDMData
();
//records = InsertDefects
();
//records =
InsertPalletDetails();
//records =
InsertHourlyCounts();
}

}
protected void Reset()
{
base.IsNewProductionCycle = false;
// Sets all elements in the
Array's to zero, to false,
// or to a null reference,
depending on the element type.
Array.Clear(palletrevolution, 0,
palletrevolution.Length);
Array.Clear(defects, 0,
defects.Length);

foreach(int[] subArray in
palletdefect)
{
Array.Clear(subArray, 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 CheckOnlineStatus()
{
int j = 0;
try
{
for(int i=3; i<=103;
i+=20)
{
online[j] = (0x1
== int.Parse(dmArray[i].Substring(3,1),
NumberStyles.HexNumber))? true : false;
j++;
}
// Establish test sevens
status by looking at the test flag and tracking flag bits
online[6] = ((0x8 ==
int.Parse(dmArray[121].Substring
(3,1),NumberStyles.HexNumber)) ||
(0x8 == int.Parse
(dmArray[122].Substring(3,1),NumberStyles.HexNumber)))?
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(dmArray[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(dmArray[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(dmArray[104]);
}
}
else if((TestOnline[5] ==
true) & (TestOnline[6] == false))
{
// Test 7 is off
line get the defualt test condition
judgements[5] =
int.Parse(dmArray[104]);
}
else if((TestOnline[5] ==
false) & (TestOnline[6] == true))
{
// Test 6 is off
line get the defualt test condition
judgements[6] =
int.Parse(dmArray[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 GetFinalDecision()
{
DecisionIsGo = (int.Parse(dmArray
[124]) == 0 & int.Parse(dmArray[123]) == 0)? true : false;
DecisionIsReject = (int.Parse
(dmArray[124]) == 1 & int.Parse(dmArray[123]) == 0)?
true : false;
DecisionIsNoTest = (int.Parse
(dmArray[124]) != 0 & int.Parse(dmArray[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.Decision:
dm =
Convert.ToString(Convert.ToInt32(dm, 16), 2).PadLeft
(16, '0');
break;
case
HexToBinType.Flag:
dm =
Convert.ToString(Convert.ToInt32(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(slump)).ToString("##0.0") : double.Parse
(slump).ToString("##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(dm) > 7999)? ((8000 - double.Parse(dm)) /
10).ToString("##0.0") : (double.Parse(dm) / 10).ToString
("##0.0");
break;
case
DecimalLocation.Hundredths:
dm =
(double.Parse(dm) > 7999)? ((8000 - double.Parse(dm)) /
100).ToString("#0.00") : (double.Parse(dm) / 100).ToString
("#0.00");
break;
case
DecimalLocation.None:
dm =
(int.Parse(dm) > 7999)? (8000 - int.Parse(dm)).ToString
("###0") : int.Parse(dm).ToString("###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 CalculateTestValues()
{
// 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(dmArray[72]), int.Parse(dmArray
[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(dmArray[73]), int.Parse(dmArray
[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(dmArray[79]), int.Parse(dmArray
[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 CalculateDefects()
{
// 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 CalculatePalletDefects()
{
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(dmArray[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(dmArray
[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 CalculateHourlyCounts()
{
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(DecisionIsNoTest)hourlyCount[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((DecisionIsReject) & 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(DecisionIsNoTest)
{
testResult = "NT";
}
else if(DecisionIsReject)
{
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_type", SqlDbType.NChar, 7),
new SqlParameter
("@production_date", SqlDbType.NChar, 10),
new SqlParameter
("@test_hour", SqlDbType.Int, 4),
new SqlParameter("@item",
SqlDbType.NVarChar, 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_flag", SqlDbType.NChar, 10),
new SqlParameter
("@tc5_data", SqlDbType.Int, 4),
new SqlParameter
("@test1_dec", SqlDbType.NChar, 16),
new SqlParameter
("@test1_trbl", SqlDbType.Int, 4),
new SqlParameter
("@test1_onl", SqlDbType.Int, 4),
new SqlParameter
("@test1_jg", SqlDbType.Int, 4),
new SqlParameter("@ins1",
SqlDbType.Decimal, 9),
new SqlParameter("@ins2",
SqlDbType.Decimal, 9),
new SqlParameter("@ins3",
SqlDbType.Decimal, 9),
new SqlParameter("@ins4",
SqlDbType.Decimal, 9),
new SqlParameter("@ins5",
SqlDbType.Decimal, 9),
new SqlParameter
("@test2_dec", SqlDbType.NChar, 16),
new SqlParameter
("@test2_trbl", SqlDbType.Int, 4),
new SqlParameter
("@test2_onl", SqlDbType.Int, 4),
new SqlParameter
("@test2_jg", SqlDbType.Int, 4),
new SqlParameter
("@ig3_1", SqlDbType.Decimal, 9),
new SqlParameter
("@ig3_2", SqlDbType.Decimal, 9),
new SqlParameter("@ig2",
SqlDbType.Decimal, 9),
new SqlParameter
("@stray_high", SqlDbType.Decimal, 9),
new SqlParameter
("@stray_low", SqlDbType.Decimal, 9),
new SqlParameter
("@test2_spark", SqlDbType.Int, 4),
new SqlParameter
("@test3_dec", SqlDbType.NChar, 16),
new SqlParameter
("@test3_trbl", 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_trbl", SqlDbType.Int, 4),
new SqlParameter
("@test4_onl", SqlDbType.Int, 4),
new SqlParameter
("@test4_jg", SqlDbType.Int, 4),
new SqlParameter("@vkr",
SqlDbType.Decimal, 9),
new SqlParameter("@vkg",
SqlDbType.Decimal, 9),
new SqlParameter("@vkb",
SqlDbType.Decimal, 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.Decimal, 9),
new SqlParameter("@srg",
SqlDbType.Decimal, 9),
new SqlParameter("@srb",
SqlDbType.Decimal, 9),
new SqlParameter("@ih",
SqlDbType.Int, 4),
new SqlParameter
("@test4_spark", SqlDbType.Int, 4),
new SqlParameter
("@test5_dec", SqlDbType.NChar, 16),
new SqlParameter
("@test5_trbl", 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_onl", SqlDbType.Int, 4),
new SqlParameter
("@visual_jg", SqlDbType.Int, 4),
new SqlParameter
("@visual_defect", 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.ProductionDate; // production date
parameters[4].Value =
testDate.Hour; // test hour
parameters[5].Value =
this.TestResult; // test
result (sceen,mask,ng, etc...)
parameters[6].Value =
this.PalletNumber; // pallet number
parameters[7].Value = int.Parse
(dmArray[124]); // total judgement
parameters[8].Value = int.Parse
(dmArray[123]); // total trouble
parameters[9].Value =
this.TroubleFlag; //
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(dmArray[5]); // ins1
parameters[18].Value =
double.Parse(dmArray[6]); // ins2
parameters[19].Value =
double.Parse(dmArray[7]); // ins3
parameters[20].Value =
double.Parse(dmArray[8]); // ins4
parameters[21].Value =
double.Parse(dmArray[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(dmArray[25]); // ig3-1
parameters[27].Value =
double.Parse(dmArray[26]); // ig3-2
parameters[28].Value =
double.Parse(dmArray[28]); // ig2
parameters[29].Value =
double.Parse(dmArray[30]); // stray high
parameters[30].Value =
double.Parse(dmArray[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(dmArray[65]); // vkr
parameters[45].Value =
double.Parse(dmArray[66]); // vkg
parameters[46].Value =
double.Parse(dmArray[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(dmArray[74]); // srr
parameters[55].Value =
double.Parse(dmArray[75]); // srg
parameters[56].Value =
double.Parse(dmArray[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.IsTestPiece)? 1 : 0; // is test piece

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

return numAffected;
}
protected int InsertPalletDetails()
{
int numAffected;
int rec = 0;
for(int j=0; j<21; j++)
{
SqlParameter[] parameters
= {
new SqlParameter
("@pallet_number", SqlDbType.Int, 4),
new SqlParameter
("@production_date", SqlDbType.NChar, 10),
new SqlParameter
("@pallet_revolutions", 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.ProductionDate; // production date
parameters[2].Value =
palletrevolution[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_palletdetails", parameters, out numAffected);
rec += numAffected;
}

return rec;

}
protected int InsertDefects()
{
int numAffected;

// create the parameters
SqlParameter[] parameters = {

new SqlParameter
("@production_date", 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_pass", 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.ProductionDate;
for(int i=0; i < defects.Length;
i++)
{
parameters[i+1].Value =
defects[i];
}
parameters[37].Value =
base.TotalRejects;

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

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

for(int i=0; i<tallyItem.Length;
i++)
{
SqlParameter[] parameters
= {
new SqlParameter
("@item", SqlDbType.NVarChar, 25),
new SqlParameter
("@production_date", 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.ProductionDate;

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

// Run the procedure
RunProcedure
("up_insert_hourlycount_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**************@exisconsulting.com

"ron" <goodr@no_spam4me_mddm.panasonic.com> wrote in

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

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

It places the some part of the child element

<MyRootElement>
<SomeOtherElement>
</SomeOtherElement>
</MyRootElement>ement> --- 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
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...
1
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...
3
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...
1
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
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...
0
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,...
3
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
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...
8
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...
0
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...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
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,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

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.