internal protected static string SetupDocument(String repositoryName, String contentId) { if (!String.IsNullOrEmpty(contentId) && OfficeApplication.TryLogOn()) { IOfficeDocument document = OfficeApplication.OfficeDocumentProxy; try { if (document.exists(repositoryName, contentId)) { return(contentId); } else { RtlAwareMessageBox.Show("El contenido parace haberse publicado en un sitio web.\r\nAl sitio donde se está intentando conectar, indica que este contenido no existe.\r\nSi desea continuar se perderá esta información, de lo contrario, cierre este documento.", "Verificación de contenido en sitio web", MessageBoxButtons.OK, MessageBoxIcon.Warning); } } catch (FormatException fe) { OfficeApplication.WriteError(fe); } catch (ApplicationException ap) { OfficeApplication.WriteError(ap); } } return(null); }
internal static void LogOff() { officeApplication = null; officedocument = null; userInfo = null; webAddress = null; }
public void loadVersions(String contentId, String repositoryName) { try { int rows = listViewVersions.Items.Count; for (int i = 1; i <= rows; i++) { listViewVersions.Items.RemoveAt(0); } IOfficeDocument document = OfficeApplication.OfficeDocumentProxy; foreach (VersionInfo versionInfo in document.getVersions(repositoryName, contentId)) { String date = String.Format(OfficeApplication.iso8601dateFormat, versionInfo.created); ListViewItem item = new ListViewItem(versionInfo.nameOfVersion); item.SubItems.Add(date); item.SubItems.Add(versionInfo.user); listViewVersions.Items.Add(item); } } catch { } }
private void ContentProperties_ValidateStep(object sender, CancelEventArgs e) { FileInfo zipFile = null; String title = this.Wizard.Data[TitleAndDescription.TITLE].ToString(); String description = this.Wizard.Data[TitleAndDescription.DESCRIPTION].ToString(); String categoryID = this.Wizard.Data[SelectCategory.CATEGORY_ID].ToString(); String repositoryName = this.Wizard.Data[SelectCategory.REPOSITORY_ID].ToString(); RepositoryInfo rep = null; foreach (RepositoryInfo temp in OfficeApplication.OfficeApplicationProxy.getRepositories()) { if (temp.name.Equals(repositoryName)) { rep = temp; } } ContentType contentType = (ContentType)this.Wizard.Data[TitleAndDescription.NODE_TYPE]; PropertyInfo[] properties = OfficeApplication.OfficeDocumentProxy.getContentProperties(repositoryName, contentType.id); String[] values = this.propertyEditor1.Values; try { OfficeApplication.OfficeDocumentProxy.validateContentValues(repositoryName, properties, values, contentType.id); } catch (Exception ue) { OfficeApplication.WriteError(ue); MessageBox.Show(this, ue.Message, this.Wizard.Text, MessageBoxButtons.OK, MessageBoxIcon.Error); return; } this.Wizard.SetProgressBarInit(3, 1, "Preparando documento para guardar..."); try { zipFile = document.CreateZipFile(); this.Wizard.SetProgressBarInit(3, 2, "Guardando documento en el sitio..."); IOfficeDocument openOfficeDocument = OfficeDocument.OfficeDocumentProxy; openOfficeDocument.Attachments.Add(new Attachment(zipFile, zipFile.Name)); String name = document.FilePath.Name.Replace(document.DefaultExtension, document.PublicationExtension); String contentID = openOfficeDocument.save(title, description, repositoryName, categoryID, document.DocumentType.ToString().ToUpper(), contentType.id, name, properties, values); this.Wizard.Data[TitleAndDescription.CONTENT_ID] = contentID; document.SaveContentProperties(contentID, repositoryName); this.Wizard.SetProgressBarEnd(); WebSiteInfo[] sites = OfficeApplication.OfficeApplicationProxy.getSites(); if (sites != null && sites.Length > 0 && rep != null && rep.siteInfo != null) { DialogResult res = MessageBox.Show(this, "¿Desea publicar el contenido en una página web?", this.Wizard.Text, MessageBoxButtons.YesNo, MessageBoxIcon.Question); if (res == DialogResult.Yes) { WebSiteInfo webSiteInfo = new WebSiteInfo(); webSiteInfo.id = rep.siteInfo.id; webSiteInfo.title = rep.siteInfo.title; document.Publish(title, description, webSiteInfo); } } if (OfficeApplication.MenuListener != null) { OfficeApplication.MenuListener.DocumentPublished(); } } catch (Exception ue) { OfficeApplication.WriteError(ue); MessageBox.Show(this, "Error al tratar de publicar un documento " + ue.Message, this.Wizard.Text, MessageBoxButtons.OK, MessageBoxIcon.Error); } finally { if (zipFile != null && zipFile.Exists) { zipFile.Delete(); } } }
private void New1_ValidateStep(object sender, CancelEventArgs e) { if (String.IsNullOrEmpty(this.textBoxTitle.Text)) { MessageBox.Show(this, "¡De indicar el título!", this.Wizard.Text, MessageBoxButtons.OK, MessageBoxIcon.Error); textBoxTitle.Focus(); e.Cancel = true; return; } if (String.IsNullOrEmpty(this.textBoxDescription.Text)) { MessageBox.Show(this, "¡De indicar la descripción!", this.Wizard.Text, MessageBoxButtons.OK, MessageBoxIcon.Error); textBoxDescription.Focus(); e.Cancel = true; return; } if (showType) { this.Wizard.Data[TITLE] = this.textBoxTitle.Text; this.Wizard.Data[DESCRIPTION] = this.textBoxDescription.Text; this.Wizard.Data[NODE_TYPE] = this.ComboBoxType.SelectedItem; FileInfo zipFile = null; String repositoryName = this.Wizard.Data[SelectCategory.REPOSITORY_ID].ToString(); RepositoryInfo rep = null; foreach (RepositoryInfo temp in OfficeApplication.OfficeApplicationProxy.getRepositories()) { if (temp.name.Equals(repositoryName)) { rep = temp; } } String title = this.Wizard.Data[TitleAndDescription.TITLE].ToString(); String description = this.Wizard.Data[TitleAndDescription.DESCRIPTION].ToString(); ContentType contentType = (ContentType)this.Wizard.Data[TitleAndDescription.NODE_TYPE]; String categoryID = this.Wizard.Data[SelectCategory.CATEGORY_ID].ToString(); PropertyInfo[] props = OfficeApplication.OfficeDocumentProxy.getContentProperties(repositoryName, contentType.id); if (props == null || props.Length == 0) { Object obj = TypeFactory.getObject(props, contentType.title); String[] values = TypeFactory.getValues(props, obj); try { OfficeApplication.OfficeDocumentProxy.validateContentValues(repositoryName, props, values, contentType.id); } catch (Exception ue) { MessageBox.Show(this, ue.Message, this.Wizard.Text, MessageBoxButtons.OK, MessageBoxIcon.Error); return; } this.Wizard.SetProgressBarInit(3, 1, "Preparando documento para guardar..."); try { zipFile = document.CreateZipFile(); this.Wizard.SetProgressBarInit(3, 2, "Guardando documento en el sitio..."); IOfficeDocument openOfficeDocument = OfficeDocument.OfficeDocumentProxy; openOfficeDocument.Attachments.Add(new Attachment(zipFile, zipFile.Name)); String name = document.FilePath.Name.Replace(document.DefaultExtension, document.PublicationExtension); String contentID = openOfficeDocument.save(title, description, repositoryName, categoryID, document.DocumentType.ToString().ToUpper(), contentType.id, name, props, values); this.Wizard.Data[TitleAndDescription.CONTENT_ID] = contentID; document.SaveContentProperties(contentID, repositoryName); WebSiteInfo[] sites = OfficeApplication.OfficeApplicationProxy.getSites(); this.Wizard.SetProgressBarEnd(); if (sites != null && sites.Length > 0 && rep != null && rep.siteInfo != null) { DialogResult res = MessageBox.Show(this, "¿Desea publicar el contenido en una página web?", this.Wizard.Text, MessageBoxButtons.YesNo, MessageBoxIcon.Question); if (res == DialogResult.Yes) { WebSiteInfo webSiteInfo = new WebSiteInfo(); webSiteInfo.id = rep.siteInfo.id; webSiteInfo.title = rep.siteInfo.title; document.Publish(title, description, webSiteInfo); } } if (OfficeApplication.MenuListener != null) { OfficeApplication.MenuListener.DocumentPublished(); } this.Wizard.Close(); } finally { if (zipFile != null && zipFile.Exists) { zipFile.Delete(); } } } } else { this.Wizard.Data[TITLE] = this.textBoxTitle.Text; this.Wizard.Data[DESCRIPTION] = this.textBoxDescription.Text; } }