Ejemplo n.º 1
0
        private void ProcessComponentsFromModelToFlow(IComponentModel compModel, ConvertedFlow newFlow, string projectName, string modelName, List <ConvertedFlow> allFlows)
        {
            List <ConvertedStep> allSteps = new List <ConvertedStep>();

            foreach (IOrchestrationComponent component in compModel.Components)
            {
                if (component is EmbeddedModelComponent)
                {
                    ConvertedFlow embeddedFlow = new ConvertedFlow();
                    embeddedFlow.FlowName = component.Name;


                    FieldInfo[] fields = component.GetType().GetFields(
                        BindingFlags.NonPublic |
                        BindingFlags.Instance);

                    IComponentModel internalModel = (IComponentModel)fields.First(xx => xx.Name == "_embeddedModel").GetValue(component);

                    SetupInputDataForFlow(internalModel.InputData, embeddedFlow, true);
                    SetupOutputDataForFlow(internalModel.OutputData, embeddedFlow);
                    embeddedFlow.Tags   = new string[] { modelName, "Embedded Model" };
                    embeddedFlow.FlowId = internalModel.Id;

                    ProcessComponentsFromModelToFlow(internalModel, embeddedFlow, projectName, component.Name + " Embedded", allFlows);

                    allFlows.Add(embeddedFlow);
                }

                ConvertedStep x = CreateFlowStepFromComponent(projectName, component, modelName);

                allSteps.Add(x);
            }

            newFlow.Steps = allSteps.ToArray();

            List <ConvertedConnection> stepConnections = new List <ConvertedConnection>();

            // Now that we have created and mapped all the steps we
            // need to create all of the necessary links
            foreach (IOrchestrationComponent component in compModel.Components)
            {
                Report("Linking {0}", component.Name);

                IComponentLink[] links = compModel.GetOutboundLinks(component);

                foreach (IComponentLink eachLink in links)
                {
                    string srcPath       = eachLink.Path;
                    int    srcPortNumber = eachLink.SourcePortNumber + 1;
                    int    dstPortNumber = eachLink.DestinationPortNumber - 1;
                    dstPortNumber = dstPortNumber < 0 ? 0 : dstPortNumber;
                    srcPortNumber = srcPortNumber > 3 ? 3 : srcPortNumber;

                    stepConnections.Add(new ConvertedConnection()
                    {
                        TargetStepId           = eachLink.DestinationComponentID,
                        SourceStepId           = eachLink.SourceComponentID,
                        TargetPortNumberOnStep = dstPortNumber,
                        SourcePortNumberOnStep = srcPortNumber,
                        PathName = eachLink.Path
                    });
                }
            }

            newFlow.Connections = stepConnections.ToArray();
        }
Ejemplo n.º 2
0
        private ConvertedStep CreateFlowStepFromComponent(string projectName, IOrchestrationComponent component, string modelName)
        {
            Report("Transforming Component {0}", component.Name);

            if (component.GetType().FullName == typeof(FormBuilderComponent).FullName)
            {
                ConvertedForm form = FormBuilderConvertor.GetForm(component);

                if (string.IsNullOrEmpty(modelName))
                {
                    form.Tags = new string[] { "Root" };
                }

                else
                {
                    form.Tags = new string[] { modelName };
                }

                form.FormId = component.Id;

                // Add this form to the converted results that we are building.
                allForms.Add(form);

                // And now create the ConvertedStep to represent the form wrapper step on the
                // decisions side.
                ConvertedStep forWrapperStep = new ConvertedStep();
                forWrapperStep.StepName = component.Name;
                forWrapperStep.X        = (int)component.Location.X;
                forWrapperStep.Y        = (int)component.Location.Y;
                forWrapperStep.UniqueStepIdForConnections = component.Id;

                forWrapperStep.FullTypeName = "FormWrapperStep";

                return(forWrapperStep);
            }

            ConvertedStep result = new ConvertedStep();

            //build up dictionary of steps and count just so we can know how many are in this flow
            if (dictAllStepsCount.ContainsKey(component.GetType().Name))
            {
                dictAllStepsCount[component.GetType().Name] = dictAllStepsCount[component.GetType().Name] + 1;
            }
            else
            {
                dictAllStepsCount.Add(component.GetType().Name, 1);
            }

            List <string> baseTypeNamesToSkip = new List <string>();

            baseTypeNamesToSkip.Add("AbstractSQLSinglePathComponent");
            //baseTypeNamesToSkip.Add("AbstractSinglePathProcessComponent");
            //baseTypeNamesToSkip.Add("AbstractConnectionStringMultiPathComponent");

            List <string> typeNamesToSkip = new List <string>();

            typeNamesToSkip.Add("LogicBase.Components.Default.Process.MultiPathEmbeddedModelComponent");
            typeNamesToSkip.Add("LogicBase.Components.Default.IO.ReadFile");
            typeNamesToSkip.Add("LogicBase.Components.Default.IterateTextFileLines");
            typeNamesToSkip.Add("LogicBase.Components.Office2003.Word2003ModelComponent");
            typeNamesToSkip.Add("LogicBase.Components.Default.IO.CreateTextFile");
            typeNamesToSkip.Add("LogicBase.Components.Default.Process.SubtractValues");

            List <string> assembliesToSkip = new List <string>();

            assembliesToSkip.Add("Wrap Up 2 Integration.dll");
            assembliesToSkip.Add("Wrap Up Client Side Integration.dll");

            if (baseTypeNamesToSkip.Contains(component.GetType().BaseType.Name) || typeNamesToSkip.Contains(component.GetType().FullName) || assembliesToSkip.Contains(component.GetType().Assembly.ManifestModule.Name))
            {
                result.StepName = component.Name;
                result.UniqueStepIdForConnections = component.Id;
                result.InputData      = new StepInput[0];
                result.OutcomeData    = new StepOutcome[0];
                result.FullTypeName   = "No type";
                result.StepProperties = new StepInput[0];
                result.X = (int)component.Location.X;
                result.Y = (int)component.Location.Y;

                return(result);
            }

            result.UniqueStepIdForConnections = component.Id;

            result.FullTypeName = component.GetType().FullName;
            result.StepName     = component.Name;
            result.X            = (int)component.Location.X;
            result.Y            = (int)component.Location.Y;

            if (ConverterFor.ContainsKey(component.GetType()))
            {
                result.InputData      = ConverterFor[component.GetType()].GetInputs(component);
                result.StepProperties = ConverterFor[component.GetType()].GetProperties(component);
                result.OutcomeData    = ConverterFor[component.GetType()].GetOutcomes(component);
            }
            else
            {
                result.InputData      = ConvertInputDataDefault(component);
                result.StepProperties = ConvertStepPropertiesDefault(component);
                result.OutcomeData    = ConvertOutDataDefault(component);
                // Setup common properties
            }
            return(result);
        }
Ejemplo n.º 3
0
        public DecisionsFramework.Design.Flow.FlowStep ConvertStep(ConversionData allConvertData, ConvertedStep stepToConvert)
        {
            InvokeMethodStep ims = new InvokeMethodStep("DecisionsFramework.Design.Flow.CoreSteps.StandardSteps.ObjectSteps", "ObjectIsNull", null);

            FlowStep fs = new FlowStep(ims);

            fs.Name = stepToConvert.StepName;
            return(fs);
        }
Ejemplo n.º 4
0
        public DecisionsFramework.Design.Flow.FlowStep ConvertStep(ConversionData allConvertData, ConvertedStep stepToConvert)
        {
            // JoinStrings(string[] source, string separator
            InvokeMethodStep ims = new InvokeMethodStep("DecisionsFramework.Design.Flow.CoreSteps.StandardSteps.StringSteps", "JoinStrings", null);

            FlowStep fs = new FlowStep(ims);

            fs.Name = stepToConvert.StepName;
            return(fs);
        }
Ejemplo n.º 5
0
        public DecisionsFramework.Design.Flow.FlowStep ConvertStep(ConversionData allConvertData, ConvertedStep stepToConvert)
        {
            IndexOfItemInList itemInList = new IndexOfItemInList();

            return(new FlowStep(itemInList));
        }
Ejemplo n.º 6
0
        public DecisionsFramework.Design.Flow.FlowStep ConvertStep(ConversionData allConvertData, ConvertedStep stepToConvert)
        {
            SystemUserContext suc = new SystemUserContext();

            using (UserContextHolder.Register(suc))
            {
                LinkedFlowStep lfs = new LinkedFlowStep();

                // Get name of flow to run / id of flow to run.
                StepInput flowId = stepToConvert.StepProperties.FirstOrDefault(x => x.Name == "EmbeddedFlowId");

                //string flowId = flowName.ConstantValue;
                //foreach (Flow cf in allConvertData.ConvertedFlows)
                //{
                //    if (cf.Name == flowName.ConstantValue)
                //    {
                //        flowId = cf.Id;
                //    }
                //}


                lfs.RegistrationId = flowId.ConstantValue;

                return(new FlowStep(lfs));
            }
        }
Ejemplo n.º 7
0
        public DecisionsFramework.Design.Flow.FlowStep ConvertStep(ConversionData allConvertData, ConvertedStep stepToConvert)
        {
            GoToStep gs     = new GoToStep();
            FlowStep result = new FlowStep(gs);

            result.Name = stepToConvert.StepName;
            //gs.GoToStepName = ((GoToComponentByName)component).ComponentName;

            return(result);
        }
Ejemplo n.º 8
0
        public DecisionsFramework.Design.Flow.FlowStep ConvertStep(ConversionData allConvertData, ConvertedStep stepToConvert)
        {
            DecisionsFramework.Design.Flow.CoreSteps.GetItemByIndex getItemStep = new DecisionsFramework.Design.Flow.CoreSteps.GetItemByIndex();
            FlowStep fs = new FlowStep(getItemStep);

            fs.Name = stepToConvert.StepName;
            return(fs);
        }
Ejemplo n.º 9
0
        public DecisionsFramework.Design.Flow.FlowStep ConvertStep(ConversionData allConvertData, ConvertedStep stepToConvert)
        {
            FlowStep         result;
            InvokeMethodStep ms = new InvokeMethodStep("DecisionsFramework.Design.Flow.CoreSteps.StandardSteps.ObjectSteps", "ObjectsAreEqual", null);

            result      = new FlowStep(ms);
            result.Name = stepToConvert.StepName;

            SelectValueInputMapping svim = new SelectValueInputMapping();

            svim.DataPath      = stepToConvert.InputData.First(x => x.Name == "value1").SelectValuePathName;
            svim.InputDataName = "value1";
            result.AddInputMapping(svim);

            SelectValueInputMapping svim2 = new SelectValueInputMapping();

            svim2.DataPath      = stepToConvert.InputData.First(x => x.Name == "value2").SelectValuePathName;
            svim2.InputDataName = "value2";
            result.AddInputMapping(svim2);


            return(result);
        }
Ejemplo n.º 10
0
        public DecisionsFramework.Design.Flow.FlowStep ConvertStep(ConversionData allConvertData, ConvertedStep stepToConvert)
        {
            // This step is really special.  We need a Form
            // step on the flow, but we also need to create the form and add
            // it to the currently being converted project.

            FormWrapperStep fws = new FormWrapperStep();

            // Get element registration id from form id
            // in already converted data.
            string erId = allConvertData.OldFormIdToNewFormIdMap[stepToConvert.UniqueStepIdForConnections];

            // We should WARN if no id found, but whatever.
            fws.RegistrationId = erId;

            FlowStep fs = new FlowStep(fws);

            return(fs);
        }
Ejemplo n.º 11
0
        public DecisionsFramework.Design.Flow.FlowStep ConvertStep(ConversionData allConvertData, ConvertedStep stepToConvert)
        {
            LogStep logStep = new LogStep();

            logStep.Category = stepToConvert.StepProperties.FirstOrDefault(x => x.Name == "Category").ConstantValue;

            string logLevel = stepToConvert.StepProperties.FirstOrDefault(x => x.Name == "Type").ConstantValue;

            switch (logLevel)
            {
            case "Debug":
                logStep.Type = LogStep.LogType.Debug;
                break;

            case "Error":
                logStep.Type = LogStep.LogType.Error;
                break;

            case "Info":
                logStep.Type = LogStep.LogType.Info;
                break;

            case "Fatal":
                logStep.Type = LogStep.LogType.Fatal;
                break;

            case "Warn":
                logStep.Type = LogStep.LogType.Warn;
                break;

            default:
                logStep.Type = LogStep.LogType.Info;
                break;
            }

            FlowStep result = new FlowStep(logStep);

            result.Name = stepToConvert.StepName;

            MergeStringInputMapping text = new MergeStringInputMapping()
            {
                //ConstantInputMapping text = new ConstantInputMapping();
                InputDataName   = "Value",
                MergeResultType = DecisionsFramework.Utilities.Data.MergeDataType.PlainText,
                MergeString     = stepToConvert.InputData.FirstOrDefault(x => x.Name == "Value").ConstantValue
            };

            result.AddInputMapping(text);

            return(result);
        }
Ejemplo n.º 12
0
        public DecisionsFramework.Design.Flow.FlowStep ConvertStep(ConversionData allConvertData, ConvertedStep stepToConvert)
        {
            CreateDataStep ps = new CreateDataStep();
            FlowStep       fs = new FlowStep(ps);

            List <PlaceholderData> allDataDefinitions = new List <PlaceholderData>();

            foreach (OutcomeDefinition outcome in stepToConvert.OutcomeData)
            {
                foreach (DataDefinition outputData in outcome.OutcomeData)
                {
                    Type t = TypeUtilities.FindTypeByFullName(outputData.FullTypeName);

                    //Type t might be null if we aren't able to resolve the type of a custom type
                    //so let's just set it to string.
                    if (t == null)
                    {
                        t = typeof(string);
                    }

                    allDataDefinitions.Add(
                        new PlaceholderData(new DecisionsNativeType(t), outputData.Name, outputData.IsList)
                        );
                }
            }

            ps.DataDefinitions = allDataDefinitions.ToArray();

            // Now do the mapping.
            List <IOutputMapping> outputMapping = new List <IOutputMapping>();

            foreach (OutcomeDefinition outcome in stepToConvert.OutcomeData)
            {
                foreach (DataDefinition outputData in outcome.OutcomeData)
                {
                    RenameOutputMapping mapping = new RenameOutputMapping();
                    mapping.DataName       = outputData.Name;
                    mapping.OutputDataName = outputData.Name;
                    outputMapping.Add(mapping);
                }
            }
            fs.OutputMapping = outputMapping.ToArray();
            //string varName = (ConvertUtility.ConvertStepInputToInputMapping(stepToConvert.InputData.FirstOrDefault())).InputDataName;
            string varName = (stepToConvert.InputData.FirstOrDefault()).Name;

            Type type = Type.GetType(stepToConvert.InputData.FirstOrDefault().FullTypeName);

            object value = new bool();

            //if (type == typeof(bool))
            //{
            //    value = Convert.ToBoolean(stepToConvert.InputData.FirstOrDefault().ConstantValue);
            //}

            bool result;

            if (bool.TryParse(stepToConvert.InputData.FirstOrDefault().ConstantValue, out result))
            {
                value = result;
            }


            //if (type == typeof(int))
            //{
            //    value = Convert.ToInt32(stepToConvert.InputData.FirstOrDefault().ConstantValue);
            //}

            //else
            //{
            //    value = stepToConvert.InputData.FirstOrDefault().ConstantValue;
            //}

            //fs.AddInputMapping(new ConstantInputMapping() { InputDataName = varName, Value = stepToConvert.InputData.FirstOrDefault().ConstantValue });
            fs.AddInputMapping(new ConstantInputMapping()
            {
                InputDataName = varName, Value = result
            });

            return(fs);
        }
Ejemplo n.º 13
0
        public DecisionsFramework.Design.Flow.FlowStep ConvertStep(ConversionData allConvertData, ConvertedStep stepToConvert)
        {
            StringMatchStep sms = new StringMatchStep();

            sms.PossibleMatches = stepToConvert.StepProperties.FirstOrDefault(x => x.Name == "PossibleMatches").ConstantValue.Split(',');

            FlowStep result = new FlowStep(sms);

            result.Name = stepToConvert.StepName;
            return(result);
        }
Ejemplo n.º 14
0
        public DecisionsFramework.Design.Flow.FlowStep ConvertStep(ConversionData allConvertData, ConvertedStep stepToConvert)
        {
            FlowStep result = new FlowStep(new StartStep());

            result.Name = stepToConvert.StepName;
            return(result);
        }
Ejemplo n.º 15
0
        public DecisionsFramework.Design.Flow.FlowStep ConvertStep(ConversionData allConvertData, ConvertedStep stepToConvert)
        {
            SendEmailStep emailStep = new SendEmailStep();

            FlowStep result = new FlowStep(emailStep);

            result.Name = stepToConvert.StepName;

            //Add From Input
            result.AddInputMapping(ConvertUtility.ConvertStepInputToInputMapping(stepToConvert.InputData.FirstOrDefault(x => x.Name == "From"), "From"));

            //Add To Input
            result.AddInputMapping(ConvertUtility.ConvertStepInputToInputMapping(stepToConvert.InputData.FirstOrDefault(x => x.Name == "To"), "To"));

            //Add Subject Input
            result.AddInputMapping(ConvertUtility.ConvertStepInputToInputMapping(stepToConvert.InputData.FirstOrDefault(x => x.Name == "Subject"), "Subject"));

            //Add Body Input
            result.AddInputMapping(ConvertUtility.ConvertStepInputToInputMapping(stepToConvert.InputData.FirstOrDefault(x => x.Name == "Body"), "Body", true));

            //MergeStringInputMapping subject = new MergeStringInputMapping()
            //{
            //    InputDataName = "Subject",
            //    MergeResultType = DecisionsFramework.Utilities.Data.MergeDataType.PlainText,
            //    MergeString = stepToConvert.InputData.FirstOrDefault(x => x.Name == "Subject").ConstantValue
            //};

            ////get To addresses together
            //List<IInputMapping> toIM = new List<IInputMapping>();
            //int counter = -1;
            //foreach (StepInput toAddress in stepToConvert.InputData.FirstOrDefault(x => x.Name == "To").ArrayParts)
            //{
            //    counter = counter + 1;
            //    string inDataName = string.Format("Item {0}", counter);

            //    if (toAddress.MappingType == InputMappingType.SelectValue)
            //    {
            //        toIM.Add(new SelectValueInputMapping() { InputDataName = inDataName, DataPath = toAddress.SelectValuePathName });
            //    }

            //    else
            //    {
            //        toIM.Add(new ConstantInputMapping() { InputDataName = inDataName, Value = toAddress.ConstantValue });
            //    }
            //}

            ////get from address together
            //StepInput fromSI = stepToConvert.InputData.FirstOrDefault(x => x.Name == "From");
            //string inDataName = "From"; //why is inDataName saying it is already declared since I delcared it in a foreach above?

            //   //IInputMapping fromAddress = new IInputMapping();
            //if (fromSI.MappingType == InputMappingType.SelectValue)
            //{
            //    //do select value stuff
            //    SelectValueInputMapping fromAddress = new SelectValueInputMapping() { InputDataName = inDataName, DataPath = fromSI.SelectValuePathName };

            //}
            //if (fromSI.MappingType == InputMappingType.MergeText)
            //{
            //    //do merge text stuff
            //    MergeStringInputMapping fromAddress = new MergeStringInputMapping() { InputDataName = inDataName, MergeResultType = MergeDataType.PlainText, MergeString = fromSI.ConstantValue };
            //}
            //else
            //{
            //    //do constant stuff
            //    ConstantInputMapping fromAddress = new ConstantInputMapping() { InputDataName = inDataName, Value = fromSI.ConstantValue };
            //}

            //result.AddInputMapping(subject);
            //result.AddInputMapping(new ArrayInputMapping() { InputDataName = "To", SubMappings = toIM.ToArray() });
            //result.AddInputMapping(fromAddress);

            return(result);
        }