コード例 #1
0
ファイル: FormEditPorlet.cs プロジェクト: Yellllllow/swb
        private void buttonSenttoAuthorize_Click(object sender, EventArgs e)
        {
            FormSendToAutorize formSendToAutorize = new FormSendToAutorize(pageInformation);

            formSendToAutorize.ShowDialog();
            if (formSendToAutorize.DialogResult == DialogResult.OK)
            {
                OfficeApplication.OfficeDocumentProxy.sendToAuthorize(pageInformation, formSendToAutorize.pflow, formSendToAutorize.textBoxMessage.Text);
                this.buttonSenttoAuthorize.Visible = false;
            }
        }
コード例 #2
0
ファイル: FormUpdateContent.cs プロジェクト: Yellllllow/swb
        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();
            }
        }
コード例 #3
0
ファイル: FormEditPorlet.cs プロジェクト: Yellllllow/swb
        /*private void toolStripButtonEdit_Click(object sender, EventArgs e)
         * {
         *  if (this.listViewCalendar.SelectedItems.Count > 0)
         *  {
         *      CalendarItem calendarItem = (CalendarItem)this.listViewCalendar.SelectedItems[0];
         *      CalendarInfo cal = calendarItem.CalendarInfo;
         *      FrmPeriodicidad frmPeriodicidad = new FrmPeriodicidad(cal.active);
         *      XmlDocument doc = new XmlDocument();
         *      doc.LoadXml(cal.xml);
         *      frmPeriodicidad.textBoxTitle.Text = cal.title;
         *      frmPeriodicidad.Document = doc;
         *      DialogResult res = frmPeriodicidad.ShowDialog(this);
         *      if (res == DialogResult.OK)
         *      {
         *          cal.xml = frmPeriodicidad.Document.OuterXml;
         *          calendarItem.Title = frmPeriodicidad.textBoxTitle.Text;
         *          calendarItem.Active = frmPeriodicidad.isActive();
         *      }
         *
         *  }
         * }*/

        private void buttonOK_Click(object sender, EventArgs e)
        {
            if (String.IsNullOrEmpty(this.textBoxTitle.Text))
            {
                MessageBox.Show(this, "¡Debe indicar el título!", this.Text, MessageBoxButtons.OK, MessageBoxIcon.Error);
                this.textBoxTitle.Focus();
                return;
            }
            if (String.IsNullOrEmpty(this.textBoxDescription.Text))
            {
                MessageBox.Show(this, "¡Debe indicar la descripción!", this.Text, MessageBoxButtons.OK, MessageBoxIcon.Error);
                this.textBoxDescription.Focus();
                return;
            }
            DialogResult res = MessageBox.Show(this, "Se va a realizar los cambios de la información de publicación.\r\n¿Desea continuar?", this.Text, MessageBoxButtons.YesNo, MessageBoxIcon.Question);

            if (res == DialogResult.Yes)
            {
                pageInformation.title       = this.textBoxTitle.Text;
                pageInformation.description = this.textBoxDescription.Text;
                pageInformation.version     = ((VersionInfo)this.comboBoxVersiones.SelectedItem).nameOfVersion;
                OfficeApplication.OfficeDocumentProxy.updatePorlet(pageInformation);
                if (this.checkBoxActive.Checked)
                {
                    if (this.pageInformation.active)
                    {
                        OfficeApplication.OfficeDocumentProxy.activateResource(pageInformation, this.checkBoxActive.Checked);
                    }
                    else
                    {
                        if (OfficeApplication.OfficeDocumentProxy.needsSendToPublish(pageInformation))
                        {
                            this.checkBoxActive.Checked = pageInformation.active;
                            res = MessageBox.Show(this, "El documento requiere una autorización para activarse" + "\r\n" + "¿Desea envíar a publicar el contenido?", this.Text, MessageBoxButtons.YesNo, MessageBoxIcon.Question);
                            if (res == DialogResult.Yes)
                            {
                                FormSendToAutorize formSendToAutorize = new FormSendToAutorize(pageInformation);
                                formSendToAutorize.ShowDialog();
                                if (formSendToAutorize.DialogResult == DialogResult.OK)
                                {
                                    OfficeApplication.OfficeDocumentProxy.sendToAuthorize(pageInformation, formSendToAutorize.pflow, formSendToAutorize.textBoxMessage.Text);
                                    this.buttonSenttoAuthorize.Visible = false;
                                }
                                else
                                {
                                    MessageBox.Show(this, "El contenido no se activo, ya que se requiere una autorización", this.Text, MessageBoxButtons.OK, MessageBoxIcon.Information);
                                }
                            }
                            else
                            {
                                MessageBox.Show(this, "El contenido no se activo, ya que se requiere una autorización", this.Text, MessageBoxButtons.OK, MessageBoxIcon.Information);
                            }
                        }
                        else if (OfficeApplication.OfficeDocumentProxy.isInFlow(pageInformation))
                        {
                            this.checkBoxActive.Checked = pageInformation.active;
                            MessageBox.Show(this, "El contenido se encuentra en proceso de ser autorizado.\r\nPara activarlo necesita terminar el proceso de autorización", this.Text, MessageBoxButtons.OK, MessageBoxIcon.Information);
                        }
                        else if (OfficeApplication.OfficeDocumentProxy.isAuthorized(pageInformation))
                        {
                            OfficeApplication.OfficeDocumentProxy.activateResource(pageInformation, this.checkBoxActive.Checked);
                        }
                        else
                        {
                            this.checkBoxActive.Checked = pageInformation.active;
                            res = MessageBox.Show(this, "El contenido fue rechazado.\r\nPara activarlo necesita enviarlo a autorización de nuevo\r\n¿Desea enviarlo a autorización?", this.Text, MessageBoxButtons.YesNo, MessageBoxIcon.Question);
                            if (res == DialogResult.Yes)
                            {
                                FormSendToAutorize formSendToAutorize = new FormSendToAutorize(pageInformation);
                                formSendToAutorize.ShowDialog();
                                if (formSendToAutorize.DialogResult == DialogResult.OK)
                                {
                                    OfficeApplication.OfficeDocumentProxy.sendToAuthorize(pageInformation, formSendToAutorize.pflow, formSendToAutorize.textBoxMessage.Text);
                                }
                                else
                                {
                                    MessageBox.Show(this, "El contenido no se activo, ya que se requiere una autorización", this.Text, MessageBoxButtons.OK, MessageBoxIcon.Information);
                                }
                            }
                            else
                            {
                                MessageBox.Show(this, "El contenido no se activo, ya que se requiere una autorización", this.Text, MessageBoxButtons.OK, MessageBoxIcon.Information);
                            }
                        }
                    }
                }
                else
                {
                    OfficeApplication.OfficeDocumentProxy.activateResource(pageInformation, this.checkBoxActive.Checked);
                }
                OfficeApplication.OfficeDocumentProxy.setTitlesOfWebPage(this.pageInformation.page, this.titleEditor1.Languages, this.titleEditor1.Titles);
                foreach (ListViewItem calendar in this.listViewCalendar.Items)
                {
                    CalendarItem calendarItem = (CalendarItem)calendar;
                    CalendarInfo cal          = (CalendarInfo)calendarItem.CalendarInfo;
                    bool         active       = cal.active;
                    OfficeApplication.OfficeDocumentProxy.insertCalendartoResource(pageInformation, cal);
                    added.Remove(cal);
                    OfficeApplication.OfficeDocumentProxy.activeCalendar(pageInformation, cal, active);
                }
                OfficeApplication.OfficeApplicationProxy.activePage(this.pageInformation.page, this.checkBoxActivePag.Checked);

                PropertyInfo[] properties = null;
                String[]       values     = null;

                properties = OfficeApplication.OfficeDocumentProxy.getResourceProperties(repositoryName, contentID);
                values     = this.propertyEditor1.Values;
                try
                {
                    OfficeApplication.OfficeDocumentProxy.validateViewValues(repositoryName, contentID, properties, values);
                }
                catch (Exception ue)
                {
                    OfficeApplication.WriteError(ue);
                    MessageBox.Show(this, ue.Message, this.Text, MessageBoxButtons.OK, MessageBoxIcon.Error);
                    tabPageProperties.Focus();
                    return;
                }

                try
                {
                    this.Cursor = Cursors.WaitCursor;
                    if (properties != null && values != null)
                    {
                        int i = 0;
                        foreach (PropertyInfo prop in properties)
                        {
                            String value = values[i];
                            OfficeApplication.OfficeDocumentProxy.setViewPropertyValue(this.pageInformation, prop, value);
                            i++;
                        }
                    }
                }
                catch (Exception ue)
                {
                    OfficeApplication.WriteError(ue);
                    MessageBox.Show(this, ue.Message, this.Text, MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
                finally
                {
                    this.Cursor = Cursors.Default;
                }
            }

            this.DialogResult = DialogResult.OK;
        }