예제 #1
0
        public WfRelativeLinkDescriptorCollection FilterByCategory(string category)
        {
            category.CheckStringIsNullOrEmpty("category");

            WfRelativeLinkDescriptorCollection result = new WfRelativeLinkDescriptorCollection();

            result.CopyFrom(this.FindAll(link => link.Category == category));

            return(result);
        }
        private void SetProcessProperties(WfProcessDescriptor processDesp, Dictionary <string, object> processProperties, IDictionary <string, object> dictionary)
        {
            if (processProperties.ContainsKey("RelativeLinks"))
            {
                processDesp.RelativeLinks.CopyFrom((WfRelativeLinkDescriptorCollection)processProperties["RelativeLinks"]);
            }
            else if (dictionary.ContainsKey("RelativeLinks"))
            {
                WfRelativeLinkDescriptorCollection relativeLinks = JSONSerializerExecute.Deserialize <WfRelativeLinkDescriptorCollection>(dictionary["Variables"]);
                processDesp.RelativeLinks.CopyFrom(relativeLinks);
            }

            if (processProperties.ContainsKey("CancelEventReceivers"))
            {
                processDesp.CancelEventReceivers.CopyFrom((WfResourceDescriptorCollection)processProperties["CancelEventReceivers"]);
            }
            else if (dictionary.ContainsKey("CancelEventReceivers"))
            {
                WfResourceDescriptorCollection cancelEventReceivers = JSONSerializerExecute.Deserialize <WfResourceDescriptorCollection>(dictionary["CancelEventReceivers"]);
                processDesp.CancelEventReceivers.CopyFrom(cancelEventReceivers);
            }

            if (processProperties.ContainsKey("CompleteEventReceivers"))
            {
                processDesp.CompleteEventReceivers.CopyFrom((WfResourceDescriptorCollection)processProperties["CompleteEventReceivers"]);
            }
            else if (dictionary.ContainsKey("CompleteEventReceivers"))
            {
                WfResourceDescriptorCollection completeEventReceivers = JSONSerializerExecute.Deserialize <WfResourceDescriptorCollection>(dictionary["CompleteEventReceivers"]);
                processDesp.CompleteEventReceivers.CopyFrom(completeEventReceivers);
            }

            if (processProperties.ContainsKey("CancelBeforeExecuteServices"))
            {
                processDesp.CancelBeforeExecuteServices.CopyFrom((WfServiceOperationDefinitionCollection)processProperties["CancelBeforeExecuteServices"]);
            }
            else if (dictionary.ContainsKey("CancelBeforeExecuteServices"))
            {
                WfServiceOperationDefinitionCollection cancelBeforeExecuteServices = JSONSerializerExecute.Deserialize <WfServiceOperationDefinitionCollection>(dictionary["CancelBeforeExecuteServices"]);
                processDesp.CancelBeforeExecuteServices.CopyFrom(cancelBeforeExecuteServices);
            }

            if (processProperties.ContainsKey("CancelAfterExecuteServices"))
            {
                processDesp.CancelAfterExecuteServices.CopyFrom((WfServiceOperationDefinitionCollection)processProperties["CancelAfterExecuteServices"]);
            }
            else if (dictionary.ContainsKey("CancelAfterExecuteServices"))
            {
                WfServiceOperationDefinitionCollection canceAfterExecuteServices = JSONSerializerExecute.Deserialize <WfServiceOperationDefinitionCollection>(dictionary["CancelAfterExecuteServices"]);
                processDesp.CancelAfterExecuteServices.CopyFrom(canceAfterExecuteServices);
            }

            if (processProperties.ContainsKey("InternalRelativeUsers"))
            {
                processDesp.InternalRelativeUsers.CopyFrom((WfResourceDescriptorCollection)processProperties["InternalRelativeUsers"]);
            }
            else if (dictionary.ContainsKey("InternalRelativeUsers"))
            {
                WfResourceDescriptorCollection interRelUser = JSONSerializerExecute.Deserialize <WfResourceDescriptorCollection>(dictionary["InternalRelativeUsers"]);
                processDesp.InternalRelativeUsers.CopyFrom(interRelUser);
            }

            if (processProperties.ContainsKey("ExternalUsers"))
            {
                processDesp.ExternalUsers.CopyFrom((WfExternalUserCollection)processProperties["ExternalUsers"]);
            }
            else if (dictionary.ContainsKey("ExternalUsers"))
            {
                WfExternalUserCollection externalUser = JSONSerializerExecute.Deserialize <WfExternalUserCollection>(dictionary["ExternalUsers"]);
                processDesp.ExternalUsers.CopyFrom(externalUser);
            }

            if (processProperties.ContainsKey("Variables"))
            {
                processDesp.Variables.CopyFrom((WfVariableDescriptorCollection)processProperties["Variables"]);
            }
            else if (dictionary.ContainsKey("Variables"))
            {
                WfVariableDescriptorCollection externalUser = JSONSerializerExecute.Deserialize <WfVariableDescriptorCollection>(dictionary["Variables"]);
                processDesp.Variables.CopyFrom(externalUser);
            }

            if (processProperties.ContainsKey("ParametersNeedToBeCollected"))
            {
                processDesp.ParametersNeedToBeCollected.CopyFrom((WfParameterNeedToBeCollected)processProperties["ParametersNeedToBeCollected"]);
            }
            else if (dictionary.ContainsKey("ParametersNeedToBeCollected"))
            {
                WfParameterNeedToBeCollected parametersNeedToBeCollected = JSONSerializerExecute.Deserialize <WfParameterNeedToBeCollected>(dictionary["ParametersNeedToBeCollected"]);
                processDesp.ParametersNeedToBeCollected.CopyFrom(parametersNeedToBeCollected);
            }
        }
예제 #3
0
        public override object Deserialize(IDictionary <string, object> dictionary, Type type, System.Web.Script.Serialization.JavaScriptSerializer serializer)
        {
            string key = DictionaryHelper.GetValue(dictionary, "Key", string.Empty);

            WfBranchProcessTemplateDescriptor branchProcTempDesp = (WfBranchProcessTemplateDescriptor)CreateInstance(key, dictionary, type, serializer);

            branchProcTempDesp.Name        = DictionaryHelper.GetValue(dictionary, "Name", string.Empty);;
            branchProcTempDesp.Enabled     = DictionaryHelper.GetValue(dictionary, "Enabled", false);
            branchProcTempDesp.Description = DictionaryHelper.GetValue(dictionary, "Description", string.Empty);

            if (dictionary.ContainsKey("Properties"))
            {
                branchProcTempDesp.Properties.Clear();

                PropertyValueCollection properties = JSONSerializerExecute.Deserialize <PropertyValueCollection>(dictionary["Properties"]);

                foreach (PropertyValue pv in properties)
                {
                    switch (pv.Definition.Name)
                    {
                    case "Resources":
                        WfResourceDescriptorCollection resources = JSONSerializerExecute.Deserialize <WfResourceDescriptorCollection>(pv.StringValue);
                        branchProcTempDesp.Resources.Clear();
                        if (resources != null)
                        {
                            branchProcTempDesp.Resources.CopyFrom(resources);
                        }
                        break;

                    case "CancelSubProcessNotifier":
                        WfResourceDescriptorCollection cancelSubProcessNotifierResources = JSONSerializerExecute.Deserialize <WfResourceDescriptorCollection>(pv.StringValue);
                        branchProcTempDesp.CancelSubProcessNotifier.Clear();
                        if (cancelSubProcessNotifierResources != null)
                        {
                            branchProcTempDesp.CancelSubProcessNotifier.CopyFrom(cancelSubProcessNotifierResources);
                        }
                        break;

                    case "Condition":
                        branchProcTempDesp.Condition       = JSONSerializerExecute.Deserialize <WfConditionDescriptor>(pv.StringValue);
                        branchProcTempDesp.Condition.Owner = branchProcTempDesp;
                        break;

                    case "OperationDefinition":
                        branchProcTempDesp.OperationDefinition = JSONSerializerExecute.Deserialize <WfServiceOperationDefinition>(pv.StringValue);
                        break;

                    case "BranchProcessKey":
                        branchProcTempDesp.Properties.Add(pv);
                        break;

                    case "RelativeLinks":
                        WfRelativeLinkDescriptorCollection links = JSONSerializerExecute.Deserialize <WfRelativeLinkDescriptorCollection>(pv.StringValue);
                        branchProcTempDesp.RelativeLinks.Clear();

                        if (links != null)
                        {
                            branchProcTempDesp.RelativeLinks.CopyFrom(links);
                        }
                        break;

                    default:
                        branchProcTempDesp.Properties.Add(pv);
                        break;
                    }
                }
            }

            return(branchProcTempDesp);
        }
        private void SetActivityProperties(WfActivityDescriptor actDesp, Dictionary <string, object> activityProperties, IDictionary <string, object> dictionary)
        {
            if (activityProperties.ContainsKey("Variables"))
            {
                var item = (WfVariableDescriptorCollection)activityProperties["Variables"];
                if (item != null)
                {
                    actDesp.Variables.CopyFrom(item);
                }
            }
            else if (dictionary.ContainsKey("Variables"))
            {
                WfVariableDescriptorCollection variables = JSONSerializerExecute.Deserialize <WfVariableDescriptorCollection>(dictionary["Variables"]);
                actDesp.Variables.CopyFrom(variables);
            }

            if (activityProperties.ContainsKey("Condition"))
            {
                var item = (WfConditionDescriptor)activityProperties["Condition"];
                if (item != null)
                {
                    actDesp.Condition = (WfConditionDescriptor)activityProperties["Condition"];
                }
                else
                {
                    actDesp.Condition.Owner = actDesp;
                }
            }
            else if (dictionary.ContainsKey("Condition"))
            {
                actDesp.Condition       = JSONSerializerExecute.Deserialize <WfConditionDescriptor>(dictionary["Condition"]);
                actDesp.Condition.Owner = actDesp;
            }

            if (activityProperties.ContainsKey("BranchProcessTemplates"))
            {
                var item = (WfBranchProcessTemplateCollection)activityProperties["BranchProcessTemplates"];
                if (item != null)
                {
                    actDesp.BranchProcessTemplates.CopyFrom(item);
                }
            }
            else if (dictionary.ContainsKey("BranchProcessTemplates"))
            {
                WfBranchProcessTemplateCollection templates = JSONSerializerExecute.Deserialize <WfBranchProcessTemplateCollection>(dictionary["BranchProcessTemplates"]);
                actDesp.BranchProcessTemplates.CopyFrom(templates);
            }

            if (activityProperties.ContainsKey("Resources"))
            {
                var item = (WfResourceDescriptorCollection)activityProperties["Resources"];
                if (item != null)
                {
                    actDesp.Resources.CopyFrom(item);
                }
            }
            else if (dictionary.ContainsKey("Resources"))
            {
                WfResourceDescriptorCollection resource = JSONSerializerExecute.Deserialize <WfResourceDescriptorCollection>(dictionary["Resources"]);
                actDesp.Resources.CopyFrom(resource);
            }

            if (activityProperties.ContainsKey("RelativeLinks"))
            {
                var item = (WfRelativeLinkDescriptorCollection)activityProperties["RelativeLinks"];
                if (item != null)
                {
                    actDesp.RelativeLinks.CopyFrom(item);
                }
            }
            else if (dictionary.ContainsKey("RelativeLinks"))
            {
                WfRelativeLinkDescriptorCollection relativeLinks = JSONSerializerExecute.Deserialize <WfRelativeLinkDescriptorCollection>(dictionary["RelativeLinks"]);
                actDesp.RelativeLinks.CopyFrom(relativeLinks);
            }

            if (activityProperties.ContainsKey("EnterEventReceivers"))
            {
                var item = (WfResourceDescriptorCollection)activityProperties["EnterEventReceivers"];
                if (item != null)
                {
                    actDesp.EnterEventReceivers.CopyFrom(item);
                }
            }
            else if (dictionary.ContainsKey("EnterEventReceivers"))
            {
                WfResourceDescriptorCollection resource = JSONSerializerExecute.Deserialize <WfResourceDescriptorCollection>(dictionary["EnterEventReceivers"]);
                actDesp.EnterEventReceivers.CopyFrom(resource);
            }

            if (activityProperties.ContainsKey("LeaveEventReceivers"))
            {
                var item = (WfResourceDescriptorCollection)activityProperties["LeaveEventReceivers"];
                if (item != null)
                {
                    actDesp.LeaveEventReceivers.CopyFrom(item);
                }
            }
            else if (dictionary.ContainsKey("LeaveEventReceivers"))
            {
                WfResourceDescriptorCollection resource = JSONSerializerExecute.Deserialize <WfResourceDescriptorCollection>(dictionary["LeaveEventReceivers"]);
                actDesp.LeaveEventReceivers.CopyFrom(resource);
            }

            if (activityProperties.ContainsKey("InternalRelativeUsers"))
            {
                var item = (WfResourceDescriptorCollection)activityProperties["InternalRelativeUsers"];
                if (item != null)
                {
                    actDesp.InternalRelativeUsers.CopyFrom(item);
                }
            }
            else if (dictionary.ContainsKey("InternalRelativeUsers"))
            {
                WfResourceDescriptorCollection interRelUser = JSONSerializerExecute.Deserialize <WfResourceDescriptorCollection>(dictionary["InternalRelativeUsers"]);
                actDesp.InternalRelativeUsers.CopyFrom(interRelUser);
            }

            if (activityProperties.ContainsKey("ExternalUsers"))
            {
                var item = (WfExternalUserCollection)activityProperties["ExternalUsers"];
                if (item != null)
                {
                    actDesp.ExternalUsers.CopyFrom(item);
                }
            }
            else if (dictionary.ContainsKey("ExternalUsers"))
            {
                WfExternalUserCollection externalUser = JSONSerializerExecute.Deserialize <WfExternalUserCollection>(dictionary["ExternalUsers"]);
                actDesp.ExternalUsers.CopyFrom(externalUser);
            }

            if (activityProperties.ContainsKey("EnterEventExecuteServices"))
            {
                var item = (WfServiceOperationDefinitionCollection)activityProperties["EnterEventExecuteServices"];
                if (item != null)
                {
                    actDesp.EnterEventExecuteServices.CopyFrom(item);
                }
            }
            else if (dictionary.ContainsKey("EnterEventExecuteServices"))
            {
                WfServiceOperationDefinitionCollection svcOperationDef =
                    JSONSerializerExecute.Deserialize <WfServiceOperationDefinitionCollection>(dictionary["EnterEventExecuteServices"]);
                actDesp.EnterEventExecuteServices.CopyFrom(svcOperationDef);
            }

            if (activityProperties.ContainsKey("LeaveEventExecuteServices"))
            {
                var item = (WfServiceOperationDefinitionCollection)activityProperties["LeaveEventExecuteServices"];

                if (item != null)
                {
                    actDesp.LeaveEventExecuteServices.CopyFrom(item);
                }
            }
            else if (dictionary.ContainsKey("LeaveEventExecuteServices"))
            {
                WfServiceOperationDefinitionCollection svcOperationDef =
                    JSONSerializerExecute.Deserialize <WfServiceOperationDefinitionCollection>(dictionary["LeaveEventExecuteServices"]);

                actDesp.LeaveEventExecuteServices.CopyFrom(svcOperationDef);
            }

            if (activityProperties.ContainsKey("WithdrawExecuteServices"))
            {
                var item = (WfServiceOperationDefinitionCollection)activityProperties["WithdrawExecuteServices"];

                if (item != null)
                {
                    actDesp.WithdrawExecuteServices.CopyFrom(item);
                }
            }
            else if (dictionary.ContainsKey("WithdrawExecuteServices"))
            {
                WfServiceOperationDefinitionCollection svcOperationDef =
                    JSONSerializerExecute.Deserialize <WfServiceOperationDefinitionCollection>(dictionary["WithdrawExecuteServices"]);

                actDesp.WithdrawExecuteServices.CopyFrom(svcOperationDef);
            }

            if (activityProperties.ContainsKey("BeWithdrawnExecuteServices"))
            {
                var item = (WfServiceOperationDefinitionCollection)activityProperties["BeWithdrawnExecuteServices"];

                if (item != null)
                {
                    actDesp.BeWithdrawnExecuteServices.CopyFrom(item);
                }
            }
            else if (dictionary.ContainsKey("BeWithdrawnExecuteServices"))
            {
                WfServiceOperationDefinitionCollection svcOperationDef =
                    JSONSerializerExecute.Deserialize <WfServiceOperationDefinitionCollection>(dictionary["BeWithdrawnExecuteServices"]);

                actDesp.BeWithdrawnExecuteServices.CopyFrom(svcOperationDef);
            }

            if (activityProperties.ContainsKey("ParametersNeedToBeCollected"))
            {
                var item = (WfParameterNeedToBeCollected)activityProperties["ParametersNeedToBeCollected"];
                if (item != null)
                {
                    actDesp.ParametersNeedToBeCollected.CopyFrom(item);
                }
            }
            else if (dictionary.ContainsKey("ParametersNeedToBeCollected"))
            {
                WfParameterNeedToBeCollected parameters =
                    JSONSerializerExecute.Deserialize <WfParameterNeedToBeCollected>(dictionary["ParametersNeedToBeCollected"]);
                actDesp.ParametersNeedToBeCollected.CopyFrom(parameters);
            }
        }
예제 #5
0
        public override object Deserialize(IDictionary <string, object> dictionary, Type type, JavaScriptSerializer serializer)
        {
            WfActivityDescriptor actDesp = (WfActivityDescriptor)base.Deserialize(dictionary, type, serializer);

            //actDesp.ActivityType = DictionaryHelper.GetValue(dictionary, "ActivityType", WfActivityType.NormalActivity);

            if (true == DictionaryHelper.GetValue(dictionary, "AllowEmptyCandidates", false))
            {
                actDesp.Properties.SetValue("AllowEmptyCandidates", true);
            }

            if (true == DictionaryHelper.GetValue(dictionary, "AllowInvalidCandidates", false))
            {
                if (actDesp.Properties.ContainsKey("AllowInvalidCandidates"))
                {
                    actDesp.Properties.SetValue("AllowInvalidCandidates", true);
                }
            }

            actDesp.Url      = DictionaryHelper.GetValue(dictionary, "Url", string.Empty);
            actDesp.CodeName = DictionaryHelper.GetValue(dictionary, "CodeName", string.Empty);

            WfVariableDescriptorCollection variables = JSONSerializerExecute.Deserialize <WfVariableDescriptorCollection>(dictionary["Variables"]);

            actDesp.Variables.Clear();
            actDesp.Variables.CopyFrom(variables);

            if (dictionary.ContainsKey("Condition"))
            {
                actDesp.Condition       = JSONSerializerExecute.Deserialize <WfConditionDescriptor>(dictionary["Condition"]);
                actDesp.Condition.Owner = actDesp;
            }

            if (dictionary.ContainsKey("BranchProcessTemplates"))
            {
                WfBranchProcessTemplateCollection templates = JSONSerializerExecute.Deserialize <WfBranchProcessTemplateCollection>(dictionary["BranchProcessTemplates"]);
                actDesp.BranchProcessTemplates.Clear();
                actDesp.BranchProcessTemplates.CopyFrom(templates);
            }

            if (dictionary.ContainsKey("Resources"))
            {
                WfResourceDescriptorCollection resource = JSONSerializerExecute.Deserialize <WfResourceDescriptorCollection>(dictionary["Resources"]);
                actDesp.Resources.Clear();
                actDesp.Resources.CopyFrom(resource);
            }

            if (dictionary.ContainsKey("RelativeLinks"))
            {
                WfRelativeLinkDescriptorCollection relativeLinks = JSONSerializerExecute.Deserialize <WfRelativeLinkDescriptorCollection>(dictionary["RelativeLinks"]);

                actDesp.RelativeLinks.Clear();
                actDesp.RelativeLinks.CopyFrom(relativeLinks);
            }

            if (dictionary.ContainsKey("EnterEventReceivers"))
            {
                WfResourceDescriptorCollection resource = JSONSerializerExecute.Deserialize <WfResourceDescriptorCollection>(dictionary["EnterEventReceivers"]);
                actDesp.EnterEventReceivers.Clear();
                actDesp.EnterEventReceivers.CopyFrom(resource);
            }

            if (dictionary.ContainsKey("LeaveEventReceivers"))
            {
                WfResourceDescriptorCollection resource = JSONSerializerExecute.Deserialize <WfResourceDescriptorCollection>(dictionary["LeaveEventReceivers"]);
                actDesp.LeaveEventReceivers.Clear();
                actDesp.LeaveEventReceivers.CopyFrom(resource);
            }

            if (dictionary.ContainsKey("InternalRelativeUsers"))
            {
                WfResourceDescriptorCollection interRelUser = JSONSerializerExecute.Deserialize <WfResourceDescriptorCollection>(dictionary["InternalRelativeUsers"]);
                actDesp.InternalRelativeUsers.Clear();
                actDesp.InternalRelativeUsers.CopyFrom(interRelUser);
            }

            if (dictionary.ContainsKey("ExternalUsers"))
            {
                WfExternalUserCollection externalUser = JSONSerializerExecute.Deserialize <WfExternalUserCollection>(dictionary["ExternalUsers"]);
                actDesp.ExternalUsers.Clear();
                actDesp.ExternalUsers.CopyFrom(externalUser);
            }

            if (dictionary.ContainsKey("EnterEventExecuteServices"))
            {
                WfServiceOperationDefinitionCollection svcOperationDef =
                    JSONSerializerExecute.Deserialize <WfServiceOperationDefinitionCollection>(dictionary["EnterEventExecuteServices"]);
                actDesp.EnterEventExecuteServices.Clear();
                actDesp.EnterEventExecuteServices.CopyFrom(svcOperationDef);
            }

            if (dictionary.ContainsKey("LeaveEventExecuteServices"))
            {
                WfServiceOperationDefinitionCollection svcOperationDef =
                    JSONSerializerExecute.Deserialize <WfServiceOperationDefinitionCollection>(dictionary["LeaveEventExecuteServices"]);
                actDesp.LeaveEventExecuteServices.Clear();
                actDesp.LeaveEventExecuteServices.CopyFrom(svcOperationDef);
            }

            if (dictionary.ContainsKey("WithdrawExecuteServices"))
            {
                WfServiceOperationDefinitionCollection svcOperationDef =
                    JSONSerializerExecute.Deserialize <WfServiceOperationDefinitionCollection>(dictionary["WithdrawExecuteServices"]);
                actDesp.WithdrawExecuteServices.Clear();
                actDesp.WithdrawExecuteServices.CopyFrom(svcOperationDef);
            }

            if (dictionary.ContainsKey("BeWithdrawnExecuteServices"))
            {
                WfServiceOperationDefinitionCollection svcOperationDef =
                    JSONSerializerExecute.Deserialize <WfServiceOperationDefinitionCollection>(dictionary["BeWithdrawnExecuteServices"]);
                actDesp.BeWithdrawnExecuteServices.Clear();
                actDesp.BeWithdrawnExecuteServices.CopyFrom(svcOperationDef);
            }

            return(actDesp);
        }