Advertisement
Guest User

Untitled

a guest
Jun 29th, 2017
77
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 10.88 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3.  
  4. namespace GlassSort
  5. {
  6.     class GlassItem
  7.     {
  8.         //Member Variables
  9.         string headerRecord;
  10.         string itemRecord;
  11.         string spacerType;
  12.         string spacerSize;
  13.         string lite1Strength = "";
  14.         string lite1Color = "";
  15.         string lite2Strength = "";
  16.         string lite2Color = "";
  17.         string lite3Strength = "";
  18.         string lite3Color = "";
  19.         string SPS;
  20.         string GRC;
  21.         string IGL;
  22.         string IGS;
  23.         string ULB;
  24.         List<string> NERecordList = new List<string>();
  25.         bool lami = false;
  26.         bool shape = false;
  27.         int shapeNumber;
  28.         bool tempered = false;
  29.         bool tripleGlazed = false;
  30.         string passCode;
  31.         string lamiInterLayer = "";
  32.        
  33.        
  34.         //Methods
  35.         public GlassItem(string NIRecord)
  36.         {
  37.             itemRecord = NIRecord;
  38.             ParseMaterialSpecification();
  39.         }
  40.         public void AddNERecord(string NERecord)
  41.         {
  42.             NERecordList.Add(NERecord);
  43.         }
  44.         public string ToInpRecord()
  45.         {
  46.             string inpRecordString = itemRecord;
  47.             inpRecordString += "\r\n";
  48.  
  49.             if (SPS != null)
  50.             {
  51.                 inpRecordString += CreateDescriptionRecord("SPS");
  52.                 inpRecordString += "\r\n";
  53.             }
  54.             if (GRC != null)
  55.             {
  56.                 inpRecordString += CreateDescriptionRecord("GRC");
  57.                 inpRecordString += "\r\n";
  58.             }
  59.             if (IGL != null)
  60.             {
  61.                 inpRecordString += CreateDescriptionRecord("IGL");
  62.                 inpRecordString += "\r\n";
  63.             }
  64.             if (IGS != null)
  65.             {
  66.                 inpRecordString += CreateDescriptionRecord("IGS");
  67.                 inpRecordString += "\r\n";
  68.             }
  69.             if (ULB != null)
  70.             {
  71.                 inpRecordString += CreateDescriptionRecord("ULB");
  72.                 inpRecordString += "\r\n";
  73.             }
  74.  
  75.             return inpRecordString;
  76.         }
  77.         private string CreateDescriptionRecord(string recordType)
  78.         {
  79.             string lineNumber = "";
  80.             string description = "";
  81.  
  82.             switch (recordType)
  83.             {
  84.                 case "SPS":
  85.                     lineNumber = "1";
  86.                     description = SPS;
  87.                     break;
  88.                 case "GRC":
  89.                     lineNumber = "2";
  90.                     description = GRC;
  91.                     break;
  92.                 case "IGL":
  93.                     lineNumber = "3";
  94.                     description = IGL;
  95.                     break;
  96.                 case "IGS":
  97.                     lineNumber = "4";
  98.                     description = IGS;
  99.                     break;
  100.                 case "ULB":
  101.                     lineNumber = "5";
  102.                     description = ULB;
  103.                     break;
  104.             }
  105.             return "ND" + OrderNumber.PadRight(10) + this.ItemNumber + SubItem + lineNumber
  106.                 + recordType + "1".PadRight(4) + description;
  107.         }
  108.         private void ParseMaterialSpecification()
  109.         {
  110.             string[] liteArray = MaterialSpecification.Split("+".ToCharArray());
  111.  
  112.             string spacer = liteArray[1];
  113.             spacerSize = spacer.Substring(0, 2);
  114.             spacerType = spacer.Substring(2, 2);
  115.  
  116.            
  117.             string lite1 = liteArray[0];
  118.             if (lite1.Length > 5)
  119.             {
  120.                 if (lite1.Substring(4, 2) == "L6")
  121.                     lami = true;
  122.             }
  123.             if (lite1.Contains("T"))
  124.                 tempered = true;
  125.             lite1Strength = lite1.Substring(0, 2);
  126.             lite1Color = lite1.Substring(2, 2);
  127.            
  128.             string lite2 = liteArray[2];
  129.             if (lite2.Length > 5)
  130.             {
  131.                 if (lite2.Substring(4, 2) == "L6")
  132.                     lami = true;
  133.             }
  134.             if (lite2.Contains("T"))
  135.                 tempered = true;
  136.             lite2Strength = lite2.Substring(0, 2);
  137.             lite2Color = lite2.Substring(2, 2);
  138.            
  139.             if (liteArray.Length == 5)
  140.             {
  141.                 tripleGlazed = true;
  142.                 string lite3 = liteArray[4];
  143.                 if (lite3.Length > 4)
  144.                 {
  145.                     if (lite3.Substring(4,2) == "L6")
  146.                         lami = true;
  147.                 }
  148.                 if (lite3.Contains("T"))
  149.                     tempered = true;
  150.                 lite3Strength = lite3.Substring(0, 2);
  151.                 lite3Color = lite3.Substring(2, 2);
  152.             }
  153.  
  154.  
  155.         }
  156.         private void ParseLamiString(string lamiLite)
  157.         {
  158.             lami = true;
  159.             string[] lamiComponents = lamiLite.Split("-".ToCharArray());
  160.             lamiInterLayer = lamiComponents[1];
  161.             // Should I break this down to .090 .105?
  162.         }        
  163.        
  164.         //Properties
  165.         public string HeaderRecord
  166.         {
  167.             get { return headerRecord; }
  168.             set { headerRecord = value; }
  169.         }        
  170.         public string NIRecord
  171.         {
  172.             get { return itemRecord; }
  173.         }
  174.         public string OrderNumber
  175.         {
  176.             get { return itemRecord.Substring(2, 7); }
  177.         }
  178.         public string ItemNumber
  179.         {
  180.             get { return itemRecord.Substring(12, 2); }
  181.         }
  182.         public string SubItem
  183.         {
  184.             get { return itemRecord.Substring(14, 1); }
  185.         }
  186.         public int Quantity
  187.         {
  188.             get { return int.Parse(itemRecord.Substring(15, 4)); }
  189.         }
  190.         public string Base
  191.         {
  192.             get { return itemRecord.Substring(19, 9); }
  193.         }
  194.         public string Left
  195.         {
  196.             get { return itemRecord.Substring(28, 9); }
  197.         }
  198.         public string ShapeNumber
  199.         {
  200.             get { return itemRecord.Substring(37, 3); }
  201.         }
  202.         public string Right
  203.         {
  204.             get { return itemRecord.Substring(40, 9); }
  205.         }
  206.         public string Top
  207.         {
  208.             get { return itemRecord.Substring(49, 9); }
  209.         }
  210.         public string S3
  211.         {
  212.             get { return itemRecord.Substring(58, 9); }
  213.         }
  214.         public string S4
  215.         {
  216.             get { return itemRecord.Substring(67, 9); }
  217.         }
  218.         public string S5
  219.         {
  220.             get { return itemRecord.Substring(76, 9); }
  221.         }
  222.         public string S6
  223.         {
  224.             get { return itemRecord.Substring(85, 9); }
  225.         }
  226.         public string ProductStyle
  227.         {
  228.             get { return itemRecord.Substring(94, 2); }
  229.         }
  230.         public string MaterialSpecification
  231.         {
  232.             get
  233.             {
  234.                 if (itemRecord.Length < 158)
  235.                     return itemRecord.Substring(124, itemRecord.Length - 124);
  236.                 else
  237.                     return itemRecord.Substring(124, 34);
  238.             }
  239.         }
  240.         public string LamiDescription
  241.         {
  242.             get { return lamiInterLayer; }
  243.         }
  244.         public string RouteCode
  245.         {
  246.             get
  247.             {
  248.                 string route = "";
  249.                 if (itemRecord.Length > 158)
  250.                     route =  itemRecord.Substring(158, itemRecord.Length - 158);
  251.                 return route;
  252.             }
  253.         }
  254.         public string SequenceNumber
  255.         {
  256.             get { return SPS; }
  257.             set { SPS = value; }
  258.         }
  259.         public string GridCode
  260.         {
  261.             get { return GRC; }
  262.             set { GRC = value; }
  263.         }
  264.         public string IGLine
  265.         {
  266.             get { return IGL; }
  267.             set { IGL = value; }
  268.         }
  269.         public string IGSequence
  270.         {
  271.             get { return IGS; }
  272.             set { IGS = value; }
  273.         }
  274.         public string UnitLabel
  275.         {
  276.             get { return ULB; }
  277.             set { ULB = value; }
  278.         }
  279.         public string SpacerType
  280.         {
  281.             get { return spacerType; }
  282.         }
  283.         public string SpacerSize
  284.         {
  285.             get { return spacerSize; }
  286.         }
  287.         public string Lite1Strength
  288.         {
  289.             get { return lite1Strength; }
  290.         }
  291.         public string Lite1Color
  292.         {
  293.             get { return lite1Color; }
  294.         }
  295.         public string Lite2Strength
  296.         {
  297.             get { return lite2Strength; }
  298.         }
  299.         public string Lite2Color
  300.         {
  301.             get { return lite2Color; }
  302.         }
  303.         public string Lite3Strength
  304.         {
  305.             get { return lite3Strength; }
  306.         }
  307.         public string Lite3Color
  308.         {
  309.             get { return lite3Color; }
  310.         }        
  311.         public bool IsLami
  312.         {
  313.             get { return lami; }
  314.         }
  315.         public bool IsShape
  316.         {
  317.             get { return int.TryParse(ShapeNumber, out shapeNumber); }
  318.         }
  319.         public bool IsTempered
  320.         {
  321.             get { return tempered; }
  322.         }
  323.         public bool IsTripleGlazed
  324.         {
  325.             get { return tripleGlazed; }
  326.         }        
  327.         public DateTime FloorDate
  328.         {
  329.             get
  330.             {
  331.                 DateTime floordt = DateTime.Parse(headerRecord.Substring(38, 8));
  332.                 //floordt.pa
  333.                 return floordt;//headerRecord.Substring(38, 8); }
  334.             }
  335.         }
  336.         public bool HasGEDRecord
  337.         {
  338.             get
  339.             {
  340.                 if (NERecordList.Count > 0)
  341.                     return true;
  342.                 else
  343.                     return false;
  344.             }
  345.         }
  346.         public string GEDRecord
  347.         {
  348.             get
  349.             {
  350.                 string GEDRecordString = "";
  351.  
  352.                 foreach (string NERecord in NERecordList)
  353.                     GEDRecordString += NERecord +"\r\n";
  354.  
  355.                 return GEDRecordString;
  356.  
  357.             }
  358.         }
  359.         public string PassCode
  360.         {
  361.             get { return passCode; }
  362.             set { passCode = value; }
  363.         }
  364.         public string FloorLine
  365.         {
  366.             get { return SPS.Substring(0, 1); }
  367.         }
  368.         public string IGUThickness
  369.         {
  370.             get
  371.             {
  372.                 string thickness = "";
  373.  
  374.                 if (NERecordList.Count > 0)
  375.                     thickness = NERecordList[0].Split(",".ToCharArray())[6];
  376.  
  377.                 return thickness;
  378.             }
  379.         }
  380.         public string ShortSeqNumber
  381.         {
  382.             get
  383.             {
  384.                 if (SPS.Length == 5)
  385.                     return FloorLine + SPS.Substring(1,4).TrimStart("0".ToCharArray());
  386.                 else
  387.                     return SPS;
  388.             }
  389.         }
  390.     }
  391. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement