MakeDisplayReady() public method

Makes the error collection user ready.
public MakeDisplayReady ( ) : string
return string
Esempio n. 1
0
        // BUG 9706 - 2013.06.22 - TWR : refactored
        void DispatchDebugErrors(ErrorResultTO errors, IDSFDataObject dataObject, StateType stateType)
        {
            if(errors.HasErrors() && dataObject.IsDebugMode())
            {
                Guid parentInstanceId;
                Guid.TryParse(dataObject.ParentInstanceID, out parentInstanceId);

                var debugState = new DebugState
                {
                    ID = dataObject.DataListID,
                    ParentID = parentInstanceId,
                    WorkspaceID = dataObject.WorkspaceID,
                    StateType = stateType,
                    StartTime = DateTime.Now,
                    EndTime = DateTime.Now,
                    ActivityType = ActivityType.Workflow,
                    DisplayName = dataObject.ServiceName,
                    IsSimulation = dataObject.IsOnDemandSimulation,
                    ServerID = dataObject.ServerID,
                    OriginatingResourceID = dataObject.ResourceID,
                    OriginalInstanceID = dataObject.OriginalInstanceID,
                    SessionID = dataObject.DebugSessionID,
                    EnvironmentID = dataObject.EnvironmentID,
                    ClientID = dataObject.ClientID,
                    Server = string.Empty,
                    Version = string.Empty,
                    Name = GetType().Name,
                    HasError = errors.HasErrors(),
                    ErrorMessage = errors.MakeDisplayReady()
                };

                DebugDispatcher.Instance.Write(debugState, dataObject.RemoteInvoke, dataObject.RemoteInvokerID);
            }
        }
        static string ExtractKeyValuePairs(NameValueCollection pairs, NameValueCollection boundVariables)
        {
            // Extract request keys ;)
            foreach(var key in pairs.AllKeys)
            {
                if(key == "wid") //Don't add the Workspace ID to DataList
            {
                    continue;
                }
                if(key.IsXml() || key.IsJSON())
                {
                    return key; //We have a workspace id and XML DataList
                }
                boundVariables.Add(key,pairs[key]);

            }

            ErrorResultTO errors = new ErrorResultTO();


            Dev2Logger.Log.Error(errors.MakeDisplayReady());

            return string.Empty;
        }
Esempio n. 3
0
        /// <summary>
        /// Invokes the specified service as per the dataObject against theHost
        /// </summary>
        /// <param name="dataObject">The data object.</param>
        /// <param name="errors">The errors.</param>
        /// <returns></returns>
        /// <exception cref="System.Exception">Can only execute workflows from web browser</exception>
        public Guid Invoke(IDSFDataObject dataObject, out ErrorResultTO errors)
        {
            var result = GlobalConstants.NullDataListID;
            var time = new Stopwatch();
            time.Start();
            errors = new ErrorResultTO();
            int update = 0;
            // BUG 9706 - 2013.06.22 - TWR : added pre debug dispatch
            if(dataObject.Environment.HasErrors())
            {
                errors.AddError(dataObject.Environment.FetchErrors());
                DispatchDebugErrors(errors, dataObject, StateType.Before);
            }
            errors.ClearErrors();
            try
            {
                var serviceId = dataObject.ResourceID;

                // we need to get better at getting this ;)

                var serviceName = dataObject.ServiceName;
                if(serviceId == Guid.Empty && string.IsNullOrEmpty(serviceName))
                {
                    errors.AddError(Resources.DynamicServiceError_ServiceNotSpecified);
                }
                else
                {

                    try
                    {
                        var sl = new ServiceLocator();
                        Dev2Logger.Log.Debug("Finding service");
                        var theService = serviceId == Guid.Empty ? sl.FindService(serviceName, _workspace.ID) : sl.FindService(serviceId, _workspace.ID);

                        if(theService == null)
                        {
                            errors.AddError("Service [ " + serviceName + " ] not found.");
                        }
                        else if(theService.Actions.Count <= 1)
                        {
                            #region Execute ESB container

                            var theStart = theService.Actions.FirstOrDefault();
                            if(theStart != null && theStart.ActionType != Common.Interfaces.Core.DynamicServices.enActionType.InvokeManagementDynamicService && theStart.ActionType != Common.Interfaces.Core.DynamicServices.enActionType.Workflow && dataObject.IsFromWebServer)
                            {
                                throw new Exception("Can only execute workflows from web browser");
                            }
                            Dev2Logger.Log.Debug("Mapping Action Dependencies");
                            MapServiceActionDependencies(theStart, sl);

                            // Invoke based upon type ;)
                            if(theStart != null)
                            {
                                theStart.DataListSpecification = theService.DataListSpecification;
                                Dev2Logger.Log.Debug("Getting container");
                                var container = GenerateContainer(theStart, dataObject, _workspace);
                                ErrorResultTO invokeErrors;
                                result = container.Execute(out invokeErrors, update);
                                errors.MergeErrors(invokeErrors);
                            }
                            #endregion
                        }
                        else
                        {
                            errors.AddError("Malformed Service [ " + serviceId + " ] it contains multiple actions");
                        }
                    }
                    catch(Exception e)
                    {
                        errors.AddError(e.Message);
                    }
                    finally
                    {
                        if (dataObject.Environment.HasErrors())
                        {
                            var errorString = dataObject.Environment.FetchErrors();
                            var executionErrors = ErrorResultTO.MakeErrorResultFromDataListString(errorString);
                            errors.MergeErrors(executionErrors);
                        }

                        dataObject.Environment.AddError(errors.MakeDataListReady());

                        if(errors.HasErrors())
                        {
                            Dev2Logger.Log.Error(errors.MakeDisplayReady());
                        }
                    }
                }
            }
            finally
            {
                time.Stop();
                ServerStats.IncrementTotalRequests();
                ServerStats.IncrementTotalTime(time.ElapsedMilliseconds);
                // BUG 9706 - 2013.06.22 - TWR : added
                DispatchDebugErrors(errors, dataObject, StateType.End);
            }
            return result;
        }
Esempio n. 4
0
        private void AddErrorsToDataList(ErrorResultTO errors, Guid dataListID)
        {
            // Upsert any errors that might have occured into the datalist
            IBinaryDataListEntry be = Dev2BinaryDataListFactory.CreateEntry(enSystemTag.Error.ToString(), string.Empty);
            string error;
            be.TryPutScalar(Dev2BinaryDataListFactory.CreateBinaryItem(errors.MakeDataListReady(), enSystemTag.Error.ToString()), out error);
            if (!string.IsNullOrWhiteSpace(error))
            {
                //At this point there was an error while trying to handle errors so we throw an exception
                throw new Exception(string.Format("The error '{0}' occured while creating the error entry for the following errors: {1}", error, errors.MakeDisplayReady()));
            }

            var upsertErrors = new ErrorResultTO();
            SvrCompiler.Upsert(null, dataListID, DataListUtil.BuildSystemTagForDataList(enSystemTag.Error, true), be, out upsertErrors);
            if (upsertErrors.HasErrors())
            {
                //At this point there was an error while trying to handle errors so we throw an exception
                throw new Exception(string.Format("The error '{0}' occured while upserting the following errors to the datalist: {1}", errors.MakeDisplayReady(), errors.MakeDisplayReady()));
            }
        }
Esempio n. 5
0
        /// <summary>
        /// Dispatches the error state to the client
        /// </summary>
        /// <param name="xmlRequest">The XML request.</param>
        /// <param name="dataListId">The data list id.</param>
        /// <param name="allErrors">All errors.</param>
        /// <author>Jurie.smit</author>
        /// <date>2013/02/18</date>
        private void DispatchDebugState(dynamic xmlRequest, Guid dataListId, ErrorResultTO allErrors)
        {
            var debugState = new DebugState()
            {
                StartTime = DateTime.Now,
                EndTime = DateTime.Now,
                IsSimulation = false,
                Server = string.Empty,
                Version = string.Empty,
                Name = GetType().Name,
                HasError = true,
                ActivityType = ActivityType.Service,
                StateType = StateType.All,
                ServerID = HostSecurityProvider.Instance.ServerID
            };

            try
            {
                var xmlReader = XmlReader.Create(new StringReader(xmlRequest.XmlString));
                var xmlDoc = XDocument.Load(xmlReader);
                var workSpaceID = (from n in xmlDoc.Descendants("wid")
                                   select n).FirstOrDefault();
                var invokedService = (from n in xmlDoc.Descendants("Service")
                                      select n).FirstOrDefault();
                if (workSpaceID != null)
                {
                    debugState.WorkspaceID = Guid.Parse(workSpaceID.Value);
                }
                if (invokedService != null)
                {
                    debugState.DisplayName = invokedService.Value;
                }

                //ParentID = dataObject.ParentInstanceID
            }
            catch (Exception exception)
            {
                //TODO what if not an xmlRequest ? IDSFDataObject dataObject = new DsfDataObject(xmlRequest, dataListId);
                throw;
            }

            debugState.ErrorMessage = XmlHelper.MakeErrorsUserReadable(allErrors.MakeDisplayReady());

            DebugDispatcher.Instance.Write(debugState);
        }
Esempio n. 6
0
        public Guid Invoke(DynamicService service, dynamic xmlRequest, Guid dataListId, out ErrorResultTO errors)
        {
            //dynamic result = new UnlimitedObject();
            //dynamic forwardResult = new UnlimitedObject();
            var allErrors = new ErrorResultTO();
            errors = new ErrorResultTO();

            if(service == null)
            {
                allErrors.AddError("Dynamic Service not found exception");
                return GlobalConstants.NullDataListID;
            }

            string dataList = service.DataListSpecification;


            // PBI : 5376 Amendedment for DataList Server
            Guid result = GlobalConstants.NullDataListID;
            string data = xmlRequest.XmlString.Trim();
            byte[] incomingData = Encoding.UTF8.GetBytes(data);
            Guid serviceDataId;


            var performDataListInMerge = false;

            if(dataList != string.Empty)
            {
                serviceDataId = SvrCompiler.ConvertTo(null, DataListFormat.CreateFormat(GlobalConstants._XML),
                                                       incomingData, dataList, out errors);
                errors = new ErrorResultTO(); // re-set to avoid carring

                // PBI : 5376
                // If dataListID == NullID, create a new list and set it as the current ID
                // Else, create a new list, union the old data into the new and continue on ;)
                if(dataListId != GlobalConstants.NullDataListID)
                {
                    serviceDataId = SvrCompiler.Merge(null, serviceDataId, dataListId, enDataListMergeTypes.Union,
                                                       enTranslationDepth.Data, false, out errors);
                }
                else
                {
                    performDataListInMerge = true;
                }
            }
            else
            {
                serviceDataId = SvrCompiler.CloneDataList(dataListId, out errors);
                performDataListInMerge = true;
            }

            if (errors.HasErrors())
            {
                allErrors.MergeErrors(errors);
            }
            IDSFDataObject dataObject = new DsfDataObject(xmlRequest.XmlString, serviceDataId);
            dataObject.DataList = dataList;

            if(performDataListInMerge)
            {
                SvrCompiler.ConditionalMerge(null, DataListMergeFrequency.Always, serviceDataId,
                                              dataObject.DatalistInMergeID,
                                              DataListMergeFrequency.Always, dataObject.DatalistInMergeType,
                                              dataObject.DatalistInMergeDepth);
            }

            // TODO  : Reset the AmbientDataList to this ID?

            // Fetch data for Input binding...
            DataListTranslatedPayloadTO tmpData = null;
            dynamic inputBinding = null;

            // End PBI Amendments

            foreach(ServiceAction serviceAction in service.Actions)
            {
                //TraceWriter.WriteTrace(_managementChannel, string.Format("Validating the inputs of Service '{0}'", service.Name), Resources.TraceMessageType_Message);
                foreach(ServiceActionInput sai in serviceAction.ServiceActionInputs)
                {
                    //Assigning the input the value from the callers request data
                    //TraceWriter.WriteTrace(_managementChannel, string.Format("Discovered input '{0}'", sai.Name), Resources.TraceMessageType_Message);
                    if(sai.CascadeSource)
                    {
                        TraceWriter.WriteTrace(_managementChannel, string.Format("Input '{0}' is cascaded", sai.Name),
                                               Resources.TraceMessageType_Message);
                        //This is a cascaded input so retrieve the value from the
                        //previous actions response
                        //sai.Value = forwardResult.GetValue(sai.Name);
                    }
                    else
                    {
                        if(tmpData == null)
                        {
                            tmpData = SvrCompiler.ConvertFrom(null, serviceDataId, enTranslationDepth.Data,
                                                               DataListFormat.CreateFormat(GlobalConstants._XML),
                                                               out errors);

                            if(!DataListUtil.isNullADL(tmpData.FetchAsString()))
                            {
                                inputBinding = new UnlimitedObject(tmpData.FetchAsString());
                            }
                            else
                            {
                                // Empty data, try the incoming stream?!
                                inputBinding = new UnlimitedObject(xmlRequest.XmlString);
                            }
                        }

                        // 16.10.2012 : Travis.Frisinger - EmptyToNull amendments
                        string tmpVal = inputBinding.GetValue(sai.Name);
                        if(sai.EmptyToNull && tmpVal == string.Empty)
                        {
                            tmpVal = AppServerStrings.NullConstant;
                        }

                        sai.Value = tmpVal;
                    }

                    //TraceWriter.WriteTrace(string.Format("Assigning value {0} to input '{1}'", sai.Value.ToString(), sai.Name));

                    //Validating inputs if there is validation set up in the service definition
                    if(sai.IsRequired && string.IsNullOrEmpty(sai.DefaultValue))
                    {
                        if(!sai.Validate())
                        {
                            allErrors.AddError(string.Format("Validation Failure. Argument '{0}' failed validation.",
                                                             sai.Name));

                            //TraceWriter.WriteTrace(_managementChannel, string.Format("Argument '{0}' failed validation", sai.Name), Resources.TraceMessageType_Message);
                            //xmlRequest.Error = string.Format("Validation Failure. Argument '{0}' failed validation.", sai.Name);
                            //return xmlRequest;
                        }
                    }
                    //This input does not have any value in the callers request
                    //so we are setting the input value to the full request
                    if(string.IsNullOrEmpty(sai.Value.ToString()))
                    {
                        sai.Value = !string.IsNullOrEmpty(sai.DefaultValue) ? sai.DefaultValue : string.Empty;
                    }
                }

                //if (service.Mode == enDynamicServiceMode.ValidationOnly)
                //{
                //    xmlRequest.ValidationOnly.Result = true;

                //    return xmlRequest;
                //}

                if(serviceAction.ActionType == enActionType.Switch)
                {
                    if(!string.IsNullOrEmpty(serviceAction.Cases.DataElementName))
                    {
                        ////Assigning the input the value from the callers request data
                        //if (serviceAction.Cases.CascadeSource)
                        //{
                        //This is a cascaded input so retrieve the value from the
                        //previous actions response
                        //sai.Value = actionResponse.GetValue(sai.Name);
                        //serviceAction.Cases.DataElementValue = forwardResult.GetValue(serviceAction.Cases.DataElementName);
                        //}
                        //else
                        //{
                        serviceAction.Cases.DataElementValue = xmlRequest.GetValue(serviceAction.Cases.DataElementName);
                        //}
                    }
                }


                //
                //Juries - This is a dirty hack, naughty naughty.
                //Hijacked current functionality to enable erros to be added to an item after its already been added to the tree
                //
                if(allErrors.HasErrors())
                {
                    DebugDispatcher.Instance.Write(new DebugState()
                    {
                        ParentID = dataObject.ParentInstanceID,
                        WorkspaceID = dataObject.WorkspaceID,
                        StartTime = DateTime.Now,
                        EndTime = DateTime.Now,
                        IsSimulation = false,
                        ServerID = dataObject.ServerID,
                        Server = string.Empty,
                        Version = string.Empty,
                        Name = GetType().Name,
                        HasError = true,
                        ErrorMessage = allErrors.MakeDisplayReady(),
                        ActivityType = ActivityType.Workflow,
                        StateType = StateType.Append
                    });
                }
                
                // TODO : properly build up DataList prior to this....
                result = Invoke(serviceAction, dataObject, dataList);

                // Remember to clean up ;)
                if(dataListId != GlobalConstants.NullDataListID)
                {
                    // Merge the execution DL into the mainDL ;)

                    Guid mergeId = SvrCompiler.Merge(null, dataListId, serviceDataId, enDataListMergeTypes.Union,
                                                      enTranslationDepth.Data, false, out errors);
                    SvrCompiler.DeleteDataListByID(serviceDataId, true);

                    // Now reset the DataListID on DataObject ;)
                    if(result != serviceDataId)
                    {
                        throw new Exception("FATAL ERROR : DataList Execution Mis-Match!");
                    }

                    dataObject.DataListID = mergeId;
                    result = mergeId;
                }
                else
                {
                    SvrCompiler.ConditionalMerge(null,
                                                  DataListMergeFrequency.Always | DataListMergeFrequency.OnCompletion,
                                                  dataObject.DatalistOutMergeID, dataObject.DataListID,
                                                  dataObject.DatalistOutMergeFrequency, dataObject.DatalistOutMergeType,
                                                  dataObject.DatalistOutMergeDepth);
                } // else we want to keep the DL around until we end execution

                #region Terminate the service if this Service Action is marked to terminate on fault

                //If this action should immediately terminate the execution of this service 
                //then stop here and return the results thus far
                if(serviceAction.TerminateServiceOnFault && errors.HasErrors())
                {
                    result = GlobalConstants.NullDataListID;
                }

                #endregion
            }

            return result;
        }
        // Travis.Frisinger : 25.01.2013 - Amended to be like decision
        internal void ConfigureSwitchCaseExpression(Tuple<ModelItem, IEnvironmentModel> payload)
        {
            IEnvironmentModel environment = payload.Item2;
            ModelItem switchCase = payload.Item1;
            string modelData = JsonConvert.SerializeObject(DataListConstants.DefaultCase);

            ErrorResultTO errors = new ErrorResultTO();
            Guid dataListID = GlobalConstants.NullDataListID;

            if (errors.HasErrors()) //BUG 8796, Added this if to handle errors
            {
                // Bad things happened... Tell the user
                PopupProvider.Show(errors.MakeDisplayReady(), GlobalConstants.SwitchWizardErrorHeading,
                                   MessageBoxButton.OK, MessageBoxImage.Error);
                // Stop configuring!!!
                return;
            }

            // now invoke the wizard ;)
            Uri requestUri;
            if (Uri.TryCreate((environment.WebServerAddress + GlobalConstants.SwitchDragWizardLocation), UriKind.Absolute, out requestUri))
            {
                string uriString = Browser.FormatUrl(requestUri.AbsoluteUri, dataListID);

                //var callBackHandler = new Dev2DecisionCallbackHandler();
                //callBackHandler.Owner = new WebPropertyEditorWindow(callBackHandler, uriString) { Width = 580, Height = 270 };
                //callBackHandler.Owner.ShowDialog();
                _callBackHandler.ModelData = modelData;

                WebSites.ShowWebPageDialog(uriString, _callBackHandler, 470, 285);


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

                    if (ds != null)
                    {
                        ModelProperty keyProperty = switchCase.Properties["Key"];

                        if (keyProperty != null)
                        {
                            keyProperty.SetValue(ds.SwitchVariable);
                        }
                    }
                }
                catch
                {
                    // Bad things happened... Tell the user
                    PopupProvider.Buttons = MessageBoxButton.OK;
                    PopupProvider.Description = GlobalConstants.SwitchWizardErrorString;
                    PopupProvider.Header = GlobalConstants.SwitchWizardErrorHeading;
                    PopupProvider.ImageType = MessageBoxImage.Error;
                    PopupProvider.Show();
                }
            }
        }
        internal void ConfigureSwitchExpression(Tuple<ModelItem, IEnvironmentModel> wrapper)
        {
            IEnvironmentModel environment = wrapper.Item2;
            ModelItem switchActivity = wrapper.Item1;

            ModelProperty switchProperty = switchActivity.Properties[GlobalConstants.SwitchExpressionPropertyText];

            if (switchProperty != null)
            {
                ModelItem activity = switchProperty.Value;

                if (activity != null)
                {
                    IDataListCompiler compiler = DataListFactory.CreateDataListCompiler(environment.DataListChannel);
                    ModelProperty activityExpression =
                        activity.Properties[GlobalConstants.SwitchExpressionTextPropertyText];

                    ErrorResultTO errors = new ErrorResultTO();
                    Guid dataListID = GlobalConstants.NullDataListID;

                    if (errors.HasErrors()) //BUG 8796, Added this if to handle errors
                    {
                        // Bad things happened... Tell the user
                        PopupProvider.Show(errors.MakeDisplayReady(), GlobalConstants.SwitchWizardErrorHeading,
                                           MessageBoxButton.OK, MessageBoxImage.Error);
                        // Stop configuring!!!
                        return;
                    }

                    string webModel = JsonConvert.SerializeObject(DataListConstants.DefaultSwitch);

                    if (activityExpression != null && activityExpression.Value == null)
                    {
                        // Its all new, push the default model
                        //compiler.PushSystemModelToDataList(dataListID, DataListConstants.DefaultSwitch, out errors);
                    }
                    else
                    {
                        if (activityExpression != null)
                        {
                            if (activityExpression.Value != null)
                            {
                                string val = activityExpression.Value.ToString();

                                if (val.IndexOf(GlobalConstants.InjectedSwitchDataFetch, StringComparison.Ordinal) >= 0)
                                {
                                    // Time to extract the data
                                    int start = val.IndexOf("(", StringComparison.Ordinal);
                                    if (start > 0)
                                    {
                                        int end = val.IndexOf(@""",AmbientData", StringComparison.Ordinal);

                                        if (end > start)
                                        {
                                            start += 2;
                                            val = val.Substring(start, (end - start));

                                            // Convert back for usage ;)
                                            val = Dev2DecisionStack.FromVBPersitableModelToJSON(val);

                                            if (!string.IsNullOrEmpty(val))
                                            {

                                                var ds = new Dev2Switch { SwitchVariable = val };
                                                webModel = JsonConvert.SerializeObject(ds);

                                            }

                                        }
                                    }
                                }
                            }
                        }
                    }

                    // now invoke the wizard ;)
                    Uri requestUri;
                    if (Uri.TryCreate((environment.WebServerAddress + GlobalConstants.SwitchDropWizardLocation), UriKind.Absolute, out requestUri))
                    {
                        string uriString = Browser.FormatUrl(requestUri.AbsoluteUri, dataListID);

                        callBackHandler.ModelData = webModel;
                        WebSites.ShowWebPageDialog(uriString, callBackHandler, 470, 285);


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

                            if (ds != null)
                            {
                                // FetchSwitchData
                                string expressionToInject = string.Join("", GlobalConstants.InjectedSwitchDataFetch, "(\"", ds.SwitchVariable, "\",", GlobalConstants.InjectedDecisionDataListVariable, ")");

                                if (activityExpression != null)
                                {
                                    activityExpression.SetValue(expressionToInject);
                                }
                            }
                        }
                        catch
                        {
                            // Bad things happened... Tell the user
                            PopupProvider.Show(GlobalConstants.SwitchWizardErrorString,
                                               GlobalConstants.SwitchWizardErrorHeading, MessageBoxButton.OK,
                                               MessageBoxImage.Error);
                        }
                    }
                }
            }
        }
        /// <summary>
        ///     Configures the decision expression.
        ///     Travis.Frisinger - Developed for new Decision Wizard
        /// </summary>
        /// <param name="wrapper">The wrapper.</param>
        internal void ConfigureDecisionExpression(Tuple<ModelItem, IEnvironmentModel> wrapper)
        {
            IEnvironmentModel environment = wrapper.Item2;
            ModelItem decisionActivity = wrapper.Item1;

            ModelProperty conditionProperty = decisionActivity.Properties[GlobalConstants.ConditionPropertyText];

            if (conditionProperty == null) return;

            var activity = conditionProperty.Value;
            if (activity != null)
            {
                string val = JsonConvert.SerializeObject(DataListConstants.DefaultStack);

                ModelProperty activityExpression = activity.Properties[GlobalConstants.ExpressionPropertyText];

                ErrorResultTO errors = new ErrorResultTO();

                if (errors.HasErrors()) //BUG 8796, Added this if to handle errors
                {
                    // Bad things happened... Tell the user
                    PopupProvider.Show(errors.MakeDisplayReady(), GlobalConstants.DecisionWizardErrorHeading, MessageBoxButton.OK, MessageBoxImage.Error);
                    // Stop configuring!!!
                    return;
                }

                // Push the correct data to the server ;)
                if (activityExpression != null && activityExpression.Value == null)
                {
                    // Its all new, push the empty model
                    //compiler.PushSystemModelToDataList(dataListID, DataListConstants.DefaultStack, out errors);
                }
                else if (activityExpression != null && activityExpression.Value != null)
                {
                    //we got a model, push it in to the Model region ;)
                    // but first, strip and extract the model data ;)

                    val = Dev2DecisionStack.ExtractModelFromWorkflowPersistedData(activityExpression.Value.ToString());

                    if (string.IsNullOrEmpty(val))
                    {

                        val = JsonConvert.SerializeObject(DataListConstants.DefaultStack);
                    }
                }

                // Now invoke the Wizard ;)
                Uri requestUri;
                if (Uri.TryCreate((environment.WebServerAddress + GlobalConstants.DecisionWizardLocation), UriKind.Absolute, out requestUri))
                {
                    string uriString = Browser.FormatUrl(requestUri.AbsoluteUri, GlobalConstants.NullDataListID);


                    _callBackHandler.ModelData = val; // set the model data

                //callBackHandler.Owner = new WebPropertyEditorWindow(callBackHandler, uriString);
                //callBackHandler.Owner.ShowDialog();
                WebSites.ShowWebPageDialog(uriString, _callBackHandler, 824, 508);
                    WebSites.ShowWebPageDialog(uriString, callBackHandler, 824, 508);

                    // Wizard finished...
                    try
                    {
                        // Remove naughty chars...
                        var tmp = callBackHandler.ModelData;
                        // remove the silly Choose... from the string
                        tmp = Dev2DecisionStack.RemoveDummyOptionsFromModel(tmp);
                        // remove [[]], &, !
                        tmp = Dev2DecisionStack.RemoveNaughtyCharsFromModel(tmp);

                        Dev2DecisionStack dds = JsonConvert.DeserializeObject<Dev2DecisionStack>(tmp);

                        if (dds != null)
                        {
                            // Empty check the arms ;)
                            if (string.IsNullOrEmpty(dds.TrueArmText.Trim()))
                            {
                                dds.TrueArmText = GlobalConstants.DefaultTrueArmText;
                            }

                            if (string.IsNullOrEmpty(dds.FalseArmText.Trim()))
                            {
                                dds.FalseArmText = GlobalConstants.DefaultFalseArmText;
                            }

                            // Update the decision node on the workflow ;)
                            string modelData = dds.ToVBPersistableModel();

                            // build up our injected expression handler ;)
                            string expressionToInject = string.Join("", GlobalConstants.InjectedDecisionHandler, "(\"", modelData, "\",", GlobalConstants.InjectedDecisionDataListVariable, ")");

                            if (activityExpression != null)
                            {
                                activityExpression.SetValue(expressionToInject);
                            }

                            // now set arms ;)
                            ModelProperty tArm = decisionActivity.Properties[GlobalConstants.TrueArmPropertyText];

                            if (tArm != null)
                            {
                                tArm.SetValue(dds.TrueArmText);
                            }

                            ModelProperty fArm = decisionActivity.Properties[GlobalConstants.FalseArmPropertyText];

                            if (fArm != null)
                            {
                                fArm.SetValue(dds.FalseArmText);
                            }
                        }
                    }
                    catch
                    {
                        // Bad things happened... Tell the user
                        //PopupProvider.Show("", "")
                        PopupProvider.Buttons = MessageBoxButton.OK;
                        PopupProvider.Description = GlobalConstants.DecisionWizardErrorString;
                        PopupProvider.Header = GlobalConstants.DecisionWizardErrorHeading;
                        PopupProvider.ImageType = MessageBoxImage.Error;
                        PopupProvider.Show();
                    }
                }
            }
        }
        // 28.01.2013 - Travis.Frisinger : Added for Case Edits
        internal void EditSwitchCaseExpression(Tuple<ModelProperty, IEnvironmentModel> payload)
        {
            IEnvironmentModel environment = payload.Item2;
            ModelProperty switchCaseValue = payload.Item1;

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


            ErrorResultTO errors = new ErrorResultTO();
            IDataListCompiler compiler = DataListFactory.CreateDataListCompiler(environment.DataListChannel);
            Guid dataListID = GlobalConstants.NullDataListID;

            if (errors.HasErrors()) //BUG 8796, Added this if to handle errors
            {
                // Bad things happened... Tell the user
                PopupProvider.Show(errors.MakeDisplayReady(), GlobalConstants.SwitchWizardErrorHeading,
                                   MessageBoxButton.OK, MessageBoxImage.Error);
                // Stop configuring!!!
                return;
            }

            // Extract existing value ;)

            if (switchCaseValue != null)
            {
                string val = switchCaseValue.ComputedValue.ToString();
                modelData = JsonConvert.SerializeObject(new Dev2Switch() { SwitchVariable = val });
            }
            else
            {
                // Problems, push empty model ;)
                compiler.PushSystemModelToDataList(dataListID, DataListConstants.DefaultCase, out errors);
            }

            // now invoke the wizard ;)
            Uri requestUri;
            if (Uri.TryCreate((environment.WebServerAddress + GlobalConstants.SwitchDragWizardLocation),
                              UriKind.Absolute, out requestUri))
            {
                string uriString = Browser.FormatUrl(requestUri.AbsoluteUri, dataListID);

                //var callBackHandler = new Dev2DecisionCallbackHandler();
                //callBackHandler.Owner = new WebPropertyEditorWindow(callBackHandler, uriString) { Width = 580, Height = 270 };
                //callBackHandler.Owner.ShowDialog();
                _callBackHandler.ModelData = modelData;
                WebSites.ShowWebPageDialog(uriString, _callBackHandler, 470, 285);


                // Wizard finished...
                // Now Fetch from DL and push the model data into the workflow
                try
                {
                    var ds = compiler.FetchSystemModelFromDataList<Dev2Switch>(dataListID, out errors);

                    if (ds != null)
                    {
                        // ReSharper disable PossibleNullReferenceException
                        switchCaseValue.SetValue(ds.SwitchVariable);
                        // ReSharper restore PossibleNullReferenceException
                    }
                }
                catch
                {
                    // Bad things happened... Tell the user
                    PopupProvider.Buttons = MessageBoxButton.OK;
                    PopupProvider.Description = GlobalConstants.SwitchWizardErrorString;
                    PopupProvider.Header = GlobalConstants.SwitchWizardErrorHeading;
                    PopupProvider.ImageType = MessageBoxImage.Error;
                    PopupProvider.Show();
                }
            }
        }