Exemplo n.º 1
0
        public static DataTable ReadPLD_Line(string strFileName)
        {
            String RLine;

            using (StreamReader SR = new StreamReader(strFileName, Encoding.Default, true))
            {
                CTrans <_st_typePLD_Line>         Trans_PLD_Line    = new CTrans <_st_typePLD_Line>();
                CMakeDataTable <_st_typePLD_Line> MakeTablePLD_Line = new CMakeDataTable <_st_typePLD_Line>();

                bool    chk99 = false;
                bool    bRead = false;
                decimal tCnt  = 0;
                int     nInc  = 0;

                while ((RLine = SR.ReadLine()) != null)
                {
                    if (RLine.Trim().Length <= 0)
                    {
                        continue;
                    }

                    if (RLine.Substring(0, 3) == "-99")
                    {
                        chk99 = true;
                        continue;
                    }

                    if (chk99)
                    {
                        tCnt = Convert.ToDecimal(RLine.Substring(0, 5).ToString());

                        if (tCnt > 0)
                        {
                            chk99 = false;
                            bRead = true;
                        }

                        continue;
                    }

                    if (bRead)
                    {
                        if (nInc < tCnt)
                        {
                            _st_typePLD_Line st_typePLD_Line = Trans_PLD_Line.ByteToStruct(RLine);
                            MakeTablePLD_Line.AddData(st_typePLD_Line);
                            nInc++;
                        }
                        else
                        {
                            continue;
                        }
                    }
                }

                return(MakeTablePLD_Line.DATATABLE);
            }
        }
Exemplo n.º 2
0
        private void button8_Click(object sender, EventArgs e)
        {
            String FileName;
            String RLine;
            CPLD   LToR = new CPLD();


            LToR.m_dt.Clear();
            gridControl3.DataSource = LToR.m_dt;

            int nIndex   = 0;
            int nRecLine = 0;

            using (OpenFileDialog openDlg = new OpenFileDialog())
            {
                openDlg.Filter      = "PLD 파일 (*.PLD)|*.PLD|모든파일(*.*)|*.*";
                openDlg.Multiselect = true;

                if (openDlg.ShowDialog() == DialogResult.OK)
                {
                    foreach (string strFileName in openDlg.FileNames)
                    {
                        FileName = Path.GetFileName(strFileName);

                        using (StreamReader SR = new StreamReader(strFileName, Encoding.Default))
                        {
                            nIndex = 0;
                            while ((RLine = SR.ReadLine()) != null)
                            {
                                nIndex++;

                                if (nIndex <= 2)
                                {
                                    continue;
                                }

                                if (RLine.Substring(0, 3) == "-99")
                                {
                                    break;
                                }

                                LToR.LineToRecord(FileName, RLine);
                            }
                        }
                    }

                    gridControl3.DataSource = LToR.m_dt;
                    //MessageBox.Show(LToR.m_dt.Rows.Count.ToString());
                }
            }
        }
Exemplo n.º 3
0
        private void simpleButton1_Click(object sender, EventArgs e)
        {
            ///marshal 로 처리 하려 하였으나
            ///원래 PLH파일의 처리가 잘 못되어 있어 Marshal 처리 불가능
            String FileName;
            String Extension;
            String RLine;



            CPLHMngr PLHMngr = new CPLHMngr();



            XtraOpenFileDialog Opendlg;

            using (Opendlg = new XtraOpenFileDialog())
            {
                //Opendlg.Filter = "PLH 파일 (*.PLH)|*.PLD|모든파일(*.*)|*.*";
                Opendlg.Filter      = "모든파일(*.*)|*.*";
                Opendlg.Multiselect = true;

                if (Opendlg.ShowDialog() == DialogResult.OK)
                {
                    foreach (string strFileName in Opendlg.FileNames)
                    {
                        FileName  = Path.GetFileName(strFileName);
                        Extension = Path.GetExtension(strFileName);

                        if (Extension.ToUpper() == ".PLD")
                        {
                            DataTable ddt = CReadPLD.ReadPLD_Line(strFileName);

                            if (ddt != null)
                            {
                                CPLHData PLHData = new CPLHData();
                                PLHData.FileName    = Path.GetFileNameWithoutExtension(strFileName);
                                PLHData.PLDLineData = ddt;
                                PLHMngr.AddPLDData(PLHData);
                            }
                        }


                        using (StreamReader SR = new StreamReader(strFileName, Encoding.Default, true))
                        {
                            if (Extension.ToUpper() == ".PLH")
                            {
                                CTrans <_st_typePLH>         Trans_PLH = new CTrans <_st_typePLH>();
                                CMakeDataTable <_st_typePLH> MakeTable = new CMakeDataTable <_st_typePLH>();


                                while ((RLine = SR.ReadLine()) != null)
                                {
                                    if (RLine.Substring(0, 2) != "NO")
                                    {
                                        continue;
                                    }

                                    //RLine = RLine.Replace('+', ' ');
                                    _st_typePLH st_typePLH = Trans_PLH.ByteToStruct(RLine);
                                    MakeTable.AddData(st_typePLH);
                                }

                                if (MakeTable.DATATABLE != null)
                                {
                                    DataTable dt = MakeTable.DATATABLE;

                                    CPLHData PLHData = new CPLHData();
                                    PLHData.FileName = Path.GetFileNameWithoutExtension(strFileName);
                                    PLHData.PLHData  = dt;
                                    PLHMngr.AddPLHData(PLHData);
                                }
                            }
                            else if (Extension.ToUpper() == ".PLD")
                            {
                                CTrans <_st_typePLD>         Trans_PLD    = new CTrans <_st_typePLD>();
                                CMakeDataTable <_st_typePLD> MakeTablePLD = new CMakeDataTable <_st_typePLD>();

                                while ((RLine = SR.ReadLine()) != null)
                                {
                                    if (RLine.Contains("CROSS") == false)
                                    {
                                        continue;
                                    }

                                    _st_typePLD st_typePLD = Trans_PLD.ByteToStruct(RLine);
                                    MakeTablePLD.AddData(st_typePLD);
                                }

                                if (MakeTablePLD.DATATABLE != null)
                                {
                                    DataTable dt = MakeTablePLD.DATATABLE;

                                    CPLHData PLHData = new CPLHData();
                                    PLHData.FileName = Path.GetFileNameWithoutExtension(strFileName);
                                    PLHData.PLDData  = dt;
                                    PLHMngr.AddPLDData(PLHData);
                                }
                            }
                        }
                    }
                }
                else
                {
                    //취소하면 이후 처리는 SKIP
                    return;
                }

                CPLHDataProc DataProc = new CPLHDataProc(PLHMngr);
                DataProc.MakePipeToolData();

                gridControl2.DataSource = PLHMngr.GetData();

                ExportToSpreadSheet(DataProc);
                ExportToSpread2(DataProc);
            }
        }