コード例 #1
0
        protected override void SizeCheckCompleted(object sender, EventArgs e)
        {
            FileSize ch = (sender as FileSize);

            ch.Pause();

            check_count++;

            if (check_count == file_size_checker_.Count)
            {
                FileProcessEventArgs event_args = new FileProcessEventArgs(this, "PROCESS_COMPLETE");

                foreach (FileInfo f in input_files)
                {
                    event_args.input_files.Add(f);
                }

                foreach (FileSize f in file_size_checker_)
                {
                    event_args.output_files.Add(f.current_file);
                    event_args.msg.Add("계산완료");
                    f.Resume();
                }

                check_count            = 0;
                event_args.output_path = output_;
                EventControl.Instance().SendEvent(event_args);

                process_flag_ = false;
            }
        }
コード例 #2
0
        public void MakeStart()
        {
            int record_number = data_.Count;

            Byte[] header = MakeHeader(record_number, 0);
            fs_shx_.Write(header, 0, header.Length);

            header = MakeHeader(record_number, 1);
            fs_shp_.Write(header, 0, header.Length);

            int data_count = 0;

            EventControl.Instance().SendEvent(new ProgressEventArgs(null, "PB_OPER", data_count, record_number));
            foreach (Point p in data_)
            {
                Byte[] shx_record    = GetShxRecordContent(20);
                Byte[] record_header = GetRecordHeader(20);

                Byte[] record_content = GetRecordContents(20, p.x, p.y);

                fs_shx_.Write(shx_record, 0, shx_record.Length);
                fs_shp_.Write(record_header, 0, record_header.Length);
                fs_shp_.Write(record_content, 0, record_content.Length);

                if ((data_count % 100) == 0)
                {
                    EventControl.Instance().SendEvent(new ProgressEventArgs(null, "PB_OPER", data_count, record_number));
                }

                data_count++;
            }
        }
コード例 #3
0
        public List <FileInfo> GetNewFiles()
        {
            List <FileInfo> new_files = GetFiles(new DirectoryInfo(path_));

            foreach (FileInfo s in last_file_list_)
            {
                int file_index = new_files.FindIndex(x => x.FullName.Contains(s.FullName));

                if (file_index >= 0)
                {
                    new_files.RemoveAt(file_index);
                }
            }

            FileProcessEventArgs event_arg = new FileProcessEventArgs(this, "FILE_STATUS");

            foreach (FileInfo f in new_files)
            {
                last_file_list_.Add(f);
                event_arg.input_files.Add(f);
                event_arg.msg.Add("수신시작");
            }

            if (event_use_ && event_arg.input_files.Count > 0)
            {
                EventControl.Instance().SendEvent(event_arg);
            }

            return(new_files);
        }
コード例 #4
0
        private List <Polygon> ReadPolygon(int shxLength, byte[] shpArray, byte[] shxArray)
        {
            int            count    = (shxLength - 100) / 8;
            int            offset   = 0;
            List <Polygon> polyList = new List <Polygon> ();

            CoordConversion cc = new CoordConversion();

            for (int i = 0; i < count; i++)
            {
                if ((i % 100) == 0)
                {
                    EventControl.Instance().SendEvent(new ProgressEventArgs(null, "PB_OPER", i, count));
                }

                offset = BitConverter.ToInt32(shxArray, 100 + 8 * i);
                offset = Swap(offset) * 2 + 8;           // BigEndian, Word(16bit) 단위 // SHP 파일의 컨텐츠 위치

                int shapeType = BitConverter.ToInt32(shpArray, offset);
                int nParts    = BitConverter.ToInt32(shpArray, offset + 36);
                int nPoints   = BitConverter.ToInt32(shpArray, offset + 40);

                if (shapeType != 0)
                {
                    Polygon poly = new Polygon(nParts, nPoints);
                    poly.shapeType = BitConverter.ToInt32(shpArray, offset);

                    poly.box[0].x = BitConverter.ToDouble(shpArray, offset + 4 + 8 * 0);
                    poly.box[0].y = BitConverter.ToDouble(shpArray, offset + 4 + 8 * 1);

                    poly.box[0].xy2ll();

                    poly.box[1].x = BitConverter.ToDouble(shpArray, offset + 4 + 8 * 2);
                    poly.box[1].y = BitConverter.ToDouble(shpArray, offset + 4 + 8 * 3);

                    poly.box[1].xy2ll();

                    for (int j = 0; j < nParts; j++)                            // Parts
                    {
                        poly.parts[j] = BitConverter.ToInt32(shpArray, offset + 44 + 4 * j);
                    }

                    for (int j = 0; j < nPoints; j++)
                    {
                        poly.points[j].x = BitConverter.ToDouble(shpArray, offset + 44 + 4 * nParts + 16 * j);
                        poly.points[j].y = BitConverter.ToDouble(shpArray, offset + 44 + 4 * nParts + 16 * j + 8);

                        poly.points[j].xy2ll();
                    }

                    poly.CalcCenter();
                    polyList.Add(poly);
                }
            }
            ////// 폴리곤 읽기 끝
            EventControl.Instance().SendEvent(new ProgressEventArgs(null, "PB_OPER", count, count));

            return(polyList);
        }
コード例 #5
0
ファイル: Main.cs プロジェクト: noday-buttoday/NDMI-Analysis
        private void WriteDbf(DataTable data, int file_index)
        {
            DbfWriter dw = new DbfWriter();

            EventControl.Instance().SendEvent(new ProgressLabelEventArgs(null, "LB_PROG", "Writing Dbf File"));
            dw.SetPath(output_path_);
            dw.SetFile(dbf_file_list_[file_index]);
            dw.SetData(data);
        }
コード例 #6
0
ファイル: Main.cs プロジェクト: noday-buttoday/NDMI-Analysis
        private void WriteDbf(DataTable data, String file_name)
        {
            DbfWriter dw = new DbfWriter();

            EventControl.Instance().SendEvent(new ProgressLabelEventArgs(null, "LB_PROG", "Writing Dbf File"));
            dw.SetPath(output_path_);
            dw.SetFile(file_name);
            dw.SetData(data);
        }
コード例 #7
0
ファイル: Main.cs プロジェクト: noday-buttoday/NDMI-Analysis
        private void WriteShp(List <Point> point, int file_index)
        {
            EventControl.Instance().SendEvent(new ProgressLabelEventArgs(null, "LB_PROG", "Writing Shp File"));
            ShapeWriter sw = new ShapeWriter();

            sw.SetShapeData(point);
            sw.OpenFile(output_path_ + "\\" + file_list_[file_index]);
            sw.MakeStart();
            sw.CloseFile();
        }
コード例 #8
0
        public void Run()
        {
            List <FileInfo> input_file_info = new List <FileInfo>();

            FileProcessEventArgs event_args = new FileProcessEventArgs(this, "FILE_COMPLETE");

            foreach (FileInfo f in input_files_)
            {
                event_args.input_files.Add(f);
                event_args.msg.Add("계산시작");
            }

            String output_path = StartEnvi(input_file_info);

            event_args.output_path = output_path;

            EventControl.Instance().SendEvent(event_args);
        }
コード例 #9
0
        public void InitializeFiles()
        {
            last_file_list_.Clear();

            FileProcessEventArgs event_arg = new FileProcessEventArgs(this, "FILE_STATUS");

            foreach (FileInfo f in GetFiles(new DirectoryInfo(path_)))
            {
                last_file_list_.Add(f);
                event_arg.input_files.Add(f);
                event_arg.msg.Add("기존파일");
            }

            if (event_use_)
            {
                EventControl.Instance().SendEvent(event_arg);
            }
        }
コード例 #10
0
        protected override void SizeCheckCompleted(object sender, EventArgs e)
        {
            FileProcessEventArgs event_args = new FileProcessEventArgs(this, "FILE_STATUS");

            FileSize ch = (sender as FileSize);

            ch.Pause();

            event_args.input_files.Add(ch.current_file);
            event_args.msg.Add("수신완료");

            EventControl.Instance().SendEvent(event_args);

            check_count++;

            if (check_count == file_size_checker_.Count)
            {
                FileProcessEventArgs new_event_args = new FileProcessEventArgs(this, "FILE_COMPLETE");
                List <FileInfo>      input_file     = new List <FileInfo>();
                foreach (FileSize f in file_size_checker_)
                {
                    input_file.Add(f.current_file);
                    new_event_args.input_files.Add(f.current_file);
                    new_event_args.msg.Add("계산시작");
                    f.Resume();
                }

                String output_path = "";

                if (module_type_ == 0)
                {
                    output_path = (new AlgorithmControl()).StartNDSIModule(input_file, output_path_);
                }
                else
                {
                }

                check_count = 0;

                new_event_args.output_path = output_path;

                EventControl.Instance().SendEvent(new_event_args);
            }
        }
コード例 #11
0
ファイル: Main.cs プロジェクト: noday-buttoday/NDMI-Analysis
        private void ExtractInfo(ref List <Point> point, ref DataTable build, List <Point> point_data, DataTable build_data)
        {
            int increase_index = 0;
            int max            = point_data.Count;

            EventControl.Instance().SendEvent(new ProgressLabelEventArgs(null, "LB_PROG", "Extracting Infomation"));
            EventControl.Instance().SendEvent(new ProgressEventArgs(null, "PB_OPER", increase_index, max));
            foreach (DataRow dr in build_data.Rows)
            {
                object[] item = dr.ItemArray;

                if ((increase_index % 1000) == 0)
                {
                    EventControl.Instance().SendEvent(new ProgressEventArgs(null, "PB_OPER", increase_index, max));
                }

                /*
                 * if (item[8] != DBNull.Value)
                 * {
                 *  String s = (item[8] as String);
                 *
                 *  int code = 0;
                 *  if (int.TryParse(s, out code))
                 *  {
                 *      code = Convert.ToInt32(item[8]);
                 *      code = code / 1000;
                 *
                 *      if (code == 1 || code == 2 || code == 21)
                 *      {
                 *          build.Rows.Add(build.NewRow().ItemArray = (object[])item.Clone());
                 *          point.Add(point_data[increase_index]);
                 *      }
                 *  }
                 *
                 * }
                 */

                build.Rows.Add(build.NewRow().ItemArray = (object[])item.Clone());
                point.Add(point_data[increase_index]);

                increase_index++;
            }
            EventControl.Instance().SendEvent(new ProgressEventArgs(null, "PB_OPER", max, max));
        }
コード例 #12
0
        private void CheckFileSize(FileInfo file)
        {
            long prev_size = 0;

            do
            {
                FileInfo check_file = new FileInfo(file.FullName);
                current_file = check_file;

                FileProcessEventArgs event_arg = new FileProcessEventArgs(this, "FILE_STATUS");

                if (prev_size == check_file.Length && check_file.Length > 0)
                {
                    event_arg.input_files.Add(check_file);
                    event_arg.msg.Add("수신완료");

                    if (event_use_)
                    {
                        EventControl.Instance().SendEvent(event_arg);
                    }

                    break;
                }

                event_arg.input_files.Add(check_file);
                event_arg.msg.Add("수신중");

                if (event_use_)
                {
                    EventControl.Instance().SendEvent(event_arg);
                }

                prev_size = check_file.Length;

                Thread.Sleep(10 * 1000);
            } while (operate_);

            if (FileSizeCheckCompleted != null && operate_ == true)
            {
                FileSizeCheckCompleted(this, null);
            }
        }
コード例 #13
0
ファイル: Main.cs プロジェクト: noday-buttoday/NDMI-Analysis
        private void WriteToDb(DataTable extract_info, List <Point> point)
        {
            DbWrite db = new DbWrite();

            db.OpenDb(db_ip_, db_id_, db_pw_);
            int increase_index = 0;
            int max            = extract_info.Rows.Count;


            foreach (DataRow dr in extract_info.Rows)
            {
                object[] item = dr.ItemArray;

                if ((increase_index % 100) == 0)
                {
                    EventControl.Instance().SendEvent(new ProgressEventArgs(null, "PB_OPER", increase_index, max));
                }

                if (item[8] != DBNull.Value)
                {
                    String s = (item[8] as String);

                    int code = 0;
                    if (int.TryParse(s, out code))
                    {
                        code = Convert.ToInt32(item[8]);
                        code = code / 1000;

                        if (code == 1 || code == 2 || code == 21)
                        {
                            db.WriteToDb(code, point[increase_index].x, point[increase_index].y);
                        }
                    }
                }
                increase_index++;
            }

            db.CloseDb();
        }
コード例 #14
0
ファイル: Main.cs プロジェクト: noday-buttoday/NDMI-Analysis
        private List <Point> GetPoint(List <Polygon> data)
        {
            List <Point> result_point = new List <Point>();

            EventControl.Instance().SendEvent(new ProgressLabelEventArgs(null, "LB_PROG", "Get Center Coordinate"));

            int point_count = 1;
            int point_max   = data.Count;

            foreach (Polygon p in data)
            {
                if ((point_count % 1000) == 0)
                {
                    EventControl.Instance().SendEvent(new ProgressEventArgs(null, "PB_OPER", point_count, point_max));
                }
                result_point.Add(new Point(p.center.x, p.center.y));
                point_count++;
            }

            EventControl.Instance().SendEvent(new ProgressEventArgs(null, "PB_OPER", point_max, point_max));

            return(result_point);
        }
コード例 #15
0
ファイル: Main.cs プロジェクト: noday-buttoday/NDMI-Analysis
 public void Stop()
 {
     EventControl.Instance().SendEvent(new ProgressLabelEventArgs(null, "LB_PROG", "Cancelled"));
     proc_thread.Abort();
 }
コード例 #16
0
 private void Window_Closing(object sender, System.ComponentModel.CancelEventArgs e)
 {
     EventControl.Instance().Stop();
     (this.DataContext as MainWindowViewModel).Close();
 }
コード例 #17
0
        public MainWindow()
        {
            EventControl.Instance().Init();

            InitializeComponent();

            GuiInit();

            Main.Instance().Init();
            Main.Instance().Finished += new EventHandler(WorkFinishEvent);


            //Thread t = new Thread(new ThreadStart(ShapeRead));
            //t.Start();

            //ShapeReader dl = new ShapeReader();
            //List<Polygon> p = dl.ReadShapeFile("D:\\00_Work\\96_SUPPORT\\Data\\161013\\AL_43_D010_20161001");

            //DbfReader r = new DbfReader();
            //r.SetPath("D:\\00_Work\\96_SUPPORT\\Data\\161013\\AL_43_D010_20161001");
            //r.SetFile("a");
            //DataTable data = r.GetData();
            //DataTable new_data = data.Clone();
            //List<Polygon> p_p = new List<Polygon>();

            //int increase_index = 0;
            //DbWrite db = new DbWrite();
            //db.OpenDb();

            //foreach (DataRow dr in data.Rows)
            //{
            //    object[] item = dr.ItemArray;

            //    if (item[8] != DBNull.Value)
            //    {
            //        String s = (item[8] as String);

            //        int code = 0;
            //        if (int.TryParse(s, out code))
            //        {
            //            code = Convert.ToInt32(item[8]);
            //            code = code / 1000;

            //            if (code == 1 || code == 2 || code == 21)
            //            {
            //                db.WriteToDb(code, p[increase_index].center.lat, p[increase_index].center.lon);
            //                new_data.Rows.Add(new_data.NewRow().ItemArray = (object[])item.Clone());
            //                p_p.Add(p[increase_index]);
            //            }
            //        }

            //    }
            //    increase_index++;
            //}

            //db.CloseDb();

            //Console.WriteLine("{0}", new_data.Rows.Count);

            //ShapeWriter sw = new ShapeWriter();
            //sw.SetShapeData(p_p, 1);
            //sw.OpenFile(@"D:\temp\shapetest\test");
            //sw.MakeStart();
            //sw.CloseFile();
        }
コード例 #18
0
ファイル: Main.cs プロジェクト: noday-buttoday/NDMI-Analysis
        private List <String> GetPartialData(List <Point> point, DataTable build_data, ref Dictionary <String, DataTable> dbf_data, ref Dictionary <String, List <Point> > point_data)
        {
            /*
             * Dictionary<String, List<Point>> point_data = new Dictionary<string, List<Point>>();
             * Dictionary<String, DataTable> dbf_data = new Dictionary<string, DataTable>();
             */

            List <String> addr_name = new List <string>();

            int data_count    = 0;
            int record_number = build_data.Rows.Count;

            EventControl.Instance().SendEvent(new ProgressEventArgs(null, "PB_OPER", data_count, record_number));

            int index_count = 0;

            foreach (DataRow dr in build_data.Rows)
            {
                data_count++;
                if ((data_count % 100) == 0)
                {
                    EventControl.Instance().SendEvent(new ProgressEventArgs(null, "PB_OPER", data_count, record_number));
                }

                object[] item = dr.ItemArray;

                Encoding kr   = Encoding.GetEncoding("EUC-KR");
                Encoding utf  = Encoding.UTF8;
                byte[]   utfb = utf.GetBytes(item[4].ToString());
                byte[]   krb  = Encoding.Convert(utf, kr, utfb);
                string   msg  = kr.GetString(krb);

                if (item[4] != DBNull.Value)
                {
                    String   addr    = item[4].ToString();
                    String[] partial = addr.Split(' ');

                    String addr_partial = "";

                    foreach (String s in partial)
                    {
                        if ((s.EndsWith("시") || s.EndsWith("군")))
                        {
                            addr_partial += s;

                            bool same_flag = false;

                            foreach (String adr in addr_name)
                            {
                                if (adr == addr_partial)
                                {
                                    same_flag = true;
                                    break;
                                }
                            }

                            if (!same_flag)
                            {
                                addr_name.Add(addr_partial);
                            }

                            if (!point_data.ContainsKey(addr_partial))
                            {
                                point_data.Add(addr_partial, new List <Point>());
                                dbf_data.Add(addr_partial, build_data.Clone());
                            }

                            dbf_data[addr_partial].Rows.Add(dbf_data[addr_partial].NewRow().ItemArray = (object[])item.Clone());
                            point_data[addr_partial].Add(point[index_count]);
                        }
                        else
                        {
                            addr_partial += s + "_";
                        }
                    }
                }
                index_count++;
            }

            return(addr_name);
        }
コード例 #19
0
        public void SetData(DataTable data)
        {
            List <string> list = new List <string>();

            string createSql = "create table " + file_ + " (";

            foreach (DataColumn dc in data.Columns)
            {
                string fieldName = dc.ColumnName;
                string type      = dc.DataType.ToString();

                switch (type)
                {
                case "System.String":
                    type = "varchar(100)";
                    break;

                case "System.Boolean":
                    type = "varchar(10)";
                    break;

                case "System.Int32":
                    type = "int";
                    break;

                case "System.Double":
                    type = "Double";
                    break;

                case "System.DateTime":
                    type = "TimeStamp";
                    break;
                }
                createSql = createSql + "[" + fieldName + "]" + " " + type + ",";

                list.Add(fieldName);
            }

            string path = "Provider=Microsoft.ACE.OLEDB.12.0;" + path_ + "Extended Properties=dBASE IV;User ID=Admin;Password=;";

            createSql = createSql.Substring(0, createSql.Length - 1) + ")";
            OleDbConnection con = new OleDbConnection(path);
            OleDbCommand    cmd = new OleDbCommand();

            cmd.Connection = con;
            con.Open();
            cmd.CommandText = createSql;
            cmd.ExecuteNonQuery();

            int data_count    = 0;
            int record_number = data.Rows.Count;

            EventControl.Instance().SendEvent(new ProgressEventArgs(null, "PB_OPER", data_count, record_number));
            foreach (DataRow row in data.Rows)
            {
                string insertSql = "insert into " + file_ + " values(";

                for (int i = 0; i < list.Count; i++)
                {
                    insertSql = insertSql + "'" + ReplaceEscape(row[list[i].ToString()].ToString()) + "',";
                }

                insertSql       = insertSql.Substring(0, insertSql.Length - 1) + ")";
                cmd.CommandText = insertSql;
                cmd.ExecuteNonQuery();

                if (stop_flag == true)
                {
                    break;
                }

                if ((data_count % 100) == 0)
                {
                    EventControl.Instance().SendEvent(new ProgressEventArgs(null, "PB_OPER", data_count, record_number));
                }
                data_count++;
            }

            con.Close();
        }
コード例 #20
0
 public OutputFileControl()
 {
     EventControl.Instance().CheckEvent += new EventHandler(OutputLogicStartEvent);
 }
コード例 #21
0
 private void Window_Closing(object sender, System.ComponentModel.CancelEventArgs e)
 {
     EventControl.Instance().Stop();
 }
コード例 #22
0
ファイル: Main.cs プロジェクト: noday-buttoday/NDMI-Analysis
        private void Go()
        {
            ShapeReader sr = new ShapeReader();
            DbfReader   dr = new DbfReader();

            dr.SetPath(input_path_);

            for (int i = 0; i < shp_file_list_.Count; ++i)
            {
                EventControl.Instance().SendEvent(new ProgressLabelEventArgs(null, "LB_PROG", "Reading Shape\n" + file_list_[i] + ".shp"));

                /*
                 * List<Polygon> polygon_list = sr.ReadShapeFile(shp_file_list_[i], shx_file_list_[i]);
                 * List<Point> point_list = GetPoint(polygon_list);
                 */


                //List<Point> point_list = sr.ReadPointShapeFile(shp_file_list_[i], shx_file_list_[i]);

                List <Point> point_list = sr.ReadPointShapeFile(shp_file_list_[i], shx_file_list_[i]);
                //polygon_list.Clear();

                dr.SetFile(dbf_file_list_[i]);

                Dictionary <String, List <Point> > point_data = new Dictionary <string, List <Point> >();
                Dictionary <String, DataTable>     dbf_data   = new Dictionary <string, DataTable>();

                EventControl.Instance().SendEvent(new ProgressLabelEventArgs(null, "LB_PROG", "Read Dbf\n" + file_list_[i] + ".dbf"));
                DataTable     build_info = dr.GetData();
                List <String> addr       = GetPartialData(point_list, build_info, ref dbf_data, ref point_data);

                foreach (String file_name in addr)
                {
                    WriteDbf(dbf_data[file_name], file_name + ".dbf");
                    WriteShp(point_data[file_name], file_name);
                }

                //EventControl.Instance().SendEvent(new ProgressLabelEventArgs(null, "LB_PROG", "Read Dbf\n" + file_list_[i] + ".dbf"));
                //EventControl.Instance().SendEvent(new ProgressEventArgs(null, "PB_OPER", 0, 1));
                //DataTable build_info = dr.GetData();

                //DataTable extract_info = build_info.Clone();
                //List<Point> extract_point = new List<Point>();

                //ExtractInfo(ref extract_point, ref extract_info, point_list, build_info);
                //point_list.Clear();
                //build_info.Clear();

                //EventControl.Instance().SendEvent(new ProgressLabelEventArgs(null, "LB_PROG", "Write to DB"));

                //WriteDbf(extract_info, i);
                //WriteShp(extract_point, i);

                //WriteShp(point_list, i);

                //extract_info.Clear();
                //extract_point.Clear();

                EventControl.Instance().SendEvent(new ProgressLabelEventArgs(null, "LB_PROG", "Complete"));

                Finished(null, null);
            }
        }
コード例 #23
0
 public void AddEventListener()
 {
     name_ = base.Name;
     EventControl.Instance().CheckEvent += new EventHandler(EventProcessor);
 }
コード例 #24
0
 public void MakeEventProcessor()
 {
     EventControl.Instance().AddEvent(EventControl.EVENT_TYPE.TYPE_SNOW_GUI_UPDATE, new EventHandler(SnowGuiEventProcess));
     EventControl.Instance().AddEvent(EventControl.EVENT_TYPE.TYPE_DROUGHT_GUI_UPDATE, new EventHandler(DroughtGuiEventProcess));
     EventControl.Instance().AddEvent(EventControl.EVENT_TYPE.TYPE_MODULE_FINISH, new EventHandler(ModuleFinishEventProcess));
 }