Esempio n. 1
0
 protected override void OnButtonAction(XRibbonButton xRibbonButton, RibbonEventArgs e)
 {
     SceneContext.Instance.Logout();
     xRibbonButton.Invalidate(); //刷新
     //Commands.DocumentAdmin.Execute(SceneContext.Instance);
     OfficeWord.Document doc = SceneContext.Instance.WordAppAdmin.ActiveDocument;
     if (doc != null)
     {
         if (SceneContext.Instance.SecretDataAdmin.Get(doc) == null)
         {
             //MessageBox.Show("该文档不是通过文档工具打开的文档,无法使用此功能!");
         }
         else
         {
             SceneContext.Instance.SecretDataAdmin.Remove(doc);
             doc.Save();
             string filename     = doc.FullName;
             string tempFileName = Path.Combine(Logger.TemporaryDirectory, doc.Name);
             File.Copy(filename, tempFileName);
             if (SceneContext.Instance.FileServer.Upload(tempFileName, doc.Name))
             {
                 MessageBox.Show("文件保存成功!");
             }
             // 缺省参数
             object unknown = Type.Missing;
             doc.Close(ref unknown, ref unknown, ref unknown);
             File.Delete(tempFileName);
             File.Delete(filename);
         }
     }
 }
Esempio n. 2
0
        protected override void OnButtonAction(XRibbonButton xRibbonButton, RibbonEventArgs e)
        {
            if (SceneContext.Instance.Login())
            {
                xRibbonButton.Invalidate();
            }
            string path = Path.Combine(SceneContext.Instance.BundleContext.Bundle.Location, "Documents");

            if (!Directory.Exists(path))
            {
                //DirectorySecurity security=new DirectorySecurity();
                //security.AddAccessRule(new FileSystemAccessRule("Everyone", FileSystemRights.FullControl, InheritanceFlags.ContainerInherit, PropagationFlags.InheritOnly, AccessControlType.Allow));
                Directory.CreateDirectory(path);
            }
        }