Esempio n. 1
0
        public static void TryEditSwitchCaseExpression(EditCaseExpressionMessage args)
        {
            OldSwitchValue = string.Empty;
            var switchCaseValue = args.ModelItem.Properties["Case"];
            var switchVal       = args.ModelItem.Properties["ParentFlowSwitch"];

            if (switchVal != null)
            {
                var variable = SwitchExpressionValue(switchVal);
                _callBackHandler = ShowSwitchDragDialog(args.ModelItem, variable, false);
            }
            if (_callBackHandler != null)
            {
                try
                {
                    EditSwitchCaseExpression(switchCaseValue, switchVal);
                }
                catch (Exception ex)
                {
                    PopupController.Show(GlobalConstants.SwitchWizardErrorString,
                                         GlobalConstants.SwitchWizardErrorHeading, MessageBoxButton.OK,
                                         MessageBoxImage.Error, null, false, true, false, false, false, false);
                }
            }
        }
Esempio n. 2
0
        // 28.01.2013 - Travis.Frisinger : Added for Case Edits
        public static void EditSwitchCaseExpression(EditCaseExpressionMessage args)
        {
            OldSwitchValue = string.Empty;
            ModelProperty switchCaseValue = args.ModelItem.Properties["Case"];
            var           switchVal       = args.ModelItem.Properties["ParentFlowSwitch"];

            if (switchVal != null)
            {
                var variable = SwitchExpressionValue(switchVal);
                _callBackHandler = ShowSwitchDragDialog(args.ModelItem, variable, false);
            }
            if (_callBackHandler != null)
            {
                try
                {
                    var ds = JsonConvert.DeserializeObject <Dev2Switch>(_callBackHandler.ModelData);
                    if (ds != null)
                    {
                        var validExpression = true;
                        var flowSwitch      = switchVal?.ComputedValue as System.Activities.Statements.FlowSwitch <string>;
                        if (flowSwitch != null)
                        {
                            if (flowSwitch.Cases.Any(flowNode => flowNode.Key == ds.SwitchExpression))
                            {
                                validExpression = false;
                            }
                        }

                        if (!validExpression)
                        {
                            PopupController.Show(Warewolf.Studio.Resources.Languages.Core.SwitchCaseUniqueMessage, Warewolf.Studio.Resources.Languages.Core.SwitchFlowErrorHeader,
                                                 MessageBoxButton.OK, MessageBoxImage.Error, "", false, true, false, false, false, false);
                        }
                        else
                        {
                            OldSwitchValue = switchCaseValue?.ComputedValue.ToString();
                            if (switchCaseValue?.ComputedValue.ToString() != ds.SwitchExpression)
                            {
                                switchCaseValue?.SetValue(ds.SwitchExpression);
                            }
                        }
                    }
                }
                catch
                {
                    PopupController.Show(GlobalConstants.SwitchWizardErrorString,
                                         GlobalConstants.SwitchWizardErrorHeading, MessageBoxButton.OK,
                                         MessageBoxImage.Error, null, false, true, false, false, false, false);
                }
            }
        }
Esempio n. 3
0
        // 28.01.2013 - Travis.Frisinger : Added for Case Edits
        public void EditSwitchCaseExpression(EditCaseExpressionMessage args)
        {
            IEnvironmentModel environment     = args.EnvironmentModel;
            ModelProperty     switchCaseValue = args.ModelItem.Properties["Case"];

            string modelData = JsonConvert.SerializeObject(DataListConstants.DefaultCase);

            // Extract existing value ;)
            if (switchCaseValue != null)
            {
                string val = switchCaseValue.ComputedValue.ToString();
                modelData = JsonConvert.SerializeObject(new Dev2Switch {
                    SwitchVariable = val
                });
            }

            // now invoke the wizard ;)
            _callBackHandler = RootWebSite.ShowSwitchDragDialog(environment, modelData);

            // Wizard finished...
            // Now Fetch from DL and push the model data into the workflow
            try
            {
                var ds = JsonConvert.DeserializeObject <Dev2Switch>(_callBackHandler.ModelData);

                if (ds != null)
                {
                    if (switchCaseValue != null)
                    {
                        switchCaseValue.SetValue(ds.SwitchVariable);
                    }
                }
            }
            catch
            {
                _popupController.Show(GlobalConstants.SwitchWizardErrorString,
                                      GlobalConstants.SwitchWizardErrorHeading, MessageBoxButton.OK,
                                      MessageBoxImage.Error, null);
            }
        }
Esempio n. 4
0
 public void Handle(EditCaseExpressionMessage message)
 {
     EditSwitchCaseExpression(message);
 }
Esempio n. 5
0
        public void FlowController_ConfigureSwitch_Handle_EditSwitchCase()
        {
            //------------Setup for test--------------------------
            var popupController = new Mock <IPopupController>();

            CustomContainer.Register(popupController.Object);

            var env = EnviromentRepositoryTest.CreateMockEnvironment();

            var properties         = new Dictionary <string, Mock <ModelProperty> >();
            var propertyCollection = new Mock <ModelPropertyCollection>();
            var testAct            = new DsfFlowSwitchActivity {
                ExpressionText = ""
            };

            var prop = new Mock <ModelProperty>();

            prop.Setup(p => p.ComputedValue).Returns(testAct);
            properties.Add("Expression", prop);

            propertyCollection.Protected().Setup <ModelProperty>("Find", "Expression", true).Returns(prop.Object);

            var source = new Mock <ModelItem>();

            source.Setup(s => s.Properties).Returns(propertyCollection.Object);

            #region setup decision Mock ModelItem

            var crmSwitch = new Mock <IContextualResourceModel>();
            crmSwitch.Setup(r => r.Environment).Returns(env.Object);
            crmSwitch.Setup(r => r.ResourceName).Returns("Test");
            crmSwitch.Setup(res => res.WorkflowXaml).Returns(new StringBuilder(StringResourcesTest.xmlServiceDefinition));

            var switchProperties         = new Dictionary <string, Mock <ModelProperty> >();
            var switchPropertyCollection = new Mock <ModelPropertyCollection>();

            var switchProp = new Mock <ModelProperty>();
            switchProp.Setup(p => p.ComputedValue).Returns(string.Empty);
            switchProperties.Add("Expression", switchProp);

            switchPropertyCollection.Protected().Setup <ModelProperty>("Find", "Expression", true).Returns(switchProp.Object);

            var switchModelItem = new Mock <ModelItem>();
            switchModelItem.Setup(s => s.Properties).Returns(switchPropertyCollection.Object);
            switchModelItem.Setup(s => s.ItemType).Returns(typeof(FlowSwitch <string>));

            prop.Setup(p => p.Value).Returns(switchModelItem.Object);

            #endregion

            #region setup Environment Model

            env.Setup(c => c.Connection).Returns(new Mock <IEnvironmentConnection>().Object);

            #endregion

            var flowController = new FlowController();

            var message = new EditCaseExpressionMessage
            {
                ModelItem = source.Object,
                Server    = env.Object
            };
            //------------Execute Test---------------------------
            flowController.Handle(message);
            //------------Assert Results-------------------------
        }