Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- namespace GlassSort
- {
- class GlassItem
- {
- //Member Variables
- string headerRecord;
- string itemRecord;
- string spacerType;
- string spacerSize;
- string lite1Strength = "";
- string lite1Color = "";
- string lite2Strength = "";
- string lite2Color = "";
- string lite3Strength = "";
- string lite3Color = "";
- string SPS;
- string GRC;
- string IGL;
- string IGS;
- string ULB;
- List<string> NERecordList = new List<string>();
- bool lami = false;
- bool shape = false;
- int shapeNumber;
- bool tempered = false;
- bool tripleGlazed = false;
- string passCode;
- string lamiInterLayer = "";
- //Methods
- public GlassItem(string NIRecord)
- {
- itemRecord = NIRecord;
- ParseMaterialSpecification();
- }
- public void AddNERecord(string NERecord)
- {
- NERecordList.Add(NERecord);
- }
- public string ToInpRecord()
- {
- string inpRecordString = itemRecord;
- inpRecordString += "\r\n";
- if (SPS != null)
- {
- inpRecordString += CreateDescriptionRecord("SPS");
- inpRecordString += "\r\n";
- }
- if (GRC != null)
- {
- inpRecordString += CreateDescriptionRecord("GRC");
- inpRecordString += "\r\n";
- }
- if (IGL != null)
- {
- inpRecordString += CreateDescriptionRecord("IGL");
- inpRecordString += "\r\n";
- }
- if (IGS != null)
- {
- inpRecordString += CreateDescriptionRecord("IGS");
- inpRecordString += "\r\n";
- }
- if (ULB != null)
- {
- inpRecordString += CreateDescriptionRecord("ULB");
- inpRecordString += "\r\n";
- }
- return inpRecordString;
- }
- private string CreateDescriptionRecord(string recordType)
- {
- string lineNumber = "";
- string description = "";
- switch (recordType)
- {
- case "SPS":
- lineNumber = "1";
- description = SPS;
- break;
- case "GRC":
- lineNumber = "2";
- description = GRC;
- break;
- case "IGL":
- lineNumber = "3";
- description = IGL;
- break;
- case "IGS":
- lineNumber = "4";
- description = IGS;
- break;
- case "ULB":
- lineNumber = "5";
- description = ULB;
- break;
- }
- return "ND" + OrderNumber.PadRight(10) + this.ItemNumber + SubItem + lineNumber
- + recordType + "1".PadRight(4) + description;
- }
- private void ParseMaterialSpecification()
- {
- string[] liteArray = MaterialSpecification.Split("+".ToCharArray());
- string spacer = liteArray[1];
- spacerSize = spacer.Substring(0, 2);
- spacerType = spacer.Substring(2, 2);
- string lite1 = liteArray[0];
- if (lite1.Length > 5)
- {
- if (lite1.Substring(4, 2) == "L6")
- lami = true;
- }
- if (lite1.Contains("T"))
- tempered = true;
- lite1Strength = lite1.Substring(0, 2);
- lite1Color = lite1.Substring(2, 2);
- string lite2 = liteArray[2];
- if (lite2.Length > 5)
- {
- if (lite2.Substring(4, 2) == "L6")
- lami = true;
- }
- if (lite2.Contains("T"))
- tempered = true;
- lite2Strength = lite2.Substring(0, 2);
- lite2Color = lite2.Substring(2, 2);
- if (liteArray.Length == 5)
- {
- tripleGlazed = true;
- string lite3 = liteArray[4];
- if (lite3.Length > 4)
- {
- if (lite3.Substring(4,2) == "L6")
- lami = true;
- }
- if (lite3.Contains("T"))
- tempered = true;
- lite3Strength = lite3.Substring(0, 2);
- lite3Color = lite3.Substring(2, 2);
- }
- }
- private void ParseLamiString(string lamiLite)
- {
- lami = true;
- string[] lamiComponents = lamiLite.Split("-".ToCharArray());
- lamiInterLayer = lamiComponents[1];
- // Should I break this down to .090 .105?
- }
- //Properties
- public string HeaderRecord
- {
- get { return headerRecord; }
- set { headerRecord = value; }
- }
- public string NIRecord
- {
- get { return itemRecord; }
- }
- public string OrderNumber
- {
- get { return itemRecord.Substring(2, 7); }
- }
- public string ItemNumber
- {
- get { return itemRecord.Substring(12, 2); }
- }
- public string SubItem
- {
- get { return itemRecord.Substring(14, 1); }
- }
- public int Quantity
- {
- get { return int.Parse(itemRecord.Substring(15, 4)); }
- }
- public string Base
- {
- get { return itemRecord.Substring(19, 9); }
- }
- public string Left
- {
- get { return itemRecord.Substring(28, 9); }
- }
- public string ShapeNumber
- {
- get { return itemRecord.Substring(37, 3); }
- }
- public string Right
- {
- get { return itemRecord.Substring(40, 9); }
- }
- public string Top
- {
- get { return itemRecord.Substring(49, 9); }
- }
- public string S3
- {
- get { return itemRecord.Substring(58, 9); }
- }
- public string S4
- {
- get { return itemRecord.Substring(67, 9); }
- }
- public string S5
- {
- get { return itemRecord.Substring(76, 9); }
- }
- public string S6
- {
- get { return itemRecord.Substring(85, 9); }
- }
- public string ProductStyle
- {
- get { return itemRecord.Substring(94, 2); }
- }
- public string MaterialSpecification
- {
- get
- {
- if (itemRecord.Length < 158)
- return itemRecord.Substring(124, itemRecord.Length - 124);
- else
- return itemRecord.Substring(124, 34);
- }
- }
- public string LamiDescription
- {
- get { return lamiInterLayer; }
- }
- public string RouteCode
- {
- get
- {
- string route = "";
- if (itemRecord.Length > 158)
- route = itemRecord.Substring(158, itemRecord.Length - 158);
- return route;
- }
- }
- public string SequenceNumber
- {
- get { return SPS; }
- set { SPS = value; }
- }
- public string GridCode
- {
- get { return GRC; }
- set { GRC = value; }
- }
- public string IGLine
- {
- get { return IGL; }
- set { IGL = value; }
- }
- public string IGSequence
- {
- get { return IGS; }
- set { IGS = value; }
- }
- public string UnitLabel
- {
- get { return ULB; }
- set { ULB = value; }
- }
- public string SpacerType
- {
- get { return spacerType; }
- }
- public string SpacerSize
- {
- get { return spacerSize; }
- }
- public string Lite1Strength
- {
- get { return lite1Strength; }
- }
- public string Lite1Color
- {
- get { return lite1Color; }
- }
- public string Lite2Strength
- {
- get { return lite2Strength; }
- }
- public string Lite2Color
- {
- get { return lite2Color; }
- }
- public string Lite3Strength
- {
- get { return lite3Strength; }
- }
- public string Lite3Color
- {
- get { return lite3Color; }
- }
- public bool IsLami
- {
- get { return lami; }
- }
- public bool IsShape
- {
- get { return int.TryParse(ShapeNumber, out shapeNumber); }
- }
- public bool IsTempered
- {
- get { return tempered; }
- }
- public bool IsTripleGlazed
- {
- get { return tripleGlazed; }
- }
- public DateTime FloorDate
- {
- get
- {
- DateTime floordt = DateTime.Parse(headerRecord.Substring(38, 8));
- //floordt.pa
- return floordt;//headerRecord.Substring(38, 8); }
- }
- }
- public bool HasGEDRecord
- {
- get
- {
- if (NERecordList.Count > 0)
- return true;
- else
- return false;
- }
- }
- public string GEDRecord
- {
- get
- {
- string GEDRecordString = "";
- foreach (string NERecord in NERecordList)
- GEDRecordString += NERecord +"\r\n";
- return GEDRecordString;
- }
- }
- public string PassCode
- {
- get { return passCode; }
- set { passCode = value; }
- }
- public string FloorLine
- {
- get { return SPS.Substring(0, 1); }
- }
- public string IGUThickness
- {
- get
- {
- string thickness = "";
- if (NERecordList.Count > 0)
- thickness = NERecordList[0].Split(",".ToCharArray())[6];
- return thickness;
- }
- }
- public string ShortSeqNumber
- {
- get
- {
- if (SPS.Length == 5)
- return FloorLine + SPS.Substring(1,4).TrimStart("0".ToCharArray());
- else
- return SPS;
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement