예제 #1
0
        private void btn_send_Click(object sender, EventArgs e)
        {
            var aa = ConfigurationManager.AppSettings.Count;

            string[] getVal = new string[] { };
            foreach (var item in cblist.CheckedItems)
            {
                PokeGroupUIModel f = item as PokeGroupUIModel;
                getVal = ConfigurationManager.AppSettings[f.ConfigKey].Split(',');

                if (getVal.Count() > 0)
                {
                    f.IpAddress = getVal[0];
                    f.Port      = int.Parse(getVal[1]);
                }

                IPAddress  address      = IPAddress.Parse(f.IpAddress);
                IPEndPoint endpoint     = new IPEndPoint(address, f.Port);
                Socket     socketClient = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);
                socketClient.Connect(endpoint);
                int i = SocketClientConnector.SendFile(socketClient, f.ZipFile, 10000, 1);
                if (i == 0)
                {
                    MessageBox.Show(f.ZipFile + "文件发送成功");
                }
                else
                {
                    MessageBox.Show(f.ZipFile + "文件发送失败,i=" + i);
                }
            }
        }
예제 #2
0
 private void btnExp_Click(object sender, EventArgs e)
 {
     foreach (var item in cblist.CheckedItems)
     {
         PokeGroupUIModel model = item as PokeGroupUIModel;
         if (model.GroupKind == "1")
         {
             FetchProducePokeData(model);
         }
     }
     MessageBox.Show("导出成功!");
 }
예제 #3
0
        private void FetchUnPokeData(PokeGroupUIModel model, String seq)
        {
            List <T_UN_POKE> _unpokeList = UnPokeService.FetchUnPokeList(model.GroupNum);

            if (_unpokeList.Count == 0)
            {
                return;
            }
            StringBuilder info = new StringBuilder();

            foreach (var item in _unpokeList)
            {
                info.AppendFormat("{0},{1},{2},{3},{4},{5},{6},{7},{8},{9},{10},{11},{12},{13},{14},{15};\r\n", item.TASKNUM, "123456789123", "测试客户", "430189", "芙蓉王", item.POKENUM, "1", "1", "0201", "xianluyi", "2018-03-07", "2018-03-09", "01", "1", "", "");
            }
            ExpToZipFile(info.ToString(), model);
        }
예제 #4
0
        private void FetchProducePokeData(PokeGroupUIModel model)
        {
            List <OrderGroupDetail> _pokeList = ProducePokeService.FetchProducePokeList(decimal.Parse(model.GroupNum));

            if (_pokeList.Count == 0)
            {
                return;
            }
            StringBuilder info = new StringBuilder();

            foreach (var item in _pokeList)
            {
                //   info.AppendFormat("{0},{1},{2},{3},{4},{5};\n", item.TASKNUM, item.TASKQTY, item.GROUPNO, item.POKENUM, item.TROUGHNUM, item.BILLCODE);
            }
            ExpToZipFile(info.ToString(), model);
        }
예제 #5
0
        private void FetchProducePokeData(PokeGroupUIModel model, String seq)
        {
            List <OrderGroupDetail> _pokeList = ProducePokeService.FetchProducePokeList(decimal.Parse(model.GroupNum));

            if (_pokeList.Count == 0)
            {
                return;
            }
            StringBuilder info = new StringBuilder();

            // info = info + tasknum + taskseq + "," + tasknum + "," + cuscode + "," + cusname + "," + itemno + "," + itemname + "," + quantity + "," + synseq + "," + seq + "," + regioncode + "," + regioncode + "," + orderdate + "," + orderdate + "," + bianhao + ",1;\r\n";
            // int i = 0;
            foreach (var item in _pokeList)
            {
                // i++;
                info.AppendFormat("{0},{1},{2},{3},{4},{5},{6},{7},{8},{9},{10},{11},{12},{13},{14},{15};\r\n", item.TaskNum, item.TaskNum, item.CustomerCode, item.CustomerName, item.CigaretteCode, item.CigaretteName, item.PokeNum, seq, item.Seq, item.RegionCode, item.RegionName, item.OrderDate, DateTime.Now.ToShortTimeString(), "01", "1", "", "");
            }
            ExpToZipFile(info.ToString(), model);
        }
예제 #6
0
        private void ExpToZipFile(string info, PokeGroupUIModel model)
        {
            string filePath = Path.Combine(Application.StartupPath, "files");

            if (!Directory.Exists(filePath))
            {
                Directory.CreateDirectory(filePath);
            }

            DateTime     dt       = DateTime.Now;
            String       time     = string.Format("{0:yyyyMMddHHmmssfff}", dt);
            String       filename = "RetailerOrder" + time;
            StreamWriter sw       = new StreamWriter(filePath + "\\" + filename + ".Order", false, Encoding.UTF8);

            sw.WriteLine(info.Substring(0, info.Length - 1));
            sw.Close();//写入
            //ToZipFile.GetFileToZip(filePath + "\\" + filename + ".Order", filePath + "\\" + filename + ".zip", filename + ".Order");
            model.ZipFile = filePath + "\\" + filename + ".zip";
        }
예제 #7
0
 private void btnExp_Click(object sender, EventArgs e)
 {
     foreach (var item in cblist.CheckedItems)
     {
         PokeGroupUIModel model = item as PokeGroupUIModel;
         for (var i = 0; i < gvdata.RowCount; i++)
         {
             if (gvdata.Rows[i].Cells[0].Selected == true)
             {
                 String seq = gvdata.Rows[i].Cells[4].Value.ToString();
                 if (model.GroupKind == "1")
                 {
                     FetchProducePokeData(model, seq);
                 }
                 else
                 {
                     FetchUnPokeData(model, seq);
                 }
             }
         }
     }
 }
예제 #8
0
        private void btn_send_Click(object sender, EventArgs e)
        {
            string[] getVal = new string[] { };
            foreach (var item in cblist.CheckedItems)
            {
                PokeGroupUIModel f = item as PokeGroupUIModel;
                getVal = ConfigurationManager.AppSettings[f.ConfigKey].Split(';');

                if (getVal.Count() > 0)
                {
                    f.IpAddress = getVal[0];
                    f.Port      = int.Parse(getVal[1]);
                }
                if (f.ZipFile == null)
                {
                    continue;
                }
                IPAddress  address      = IPAddress.Parse(f.IpAddress);
                IPEndPoint endpoint     = new IPEndPoint(address, f.Port);
                Socket     socketClient = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);
                socketClient.Connect(endpoint);
                int i = SocketClientConnector.SendFile(socketClient, f.ZipFile, 102400, 1);

                if (i == 0)
                {
                    MessageBox.Show(f.ZipFile + "文件发送成功");
                    Byte[] bytes = new Byte[1024];
                    socketClient.Receive(bytes);
                    System.Text.UTF8Encoding.UTF8.GetString(bytes);
                    socketClient.Disconnect(false);
                    socketClient.Close();
                }
                else
                {
                    MessageBox.Show(f.ZipFile + "文件发送失败,i=" + i);
                }
            }
        }