Exemplo n.º 1
0
        /// <summary>
        /// 发生在PreRender环节,生成流程编辑界面
        /// </summary>
        /// <param name="levels"></param>
        private void RenderActivitiesEditor(WfMainStreamActivityDescriptorCollection msActivities)
        {
            if (CurrentActivity.Process.Status == WfProcessStatus.Running)
            {
                Dictionary <string, Dictionary <string, string> > changeParams = GetActivityKeysCanBeChanged(CurrentActivity.Descriptor);

                if (CurrentActivity.Descriptor.ActivityType == WfActivityType.InitialActivity &&
                    CurrentActivity.OpinionRootActivity == CurrentActivity)
                {
                    if (_Table.Rows.Count > 0)
                    {
                        Control container = _Table.Rows[0].Cells[0];

                        HtmlGenericControl div = new HtmlGenericControl("div");

                        container.Controls.Add(div);

                        IWfActivityDescriptor actDesp = GetCanModifiedActivityDescriptorFromGroup(CurrentActivity.Descriptor);

                        ActivityEditMode editMode = GetActivityDespEditMode(actDesp, msActivities, changeParams);
                        RenderOneActivityEditor(div, CurrentActivity.Descriptor, editMode);

                        div.Attributes["class"] = "command";
                    }
                }

                foreach (IWfMainStreamActivityDescriptor msActivity in msActivities)
                {
                    Control container = null;

                    if (_activityEditorPlaceHolders.TryGetValue(msActivity.Activity.Key, out container))
                    {
                        HtmlGenericControl div = new HtmlGenericControl("div");

                        container.Controls.Add(div);

                        if (ReadOnly == false || WfClientContext.Current.InAdminMode)
                        {
                            IWfActivityDescriptor actDesp = GetCanModifiedActivityDescriptorFromGroup(msActivity.Activity);

                            ActivityEditMode editMode = GetActivityDespEditMode(actDesp, msActivities, changeParams);

                            if (editMode != ActivityEditMode.None)
                            {
                                RenderOneActivityEditor(div, actDesp, editMode);

                                div.Attributes["class"] = "command";
                            }
                        }
                    }
                }
            }
        }
Exemplo n.º 2
0
        private ActivityEditMode GetActivityDespEditMode(IWfActivityDescriptor actDesp, WfMainStreamActivityDescriptorCollection msActivities, Dictionary <string, Dictionary <string, string> > changeParams)
        {
            ActivityEditMode result = ActivityEditMode.None;

            if (actDesp != null)
            {
                if (actDesp.Properties.GetValue("AllowToBeAppended", true) &&
                    WfClientContext.Current.CurrentActivity.Descriptor.Properties.GetValue("AllowAppendActivityAfterUnstartActivities", true) &&
                    TargetActivityCanBeChangedByCurrentActivity(actDesp, "CanAppendActivityKeys", changeParams) &&
                    IsExceedMaximizeMainStreamActivityCount(msActivities.Count) == false ||
                    WfClientContext.Current.InAdminMode)
                {
                    result |= ActivityEditMode.Add;
                }

                if (ActivityGroupIsRunningOrPassed(actDesp) == false)
                {
                    if (actDesp.Properties.GetValue("AllowToBeModified", true) &&
                        WfClientContext.Current.CurrentActivity.Descriptor.Properties.GetValue("AllowModifyUnstartActivities", true) &&
                        TargetActivityCanBeChangedByCurrentActivity(actDesp, "CanModifyActivityKeys", changeParams) || WfClientContext.Current.InAdminMode)
                    {
                        result |= ActivityEditMode.Edit;
                    }

                    if (actDesp.Properties.GetValue("AllowToBeDeleted", true) &&
                        WfClientContext.Current.CurrentActivity.Descriptor.Properties.GetValue("AllowDeleteUnstartActivities", true) &&
                        TargetActivityCanBeChangedByCurrentActivity(actDesp, "CanDeleteActivityKeys", changeParams) || WfClientContext.Current.InAdminMode)
                    {
                        result |= ActivityEditMode.Delete;
                    }
                }

                RenderOneActivityEventArgs eventArgs = new RenderOneActivityEventArgs();
                eventArgs.CurrentActivity    = CurrentActivity;
                eventArgs.ActivityDescriptor = actDesp;
                eventArgs.EditMode           = result;

                OnRenderOneActivity(CurrentActivity, actDesp, eventArgs);

                result = eventArgs.EditMode;
            }

            return(result);
        }
Exemplo n.º 3
0
        private void RenderOneActivityEditor(Control parent, IWfActivityDescriptor actDesp, ActivityEditMode editMode)
        {
            if ((editMode & ActivityEditMode.Add) != ActivityEditMode.None)
            {
                HtmlAnchor addAnchor = CreateEditActivityAnchor(Translator.Translate(Define.DefaultCulture, "增加"), "add", false, actDesp);
                parent.Controls.Add(addAnchor);
            }

            if ((editMode & ActivityEditMode.Edit) != ActivityEditMode.None)
            {
                HtmlAnchor editAnchor = CreateEditActivityAnchor(Translator.Translate(Define.DefaultCulture, "修改"), "update",
                                                                 WfVariableDefine.UseSmallEditModeDescriptor(actDesp), actDesp);
                parent.Controls.Add(editAnchor);
            }

            if ((editMode & ActivityEditMode.Delete) != ActivityEditMode.None)
            {
                HtmlAnchor deleteAnchor = CreateEditActivityAnchor(Translator.Translate(Define.DefaultCulture, "删除"), "delete", false, actDesp);
                parent.Controls.Add(deleteAnchor);
            }
        }
		private void RenderOneActivityEditor(Control parent, IWfActivityDescriptor actDesp, ActivityEditMode editMode)
		{
			if ((editMode & ActivityEditMode.Add) != ActivityEditMode.None)
			{
				HtmlAnchor addAnchor = CreateEditActivityAnchor(Translator.Translate(Define.DefaultCulture, "增加"), "add", false, actDesp);
				parent.Controls.Add(addAnchor);
			}

			if ((editMode & ActivityEditMode.Edit) != ActivityEditMode.None)
			{
				HtmlAnchor editAnchor = CreateEditActivityAnchor(Translator.Translate(Define.DefaultCulture, "修改"), "update",
					WfVariableDefine.UseSmallEditModeDescriptor(actDesp), actDesp);
				parent.Controls.Add(editAnchor);
			}

			if ((editMode & ActivityEditMode.Delete) != ActivityEditMode.None)
			{
				HtmlAnchor deleteAnchor = CreateEditActivityAnchor(Translator.Translate(Define.DefaultCulture, "删除"), "delete", false, actDesp);
				parent.Controls.Add(deleteAnchor);
			}
		}