Beispiel #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;
     }
 }
Beispiel #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();
        }
Beispiel #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);
        }
Beispiel #4
0
        /// <summary>
        /// Saves the state of to view.
        /// </summary>
        /// <param name="workflowTemplateElementId">The workflow template element id.</param>
        /// <param name="item">The item.</param>
        protected void SaveToViewState(Guid workflowTemplateElementId, GridEditableItem item)
        {
            var userControl = (UserControl)item.FindControl(GridEditFormItem.EditFormUserControlID);

            var workflowTemplateElement = ((List <WorkflowTemplateElementMap>)ViewState["WorkflowTemplateElements"]).Where(s => s.ID == workflowTemplateElementId).FirstOrDefault() ?? new WorkflowTemplateElementMap();

            workflowTemplateElement.Name                     = ((TextBox)userControl.FindControl("txtName")).Text;
            workflowTemplateElement.ElementType              = ((DropDownList)userControl.FindControl("ddlElementType")).SelectedValue.ToInt();
            workflowTemplateElement.Optional                 = ((CheckBox)userControl.FindControl("cbOptional")).Checked;
            workflowTemplateElement.ResultName               = ((TextBox)userControl.FindControl("txtResultName")).Text;
            workflowTemplateElement.AllowOptionalTransfer    = ((CheckBox)userControl.FindControl("cbAllowOptionalTransfer")).Checked;
            workflowTemplateElement.ShowCurrentUser          = ((CheckBox)userControl.FindControl("cbShowCurrentUser")).Checked;
            workflowTemplateElement.Description              = ((TextBox)userControl.FindControl("txtDescription")).Text;
            workflowTemplateElement.StartAfter               = ((RadNumericTextBox)userControl.FindControl("txtStartAfter")).Text.ToInt();
            workflowTemplateElement.StartPeriod              = ((DropDownList)userControl.FindControl("ddlStartPeriod")).SelectedValue.ToInt();
            workflowTemplateElement.DurationHours            = userControl.FindControl("pnlTypicalDuration").Visible ? ((RadNumericTextBox)userControl.FindControl("txtDurationHours")).Text.ToInt() : (int?)null;
            workflowTemplateElement.DurationMinutes          = userControl.FindControl("pnlTypicalDuration").Visible ? ((RadNumericTextBox)userControl.FindControl("txtDurationMinutes")).Text.ToInt() : (int?)null;
            workflowTemplateElement.ControlAfter             = userControl.FindControl("pnlRequiredControl").Visible ? ((RadNumericTextBox)userControl.FindControl("txtControlAfter")).Text.ToInt() : (int?)null;
            workflowTemplateElement.ControlPeriod            = userControl.FindControl("pnlRequiredControl").Visible ? ((DropDownList)userControl.FindControl("ddlControlPeriod")).SelectedValue.ToInt() : (int?)null;
            workflowTemplateElement.ControlFromBeginProccess = userControl.FindControl("pnlRequiredControl").Visible ? ((CheckBox)userControl.FindControl("cbControlFromBeginProccess")).Checked : false;

            workflowTemplateElement.Parameters = new Dictionary <string, string>();
            switch ((WorkflowTemplateElementType)workflowTemplateElement.ElementType)
            {
            case WorkflowTemplateElementType.Message:
                workflowTemplateElement.Parameters.Add("SiteActionTemplateID", ((UserControls.SiteActionTemplate)userControl.FindControl("ucSiteActionTemplate")).SelectedSiteActionTemplateId.ToString());
                //workflowTemplateElement.Parameters.Add("SiteActionTemplateID", ((DictionaryComboBox)userControl.FindControl("dcbMessageSiteActionTemplate")).SelectedId.ToString());
                break;

            case WorkflowTemplateElementType.WaitingEvent:
                workflowTemplateElement.Condition = ((DropDownList)(userControl.FindControl("ucWorkflowTemplateElementConditionEvent")).FindControl("ddlCondition")).SelectedValue.ToInt();
                if (!string.IsNullOrEmpty(((RadNumericTextBox)(userControl.FindControl("ucWorkflowTemplateElementConditionEvent")).FindControl("txtActivityCount")).Text))
                {
                    workflowTemplateElement.ActivityCount = ((RadNumericTextBox)(userControl.FindControl("ucWorkflowTemplateElementConditionEvent")).FindControl("txtActivityCount")).Text.ToInt();
                }
                else
                {
                    workflowTemplateElement.ActivityCount = null;
                }
                workflowTemplateElement.ConditionEvent = ((WorkflowTemplateElementConditionEvent)userControl.FindControl("ucWorkflowTemplateElementConditionEvent")).WorkflowTemplateConditionEventList;
                break;

            case WorkflowTemplateElementType.Activity:
                workflowTemplateElement.Parameters.Add("ContactActivityDescription", ((TextBox)userControl.FindControl("txtContactActivityDescription")).Text);
                break;

            case WorkflowTemplateElementType.Task:
                workflowTemplateElement.Parameters.Add("TaskType", ((DictionaryComboBox)userControl.FindControl("dcbTaskType")).SelectedId.ToString());
                workflowTemplateElement.Parameters.Add("TaskIsImportantTask", ((CheckBox)userControl.FindControl("cbIsImportantTask")).Checked ? "1" : "0");
                workflowTemplateElement.Parameters.Add("TaskIsUrgentTask", ((CheckBox)userControl.FindControl("cbIsUrgentTask")).Checked ? "1" : "0");
                workflowTemplateElement.ElementResult = ((WorkflowTemplateElementResult)userControl.FindControl("ucWorkflowTemplateElementResult")).WorkflowTemplateElementResultList;
                break;
            }

            if (workflowTemplateElement.ID == Guid.Empty)
            {
                if (WorkflowTemplateElementList.Count > 0)
                {
                    workflowTemplateElement.Order = WorkflowTemplateElementList.Max(a => a.Order) + 1;
                }

                workflowTemplateElement.ID = Guid.NewGuid();
                ((List <WorkflowTemplateElementMap>)ViewState["WorkflowTemplateElements"]).Add(workflowTemplateElement);
            }

            ((WorkflowTemplateElementRelation)Parent.FindControl("ucWorkflowTemplateElementRelation")).RebindData();
        }