private void buttonAccept_Click(object sender, EventArgs e) { if (string.IsNullOrEmpty(this.textBoxMessage.Text)) { MessageBox.Show(this, "¡Debe indicar el mensaje!", this.Text, MessageBoxButtons.OK, MessageBoxIcon.Error); this.textBoxMessage.Focus(); return; } pflow = (PFlow)this.comboBoxFlujo.SelectedItem; this.DialogResult = DialogResult.OK; this.Close(); }
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(); } }
public void LV_List_OnItemDataBound(object sender, ListViewItemEventArgs e) { Orders boundOrder = (Orders)((ListViewDataItem)(e.Item)).DataItem; PFlow flow = new PFlow(); flowQueue.Enqueue(flow); flow.FlowCode = boundOrder.Flow.Code; flow.PartyFrom = boundOrder.Flow.PartyFrom; foreach (ItemFlow itemFlow in boundOrder.ItemFlows) { IList<string> orderedPOList = new List<string>(); PItem item = new PItem(); item.Code = itemFlow.Item; Item i = TheItemMgr.LoadItem(item.Code); item.Desc = i.Desc1; item.Spec = i.Spec; var demand = itemFlow.OrderTracers.Where(o => o.TracerType == LeanEngine.Utility.Enumerators.TracerType.Demand).ToList(); if (demand.Count != null && demand.Count > 0) { item.SaveStock = demand[0].Qty; } var onhandInv = itemFlow.OrderTracers.Where(o => o.TracerType == LeanEngine.Utility.Enumerators.TracerType.OnhandInv).ToList(); if (onhandInv.Count != null && onhandInv.Count > 0) { item.Inventory = onhandInv[0].Qty; } var orderIss = itemFlow.OrderTracers.Where(o => o.TracerType == LeanEngine.Utility.Enumerators.TracerType.OrderIss).ToList(); if (orderIss != null && orderIss.Count > 0) { foreach (OrderTracer ot in orderIss) { string hql = @"select od from OrderDetail od inner join od.OrderHead oh where od.Item.Code = ? and oh.OrderNo = ? '"; IList<OrderDetail> orderDetailList = this.TheCriteriaMgr.FindAllWithHql<OrderDetail>(hql, new object[] { ot.Item, ot.Code }); if (orderDetailList != null && orderDetailList.Count > 0) { OrderDetail orderDetail = orderDetailList[0]; OrderHead orderHead = orderDetail.OrderHead; POrder pOrder = new POrder(); pOrder.OrderNo = orderHead.OrderNo; pOrder.CustomerCode = orderHead.PartyTo.Code; pOrder.CustomerName = orderHead.PartyTo.Name; pOrder.NeedPrepayment = orderHead.PartyTo.BoolField1.HasValue ? orderHead.PartyTo.BoolField1.Value : false; pOrder.HasPrepayed = orderHead.BoolField1; pOrder.RequiredQty = orderDetail.OrderedQty; pOrder.ShippedQty = orderDetail.ShippedQty.HasValue ? orderDetail.ShippedQty.Value : 0; pOrder.DeliverDate = orderHead.WindowTime; hql = @"select oh.OrderNo, ot.Qty from OrderTracer as ot, OrderLocationTransaction as olt inner join olt.OrderDetail as od inner join od.OrderHead as oh where olt.Id = ot.RefOrderLocTransId and ot.OrderDetail.Id = ?"; IList<object[]> qtyList = this.TheCriteriaMgr.FindAllWithHql<object[]>(hql, new object[] { orderDetail.Id }); if (qtyList != null && qtyList.Count > 0) { foreach (object[] obj in qtyList) { orderedPOList.Add((string)obj[0]); pOrder.OrderedQty += (decimal)obj[1]; } } else { pOrder.OrderedQty = 0; } if (pOrder.RequiredQty > pOrder.ShippedQty && pOrder.RequiredQty > pOrder.OrderedQty) { item.AddOrder(pOrder); } } } } var orderRct = itemFlow.OrderTracers.Where(o => o.TracerType == LeanEngine.Utility.Enumerators.TracerType.OrderRct).ToList(); if (orderRct != null && orderRct.Count > 0) { foreach (OrderTracer ot in orderRct) { if (!orderedPOList.Contains(ot.Code)) { item.OrderedQty += ot.Qty; } } } if ((item.OrderList != null && item.OrderList.Count > 0) || (item.SaveStock > (item.Inventory + item.OrderedQty))) { flow.AddItem(item); } } }