public WordActiveDocument(IOfficeApplication application, MsWord._Document document) : base(application, document.FullName) { _document = document; InitializeWsDocument(FullPath); }
private void SelectWebPageID_ValidateStep(object sender, CancelEventArgs e) { if (String.IsNullOrEmpty(textBoxID.Text)) { textBoxID.Focus(); MessageBox.Show(this, "¡Debe indicar un identificador!", this.Wizard.Text, MessageBoxButtons.OK, MessageBoxIcon.Error); e.Cancel = true; return; } IOfficeApplication openOfficeApplication = OfficeApplication.OfficeApplicationProxy; String title = this.Wizard.Data[TitleAndDescription.TITLE].ToString(); String description = this.Wizard.Data[TitleAndDescription.DESCRIPTION].ToString(); WebPageInfo parent = (WebPageInfo)this.Wizard.Data[SelectSiteCreatePage.WEB_PAGE]; try { this.Cursor = Cursors.WaitCursor; openOfficeApplication.createPage(parent, this.textBoxID.Text, title, description); MessageBox.Show(this, "¡Se ha creado la página web correctamente!", this.Wizard.Text, MessageBoxButtons.OK, MessageBoxIcon.Information); } catch (Exception ue) { MessageBox.Show(this, "¡Existe un error al crear la página web!\r\nDetalle: " + ue.Message, this.Wizard.Text, MessageBoxButtons.OK, MessageBoxIcon.Error); } finally { this.Cursor = Cursors.Default; } }
internal static void LogOff() { officeApplication = null; officedocument = null; userInfo = null; webAddress = null; }
public static void ShowPdfPublishForm(IOfficeApplication application, bool emailPdf) { _createPdf = new PublishPdfForm(application, emailPdf); _createPdf.PublishCompleted += OnPublishCompleted; _createPdf.ShowDialog(new WindowWrapper(Process.GetCurrentProcess().MainWindowHandle)); }
public PdfCreatorApplicationContext(string filename, bool email) { var fullName = GetFullNameFromDms(filename); _application = ApplicationFactory.Create(fullName); _view = new PublishPdfForm(_application, email); _view.PublishCompleted += OnPublishCompleted; _view.PublishCancelled += OnShutdownApplication; _view.ShowDialog(); }
protected override void OnClicked(IOfficeApplication application) { var applicationState = application.ApplicationReadyState(); if (applicationState == OfficeApplicationReadyState.Success) { PdfUiHelper.ShowPdfPublishForm(application, false); } else Utils.ShowErrorMessage(applicationState); }
public PublishPdfForm(IOfficeApplication application, bool emailPdf) : base(WorkshareFormUtility.DialogLevel.Primary, WorkshareFormUtility.BrandType.Protect, "Convert to PDF") { InitializeComponent(); this.VisibleChanged += OnVisibleChanged; _presenter = new PublishPdfPresenter(this, new PublishPdfModel(application, Handle)); InitializeUserInterface(emailPdf); BindCreationFlags(); Shown += Form1_Shown; }
protected override void OnClicked(IOfficeApplication application) { try { Common.Help.HelpProvider.Instance.ShowHelp(Common.Help.HelpId.None); } catch (Exception e) { Logger.LogError(e); } }
protected override void OnClicked(IOfficeApplication application) { try { Items.First().Action(application); } catch (Exception e) { Logger.LogError(e); } }
protected ActiveDocument(IOfficeApplication application, string fullName) { _tempFileController = new TempFileController(); _application = application; _fullPath = fullName; if (!File.Exists(fullName)) { _isDocumentSaved = false; _fullPath = GetTemporaryFileName(); } }
protected override void OnClicked(IOfficeApplication application) { var applicationState = application.ApplicationReadyState(); if (applicationState == OfficeApplicationReadyState.Success) { var helper = new PlatformHelper(); helper.SaveOnline(application); } else Utils.ShowErrorMessage(applicationState); }
protected override void OnClicked(IOfficeApplication application) { var assembly = Assembly.Load("Workshare.Common.WPF"); if (assembly != null) { var aboutdlg = assembly.GetType("Workshare.Common.WPF.AboutDialog"); if (aboutdlg != null) { object aboutdlgInst = Activator.CreateInstance(aboutdlg, new object[] { "", "" }); aboutdlg.InvokeMember("ShowDialog", BindingFlags.InvokeMethod | BindingFlags.Instance | BindingFlags.Public, null, aboutdlgInst, null); } } }
protected override void OnClicked(IOfficeApplication application) { try { var assemblyLocation = Path.GetDirectoryName(new Uri(Assembly.GetExecutingAssembly().CodeBase).LocalPath); if (string.IsNullOrEmpty(assemblyLocation)) throw new ArgumentNullException("Unable to get assembly location"); var path = new Uri(assemblyLocation).LocalPath; path = Path.Combine(path, "Workshare.Configuration.User.Console.exe"); Process.Start(path); } catch (Exception e) { Logger.LogError(e); } }
protected override void OnClicked(IOfficeApplication application) { try { var applicationState = application.ApplicationReadyState(); if (applicationState == OfficeApplicationReadyState.Success) { Utils.LaunchPdfCombine(application); } else Utils.ShowErrorMessage(applicationState); } catch (Exception e) { Logger.LogError(e); } }
protected override void OnClicked(IOfficeApplication application) { try { var applicationState = application.ApplicationCompareState(); if (applicationState == OfficeApplicationReadyState.Success) { Utils.LaunchDeckCompare(application.ActiveDocument.FullPath); } else Utils.ShowErrorMessage(applicationState); } catch (Exception e) { Logger.LogError(e); } }
protected override void OnClicked(IOfficeApplication application) { try { var applicationState = application.ApplicationReadyState(); if (applicationState == OfficeApplicationReadyState.Success) { NativeMethods.ShowDiscoveryDialogEx(application.ActiveDocument.Instance, Process.GetCurrentProcess().MainWindowHandle); } else Utils.ShowErrorMessage(applicationState); } catch (Exception e) { Logger.LogError(e); } }
protected override void OnClicked(IOfficeApplication application) { try { var window = new ShareWindow(); window.ShowDialog(); //if (application.CanAccessWorkshareFunctionality) //{ // PdfUiHelper.ShowPdfPublishForm(application, false); //} //else //{ // Utils.ShowShouldSaveMessage(); //} } catch (Exception e) { Logger.LogError(e); } }
protected override void OnClicked(IOfficeApplication application) { try { var applicationState = application.ApplicationCompareState(); if (applicationState == OfficeApplicationReadyState.Success) { using (var activeDocument = application.ActiveDocument) { var d = new SelectDocumentsWindow(activeDocument); new System.Windows.Interop.WindowInteropHelper(d).Owner = Process.GetCurrentProcess().MainWindowHandle; d.ShowDialog(); } } else Utils.ShowErrorMessage(applicationState); } catch (Exception e) { Logger.LogError(e); } }
protected override void OnClicked(IOfficeApplication application) { var ph = new PlatformHelper(); ph.ShareOnline(application); }
private void OnAction(IOfficeApplication application, IRibbonControl control) { try { var helper = new PlatformHelper(); switch (control.Id) { case "SaveToWorkshareButton": { helper.SaveOnline(application); break; } case "ShareToWorkshareButton": { helper.ShareOnline(application); break; } } } catch (Exception e) { Logger.LogError(e); } }
public static void LaunchPdfCombine(IOfficeApplication application) { string documentPath = application.ActiveDocument.SaveSnapShot(); var startInfo = new ProcessStartInfo("Workshare.PDF.Combine.exe", "\"" + documentPath + "\""); Process.Start(startInfo); }
public async void SaveOnline(IOfficeApplication application) { if (!CanExcecuteEvent.WaitOne(TimeSpan.FromSeconds(1))) { Workshare.Interop.Messaging.WsMessage.ShowMessage(IntPtr.Zero, "Other operation still in progress", Workshare.Interop.Messaging.MessageButtons.WsOK, Workshare.Interop.Messaging.MessageBranding.WsDefault, Workshare.Interop.Messaging.MessageType.WsInfoIcon, "", 0); return; } try { if (SynchronizationContext.Current == null) { SynchronizationContext.SetSynchronizationContext(new WindowsFormsSynchronizationContext()); } var context = SynchronizationContext.Current; WorkshareOnline.Instance.Security.Authenticate(context); var activeDocument = application.ActiveDocument; try { var path = activeDocument.SaveSnapShot(); var versionId = IsFileAlreadySaved(activeDocument.Instance); if (versionId <= 0) { var window = new FileSaveWindow(path, GetSupportedFileFormats()); new System.Windows.Interop.WindowInteropHelper(window).Owner = Process.GetCurrentProcess().MainWindowHandle; Debug.Assert(File.Exists(path), "file was not created"); if (!File.Exists(path)) throw new Exception("Cannot save snapshot of file"); if (window.ShowDialog() == true) { path = ConvertToFileFormat(application, activeDocument.DefaultExtension, path, window.FileName, window.SelectedFileFormatIndex); var platformFolder = window.SelectedEntity as IPlatformFolder; if (platformFolder != null) { Events.Events.Stream.GetEvent<DocumentSavingOnlineEvent>() .Publish(new SaveDocumentEventArgs() { Document = activeDocument.Instance }); try { var file = await Task.Factory.StartNew(() => { var breadCrumb = PlatformUtils.GetBreadCrumb(platformFolder); MostRecentlyUsedFolders.Add(platformFolder.Url, breadCrumb); IPlatformFileTransfer fileTransfer = WorkshareOnline.Instance.FileTransfer; Debug.Assert(File.Exists(path), "file was not existes before upload"); return fileTransfer.Upload(path, Path.GetFileNameWithoutExtension(path), platformFolder); }); Events.Events.Stream.GetEvent<DocumentSavedOnlineEvent>() .Publish(new SaveDocumentEventArgs() { Document = activeDocument.Instance, VersionId = file.VersionId, File = file }); } catch (Exception ex) { Logger.LogError(ex); Events.Events.Stream.GetEvent<DocumentSavedOnlineEvent>() .Publish(new SaveDocumentEventArgs() { Document = activeDocument.Instance, Exception = ex }); } } } } else { try { Events.Events.Stream.GetEvent<DocumentNewVersionSavingOnlineEvent>() .Publish(new SaveDocumentEventArgs() { Document = activeDocument.Instance }); var uploadRes = await Task.Factory.StartNew(() => { IPlatformVersion versionInfo = WorkshareOnline.Instance.Files.GetVersion(versionId); var res = WorkshareOnline.Instance.FileTransfer.UploadNewVersion2(path, versionInfo.FileId); return res; }); Events.Events.Stream.GetEvent<DocumentNewVersionSavedOnlineEvent>() .Publish(new SaveDocumentEventArgs() { Document = activeDocument.Instance, VersionId = (int) uploadRes.Item1.Id, File = uploadRes.Item2, Version = uploadRes.Item1 }); } catch (Exception ex) { Logger.LogError(ex); Events.Events.Stream.GetEvent<DocumentNewVersionSavedOnlineEvent>() .Publish(new SaveDocumentEventArgs() { Document = activeDocument.Instance, Exception = ex, }); } } } finally { activeDocument.Dispose(); _lcfm.Dispose(); } } catch (OperationCanceledException) { // ignore the user has cancelled } catch (UnauthorizedAccessException e) { Workshare.Interop.Messaging.WsMessage.ShowMessage(IntPtr.Zero, e.Message, Workshare.Interop.Messaging.MessageButtons.WsOK, Workshare.Interop.Messaging.MessageBranding.WsDefault, Workshare.Interop.Messaging.MessageType.WsErrorIcon, "", 0); Logger.LogError(e); } catch (Exception e) { var message = e.InnerException == null ? e.Message : e.InnerException.Message; Workshare.Interop.Messaging.WsMessage.ShowMessage(IntPtr.Zero, "Error saving to Workshare: \n\n" + message, Workshare.Interop.Messaging.MessageButtons.WsOK, Workshare.Interop.Messaging.MessageBranding.WsDefault, Workshare.Interop.Messaging.MessageType.WsErrorIcon, "", 0); Logger.LogError(e); } finally { CanExcecuteEvent.Set(); } }
private string ConvertToFileFormat(IOfficeApplication application, string defaultExtension, string source, string fileName, int format) { switch (format) { case 0: // Native format { var extension = Path.GetExtension(source); if (String.Compare(extension, ".pdf", StringComparison.OrdinalIgnoreCase) == 0) { extension = defaultExtension; } var tempfile = _lcfm.GetLocalCopyOfFileTarget(fileName + extension); File.Copy(source, tempfile, true); return tempfile; } case 1: // PDF format { var pdfOptions = new PublishPdfOptions(IntPtr.Zero); pdfOptions.Destination = _lcfm.GetLocalCopyOfFileTarget(fileName + ".pdf"); TaskPdf.Execute(application.ActiveDocument, pdfOptions); return pdfOptions.Destination; } case 2: // PDF / A { var pdfOptions = new PublishPdfOptions(IntPtr.Zero); pdfOptions.PdfFormat = false; pdfOptions.Destination = _lcfm.GetLocalCopyOfFileTarget(fileName + ".pdf"); TaskPdf.Execute(application.ActiveDocument, pdfOptions); return pdfOptions.Destination; } } return string.Empty; }
protected abstract void OnClicked(IOfficeApplication application);
public void ShareOnline(IOfficeApplication application) { try { var applicationState = application.ApplicationReadyState(); if (applicationState == OfficeApplicationReadyState.Success) { var context = SynchronizationContext.Current ?? new WindowsFormsSynchronizationContext(); var user = WorkshareOnline.Instance.Security.Authenticate(context); using (var activeDocument = application.ActiveDocument) { using (GroupsServiceLocator.Instance) { GroupsServiceLocator.Instance.Initialize(activeDocument.SaveSnapShot(), user); var window = new ShareWindow(); new System.Windows.Interop.WindowInteropHelper(window).Owner = Process.GetCurrentProcess().MainWindowHandle; window.Error += OnShareError; window.Error += new System.EventHandler<ExceptionEventArgs>((object sender, ExceptionEventArgs e) => { Events.Events.Stream.GetEvent<DocumentSavedOnlineEvent>() .Publish(new SaveDocumentEventArgs() { Document = activeDocument.Instance, Exception = e.Exception.Flatten().InnerException }); }); window.StartSharing += new System.EventHandler((object sender, EventArgs e) => { Events.Events.Stream.GetEvent<DocumentSharingOnlineEvent>() .Publish(new SaveDocumentEventArgs() { Document = activeDocument.Instance }); }); window.EndSharing += new System.EventHandler((object sender, EventArgs e) => { Events.Events.Stream.GetEvent<DocumentSharedOnlineEvent>() .Publish(new SaveDocumentEventArgs() { Document = activeDocument.Instance, VersionId = ((FileInfoArgs)e).File.VersionId }); }); if (window.ShowDialog().GetValueOrDefault(false)) { if (!string.IsNullOrEmpty(window.GroupUuid)) { activeDocument.SetCustomProperty("WorkshareGroupUuid", window.GroupUuid); activeDocument.SetCustomProperty("WorkshareFileId", window.FileId); activeDocument.Instance.Save(); } } } } } else Utils.ShowErrorMessage(applicationState); } catch (Exception e) { Logger.LogError(e); Workshare.Interop.Messaging.WsMessage.ShowMessage(IntPtr.Zero, e.Message, Workshare.Interop.Messaging.MessageButtons.WsOK, Workshare.Interop.Messaging.MessageBranding.WsDefault, Workshare.Interop.Messaging.MessageType.WsErrorIcon, "", 0); Events.Events.Stream.GetEvent<DocumentSavedOnlineEvent>() .Publish(new SaveDocumentEventArgs() { Exception = e }); } }
public ExcelActiveDocument(IOfficeApplication application, MsExcel._Workbook workbook) : base(application, workbook.FullName) { _workbook = workbook; InitializeWsDocument(FullPath); }
private void SelectDirectory_ValidateStep(object sender, CancelEventArgs e) { //System.Threading.Thread t=null; if (this.treedir.SelectedNode != null && this.treedir.SelectedNode.Tag is DirectoryInfo) { DirectoryInfo dir = (DirectoryInfo)this.treedir.SelectedNode.Tag; lastpath = dir.FullName; this.Wizard.Data[DIRECTORY_PATH] = lastpath; rep = this.Wizard.Data[Search.REPOSITORY_ID].ToString(); version = (VersionInfo)this.Wizard.Data[SelectVersionToOpen.VERSION]; IOfficeApplication app = OfficeApplication.OfficeApplicationProxy; this.Wizard.SetProgressBarInit(5, 1, "Descargando contenido..."); fileName = app.openContent(rep, version); this.Wizard.SetProgressBarInit(5, 2, "Validando contenido..."); String pathFile = dir.FullName + "/" + fileName; pathFile = pathFile.Replace('/', '\\'); contentfile = new FileInfo(pathFile); if (contentfile.Exists) { DialogResult res = MessageBox.Show(this, "Existe un archivo con el nombre " + fileName + "\r\n¿Desea sobre escribir el archivo?", this.Wizard.Text, MessageBoxButtons.YesNo, MessageBoxIcon.Question); if (res == DialogResult.Yes) { try { contentfile.Delete(); } catch (Exception ue) { MessageBox.Show(ue.Message, this.Wizard.Text, MessageBoxButtons.OK, MessageBoxIcon.Error); return; } } else { return; } } String guid = Guid.NewGuid().ToString().Replace('-', '_'); FileInfo zipFile = new FileInfo(dir.FullName + "/" + guid + ".zip"); try { foreach (Part part in OfficeApplication.OfficeApplicationProxy.ResponseParts) { FileStream fout = zipFile.Open(FileMode.Create, FileAccess.ReadWrite, FileShare.ReadWrite); fout.Write(part.getContent(), 0, part.getContent().Length); fout.Close(); } using (ZipInputStream s = new ZipInputStream(zipFile.OpenRead())) { ZipEntry entry; // extract the file or directory entry while ((entry = s.GetNextEntry()) != null) { if (entry.IsDirectory) { ExtractDirectory(s, entry.Name, entry.DateTime, zipFile.Directory); } else { ExtractFile(s, entry.Name, entry.DateTime, entry.Size, zipFile.Directory); } s.CloseEntry(); } s.Close(); } this.Wizard.SetProgressBarInit(5, 3, "Abriendo contenido..."); //t = new System.Threading.Thread(new System.Threading.ThreadStart(open)); this.Wizard.Visible = false; this.Wizard.Close(); } catch (Exception ue) { MessageBox.Show(this, "El contenido tiene una falla\r\nDetalle: " + ue.Message, this.Wizard.Text, MessageBoxButtons.OK, MessageBoxIcon.Error); } finally { zipFile.Delete(); } } else { MessageBox.Show(this, "¡Debe indicar un directorio!", this.Wizard.Text, MessageBoxButtons.OK, MessageBoxIcon.Error); } }
public PowerPointActivePresentation(IOfficeApplication application, MsPowerPoint._Presentation presentation) : base(application, presentation.FullName) { _presentation = presentation; InitializeWsDocument(FullPath); }
protected override void OnClicked(IOfficeApplication application) { string progfilesLocation = OptionApi.GetString("ProgramLocation"); string wcmLocation = Path.Combine(progfilesLocation, "Workshare.Configuration.User.Console.exe"); Process.Start(wcmLocation, "/Licensing"); }