예제 #1
0
        public void WfBranchProcessTemplateDescriptorConverterTest()
        {
            WfConverterHelper.RegisterConverters();

            WfBranchProcessTemplateDescriptor branchProcessTempDesp = new WfBranchProcessTemplateDescriptor(Guid.NewGuid().ToString());

            branchProcessTempDesp.BlockingType    = WfBranchProcessBlockingType.WaitAnyoneBranchProcessComplete;
            branchProcessTempDesp.ExecuteSequence = WfBranchProcessExecuteSequence.Serial;


            string result = JSONSerializerExecute.Serialize(branchProcessTempDesp);

            Console.WriteLine(result);

            WfBranchProcessTemplateDescriptor deserializedBranchProcTempDesp = JSONSerializerExecute.Deserialize <WfBranchProcessTemplateDescriptor>(result);
            string reSerialized = JSONSerializerExecute.Serialize(deserializedBranchProcTempDesp);

            Assert.AreEqual(result, reSerialized);

            WfProcessDescriptor processDesp = (WfProcessDescriptor)WfProcessTestCommon.CreateSimpleProcessDescriptor();

            processDesp.InitialActivity.BranchProcessTemplates.Add(branchProcessTempDesp);

            string procResult = JSONSerializerExecute.Serialize(processDesp);

            Console.WriteLine(procResult);

            WfProcessDescriptor deserializedProcDesp = JSONSerializerExecute.Deserialize <WfProcessDescriptor>(procResult);
            string procReSerialized = JSONSerializerExecute.Serialize(deserializedProcDesp);

            Assert.AreEqual(procResult, procReSerialized);
        }
예제 #2
0
        protected void buttonCallBranchProcess_Click(object sender, EventArgs e)
        {
            WfServiceAddressDefinition address = new WfServiceAddressDefinition(WfServiceRequestMethod.Post,
                                                                                "http://localhost/MCSWebApp/WfFormTemplate/Services/WfProcessService.svc",
                                                                                WfServiceContentType.Json);

            WfServiceOperationDefinition definition = new WfServiceOperationDefinition(address, "StartBranchProcesses");

            WfServiceOperationParameter p1 = new WfServiceOperationParameter("ownerActivityID", UuidHelper.NewUuidString());

            IWfBranchProcessTemplateDescriptor template       = new WfBranchProcessTemplateDescriptor("Test");
            WfBranchProcessTransferParams      transferParams = new WfBranchProcessTransferParams(template);

            WfServiceOperationParameter p2 = new WfServiceOperationParameter("branchTransferParams", WfSvcOperationParameterType.RuntimeParameter, "transferParams");

            definition.Params.Add(p1);
            definition.Params.Add(p2);

            WfServiceInvoker invoker = new WfServiceInvoker(definition);

            WfServiceInvoker.InvokeContext["transferParams"] = transferParams;

            object result = invoker.Invoke();

            resultLabel.Text = Server.HtmlEncode(result.ToString());
        }
		protected void buttonCallBranchProcess_Click(object sender, EventArgs e)
		{
			WfServiceAddressDefinition address = new WfServiceAddressDefinition(WfServiceRequestMethod.Post,
				"http://localhost/MCSWebApp/WfFormTemplate/Services/WfProcessService.svc",
				WfServiceContentType.Json);

			WfServiceOperationDefinition definition = new WfServiceOperationDefinition(address, "StartBranchProcesses");

			WfServiceOperationParameter p1 = new WfServiceOperationParameter("ownerActivityID", UuidHelper.NewUuidString());

			IWfBranchProcessTemplateDescriptor template = new WfBranchProcessTemplateDescriptor("Test");
			WfBranchProcessTransferParams transferParams = new WfBranchProcessTransferParams(template);

			WfServiceOperationParameter p2 = new WfServiceOperationParameter("branchTransferParams", WfSvcOperationParameterType.RuntimeParameter, "transferParams");

			definition.Params.Add(p1);
			definition.Params.Add(p2);

			WfServiceInvoker invoker = new WfServiceInvoker(definition);

			WfServiceInvoker.InvokeContext["transferParams"] = transferParams;

			object result = invoker.Invoke();

			resultLabel.Text = Server.HtmlEncode(result.ToString());
		}
예제 #4
0
        public static IWfBranchProcessTemplateDescriptor CreateConsignTemplate(WfBranchProcessExecuteSequence execSequence, WfBranchProcessBlockingType blockingType)
        {
            WfBranchProcessTemplateDescriptor template = new WfBranchProcessTemplateDescriptor("ConsignTemplateKey");

            template.BranchProcessKey = WfProcessDescriptorManager.DefaultConsignProcessKey;
            template.ExecuteSequence  = execSequence;
            template.BlockingType     = blockingType;
            return(template);
        }
        public void ClientBranchProcessTemplateToServer()
        {
            WfClientBranchProcessTemplateDescriptor client = PrepareClientBranchProcessTemplate();

            WfBranchProcessTemplateDescriptor server = null;

            WfClientBranchProcessTemplateDescriptorConverter.Instance.ClientToServer(client, ref server);

            client.AreSame(server);
        }
        public void ServerBranchProcessTemplateToClient()
        {
            WfBranchProcessTemplateDescriptor server = PrepareServerBranchProcessTemplate();

            WfClientBranchProcessTemplateDescriptor client = null;

            WfClientBranchProcessTemplateDescriptorConverter.Instance.ServerToClient(server, ref client);

            client.AreSame(server);
        }
예제 #7
0
        public static IWfBranchProcessTemplateDescriptor CreateTemplate(string key, IUser user)
        {
            WfBranchProcessTemplateDescriptor template = new WfBranchProcessTemplateDescriptor(key);

            template.BranchProcessKey = WfProcessDescriptorManager.DefaultConsignProcessKey;
            template.ExecuteSequence  = WfBranchProcessExecuteSequence.Parallel;
            template.BlockingType     = WfBranchProcessBlockingType.WaitAllBranchProcessesComplete;
            template.Resources.Add(new WfUserResourceDescriptor(user));

            return(template);
        }
예제 #8
0
        public void ClientToServer(WfClientBranchProcessTemplateCollection client, WfBranchProcessTemplateCollection server)
        {
            client.NullCheck("client");
            server.NullCheck("server");

            server.Clear();

            foreach (WfClientBranchProcessTemplateDescriptor ct in client)
            {
                WfBranchProcessTemplateDescriptor st = null;

                WfClientBranchProcessTemplateDescriptorConverter.Instance.ClientToServer(ct, ref st);

                server.Add(st);
            }
        }
예제 #9
0
        public void CreateProcessDescriptorWithBranchProcDesp()
        {
            //分支流程描述
            IWfProcessDescriptor procDesp = WfProcessTestCommon.CreateSimpleProcessDescriptor();

            //主流程描述
            IWfProcessDescriptor processDesp = WfProcessTestCommon.CreateProcessDescriptor();

            WfBranchProcessTemplateDescriptor data = new WfBranchProcessTemplateDescriptor("branchProcessTemplateDesp");

            data.BlockingType     = WfBranchProcessBlockingType.WaitAllBranchProcessesComplete;
            data.ExecuteSequence  = WfBranchProcessExecuteSequence.Parallel;
            data.BranchProcessKey = procDesp.Key;

            processDesp.Activities[1].BranchProcessTemplates.Add(data);
        }
예제 #10
0
        public WfBranchProcessTransferParams ClientToServer(WfClientBranchProcessTransferParams client, ref WfBranchProcessTransferParams server)
        {
            client.NullCheck("client");
            client.Template.NullCheck("Template");

            if (server == null)
            {
                server = new WfBranchProcessTransferParams();
            }

            WfBranchProcessTemplateDescriptor serverTemplate = null;

            WfClientBranchProcessTemplateDescriptorConverter.Instance.ClientToServer(client.Template, ref serverTemplate);
            server.Template = serverTemplate;

            WfClientBranchProcessStartupParamsCollectionConverter.Instance.ClientToServer(client.BranchParams, server.BranchParams);

            return(server);
        }
        internal static WfBranchProcessTemplateDescriptor PrepareServerBranchProcessTemplate()
        {
            WfBranchProcessTemplateDescriptor server = new WfBranchProcessTemplateDescriptor("B1");

            server.BlockingType           = WfBranchProcessBlockingType.WaitAllBranchProcessesComplete;
            server.BranchProcessKey       = "Branch1";
            server.DefaultProcessName     = "Test Process";
            server.Condition.Expression   = "Amount > 0";
            server.SubProcessApprovalMode = WfSubProcessApprovalMode.LastActivityDecide;
            server.ExecuteSequence        = WfBranchProcessExecuteSequence.Parallel;

            server.Resources.Add(new WfUserResourceDescriptor((IUser)Consts.Users["Requestor"].ToOguObject()));
            server.CancelSubProcessNotifier.Add(new WfUserResourceDescriptor((IUser)Consts.Users["CEO"].ToOguObject()));
            server.RelativeLinks.Add(new WfRelativeLinkDescriptor("R1")
            {
                Category = "Doc Lib", Url = "http://www.baidu.com"
            });

            return(server);
        }
예제 #12
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!this.Page.IsPostBack)
            {
                PropertyEditorRegister();

                WfConverterHelper.RegisterConverters();
                WfBranchProcessTemplateDescriptor branchProcessTempDesc = new WfBranchProcessTemplateDescriptor(string.Empty);
                //branchProcessTempDesc.BlockingType = WfBranchProcessBlockingType.WaitAllBranchProcessesComplete;
                //branchProcessTempDesc.ExecuteSequence = WfBranchProcessExecuteSequence.Parallel;
                this.hiddenBranchProcessTemplate.Value = JSONSerializerExecute.Serialize(branchProcessTempDesc);
                this.hiddenKey.Value = branchProcessTempDesc.Key;

                #region "用hidden properties 初始化没有属性值"
                //PropertyDefineCollection propetydefines = PropertyDefineCollection.CreatePropertiesFromConfiguration(WfActivitySettings.GetConfig().PropertyGroups["BasicBranchProcessTemplateProperties"]);
                //PropertyValueCollection properties = new PropertyValueCollection();
                //properties.InitFromPropertyDefineCollection(propetydefines);
                //this.hiddenBrnachConfigProperties.Value = JSONSerializerExecute.Serialize(properties);
                #endregion
            }
        }
		protected void Page_Load(object sender, EventArgs e)
		{
			if (!this.Page.IsPostBack)
			{
				PropertyEditorRegister();

				WfConverterHelper.RegisterConverters();
				WfBranchProcessTemplateDescriptor branchProcessTempDesc = new WfBranchProcessTemplateDescriptor(string.Empty);
				//branchProcessTempDesc.BlockingType = WfBranchProcessBlockingType.WaitAllBranchProcessesComplete;
				//branchProcessTempDesc.ExecuteSequence = WfBranchProcessExecuteSequence.Parallel;
				this.hiddenBranchProcessTemplate.Value = JSONSerializerExecute.Serialize(branchProcessTempDesc);
				this.hiddenKey.Value = branchProcessTempDesc.Key;

				#region "用hidden properties 初始化没有属性值"
				//PropertyDefineCollection propetydefines = PropertyDefineCollection.CreatePropertiesFromConfiguration(WfActivitySettings.GetConfig().PropertyGroups["BasicBranchProcessTemplateProperties"]);
				//PropertyValueCollection properties = new PropertyValueCollection();
				//properties.InitFromPropertyDefineCollection(propetydefines);
				//this.hiddenBrnachConfigProperties.Value = JSONSerializerExecute.Serialize(properties);
				#endregion
			}
		}
예제 #14
0
		/// <summary>
		/// 构造缺省的会签模板
		/// </summary>
		/// <param name="key"></param>
		/// <param name="blockingType"></param>
		/// <returns></returns>
		public static IWfBranchProcessTemplateDescriptor CreateDefaultConsignTemplate(
			string key, 
			WfBranchProcessExecuteSequence execSequence,
			WfBranchProcessBlockingType blockingType,
			IEnumerable<IUser> users)
		{
			key.CheckStringIsNullOrEmpty("key");
			users.NullCheck("users");

			WfBranchProcessTemplateDescriptor template = new WfBranchProcessTemplateDescriptor(key);

			template.BranchProcessKey = WfProcessDescriptorManager.DefaultConsignProcessKey;
			template.ExecuteSequence = execSequence;
			template.BlockingType = blockingType;

			users = users.Distinct(new OguObjectIDEqualityComparer<IUser>());

			foreach (IUser user in users)
				template.Resources.Add(new WfUserResourceDescriptor(user));
			
			return template;
		}
		private void SetPropertiesValue(WfBranchProcessTemplateDescriptor branchTemplate, string propertyName, object input)
		{
			if (branchTemplate.Properties.ContainsKey(propertyName))
			{
				string itemValue = JSONSerializerExecute.Serialize(input);
				branchTemplate.Properties.SetValue<string>(propertyName, itemValue);
			}
		}
        public void CreateProcessDescriptorWithBranchProcDesp()
        {
            //分支流程描述
            IWfProcessDescriptor procDesp = WfProcessTestCommon.CreateSimpleProcessDescriptor();

            //主流程描述
            IWfProcessDescriptor processDesp = WfProcessTestCommon.CreateProcessDescriptor();

            WfBranchProcessTemplateDescriptor data = new WfBranchProcessTemplateDescriptor("branchProcessTemplateDesp");
            data.BlockingType = WfBranchProcessBlockingType.WaitAllBranchProcessesComplete;
            data.ExecuteSequence = WfBranchProcessExecuteSequence.Parallel;
            data.BranchProcessKey = procDesp.Key;

            processDesp.Activities[1].BranchProcessTemplates.Add(data);
        }
예제 #17
0
		private static IWfBranchProcessTemplateDescriptor CreateConsignTemplate(WfBranchProcessExecuteSequence execSequence, WfBranchProcessBlockingType blockingType)
		{
			string key = "WfBranchProcessTemplateDescriptorKey";

			WfBranchProcessTemplateDescriptor template = new WfBranchProcessTemplateDescriptor(key);

			template.BranchProcessKey = WfProcessDescriptorManager.DefaultConsignProcessKey;
			template.ExecuteSequence = execSequence;
			template.BlockingType = blockingType;

			return template;
		}
예제 #18
0
        public static IWfBranchProcessTemplateDescriptor CreateTemplate(string key, IUser user)
        {
            WfBranchProcessTemplateDescriptor template = new WfBranchProcessTemplateDescriptor(key);

            template.BranchProcessKey = WfProcessDescriptorManager.DefaultConsignProcessKey;
            template.ExecuteSequence = WfBranchProcessExecuteSequence.Parallel;
            template.BlockingType = WfBranchProcessBlockingType.WaitAllBranchProcessesComplete;
            template.Resources.Add(new WfUserResourceDescriptor(user));

            return template;
        }
		public void WfBranchProcessTemplateDescriptorConverterTest()
		{
			WfConverterHelper.RegisterConverters();

			WfBranchProcessTemplateDescriptor branchProcessTempDesp = new WfBranchProcessTemplateDescriptor(Guid.NewGuid().ToString());
			branchProcessTempDesp.BlockingType = WfBranchProcessBlockingType.WaitAnyoneBranchProcessComplete;
			branchProcessTempDesp.ExecuteSequence = WfBranchProcessExecuteSequence.Serial;


			string result = JSONSerializerExecute.Serialize(branchProcessTempDesp);
			Console.WriteLine(result);

			WfBranchProcessTemplateDescriptor deserializedBranchProcTempDesp = JSONSerializerExecute.Deserialize<WfBranchProcessTemplateDescriptor>(result);
			string reSerialized = JSONSerializerExecute.Serialize(deserializedBranchProcTempDesp);

			Assert.AreEqual(result, reSerialized);

			WfProcessDescriptor processDesp = (WfProcessDescriptor)WfProcessTestCommon.CreateSimpleProcessDescriptor();

			processDesp.InitialActivity.BranchProcessTemplates.Add(branchProcessTempDesp);

			string procResult = JSONSerializerExecute.Serialize(processDesp);
			Console.WriteLine(procResult);

			WfProcessDescriptor deserializedProcDesp = JSONSerializerExecute.Deserialize<WfProcessDescriptor>(procResult);
			string procReSerialized = JSONSerializerExecute.Serialize(deserializedProcDesp);

			Assert.AreEqual(procResult, procReSerialized);
		}
        /// <summary>
        /// 
        /// </summary>
        /// <param name="newActDesp"></param>
        /// <param name="createParams"></param>
        private static void AdjustActivityDescriptorProperties(WfActivityDescriptor newActDesp, WfActivityDescriptorCreateParams createParams)
        {
            newActDesp.Name = createParams.Name;

            if (createParams.Variables != null)
            {
                foreach (WfVariableDescriptor variable in createParams.Variables)
                {
                    if (newActDesp.Properties.ContainsKey(variable.Key) == false)
                    {
                        PropertyDefine pd = new PropertyDefine();

                        pd.Name = variable.Key;
                        pd.DataType = PropertyDataType.Boolean;
                        pd.DefaultValue = variable.OriginalValue;

                        newActDesp.Properties.Add(new PropertyValue(pd));
                    }

                    newActDesp.Properties.SetValue(variable.Key, variable.ActualValue);
                }
            }

            if (createParams.Users != null)
            {
                newActDesp.Resources.Clear();
                createParams.Users.ForEach(u => newActDesp.Resources.Add(new WfUserResourceDescriptor(u)));
            }

            if (createParams.CirculateUsers != null)
            {
                newActDesp.EnterEventReceivers.Clear();
                createParams.CirculateUsers.ForEach(u => newActDesp.EnterEventReceivers.Add(new WfUserResourceDescriptor(u)));
            }

            newActDesp.BranchProcessTemplates.Clear();

            if (createParams.AllAgreeWhenConsign && newActDesp.Resources.Count > 1)
            {
                newActDesp.Properties.SetValue("AutoMoveAfterPending", true);

				if (newActDesp.BranchProcessTemplates.ContainsKey(WfTemplateBuilder.AutoStartSubProcessTemplateKey))
					newActDesp.BranchProcessTemplates.Remove(t => t.Key == WfTemplateBuilder.AutoStartSubProcessTemplateKey);

				WfBranchProcessTemplateDescriptor template = new WfBranchProcessTemplateDescriptor(WfTemplateBuilder.AutoStartSubProcessTemplateKey);

                template.BranchProcessKey = WfProcessDescriptorManager.DefaultConsignProcessKey;
                template.ExecuteSequence = WfBranchProcessExecuteSequence.Parallel;
                template.BlockingType = WfBranchProcessBlockingType.WaitAllBranchProcessesComplete;

                template.Resources.CopyFrom(newActDesp.Resources);

                newActDesp.BranchProcessTemplates.Add(template);
            }
        }