{"id":2109,"date":"2017-12-08T22:52:09","date_gmt":"2017-12-08T13:52:09","guid":{"rendered":"http:\/\/okamurax.com\/?p=2109"},"modified":"2020-05-05T01:06:49","modified_gmt":"2020-05-04T16:06:49","slug":"c-%e6%ad%a3%e8%a6%8f%e8%a1%a8%e7%8f%be%e3%81%a7%e3%83%86%e3%82%ad%e3%82%b9%e3%83%88%e8%a7%a3%e6%9e%90","status":"publish","type":"post","link":"https:\/\/appbay.org\/?p=2109","title":{"rendered":"C# \u6b63\u898f\u8868\u73fe\u3067\u30c6\u30ad\u30b9\u30c8\u89e3\u6790"},"content":{"rendered":"<p>\u4ee5\u524d\u3082\u4f3c\u305f\u3088\u3046\u306a\u3082\u306e\u3092\u4f5c\u3063\u305f\u3002<\/p>\n<pre class=\"lang:c# decode:true \">using System;\r\nusing System.Collections.Generic;\r\nusing System.ComponentModel;\r\nusing System.Data;\r\nusing System.Drawing;\r\nusing System.Linq;\r\nusing System.Text;\r\nusing System.Threading.Tasks;\r\nusing System.Windows.Forms;\r\nusing System.IO;\r\nusing System.Text.RegularExpressions;\r\n\r\nnamespace JAN\u89e3\u6790\r\n{\r\n    public partial class Form1 : Form\r\n    {\r\n        public Form1()\r\n        {\r\n            InitializeComponent();\r\n        }\r\n\r\n        private void button1_Click(object sender, EventArgs e)\r\n        {\r\n            int i = 1;\r\n            string path = Application.StartupPath + @\"\\jan\";\r\n            StreamWriter sw = new StreamWriter(Application.StartupPath + @\"\\out.txt\", false, Encoding.GetEncoding(\"shift_jis\"));\r\n\r\n            foreach (string fileName in Directory.GetFiles(path))\r\n            {\r\n                this.Text = i.ToString();\r\n                using (StreamReader sr = new StreamReader(fileName, Encoding.GetEncoding(\"shift_jis\")))\r\n                {\r\n                    string line = \"\";\r\n                    string date = \"\";\r\n                    string staff_name = \"\";\r\n                    string point = \"\";\r\n                    string card_no = \"\";\r\n\r\n                    while (sr.Peek() &gt; -1)\r\n                    {\r\n                        line = sr.ReadLine();\r\n\r\n                        if (new Regex(\"--------------------------------\").IsMatch(line))\r\n                        {\r\n                            date = \"\";\r\n                            staff_name = \"\";\r\n                            point = \"\";\r\n                            card_no = \"\";\r\n                        }\r\n                        else if (new Regex(@\"^\\d{4}\u5e74\\d{2}\u6708\\d{2}\u65e5\").IsMatch(line))\r\n                        {\r\n                            Match m = new Regex(@\"^\\d{4}\u5e74\\d{2}\u6708\\d{2}\u65e5\").Match(line);\r\n                            date = m.Groups[0].Value;\r\n                        }\r\n                        else if (new Regex(@\"^No00[0-9]\\S*\").IsMatch(line))\r\n                        {\r\n                            Match m = new Regex(@\"^No00[0-9](\\S*)\").Match(line);\r\n                            staff_name = m.Groups[1].Value;\r\n                        }\r\n                        else if (new Regex(@\"^\\s\u8a02\u6b63\uff8e\uff9f\uff72\uff9d\uff84\\s*[0-9]*\u70b9\").IsMatch(line))\r\n                        {\r\n                            Match m = new Regex(@\"^\\s\u8a02\u6b63\uff8e\uff9f\uff72\uff9d\uff84\\s*([0-9]*\u70b9)\").Match(line);\r\n                            point = m.Groups[1].Value;\r\n                        }\r\n                        else if (new Regex(@\"^\uff76-\uff84\uff9eNO[0-9]*\").IsMatch(line))\r\n                        {\r\n                            Match m = new Regex(@\"^\uff76-\uff84\uff9eNO([0-9]*)\").Match(line);\r\n                            card_no = m.Groups[1].Value;\r\n                        }\r\n\r\n                        if (date != \"\" &amp;&amp; staff_name != \"\" &amp;&amp; point != \"\" &amp;&amp; card_no != \"\")\r\n                        {\r\n                            string matched = date + \",\" + staff_name + \",\" + card_no + \",\" + point + \"\\r\\n\";\r\n                            sw.Write(matched);\r\n\r\n                            date = \"\";\r\n                            staff_name = \"\";\r\n                            point = \"\";\r\n                            card_no = \"\";\r\n                        }\r\n                    }\r\n                }\r\n                i++;\r\n            }\r\n            sw.Close();\r\n            MessageBox.Show(\"\u5b8c\u4e86\");\r\n        }\r\n\r\n        private void button2_Click(object sender, EventArgs e)\r\n        {\r\n            int i = 1;\r\n            string path = Application.StartupPath + @\"\\jan\";\r\n            StreamWriter sw = new StreamWriter(Application.StartupPath + @\"\\out.txt\", false, Encoding.GetEncoding(\"shift_jis\"));\r\n\r\n            foreach (string fileName in Directory.GetFiles(path))\r\n            {\r\n                this.Text = i.ToString();\r\n                using (StreamReader sr = new StreamReader(fileName, Encoding.GetEncoding(\"shift_jis\")))\r\n                {\r\n                    string line = \"\";\r\n                    string date = \"\";\r\n                    string staff_name = \"\";\r\n                    string point = \"\";\r\n                    string card_no = \"\";\r\n\r\n                    while (sr.Peek() &gt; -1)\r\n                    {\r\n                        line = sr.ReadLine();\r\n\r\n                        if (new Regex(\"--------------------------------\").IsMatch(line))\r\n                        {\r\n                            date = \"\";\r\n                            staff_name = \"\";\r\n                            point = \"\";\r\n                            card_no = \"\";\r\n                        }\r\n                        else if (new Regex(@\"^\\d{4}\u5e74\\d{2}\u6708\\d{2}\u65e5\").IsMatch(line))\r\n                        {\r\n                            Match m = new Regex(@\"^\\d{4}\u5e74\\d{2}\u6708\\d{2}\u65e5\").Match(line);\r\n                            date = m.Groups[0].Value;\r\n                        }\r\n                        else if (new Regex(@\"^No00[0-9]\\S*\").IsMatch(line))\r\n                        {\r\n                            Match m = new Regex(@\"^No00[0-9](\\S*)\").Match(line);\r\n                            staff_name = m.Groups[1].Value;\r\n                        }\r\n                        else if (new Regex(@\"^\\s\u5272\u5f15\u5238\\s*[0-9]*\u70b9\").IsMatch(line))\r\n                        {\r\n                            Match m = new Regex(@\"^\\s\u5272\u5f15\u5238\\s*([0-9]*)\u70b9\").Match(line);\r\n                            point = m.Groups[1].Value;\r\n                        }\r\n                        else if (new Regex(@\"^\uff76-\uff84\uff9eNO[0-9]*\").IsMatch(line))\r\n                        {\r\n                            Match m = new Regex(@\"^\uff76-\uff84\uff9eNO([0-9]*)\").Match(line);\r\n                            card_no = m.Groups[1].Value;\r\n                        }\r\n\r\n                        if (date != \"\" &amp;&amp; staff_name != \"\" &amp;&amp; point != \"\" &amp;&amp; card_no != \"\")\r\n                        {\r\n                            string matched = date + \",\" + staff_name + \",\" + card_no + \",\" + point + \"\\r\\n\";\r\n                            sw.Write(matched);\r\n\r\n                            date = \"\";\r\n                            staff_name = \"\";\r\n                            point = \"\";\r\n                            card_no = \"\";\r\n                        }\r\n                    }\r\n                }\r\n                i++;\r\n            }\r\n            sw.Close();\r\n            MessageBox.Show(\"\u5b8c\u4e86\");\r\n        }\r\n\r\n        private void button3_Click(object sender, EventArgs e)\r\n        {\r\n            int i = 1;\r\n            string path = Application.StartupPath + @\"\\jan\";\r\n            StreamWriter sw = new StreamWriter(Application.StartupPath + @\"\\out.txt\", false, Encoding.GetEncoding(\"shift_jis\"));\r\n\r\n            foreach (string fileName in Directory.GetFiles(path))\r\n            {\r\n                this.Text = i.ToString();\r\n                using (StreamReader sr = new StreamReader(fileName, Encoding.GetEncoding(\"shift_jis\")))\r\n                {\r\n                    string line = \"\";\r\n                    string date = \"\";\r\n                    string staff_name = \"\";\r\n                    string amount = \"\";\r\n                    string card_no = \"\";\r\n\r\n                    while (sr.Peek() &gt; -1)\r\n                    {\r\n                        line = sr.ReadLine();\r\n\r\n                        if (new Regex(\"--------------------------------\").IsMatch(line))\r\n                        {\r\n                            date = \"\";\r\n                            staff_name = \"\";\r\n                            amount = \"\";\r\n                            card_no = \"\";\r\n                        }\r\n                        else if (new Regex(@\"^\\d{4}\u5e74\\d{2}\u6708\\d{2}\u65e5\").IsMatch(line))\r\n                        {\r\n                            Match m = new Regex(@\"^\\d{4}\u5e74\\d{2}\u6708\\d{2}\u65e5\").Match(line);\r\n                            date = m.Groups[0].Value;\r\n                        }\r\n                        else if (new Regex(@\"^No00[0-9]\\S*\").IsMatch(line))\r\n                        {\r\n                            Match m = new Regex(@\"^No00[0-9](\\S*)\").Match(line);\r\n                            staff_name = m.Groups[1].Value;\r\n                        }\r\n                        else if (new Regex(@\"^\u5408\u8a08\\s*\\\\[0-9,]*\").IsMatch(line))\r\n                        {\r\n                            Match m = new Regex(@\"^\u5408\u8a08\\s*(\\\\[0-9,]*)\").Match(line);\r\n                            amount = m.Groups[1].Value;\r\n                            amount = amount.Replace(\",\", \"\");\r\n                        }\r\n                        else if (new Regex(@\"^\uff76-\uff84\uff9eNO[0-9]*\").IsMatch(line))\r\n                        {\r\n                            Match m = new Regex(@\"^\uff76-\uff84\uff9eNO([0-9]*)\").Match(line);\r\n                            card_no = m.Groups[1].Value;\r\n                            if (card_no != textBox1.Text) card_no = \"\";\r\n                        }\r\n\r\n                        if (date != \"\" &amp;&amp; staff_name != \"\" &amp;&amp; amount != \"\" &amp;&amp; card_no != \"\")\r\n                        {\r\n                            string matched = date + \",\" + staff_name + \",\" + card_no + \",\" + amount + \"\\r\\n\";\r\n                            sw.Write(matched);\r\n\r\n                            date = \"\";\r\n                            staff_name = \"\";\r\n                            amount = \"\";\r\n                            card_no = \"\";\r\n                        }\r\n                    }\r\n                }\r\n                i++;\r\n            }\r\n            sw.Close();\r\n            MessageBox.Show(\"\u5b8c\u4e86\");\r\n        }\r\n    }\r\n}\r\n<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>\u4ee5\u524d\u3082\u4f3c\u305f\u3088\u3046\u306a\u3082\u306e\u3092\u4f5c\u3063\u305f\u3002 using System; using System.Collections.Generic; using System.ComponentModel; using System.Data &hellip; <\/p>\n<p class=\"link-more\"><a href=\"https:\/\/appbay.org\/?p=2109\" class=\"more-link\"><span class=\"screen-reader-text\">&#8220;C# \u6b63\u898f\u8868\u73fe\u3067\u30c6\u30ad\u30b9\u30c8\u89e3\u6790&#8221; \u306e<\/span>\u7d9a\u304d\u3092\u8aad\u3080<\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[9,39],"class_list":["post-2109","post","type-post","status-publish","format-standard","hentry","category-1","tag-c-net","tag-39"],"_links":{"self":[{"href":"https:\/\/appbay.org\/index.php?rest_route=\/wp\/v2\/posts\/2109","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/appbay.org\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/appbay.org\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/appbay.org\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/appbay.org\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=2109"}],"version-history":[{"count":1,"href":"https:\/\/appbay.org\/index.php?rest_route=\/wp\/v2\/posts\/2109\/revisions"}],"predecessor-version":[{"id":2110,"href":"https:\/\/appbay.org\/index.php?rest_route=\/wp\/v2\/posts\/2109\/revisions\/2110"}],"wp:attachment":[{"href":"https:\/\/appbay.org\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=2109"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/appbay.org\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=2109"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/appbay.org\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=2109"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}