protected void btnOK_Click(object sender, EventArgs e)
        {
            string returnUrl = Request.QueryString.GetValue("ru", string.Empty);

            WfProcessDescriptor processDesc = new WfProcessDescriptor();

            processDesc.Key              = UuidHelper.NewUuidString();
            processDesc.Name             = "自由流程";
            processDesc.ApplicationName  = "秘书服务";
            processDesc.ProgramName      = "部门通知";
            processDesc.Url              = returnUrl;
            processDesc.DefaultTaskTitle = "${Subject}$";

            WfActivityDescriptor initAct = new WfActivityDescriptor("Initial", WfActivityType.InitialActivity);

            initAct.Name     = "起草";
            initAct.CodeName = "Initial Activity";
            initAct.Properties.SetValue("AutoSendUserTask", false);
            initAct.Properties.TrySetValue("AllowWithdraw", true);

            processDesc.Activities.Add(initAct);

            foreach (IUser user in processUsers.SelectedOuUserData)
            {
                string key = processDesc.FindNotUsedActivityKey();
                WfActivityDescriptor normalAct = new WfActivityDescriptor(key, WfActivityType.NormalActivity);
                normalAct.Name     = user.DisplayName;
                normalAct.CodeName = key;
                normalAct.Properties.SetValue("AutoAppendSecretary", true);
                //normalAct.ActivityType = WfActivityType.NormalActivity;

                WfUserResourceDescriptor userResourceDesc = new WfUserResourceDescriptor(user);
                normalAct.Resources.Add(userResourceDesc);

                processDesc.Activities.Add(normalAct);
            }

            WfActivityDescriptor completedAct = new WfActivityDescriptor("Completed", WfActivityType.CompletedActivity);

            completedAct.Name     = "完成";
            completedAct.CodeName = "Completed Activity";

            processDesc.Activities.Add(completedAct);

            for (int j = 0; j < processDesc.Activities.Count - 1; j++)
            {
                processDesc.Activities[j].ToTransitions.AddForwardTransition(processDesc.Activities[j + 1]);
            }

            WfProcessStartupParams startupParams = new WfProcessStartupParams();

            startupParams.ProcessDescriptor = processDesc;
            startupParams.Creator           = DeluxeIdentity.CurrentUser;
            startupParams.Assignees.Add(DeluxeIdentity.CurrentUser);
            startupParams.DefaultTaskTitle   = "${Subject}$";
            startupParams.RuntimeProcessName = "${Subject}$";
            startupParams.ResourceID         = UuidHelper.NewUuidString();
            startupParams.Department         = DeluxeIdentity.CurrentUser.Parent;

            string relativeParams = Request.QueryString["relativeParams"];

            if (relativeParams.IsNotEmpty())
            {
                startupParams.RelativeParams.CopyFrom(UriHelper.GetUriParamsCollection(relativeParams));
            }

            WfStartWorkflowExecutor executor = new WfStartWorkflowExecutor(WfClientContext.Current.OriginalActivity, startupParams);

            executor.AfterModifyWorkflow += new ExecutorEventHandler(executor_AfterModifyWorkflow);
            executor.Execute();

            IWfProcess process = WfClientContext.Current.OriginalActivity.Process;

            returnUrl = UriHelper.RemoveUriParams(returnUrl, "relativeParams");

            Response.Redirect(string.Format("{0}?resourceID={1}&activityID={2}",
                                            returnUrl, process.ResourceID, process.CurrentActivity.ID));
        }
        /// <summary>
        /// 准备流程
        /// </summary>
        private void PrepareProcess()
        {
            string returnUrl = Request.QueryString.GetValue("ru", string.Empty);

            WfProcessDescriptor processDesp = new WfProcessDescriptor();

            processDesp.Key              = UuidHelper.NewUuidString();
            processDesp.Name             = "自由流程";
            processDesp.ApplicationName  = "秘书服务";
            processDesp.ProgramName      = "部门通知";
            processDesp.Url              = returnUrl;
            processDesp.DefaultTaskTitle = "${Subject}$";

            WfActivityDescriptor initDesp = new WfActivityDescriptor("Initial", WfActivityType.InitialActivity);

            initDesp.Name     = "起草";
            initDesp.CodeName = "Initial Activity";
            initDesp.Properties.SetValue("AutoSendUserTask", false);

            processDesp.Activities.Add(initDesp);

            processDesp.Activities.Add(PrepareAURelativeActivityDescriptor(processDesp.FindNotUsedActivityKey()));

            WfActivityDescriptor completedActDesp = new WfActivityDescriptor("Completed", WfActivityType.CompletedActivity);

            completedActDesp.Name     = "完成";
            completedActDesp.CodeName = "Completed Activity";

            processDesp.Activities.Add(completedActDesp);

            for (int i = 0; i < processDesp.Activities.Count - 1; i++)
            {
                processDesp.Activities[i].ToTransitions.AddForwardTransition(processDesp.Activities[i + 1]);
            }

            WfProcessStartupParams startupParams = new WfProcessStartupParams();

            startupParams.ApplicationRuntimeParameters["AdministrativeUnit"] = "Group";
            startupParams.ApplicationRuntimeParameters["Amount"]             = "";
            startupParams.ApplicationRuntimeParameters["CostCenter"]         = "1001";
            startupParams.ProcessDescriptor = processDesp;
            startupParams.Creator           = DeluxeIdentity.CurrentUser;
            startupParams.Assignees.Add(DeluxeIdentity.CurrentUser);
            startupParams.DefaultTaskTitle = "${Subject}$";
            startupParams.ResourceID       = UuidHelper.NewUuidString();
            startupParams.Department       = DeluxeIdentity.CurrentUser.Parent;

            string relativeParams = Request.QueryString["relativeParams"];

            if (relativeParams.IsNotEmpty())
            {
                startupParams.RelativeParams.CopyFrom(UriHelper.GetUriParamsCollection(relativeParams));
            }

            WfStartWorkflowExecutor executor = new WfStartWorkflowExecutor(WfClientContext.Current.OriginalActivity, startupParams);

            executor.AfterModifyWorkflow += new ExecutorEventHandler(executor_AfterModifyWorkflow);
            executor.Execute();

            IWfProcess process = WfClientContext.Current.OriginalActivity.Process;

            returnUrl = UriHelper.RemoveUriParams(returnUrl, "relativeParams");

            HttpContext.Current.Response.Redirect(string.Format("{0}?resourceID={1}&activityID={2}",
                                                                returnUrl, process.ResourceID, process.CurrentActivity.ID));
        }
Exemple #3
0
        public static WfClientProcess Startup(WfClientStartupFreeStepsParameters parameters, string viewUrl)
        {
            parameters.NullCheck("parameters");
            parameters.Approvers.NullCheck("Approvers");

            (parameters.Approvers.Count > 0).FalseThrow("必须包含至少一个以上的审批人");

            WfProcessDescriptor processDesc = new WfProcessDescriptor();

            processDesc.Key             = UuidHelper.NewUuidString();
            processDesc.Name            = "自由流程";
            processDesc.ApplicationName = "秘书服务";
            processDesc.ProgramName     = "部门通知";

            WfActivityDescriptor initActDesp = new WfActivityDescriptor("Initial", WfActivityType.InitialActivity);

            initActDesp.Name     = "起草";
            initActDesp.CodeName = "Initial Activity";
            initActDesp.Properties.SetValue("AutoSendUserTask", false);
            initActDesp.Properties.TrySetValue("AllowWithdraw", true);

            processDesc.Activities.Add(initActDesp);

            foreach (IUser user in parameters.Approvers)
            {
                string key = processDesc.FindNotUsedActivityKey();
                WfActivityDescriptor normalActDesp = new WfActivityDescriptor(key, WfActivityType.NormalActivity);
                normalActDesp.Name     = user.DisplayName;
                normalActDesp.CodeName = key;
                normalActDesp.Properties.SetValue("AutoAppendSecretary", true);

                WfUserResourceDescriptor userResourceDesc = new WfUserResourceDescriptor(user);
                normalActDesp.Resources.Add(userResourceDesc);

                processDesc.Activities.Add(normalActDesp);
            }

            WfActivityDescriptor completedActDesp = new WfActivityDescriptor("Completed", WfActivityType.CompletedActivity);

            completedActDesp.Name     = "完成";
            completedActDesp.CodeName = "Completed Activity";

            processDesc.Activities.Add(completedActDesp);

            for (int j = 0; j < processDesc.Activities.Count - 1; j++)
            {
                processDesc.Activities[j].ToTransitions.AddForwardTransition(processDesc.Activities[j + 1]);
            }

            WfProcessStartupParams startupParams = new WfProcessStartupParams();

            startupParams.ProcessDescriptor = processDesc;
            startupParams.Creator           = DeluxeIdentity.CurrentUser;
            startupParams.Assignees.Add(DeluxeIdentity.CurrentUser);
            startupParams.DefaultTaskTitle   = "${Subject}$";
            startupParams.RuntimeProcessName = "${Subject}$";
            startupParams.ResourceID         = UuidHelper.NewUuidString();
            startupParams.Department         = DeluxeIdentity.CurrentUser.Parent;
            startupParams.DefaultUrl         = viewUrl;

            string subject = parameters.Title;

            if (subject.IsNullOrEmpty())
            {
                subject = "自由审批流程";
            }

            startupParams.ApplicationRuntimeParameters["Subject"] = subject;

            WfStartWorkflowExecutor executor = new WfStartWorkflowExecutor(null, startupParams, null, true);

            //添加审批意见
            executor.AfterSaveApplicationData += (dataContext) =>
            {
                PrepareStartupOpinions(dataContext, DeluxeIdentity.CurrentUser, "请审批");
            };

            IWfProcess process = executor.Execute();

            return(GetClientProcess(process));
        }
		/// <summary>
		/// 准备流程
		/// </summary>
		private void PrepareProcess()
		{
			string returnUrl = Request.QueryString.GetValue("ru", string.Empty);

			WfProcessDescriptor processDesp = new WfProcessDescriptor();

			processDesp.Key = UuidHelper.NewUuidString();
			processDesp.Name = "自由流程";
			processDesp.ApplicationName = "秘书服务";
			processDesp.ProgramName = "部门通知";
			processDesp.Url = returnUrl;
			processDesp.DefaultTaskTitle = "${Subject}$";

			WfActivityDescriptor initDesp = new WfActivityDescriptor("Initial", WfActivityType.InitialActivity);
			initDesp.Name = "起草";
			initDesp.CodeName = "Initial Activity";
			initDesp.Properties.SetValue("AutoSendUserTask", false);

			processDesp.Activities.Add(initDesp);

			processDesp.Activities.Add(PrepareAURelativeActivityDescriptor(processDesp.FindNotUsedActivityKey()));

			WfActivityDescriptor completedActDesp = new WfActivityDescriptor("Completed", WfActivityType.CompletedActivity);
			completedActDesp.Name = "完成";
			completedActDesp.CodeName = "Completed Activity";

			processDesp.Activities.Add(completedActDesp);

			for (int i = 0; i < processDesp.Activities.Count - 1; i++)
			{
				processDesp.Activities[i].ToTransitions.AddForwardTransition(processDesp.Activities[i + 1]);
			}

			WfProcessStartupParams startupParams = new WfProcessStartupParams();

			startupParams.ApplicationRuntimeParameters["AdministrativeUnit"] = "Group";
			startupParams.ApplicationRuntimeParameters["Amount"] = "";
			startupParams.ApplicationRuntimeParameters["CostCenter"] = "1001";
			startupParams.ProcessDescriptor = processDesp;
			startupParams.Creator = DeluxeIdentity.CurrentUser;
			startupParams.Assignees.Add(DeluxeIdentity.CurrentUser);
			startupParams.DefaultTaskTitle = "${Subject}$";
			startupParams.ResourceID = UuidHelper.NewUuidString();
			startupParams.Department = DeluxeIdentity.CurrentUser.Parent;

			string relativeParams = Request.QueryString["relativeParams"];

			if (relativeParams.IsNotEmpty())
				startupParams.RelativeParams.CopyFrom(UriHelper.GetUriParamsCollection(relativeParams));

			WfStartWorkflowExecutor executor = new WfStartWorkflowExecutor(WfClientContext.Current.OriginalActivity, startupParams);

			executor.AfterModifyWorkflow += new ExecutorEventHandler(executor_AfterModifyWorkflow);
			executor.Execute();

			IWfProcess process = WfClientContext.Current.OriginalActivity.Process;

			returnUrl = UriHelper.RemoveUriParams(returnUrl, "relativeParams");

			HttpContext.Current.Response.Redirect(string.Format("{0}?resourceID={1}&activityID={2}",
				returnUrl, process.ResourceID, process.CurrentActivity.ID));
		}
		protected void btnOK_Click(object sender, EventArgs e)
		{
			string returnUrl = Request.QueryString.GetValue("ru", string.Empty);

			WfProcessDescriptor processDesc = new WfProcessDescriptor();

			processDesc.Key = UuidHelper.NewUuidString();
			processDesc.Name = "自由流程";
			processDesc.ApplicationName = "秘书服务";
			processDesc.ProgramName = "部门通知";
			processDesc.Url = returnUrl;
			processDesc.DefaultTaskTitle = "${Subject}$";

			WfActivityDescriptor initAct = new WfActivityDescriptor("Initial", WfActivityType.InitialActivity);
			initAct.Name = "起草";
			initAct.CodeName = "Initial Activity";
			initAct.Properties.SetValue("AutoSendUserTask", false);
			initAct.Properties.TrySetValue("AllowWithdraw", true);

			processDesc.Activities.Add(initAct);

			foreach (IUser user in processUsers.SelectedOuUserData)
			{
				string key = processDesc.FindNotUsedActivityKey();
				WfActivityDescriptor normalAct = new WfActivityDescriptor(key, WfActivityType.NormalActivity);
				normalAct.Name = user.DisplayName;
				normalAct.CodeName = key;
				normalAct.Properties.SetValue("AutoAppendSecretary", true);
				//normalAct.ActivityType = WfActivityType.NormalActivity;

				WfUserResourceDescriptor userResourceDesc = new WfUserResourceDescriptor(user);
				normalAct.Resources.Add(userResourceDesc);

				processDesc.Activities.Add(normalAct);
			}

			WfActivityDescriptor completedAct = new WfActivityDescriptor("Completed", WfActivityType.CompletedActivity);
			completedAct.Name = "完成";
			completedAct.CodeName = "Completed Activity";

			processDesc.Activities.Add(completedAct);

			for (int j = 0; j < processDesc.Activities.Count - 1; j++)
			{
				processDesc.Activities[j].ToTransitions.AddForwardTransition(processDesc.Activities[j + 1]);
			}

			WfProcessStartupParams startupParams = new WfProcessStartupParams();
			startupParams.ProcessDescriptor = processDesc;
			startupParams.Creator = DeluxeIdentity.CurrentUser;
			startupParams.Assignees.Add(DeluxeIdentity.CurrentUser);
			startupParams.DefaultTaskTitle = "${Subject}$";
			startupParams.RuntimeProcessName = "${Subject}$";
			startupParams.ResourceID = UuidHelper.NewUuidString();
			startupParams.Department = DeluxeIdentity.CurrentUser.Parent;

			string relativeParams = Request.QueryString["relativeParams"];

			if (relativeParams.IsNotEmpty())
				startupParams.RelativeParams.CopyFrom(UriHelper.GetUriParamsCollection(relativeParams));

			WfStartWorkflowExecutor executor = new WfStartWorkflowExecutor(WfClientContext.Current.OriginalActivity, startupParams);

			executor.AfterModifyWorkflow += new ExecutorEventHandler(executor_AfterModifyWorkflow);
			executor.Execute();

			IWfProcess process = WfClientContext.Current.OriginalActivity.Process;

			returnUrl = UriHelper.RemoveUriParams(returnUrl, "relativeParams");

			Response.Redirect(string.Format("{0}?resourceID={1}&activityID={2}",
				returnUrl, process.ResourceID, process.CurrentActivity.ID));
		}