Esempio n. 1
0
        protected override void OnButtonAction(XRibbonButton xRibbonButton, RibbonEventArgs e)
        {
            // 缺省参数
            object unknown = Type.Missing;
            //doc.Close(ref saveChange, ref nullobj, ref nullobj);
            var    doc     = SceneContext.Instance.WordAppAdmin.ActiveDocument;
            string docName = "";

            if (doc != null)
            {
                docName = doc.FullName;
                SceneContext.Instance.SecretDataAdmin.Remove(doc);
                object saveChanges = false;
                doc.Close(ref saveChanges, ref unknown, ref unknown);
            }
            //删除此文件
            if (!string.IsNullOrEmpty(docName))
            {
                File.Delete(docName);
            }

            var panes      = SceneContext.Instance.CustomTaskPanesAdmin.CustomTaskPanes;
            int panesCount = panes.Count;

            if (panesCount > 0)
            {
                CustomTaskPane taskPane = panes[0];
                if (taskPane.Visible)
                {
                    taskPane.Visible = false;
                }
            }
        }
Esempio n. 2
0
 protected override void OnButtonAction(XRibbonButton xRibbonButton, RibbonEventArgs e)
 {
     //Commands.DocumentAdmin.Execute(SceneContext.Instance);
     OfficeWord.Application app = SceneContext.Instance.WordAppAdmin.Application;
     OfficeWord.Document    doc = app.ActiveDocument;
     if (doc != null)
     {
         doc.Save();
         var entry = new SecretEntry()
         {
             LoginEntity = null,
             BizFileName = doc.FullName,
             BizFileId   = "",
         };
         SceneContext.Instance.SecretDataAdmin.Set(doc, entry);
         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("文件新增成功!");
         }
         File.Delete(tempFileName);
     }
 }
Esempio n. 3
0
 protected override void OnButtonAction(XRibbonButton xRibbonButton, RibbonEventArgs e)
 {
     //Commands.DocumentAdmin.Execute(SceneContext.Instance);
     OfficeWord.Application app = SceneContext.Instance.WordAppAdmin.Application;
     OfficeWord.Document    doc = app.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. 4
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);
            }
        }
Esempio n. 5
0
        protected override void OnButtonAction(XRibbonButton xRibbonButton, RibbonEventArgs e)
        {
            Log.Debug("---VersionCommand--Begin:" + DateTime.Now.ToLongTimeString());
            CustomTaskPaneCollection panes = SceneContext.Instance.CustomTaskPanesAdmin.CustomTaskPanes;
            int panesCount = panes.Count;

            Log.Debug("---VersionCommand--01:" + DateTime.Now.ToLongTimeString());
            if (panesCount == 0)
            {
                var pane = new CustomPane();
                Log.Debug("---VersionCommand--02:" + DateTime.Now.ToLongTimeString());
                var host = new PaneDecorator(pane);
                Log.Debug("---VersionCommand--03:" + DateTime.Now.ToLongTimeString());
                panes.Add(host, "版本信息");
                Log.Debug("---VersionCommand--04:" + DateTime.Now.ToLongTimeString());
            }
            CustomTaskPane taskPane = panes[0];

            taskPane.VisibleChanged += new EventHandler(taskPane_VisibleChanged);
            taskPane.Width           = 430;
            taskPane.Visible         = true;
        }
Esempio n. 6
0
 protected override void OnButtonAction(XRibbonButton xRibbonButton, RibbonEventArgs e)
 {
     //Commands.DocumentAdmin.Execute(SceneContext.Instance);
     throw new NotImplementedException("功能暂时未实现!");
 }
Esempio n. 7
0
        protected override void OnButtonAction(XRibbonButton xRibbonButton, RibbonEventArgs e)
        {
            OfficeWord.Application app = SceneContext.Instance.WordAppAdmin.Application;

            var file = new FilesForm(context, app);

            if (file.ShowDialog() == DialogResult.OK)
            {
                if (string.IsNullOrEmpty(file.LocalFileName))
                {
                    return;
                }
                // 关闭当前的文档
                object missing = System.Reflection.Missing.Value;

                var newFile = new FileInfo(file.LocalFileName);
                if (newFile.Exists)
                {
                    // 注入用户数据
                    //CreateCustomXml(openFileName, loginObj);

                    // 打开该文件
                    object fileNameObj = file.LocalFileName;
                    object visible     = true;
                    app.ScreenUpdating = false;
                    OfficeWord.Document wDoc = app.Documents.Open(ref fileNameObj, ref missing, ref missing
                                                                  , ref missing, ref missing, ref missing
                                                                  , ref missing, ref missing, ref missing
                                                                  , ref missing, ref missing, ref visible
                                                                  , ref missing, ref missing, ref missing
                                                                  , ref missing);
                    app.ScreenUpdating = true;
                    // 记录当前文档数据
                    var entry = new SecretEntry()
                    {
                        LoginEntity = null,
                        BizFileName = file.LocalFileName,
                        BizFileId   = "",
                    };
                    SceneContext.Instance.SecretDataAdmin.Set(wDoc, entry);

                    //wDoc.ActiveWindow.View.Type = Microsoft.Office.Interop.Word.WdViewType.wdPrintView;
                    // 记录当前文档数据
                    //SecretEntry entry = new SecretEntry()
                    //{
                    //    LoginEntity = loginEntity,
                    //    BizFileName = fileInfo.FullName,
                    //    BizFileId = fileInfo.FileId,
                    //    AuthAdmin = secretEntry.AuthAdmin,
                    //};
                    //context.SecretDataAdmin.Set(wDoc, entry);

                    // 获取数据
                    //string xml = wDoc.SelectPartXmlByNamespace("---namespace----");

                    //object saveChange = false;
                    //doc.Close(ref saveChange, ref nullobj, ref nullobj);
                }
            }



            //var dialog = new F.OpenFileDialog();
            //dialog.InitialDirectory = @"C:\";
            //dialog.Filter = "所有Word文档|*.docx;*.docm;*.dotx;*.doc;*.dot;*.htm;*.html|Word文档|*.docx|启用宏的Word文档|*.docm|Xml文件|*.xml|Word97-2003文档|*.doc";
            //dialog.FilterIndex = 1;
            //if (dialog.ShowDialog() == F.DialogResult.OK)
            //{
            //    string fileName = dialog.FileName;
            //    //// 检查文件是否已打开
            //    //string fileName = context.WordAppAdmin.Application.ActiveDocument.Name;
            //    //if (fileName.Equals(dialog.FileName))
            //    //{
            //    //    MessageBox.Show(string.Format("文件 {0}已打开.",fileName));
            //    //    return false;
            //    //}
        }
Esempio n. 8
0
 protected override void OnButtonAction(XRibbonButton xRibbonButton, RibbonEventArgs e)
 {
     //SceneContext.Instance.Logout();
 }
Esempio n. 9
0
 protected abstract void OnButtonAction(XRibbonButton xRibbonButton, RibbonEventArgs e);