Example #1
0
 private void toolStripButtonPublish_Click(object sender, EventArgs e)
 {
     document.Publish();
     loadPorlets();
 }
Example #2
0
        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();
                }
            }
        }
Example #3
0
 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;
     }
 }