Ejemplo n.º 1
0
 /// <summary>
 /// Updates the order.
 /// </summary>
 protected void UpdateOrder()
 {
     for (int i = 0; i < rgWorkflowTemplateElement.Items.Count; i++)
     {
         WorkflowTemplateElementList.SingleOrDefault(a => a.ID == rgWorkflowTemplateElement.Items[i].GetDataKeyValue("ID").ToString().ToGuid()).Order = i;
     }
 }
Ejemplo n.º 2
0
        /// <summary>
        /// Handles the RowDrop event of the rgWorkflowTemplateElement control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="Telerik.Web.UI.GridDragDropEventArgs"/> instance containing the event data.</param>
        protected void rgWorkflowTemplateElement_RowDrop(object sender, GridDragDropEventArgs e)
        {
            if (string.IsNullOrEmpty(e.HtmlElement))
            {
                if (e.DraggedItems[0].OwnerGridID == rgWorkflowTemplateElement.ClientID)
                {
                    if (e.DestDataItem != null && e.DestDataItem.OwnerGridID == rgWorkflowTemplateElement.ClientID)
                    {
                        //reorder items in pending grid
                        var element          = WorkflowTemplateElementList.SingleOrDefault(a => a.ID == e.DestDataItem.GetDataKeyValue("ID").ToString().ToGuid());
                        int destinationIndex = WorkflowTemplateElementList.IndexOf(element);

                        if (e.DropPosition == GridItemDropPosition.Above && e.DestDataItem.ItemIndex > e.DraggedItems[0].ItemIndex)
                        {
                            destinationIndex -= 1;
                        }
                        if (e.DropPosition == GridItemDropPosition.Below && e.DestDataItem.ItemIndex < e.DraggedItems[0].ItemIndex)
                        {
                            destinationIndex += 1;
                        }

                        var workflowTemplateElementListToMove = new List <WorkflowTemplateElementMap>();
                        foreach (GridDataItem draggedItem in e.DraggedItems)
                        {
                            var tmpElement = WorkflowTemplateElementList.SingleOrDefault(a => a.ID == draggedItem.GetDataKeyValue("ID").ToString().ToGuid());
                            if (tmpElement != null)
                            {
                                workflowTemplateElementListToMove.Add(tmpElement);
                            }
                        }

                        foreach (var elementToMove in workflowTemplateElementListToMove)
                        {
                            WorkflowTemplateElementList.Remove(elementToMove);
                            WorkflowTemplateElementList.Insert(destinationIndex, elementToMove);
                        }
                        rgWorkflowTemplateElement.Rebind();

                        int destinationItemIndex = destinationIndex - (rgWorkflowTemplateElement.PageSize * rgWorkflowTemplateElement.CurrentPageIndex);
                        e.DestinationTableView.Items[destinationItemIndex].Selected = true;
                    }
                }
            }

            UpdateOrder();
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Handles the UpdateCommand event of the rgWorkflowTemplateElement control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="Telerik.Web.UI.GridCommandEventArgs"/> instance containing the event data.</param>
        protected void rgWorkflowTemplateElement_UpdateCommand(object sender, GridCommandEventArgs e)
        {
            var item   = e.Item as GridEditableItem;
            var editId = item.GetDataKeyValue("ID").ToString().ToGuid();

            var userControl    = (UserControl)item.FindControl(GridEditFormItem.EditFormUserControlID);
            var ddlElementType = (DropDownList)userControl.FindControl("ddlElementType");

            var selectedElementType = ddlElementType.SelectedValue.ToEnum <WorkflowTemplateElementType>();

            if ((selectedElementType == WorkflowTemplateElementType.StartProcess || selectedElementType == WorkflowTemplateElementType.EndProcess) &&
                WorkflowTemplateElementList.SingleOrDefault(a => a.ID != editId && a.ElementType == (int)ddlElementType.SelectedValue.ToEnum <WorkflowTemplateElementType>()) != null)
            {
                e.Canceled = true;
                ScriptManager.RegisterStartupScript(Page, typeof(Page), "ExistElementType", string.Format("alert(\"Элемент процесса с типом элемента '{0}' уже существует.\");", EnumHelper.GetEnumDescription(selectedElementType)), true);
                return;
            }

            SaveToViewState(editId, item);
        }