Beispiel #1
0
        private void btnRepair_Click(object sender, EventArgs e)
        {
            int idx = int.Parse(tbNumber.Text.Trim());

            ServiceReference1.WebService1SoapClient service1 = new ServiceReference1.WebService1SoapClient();
            //ServiceReference2.WebService1SoapClient service1 = new ServiceReference2.WebService1SoapClient();
            try
            {
                string result = service1.RepairStatus(idx);
                lbResult.Text = result + DateTime.Now.ToString(" MM-dd HH:mm:ss");
            }
            catch (Exception ex)
            {
            }
        }
Beispiel #2
0
        private void button1_Click(object sender, EventArgs e)
        {
            //localhost.WebService1 client = new localhost.WebService1();
            ServiceReference1.WebService1SoapClient client = new ServiceReference1.WebService1SoapClient();
            //上传服务器后的文件名  一般不修改文件名称
            int    start      = textBox1.Text.LastIndexOf("\\");
            int    length     = textBox1.Text.Length;
            string serverfile = textBox1.Text.Substring(start + 1, length - textBox1.Text.LastIndexOf("."))
                                + DateTime.Now.ToString("-yyyy-mm-dd-hh-mm-ss")
                                + textBox1.Text.Substring(textBox1.Text.LastIndexOf("."), textBox1.Text.Length - textBox1.Text.LastIndexOf("."));

            client.CreateFile(serverfile);
            //要上传文件的路径
            string sourceFile = textBox1.Text;
            string md5        = GetMD5(sourceFile);

            FileStream fs         = new FileStream(sourceFile, FileMode.Open, FileAccess.Read, FileShare.ReadWrite);
            int        size       = (int)fs.Length;
            int        bufferSize = 1024 * 512;
            int        count      = (int)Math.Ceiling((double)size / (double)bufferSize);

            for (int i = 0; i < count; i++)
            {
                int readSize = bufferSize;
                if (i == count - 1)
                {
                    readSize = size - bufferSize * i;
                }
                byte[] buffer = new byte[readSize];
                fs.Read(buffer, 0, readSize);
                client.Append(serverfile, buffer);
            }

            bool isVerify = client.Verify(serverfile, md5);

            if (isVerify)
            {
                MessageBox.Show("上传成功");
            }
            else
            {
                MessageBox.Show("上传失败");
            }
        }