private void MyButton_Click(CommandBarButton cmdBarbutton, ref bool cancel) { //SendToWebSevice send = new SendToWebSevice(); SendVdxFile = new System.ComponentModel.BackgroundWorker(); SendVdxFile.DoWork += new System.ComponentModel.DoWorkEventHandler(SendVdxFile_DoWork); SendVdxFile.RunWorkerCompleted += new System.ComponentModel.RunWorkerCompletedEventHandler(SendVdxFile_RunWorkerCompleted); //try { foreach (Microsoft.Office.Interop.Visio.Document doc in (applicationObject as Microsoft.Office.Interop.Visio.Application).Documents) { //doc.close(); frmSendWait sendWait = new frmSendWait(); sendWait.Show(); sendWait.Focus(); string filename = doc.Name.Replace("vsd", "vdx"); //doc.Name.Split(new char[] { '.' })[doc.Name.Split(new char[] { '.' }).Length - 1].Replace("vsd", "vdx"); doc.SaveAs(filename); SendToWebSevice send = new SendToWebSevice(); send.SendFile(doc.Path + filename, filename, sendWait); //SendVdxFile.RunWorkerAsync(SendWait); break; } } //catch (Exception ex) { //MessageBox.Show(ex.ToString()); } }
public void SendFile(string FilePath,string FileName,frmSendWait sendWait) { this.sendWait = sendWait; string[] file = new string[2]{FilePath,FileName}; SendVdxFile.RunWorkerAsync(file); //SiteView.Ecc.Core.UserPermissionContext.Instance.Url = "http://218.249.196.87:18080/webservice/InterfaceEccService"; //Helper.NeedDecoding = true; //UserPermissionContext.Instance.CurrentUser = new SiteView.Ecc.Core.Models.User(); //UserPermissionContext.Instance.CurrentUser.UserName = "******"; //UserPermissionContext.Instance.CurrentUser.LoginName = "admin"; //SiteView.Ecc.WSClient.TuopuDaoImpl TuopuDao = new SiteView.Ecc.WSClient.TuopuDaoImpl(); ////TuopuDao.UploadTuopuFile(); //try //{ //// //if (!File.Exists("c:\\temp.vdx")) //// //{ //// // File.Create("c:\\temp.vdx"); //// //} // File.Copy(FilePath, "c:\\"+FileName, true); //// FileStream fs = File.Open("c:\\temp.vdx", FileMode.Open, FileAccess.Read); //// byte[] file = new byte[fs.Length]; //// fs.Read(file, 0, file.Length); //// TuopuDao.UploadTuopuFile(file, "\\..\\TuopuList\\gongtao.zip", true); //// fs.Dispose(); // string tmpName = FileName.Split(new char[] { '.' })[0]; // //TuopuDao.UploadTuopuFile("c:\\"+FileName, "\\..\\TuopuList\\"+tmpName+".zip", true); // TuopuDao.UploadTuopuFile("c:\\" + FileName, "\\..\\TuopuList\\" + FileName + ".zip", true); // MessageBox.Show("上传成功"); //} //catch (Exception ex) //{ // MessageBox.Show(ex.ToString()); //} ////string context = ""; ////try ////{ //// FileStream fi = new FileStream(FilePath, FileMode.Open); //// StreamReader sr = new StreamReader(fi, Encoding.UTF8); //// byte[] contextByte = new byte[fi.Length]; //// fi.Read(contextByte, 0, (int)fi.Length); //// //context = sr.ReadToEnd(); //// fi.Read(contextByte, 0, (int)fi.Length); //// TuopuDao.UploadTuopuFile(contextByte, "\\..\\TuopuList\\gongtao.zip", true); //// //while (!sr.EndOfStream) //// //{ //// // string RecordLine = sr.ReadLine(); //// // sendMailAddressTmp.Add(RecordLine); //// //} //// sr.Close(); //// fi.Close(); //// MessageBox.Show("s"); ////} ////catch (Exception ex) ////{ //// MessageBox.Show(ex.ToString()); ////} }