Exemplo n.º 1
0
        private static void makeTextFile(string sumfolder, string saveFolder, Reserve_R[] data)
        {
            DirectoryInfo di = new DirectoryInfo(sumfolder);
            string di_name = di.Name;

            FileStream fs = File.OpenWrite(saveFolder + "\\" + di_name + ".txt");

            StringBuilder sb = new StringBuilder();

            int recNo = data.Length;

            using (StreamWriter sw = new StreamWriter(fs))
            {
                for (int i = 0; i < recNo; i++)
                {
                    data[i].append_data(sw, ",");
                }

            }

            fs.Close();
        }
Exemplo n.º 2
0
        //private static void ReadPolicyReserveData(string fileFullName , long recNo)
        //private static void ReadPolicyReserveData()
        //{

        //    string fileFullName = @"F:\Data\testBinary.dat";

        //    //FileStream fs = File.Open(fileFullName, FileMode.Open);
        //    byte[] bdata = File.ReadAllBytes(fileFullName);
        //    MemoryStream memStream = new MemoryStream(bdata);
        //    BinaryReader bReader = new BinaryReader(memStream);

        //    for (int i = 0; i < 100; i++)
        //    {
                
        //        double k1 = bReader.ReadDouble();
        //        double k2 = bReader.ReadDouble();

        //        Console.WriteLine(k1);
        //        Console.WriteLine(k2);
        //    }

        //    //string[] subDirectories = Directory.GetDirectories();

        //}

        //private static void folderSum(string sumfolder,string saveFolder, int recNo)
        //{ 
        //    // file List을 가져옴.

        //    string[] files = Directory.GetFiles(sumfolder);

        //    // option 개수를 파악함

        //    // option 개수 마다 더함


        //    // 

            
        //}

        private static void ReadPolicyReserveData(string sumfolder, string saveFolder, long recNo)
        {
            Reserve_R[] Reserves = new Reserve_R[recNo];

	        long idx = 0;

            string[] files = Directory.GetFiles(sumfolder);

            #region Aggregate

            foreach (string File_loopVariable in files) 
            {
                Console.WriteLine("fileName : " + File_loopVariable);

		        if (File_loopVariable.Contains("GMDB")) 
                {
			        //FileStream fs = File.Open(File_loopVariable,FileMode.Open);

			        byte[] bdata = File.ReadAllBytes(File_loopVariable);

			        MemoryStream memStream = new MemoryStream(bdata);
			        BinaryReader bReader = new BinaryReader(memStream);
                    
                    for (idx = 0; idx < recNo; idx++)
                    {
				        //FileGet(guidFileNo, fc, idx)
				        Reserves[idx].GMDB_FEE = Reserves[idx].GMDB_FEE + bReader.ReadDouble();
				        //fc.fee
				        Reserves[idx].GMDB_CLAIM = Reserves[idx].GMDB_CLAIM + bReader.ReadDouble();
				        //fc.claim
			        }

		        }
                else if (File_loopVariable.Contains("GMAB")) 
                {
			        //FileStream fs = File.Open(File_loopVariable,FileMode.Open);

			        byte[] bdata = File.ReadAllBytes(File_loopVariable);

			        MemoryStream memStream = new MemoryStream(bdata);
			        BinaryReader bReader = new BinaryReader(memStream);

			        for (idx = 0; idx < recNo; idx++) {
				        //FileGet(guidFileNo, fc, idx)
                        Reserves[idx].GMAB_FEE = Reserves[idx].GMAB_FEE + bReader.ReadDouble();
				        //fc.fee
                        Reserves[idx].GMAB_CLAIM = Reserves[idx].GMAB_CLAIM + bReader.ReadDouble();
				        //fc.claim
			        }

                }
                else if (File_loopVariable.Contains("GMEB"))
                {
                    //FileStream fs = File.Open(File_loopVariable, FileMode.Open);

                    byte[] bdata = File.ReadAllBytes(File_loopVariable);

                    MemoryStream memStream = new MemoryStream(bdata);
                    BinaryReader bReader = new BinaryReader(memStream);

                    for (idx = 0; idx < recNo; idx++) 
                    {
                        //FileGet(guidFileNo, fc, idx)
                        Reserves[idx].GMEB_FEE = Reserves[idx].GMEB_FEE + bReader.ReadDouble();
                        //fc.fee
                        Reserves[idx].GMEB_CLAIM = Reserves[idx].GMEB_CLAIM + bReader.ReadDouble();
                        //fc.claim
                    }

		        }
                else if (File_loopVariable.Contains("GLWB"))
                {
                    //FileStream fs = File.Open(File_loopVariable, FileMode.Open);

                    //recNoFC = Convert.ToInt64(FileSystem.LOF(guidFileNo) / Strings.Len(fc));

                    //if (recNo != recNoFC) {
                    //    Interaction.MsgBox("policy의 갯수가 틀립니다." + Convert.ToString(recNo) + "," + Convert.ToString(recNoFC) + File.ToString());
                    //    return false;
                    //}


                    //byte[] bdata = File.ReadAllBytes(File_loopVariable);

                    byte[] bdata = File.ReadAllBytes(File_loopVariable);

                    MemoryStream memStream = new MemoryStream(bdata);
                    BinaryReader bReader = new BinaryReader(memStream);

                    for (idx = 0; idx < recNo; idx++)
                    {
                        //FileGet(guidFileNo, fc, idx)
                        Reserves[idx].GLWB_FEE = Reserves[idx].GLWB_FEE + bReader.ReadDouble();
                        //fc.fee
                        Reserves[idx].GLWB_CLAIM = Reserves[idx].GLWB_CLAIM + bReader.ReadDouble();
                        //fc.claim
                    }

                }
                else 
                {
                
                }

	        }
            #endregion

            makeTextFile(sumfolder, saveFolder,Reserves);

            Console.WriteLine(sumfolder);
        }