Beispiel #1
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();
                }
            }
        }
Beispiel #2
0
        private void buttonUpdate_Click(object sender, EventArgs e)
        {
            int limit = OfficeApplication.OfficeApplicationProxy.getLimitOfVersions();

            if (limit > 0)
            {
                int versions = OfficeApplication.OfficeDocumentProxy.getNumberOfVersions(this.document.reporitoryID, this.document.contentID);
                if (OfficeApplication.OfficeDocumentProxy.allVersionsArePublished(this.document.reporitoryID, this.document.contentID))
                {
                    if (versions >= limit)
                    {
                        DialogResult resp = MessageBox.Show(this, "¡El limite máximo de versiones es de " + limit + "!\r\nPuede publicar este contenido, debido a que tiene todas las versiones publicadas, pero excederá del límite de versiones\r\n¿Desea continuar?", this.Text, MessageBoxButtons.YesNo, MessageBoxIcon.Question);
                        if (resp == DialogResult.No)
                        {
                            return;
                        }
                    }
                }
                else
                {
                    if (versions >= limit)
                    {
                        MessageBox.Show(this, "¡El limite máximo de versiones es de " + limit + "!\r\nSi desea crear una nueva version, debe borrar alguna de las existentes, que no este publicada.", this.Text, MessageBoxButtons.OK, MessageBoxIcon.Error);
                        return;
                    }
                }
            }

            Dictionary <ResourceInfo, Dictionary <PFlow, String> > flows = new Dictionary <ResourceInfo, Dictionary <PFlow, String> >();

            ResourceInfo[] resources = OfficeApplication.OfficeDocumentProxy.listResources(document.reporitoryID, document.contentID);
            if (resources != null && resources.Length > 0)
            {
                bool showMessage = false;
                foreach (ResourceInfo resourceInfo in resources)
                {
                    if (OfficeApplication.OfficeDocumentProxy.isInFlow(resourceInfo) && resourceInfo.version.EndsWith("*"))
                    {
                        DialogResult res = MessageBox.Show(this, "La publicación de este contenido en la página" + " " + resourceInfo.title + " " + "esta en trámite" + NL + "Si continua se perderá este proceso de autorización, ¿Desea continuar?", this.Text, MessageBoxButtons.YesNo, MessageBoxIcon.Warning);
                        if (res == DialogResult.No)
                        {
                            return;
                        }
                        PFlow[] aflows     = OfficeApplication.OfficeDocumentProxy.getFlows(resourceInfo);
                        PFlow   flowtoSend = null;
                        String  msg        = null;

                        FormSendToAutorize dialogSelectFlow = new FormSendToAutorize(resourceInfo);
                        dialogSelectFlow.Text = dialogSelectFlow.Text + " " + "para página" + " " + resourceInfo.title;
                        dialogSelectFlow.ShowDialog(this);
                        if (dialogSelectFlow.DialogResult == DialogResult.Cancel)
                        {
                            return;
                        }


                        flowtoSend = dialogSelectFlow.pflow;
                        msg        = dialogSelectFlow.textBoxMessage.Text;
                        if (aflows.Length == 1)
                        {
                            flowtoSend = aflows[0];
                        }
                        if (flowtoSend != null && msg != null)
                        {
                            flows.Add(resourceInfo, new Dictionary <PFlow, String>());
                            flows[resourceInfo].Add(flowtoSend, msg);
                        }
                        break;
                    }
                }

                foreach (ResourceInfo resourceInfo in resources)
                {
                    PFlow[] pflows = OfficeApplication.OfficeDocumentProxy.getFlows(resourceInfo);
                    if (pflows != null && pflows.Length >= 1)
                    {
                        if (resourceInfo.version.EndsWith("*") && !flows.ContainsKey(resourceInfo))
                        {
                            showMessage = true;
                        }
                    }
                }
                if (showMessage)
                {
                    DialogResult res = MessageBox.Show(this, "Se encontró que algunas páginas requieren autorización para publicar este contenido, ¿Desea continuar?", this.Text, MessageBoxButtons.YesNo, MessageBoxIcon.Question);
                    if (res == DialogResult.No)
                    {
                        return;
                    }
                }
                foreach (ResourceInfo resourceInfo in resources)
                {
                    PFlow[] aflows = OfficeApplication.OfficeDocumentProxy.getFlows(resourceInfo);
                    if (aflows != null && aflows.Length >= 1)
                    {
                        // solo avisa de las que va a actualizar
                        if (resourceInfo.version.EndsWith("*") && !flows.ContainsKey(resourceInfo))
                        {
                            PFlow              flowtoSend       = null;
                            String             msg              = null;
                            FormSendToAutorize dialogSelectFlow = new FormSendToAutorize(resourceInfo);
                            dialogSelectFlow.Text = dialogSelectFlow.Text + " " + "para página" + " " + resourceInfo.title;
                            dialogSelectFlow.ShowDialog(this);
                            if (dialogSelectFlow.DialogResult == DialogResult.Cancel)
                            {
                                return;
                            }


                            flowtoSend = dialogSelectFlow.pflow;
                            msg        = dialogSelectFlow.textBoxMessage.Text;
                            if (aflows.Length == 1)
                            {
                                flowtoSend = aflows[0];
                            }
                            if (flowtoSend != null && msg != null)
                            {
                                flows.Add(resourceInfo, new Dictionary <PFlow, String>());
                                flows[resourceInfo].Add(flowtoSend, msg);
                            }
                        }
                    }
                }
            }
            ResourceInfo[] resourcestoSend = flows.Keys.ToArray <ResourceInfo>();
            String[]       messages        = new String[flows.Count];
            PFlow[]        flowsToSend     = new PFlow[flows.Count];
            int            i = 0;

            foreach (ResourceInfo res in resourcestoSend)
            {
                flowsToSend[i] = flows[res].Keys.ElementAt(0);
                messages[i]    = flows[res][flowsToSend[i]];
                i++;
            }

            this.progressBarSave.Maximum = 1;
            FileInfo zipFile = document.CreateZipFile();

            this.progressBarSave.Value = 1;
            OfficeDocument.OfficeDocumentProxy.Attachments.Add(new Attachment(zipFile, zipFile.Name));
            this.Cursor = Cursors.WaitCursor;
            try
            {
                String name = document.FilePath.Name.Replace(document.DefaultExtension, document.PublicationExtension);
                OfficeDocument.OfficeDocumentProxy.updateContent(document.reporitoryID, document.contentID, name, resourcestoSend, flowsToSend, messages);
                MessageBox.Show(this, "¡Version actualizada!", this.Text, MessageBoxButtons.OK, MessageBoxIcon.Information);
                loadVersions();
                this.buttonUpdate.Enabled = false;
            }
            catch
            {
                throw;
            }
            finally
            {
                this.Cursor = Cursors.Default;
                zipFile.Delete();
            }
        }
Beispiel #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;
     }
 }