Exemple #1
0
        private static WfClientTransferParams PrepareClientTransferParams()
        {
            WfClientTransferParams transferParams = new WfClientTransferParams("N1");

            transferParams.Operator = Consts.Users["Requestor"];
            transferParams.FromTransitionDescriptorKey = "L1";
            transferParams.Assignees.Add(Consts.Users["Approver1"]);

            WfClientBranchProcessTemplateDescriptor template             = BranchProcessTemplateConverterTest.PrepareClientBranchProcessTemplate();
            WfClientBranchProcessTransferParams     branchTransferParams = new WfClientBranchProcessTransferParams(template);

            WfClientBranchProcessStartupParams branchStartupParams = new WfClientBranchProcessStartupParams(Consts.Users["CFO"]);

            branchStartupParams.DefaultTaskTitle = "Hello Branch";
            branchStartupParams.Department       = Consts.Departments["RequestorOrg"];
            branchStartupParams.ApplicationRuntimeParameters["Amount"] = 1024;
            branchStartupParams.ResourceID                 = UuidHelper.NewUuidString();
            branchStartupParams.StartupContext             = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
            branchStartupParams.RelativeParams["Relative"] = "Hello world";

            branchTransferParams.BranchParams.Add(branchStartupParams);

            transferParams.BranchTransferParams.Add(branchTransferParams);

            return(transferParams);
        }
        public void ServerBranchProcessTemplateToClient()
        {
            WfBranchProcessTemplateDescriptor server = PrepareServerBranchProcessTemplate();

            WfClientBranchProcessTemplateDescriptor client = null;

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

            client.AreSame(server);
        }
        public void ClientBranchProcessTemplateToServer()
        {
            WfClientBranchProcessTemplateDescriptor client = PrepareClientBranchProcessTemplate();

            WfBranchProcessTemplateDescriptor server = null;

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

            client.AreSame(server);
        }
Exemple #4
0
        public override object Deserialize(IDictionary <string, object> dictionary, Type type, JavaScriptSerializer serializer)
        {
            WfClientBranchProcessTemplateDescriptor template = (WfClientBranchProcessTemplateDescriptor)base.Deserialize(dictionary, type, serializer);

            template.Condition = JSONSerializerExecute.Deserialize <WfClientConditionDescriptor>(dictionary.GetValue("condition", (object)null));

            JSONSerializerExecute.FillDeserializedCollection <WfClientResourceDescriptor>(dictionary.GetValue("resources", (object)null), template.Resources);
            JSONSerializerExecute.FillDeserializedCollection <WfClientResourceDescriptor>(dictionary.GetValue("cancelSubProcessNotifier", (object)null), template.CancelSubProcessNotifier);
            JSONSerializerExecute.FillDeserializedCollection <WfClientRelativeLinkDescriptor>(dictionary.GetValue("relativeLinks", (object)null), template.RelativeLinks);

            return(template);
        }
Exemple #5
0
        public override IDictionary <string, object> Serialize(object obj, JavaScriptSerializer serializer)
        {
            Dictionary <string, object>             dictionary = (Dictionary <string, object>)base.Serialize(obj, serializer);
            WfClientBranchProcessTemplateDescriptor template   = (WfClientBranchProcessTemplateDescriptor)obj;

            dictionary.AddNonDefaultValue("condition", template.Condition);

            dictionary.Add("resources", template.Resources);
            dictionary.Add("cancelSubProcessNotifier", template.CancelSubProcessNotifier);
            dictionary.Add("relativeLinks", template.RelativeLinks);

            return(dictionary);
        }
        public void ClientBranchProcessTemplateSerializationTest()
        {
            WfClientJsonConverterHelper.Instance.RegisterConverters();

            WfClientBranchProcessTemplateDescriptor client = PrepareClientBranchProcessTemplate();

            string data = JSONSerializerExecute.Serialize(client);

            Console.WriteLine(data);

            WfClientBranchProcessTemplateDescriptor deserialized = JSONSerializerExecute.Deserialize <WfClientBranchProcessTemplateDescriptor>(data);

            client.AreSame(deserialized);
        }
Exemple #7
0
        public void ServerToClient(WfBranchProcessTemplateCollection server, WfClientBranchProcessTemplateCollection client)
        {
            client.NullCheck("client");
            server.NullCheck("server");

            client.Clear();

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

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

                client.Add(ct);
            }
        }
        internal static WfClientBranchProcessTemplateDescriptor PrepareClientBranchProcessTemplate()
        {
            WfClientBranchProcessTemplateDescriptor client = new WfClientBranchProcessTemplateDescriptor("B1");

            client.BlockingType           = WfClientBranchProcessBlockingType.WaitAllBranchProcessesComplete;
            client.BranchProcessKey       = "Branch1";
            client.DefaultProcessName     = "Test Process";
            client.Condition.Expression   = "Amount > 0";
            client.SubProcessApprovalMode = WfClientSubProcessApprovalMode.LastActivityDecide;
            client.ExecuteSequence        = WfClientBranchProcessExecuteSequence.Parallel;

            client.Resources.Add(new WfClientUserResourceDescriptor(Consts.Users["Requestor"]));
            client.CancelSubProcessNotifier.Add(new WfClientUserResourceDescriptor(Consts.Users["CEO"]));
            client.RelativeLinks.Add(new WfClientRelativeLinkDescriptor("R1")
            {
                Category = "Doc Lib", Url = "http://www.baidu.com"
            });

            return(client);
        }
Exemple #9
0
        public static void AreSame(this WfClientBranchProcessTemplateDescriptor expected, IWfBranchProcessTemplateDescriptor actual)
        {
            if (expected != null && actual != null)
            {
                Assert.AreEqual(expected.BlockingType, actual.BlockingType.ToClientBranchProcessBlockingType());
                Assert.AreEqual(expected.SubProcessApprovalMode, actual.SubProcessApprovalMode.ToClientSubProcessApprovalMode());
                Assert.AreEqual(expected.ExecuteSequence, actual.ExecuteSequence.ToClientBranchProcessExecuteSequence());
                Assert.AreEqual(expected.BranchProcessKey, actual.BranchProcessKey);
                Assert.AreEqual(expected.DefaultProcessName, actual.DefaultProcessName);
                Assert.AreEqual(expected.DefaultTaskTitle, actual.DefaultTaskTitle);

                expected.Condition.AreSame(actual.Condition);

                expected.Resources.AssertResources(actual.Resources);
                expected.CancelSubProcessNotifier.AssertResources(actual.CancelSubProcessNotifier);
                expected.RelativeLinks.AssertRelativeLinks(actual.RelativeLinks);
            }
            else
            {
                Assert.AreEqual(expected, actual);
            }
        }
        public WfClientBranchProcessTransferParams(WfClientBranchProcessTemplateDescriptor template)
        {
            template.NullCheck("template");

            this._Template = template;
        }
        public static void AreSame(this WfClientBranchProcessTemplateDescriptor expected, WfClientBranchProcessTemplateDescriptor actual)
        {
            if (expected != null && actual != null)
            {
                Assert.AreEqual(expected.BlockingType, actual.BlockingType);
                Assert.AreEqual(expected.SubProcessApprovalMode, actual.SubProcessApprovalMode);
                Assert.AreEqual(expected.ExecuteSequence, actual.ExecuteSequence);
                Assert.AreEqual(expected.BranchProcessKey, actual.BranchProcessKey);
                Assert.AreEqual(expected.DefaultProcessName, actual.DefaultProcessName);
                Assert.AreEqual(expected.DefaultTaskTitle, actual.DefaultTaskTitle);

                expected.Condition.AreSame(actual.Condition);

                expected.Resources.AssertResources(actual.Resources);
                expected.CancelSubProcessNotifier.AssertResources(actual.CancelSubProcessNotifier);
                expected.RelativeLinks.AssertRelativeLinks(actual.RelativeLinks);
            }
            else
                Assert.AreEqual(expected, actual);
        }