static void OnSelectedRandomTypeChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
        {
            var viewModel = (RandomDesignerViewModel)d;
            var value     = e.NewValue as string;

            if (!string.IsNullOrWhiteSpace(value))
            {
                switch (value)
                {
                case "GUID":
                    viewModel.IsLengthPath  = false;
                    viewModel.Visibility    = Visibility.Hidden;
                    viewModel.LengthContent = "Length";
                    break;

                case "Numbers":
                    viewModel.IsLengthPath  = false;
                    viewModel.Visibility    = Visibility.Visible;
                    viewModel.LengthContent = "Range";
                    break;

                default:
                    viewModel.IsLengthPath  = true;
                    viewModel.Visibility    = Visibility.Hidden;
                    viewModel.LengthContent = "Length";
                    break;
                }

                viewModel.RandomType = (enRandomType)Dev2EnumConverter.GetEnumFromStringDiscription(value, typeof(enRandomType));
            }
        }
Exemplo n.º 2
0
 Func <DataASTMutable.WarewolfAtom, DataASTMutable.WarewolfAtom> TryConvertFunc(BaseConvertTO item, IExecutionEnvironment env, int update)
 {
     return(a =>
     {
         IBaseConverter from = _fac.CreateConverter((enDev2BaseConvertType)Dev2EnumConverter.GetEnumFromStringDiscription(item.FromType, typeof(enDev2BaseConvertType)));
         IBaseConverter to = _fac.CreateConverter((enDev2BaseConvertType)Dev2EnumConverter.GetEnumFromStringDiscription(item.ToType, typeof(enDev2BaseConvertType)));
         IBaseConversionBroker broker = _fac.CreateBroker(@from, to);
         var value = a.ToString();
         if (a.IsNothing)
         {
             throw new Exception(string.Format("Scalar value {{{0}}} is NULL", item.FromExpression));
         }
         if (String.IsNullOrEmpty(value))
         {
             return DataASTMutable.WarewolfAtom.NewDataString("");
         }
         var upper = broker.Convert(value);
         var evalled = env.Eval(upper, update);
         if (evalled.IsWarewolfAtomResult)
         {
             var warewolfAtomResult = evalled as WarewolfDataEvaluationCommon.WarewolfEvalResult.WarewolfAtomResult;
             if (warewolfAtomResult != null)
             {
                 return warewolfAtomResult.Item;
             }
             return DataASTMutable.WarewolfAtom.Nothing;
         }
         return DataASTMutable.WarewolfAtom.NewDataString(WarewolfDataEvaluationCommon.EvalResultToString(evalled));
     });
 }
Exemplo n.º 3
0
 public void Dev2EnumConverter_GetEnumFromStringDiscription_WhenTypeIsNotEnum_ExpectInvalidOperationException()
 {
     //----------------------Arrange-------------------------
     //----------------------Act-----------------------------
     //----------------------Assert--------------------------
     Assert.ThrowsException <InvalidOperationException>(() => Dev2EnumConverter.GetEnumFromStringDiscription("Up", typeof(object)));
 }
Exemplo n.º 4
0
 Func <DataStorage.WarewolfAtom, DataStorage.WarewolfAtom> TryConvertFunc(BaseConvertTO item, IExecutionEnvironment env, int update) => a =>
 {
     var from   = _fac.CreateConverter((enDev2BaseConvertType)Dev2EnumConverter.GetEnumFromStringDiscription(item.FromType, typeof(enDev2BaseConvertType)));
     var to     = _fac.CreateConverter((enDev2BaseConvertType)Dev2EnumConverter.GetEnumFromStringDiscription(item.ToType, typeof(enDev2BaseConvertType)));
     var broker = _fac.CreateBroker(@from, to);
     var value  = a.ToString();
     if (a.IsNothing)
     {
         throw new Exception(string.Format(ErrorResource.NullScalarValue, item.FromExpression));
     }
     if (String.IsNullOrEmpty(value))
     {
         return(DataStorage.WarewolfAtom.NewDataString(""));
     }
     var upper   = broker.Convert(value);
     var evalled = env.Eval(upper, update);
     if (evalled.IsWarewolfAtomResult)
     {
         if (evalled is CommonFunctions.WarewolfEvalResult.WarewolfAtomResult warewolfAtomResult)
         {
             return(warewolfAtomResult.Item);
         }
         return(DataStorage.WarewolfAtom.Nothing);
     }
     return(DataStorage.WarewolfAtom.NewDataString(CommonFunctions.evalResultToString(evalled)));
 };
Exemplo n.º 5
0
        public void Dev2EnumConverter_GetEnumFromStringDiscription_WhenDiscriptionIsNotMacthedInEnum_IsNull_ExpectTrue()
        {
            //----------------------Arrange-------------------------
            //----------------------Act-----------------------------
            var convertEnumValueToString = Dev2EnumConverter.GetEnumFromStringDiscription("TestDiscription", typeof(enRoundingType));

            //----------------------Assert--------------------------
            Assert.IsNull(convertEnumValueToString);
        }
Exemplo n.º 6
0
        public void Dev2EnumConverter_GetEnumFromStringDiscription_WhenDiscriptionIsMacthedInEnum_AreEqual_ExpectTrue()
        {
            //----------------------Arrange-------------------------
            var discription = "Up";
            //----------------------Act-----------------------------
            var convertEnumValueToString = Dev2EnumConverter.GetEnumFromStringDiscription(discription, typeof(enRoundingType));

            //----------------------Assert--------------------------
            Assert.AreEqual(discription, convertEnumValueToString.ToString());
        }
Exemplo n.º 7
0
        static void OnSelectedCompressionRatioDescriptionPropertyChanged(DependencyObject d, DependencyPropertyChangedEventArgs args)
        {
            var viewModel   = (ZipDesignerViewModel)d;
            var description = args.NewValue as string;

            var enumValue = Dev2EnumConverter.GetEnumFromStringDiscription(description, typeof(CompressionRatios));

            if (enumValue != null)
            {
                viewModel.CompressionRatio = enumValue.ToString();
            }
        }
Exemplo n.º 8
0
        static enDev2ColumnArgumentDirection GetDev2ColumnArgumentDirection(XmlNode tmpNode)
        {
            XmlAttribute ioDirectionAttribute = tmpNode.Attributes[GlobalConstants.DataListIoColDirection];

            enDev2ColumnArgumentDirection ioDirection;

            if (ioDirectionAttribute != null)
            {
                ioDirection = (enDev2ColumnArgumentDirection)Dev2EnumConverter.GetEnumFromStringDiscription(ioDirectionAttribute.Value, typeof(enDev2ColumnArgumentDirection));
            }
            else
            {
                ioDirection = enDev2ColumnArgumentDirection.Both;
            }
            return(ioDirection);
        }
Exemplo n.º 9
0
        public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
        {
            if (value == null)
            {
                return(Visibility.Collapsed);
            }

            var enumValue = Dev2EnumConverter.GetEnumFromStringDiscription(value as string, typeof(enForEachType));

            Enum.TryParse((string)parameter, out enForEachType visibleEnumValue);

            if (visibleEnumValue.Equals(enumValue))
            {
                return(Visibility.Visible);
            }
            return(Visibility.Collapsed);
        }
Exemplo n.º 10
0
        public void GivenItContainsGatherSystemInfoAs(string parentName, string activityName, Table table)
        {
            var activity = new DsfGatherSystemInformationActivity {
                DisplayName = activityName
            };

            foreach (var tableRow in table.Rows)
            {
                var variable = tableRow["Variable"];

                _commonSteps.AddVariableToVariableList(variable);

                var systemInfo = (enTypeOfSystemInformationToGather)Dev2EnumConverter.GetEnumFromStringDiscription(tableRow["Selected"], typeof(enTypeOfSystemInformationToGather));
                activity.SystemInformationCollection.Add(new GatherSystemInformationTO(systemInfo, variable, 1));
            }

            _commonSteps.AddActivityToActivityList(parentName, activityName, activity);
        }
Exemplo n.º 11
0
        static void OnSelectedForeachTypeChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
        {
            var viewModel = (ForeachDesignerViewModel)d;
            var value     = e.NewValue as string;

            if (!string.IsNullOrWhiteSpace(value))
            {
                switch (value)
                {
                case "* in Range":
                    viewModel.FromVisibility       = Visibility.Visible;
                    viewModel.ToVisibility         = Visibility.Visible;
                    viewModel.CsvIndexesVisibility = Visibility.Hidden;
                    viewModel.NumberVisibility     = Visibility.Hidden;
                    viewModel.RecordsetVisibility  = Visibility.Hidden;
                    break;

                case "* in CSV":
                    viewModel.FromVisibility       = Visibility.Hidden;
                    viewModel.ToVisibility         = Visibility.Hidden;
                    viewModel.CsvIndexesVisibility = Visibility.Visible;
                    viewModel.NumberVisibility     = Visibility.Hidden;
                    viewModel.RecordsetVisibility  = Visibility.Hidden;
                    break;

                case "* in Recordset":
                    viewModel.FromVisibility       = Visibility.Hidden;
                    viewModel.ToVisibility         = Visibility.Hidden;
                    viewModel.CsvIndexesVisibility = Visibility.Visible;
                    viewModel.NumberVisibility     = Visibility.Hidden;
                    viewModel.RecordsetVisibility  = Visibility.Visible;
                    break;

                default:
                    viewModel.FromVisibility       = Visibility.Hidden;
                    viewModel.ToVisibility         = Visibility.Hidden;
                    viewModel.CsvIndexesVisibility = Visibility.Hidden;
                    viewModel.NumberVisibility     = Visibility.Visible;
                    viewModel.RecordsetVisibility  = Visibility.Hidden;
                    break;
                }
                viewModel.ForEachType = (enForEachType)Dev2EnumConverter.GetEnumFromStringDiscription(value, typeof(enForEachType));
            }
        }
Exemplo n.º 12
0
        public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
        {
            if (value == null)
            {
                return(NullValue);
            }

            if (value is string)
            {
                return(TrueEnumValues.Any(e =>
                {
                    object tempEnumValue = Dev2EnumConverter.GetEnumFromStringDiscription(value.ToString(), e.GetType());
                    return Equals(e, tempEnumValue);
                }));
            }

            if (!value.GetType().IsEnum)
            {
                return(Binding.DoNothing);
            }

            return(TrueEnumValues.Any(e => Equals(e, value)));
        }
Exemplo n.º 13
0
        static void OnSelectedScriptTypeChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
        {
            var viewModel = (ScriptDesignerViewModel)d;
            var value     = e.NewValue as string;

            if (!string.IsNullOrWhiteSpace(value))
            {
                switch (value)
                {
                case "Ruby":
                    viewModel.ScriptTypeDefaultText = "Ruby Syntax";
                    break;

                case "Python":
                    viewModel.ScriptTypeDefaultText = "Python Syntax";
                    break;

                default:
                    viewModel.ScriptTypeDefaultText = "JavaScript Syntax";
                    break;
                }
                viewModel.ScriptType = (enScriptType)Dev2EnumConverter.GetEnumFromStringDiscription(value, typeof(enScriptType));
            }
        }
Exemplo n.º 14
0
 /// <summary>
 /// Converts a value.
 /// </summary>
 /// <returns>
 /// A converted value. If the method returns null, the valid null value is used.
 /// </returns>
 /// <param name="value">The value that is produced by the binding target.</param><param name="targetType">The type to convert to.</param><param name="parameter">The converter parameter to use.</param><param name="culture">The culture to use in the converter.</param>
 public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
 {
     return(Dev2EnumConverter.GetEnumFromStringDiscription(value as string, targetType));
 }
 public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
 {
     return(Dev2EnumConverter.GetEnumFromStringDiscription(value.ToString(), targetType));
 }
Exemplo n.º 16
0
 public enRoundingType GetRoundingTypeEnum() => (enRoundingType)Dev2EnumConverter.GetEnumFromStringDiscription(RoundingType, typeof(enRoundingType));
Exemplo n.º 17
0
 public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) => Dev2EnumConverter.GetEnumFromStringDiscription(value?.ToString(), targetType);
Exemplo n.º 18
0
        // ReSharper restore RedundantOverridenMember


        /// <summary>
        /// The execute method that is called when the activity is executed at run time and will hold all the logic of the activity
        /// </summary>
        protected override void OnExecute(NativeActivityContext context)
        {
            _debugInputs  = new List <DebugItem>();
            _debugOutputs = new List <DebugItem>();
            _indexCounter = 0;
            IDSFDataObject    dataObject = context.GetExtension <IDSFDataObject>();
            IDataListCompiler compiler   = DataListFactory.CreateDataListCompiler();

            ErrorResultTO allErrors = new ErrorResultTO();
            ErrorResultTO errors;
            Guid          executionId = DataListExecutionID.Get(context);
            IDev2DataListUpsertPayloadBuilder <string> toUpsert = Dev2DataListBuilderFactory.CreateStringDataListUpsertBuilder(false);

            InitializeDebug(dataObject);

            try
            {
                CleanArgs();

                toUpsert.IsDebug = dataObject.IsDebugMode();

                foreach (var item in ConvertCollection)
                {
                    try
                    {
                        _indexCounter++;
                        // Travis.Frisinger - This needs to be in the ViewModel not here ;)
                        if (item.ToExpression == string.Empty)
                        {
                            item.ToExpression = item.FromExpression;
                        }
                        IsSingleValueRule.ApplyIsSingleValueRule(item.FromExpression, allErrors);
                        var fieldName = item.FromExpression;
                        fieldName = DataListUtil.IsValueRecordset(fieldName) ? DataListUtil.ReplaceRecordsetIndexWithBlank(fieldName) : fieldName;
                        var datalist = compiler.ConvertFrom(dataObject.DataListID, DataListFormat.CreateFormat(GlobalConstants._Studio_XML), Dev2.DataList.Contract.enTranslationDepth.Shape, out errors);
                        if (!datalist.IsNullOrEmpty())
                        {
                            var isValidExpr = new IsValidExpressionRule(() => fieldName, datalist.ToString())
                            {
                                LabelText = fieldName
                            };

                            var errorInfo = isValidExpr.Check();
                            if (errorInfo != null)
                            {
                                item.FromExpression = "";
                                errors.AddError(errorInfo.Message);
                            }
                            allErrors.MergeErrors(errors);
                        }

                        IBinaryDataListEntry tmp = compiler.Evaluate(executionId, enActionType.User, item.FromExpression, false, out errors);
                        if (dataObject.IsDebugMode())
                        {
                            AddDebugInputItem(item.FromExpression, tmp, executionId, item.FromType, item.ToType);
                        }
                        allErrors.MergeErrors(errors);
                        if (tmp != null)
                        {
                            IDev2DataListEvaluateIterator itr = Dev2ValueObjectFactory.CreateEvaluateIterator(tmp);

                            IBaseConverter        from   = _fac.CreateConverter((enDev2BaseConvertType)Dev2EnumConverter.GetEnumFromStringDiscription(item.FromType, typeof(enDev2BaseConvertType)));
                            IBaseConverter        to     = _fac.CreateConverter((enDev2BaseConvertType)Dev2EnumConverter.GetEnumFromStringDiscription(item.ToType, typeof(enDev2BaseConvertType)));
                            IBaseConversionBroker broker = _fac.CreateBroker(from, to);

                            // process result information
                            while (itr.HasMoreRecords())
                            {
                                IList <IBinaryDataListItem> cols = itr.FetchNextRowData();
                                foreach (IBinaryDataListItem c in cols)
                                {
                                    // set up live flushing iterator details
                                    if (c.IsDeferredRead)
                                    {
                                        if (toUpsert != null)
                                        {
                                            toUpsert.HasLiveFlushing      = true;
                                            toUpsert.LiveFlushingLocation = executionId;
                                        }
                                    }

                                    int indexToUpsertTo = c.ItemCollectionIndex;

                                    string val        = string.IsNullOrEmpty(c.TheValue) ? "" : broker.Convert(c.TheValue);
                                    string expression = item.ToExpression;

                                    if (DataListUtil.IsValueRecordset(item.ToExpression) && DataListUtil.GetRecordsetIndexType(item.ToExpression) == enRecordsetIndexType.Star)
                                    {
                                        expression = item.ToExpression.Replace(GlobalConstants.StarExpression, indexToUpsertTo.ToString(CultureInfo.InvariantCulture));
                                    }
                                    toUpsert.Add(expression, val);
                                    if (toUpsert != null && toUpsert.HasLiveFlushing)
                                    {
                                        toUpsert.FlushIterationFrame();
                                        toUpsert = null;
                                    }
                                }
                            }
                        }
                    }
                    catch (Exception e)
                    {
                        Dev2Logger.Log.Error("DSFBaseConvert", e);
                        allErrors.AddError(e.Message);
                    }
                    finally
                    {
                        if (allErrors.HasErrors())
                        {
                            toUpsert.Add(item.ToExpression, null);
                        }
                    }
                }

                if (toUpsert != null && toUpsert.HasLiveFlushing)
                {
                    try
                    {
                        toUpsert.FlushIterationFrame();
                    }
                    catch (Exception e)
                    {
                        Dev2Logger.Log.Error("DSFBaseConvert", e);
                        allErrors.AddError(e.Message);
                    }
                }
                else
                {
                    compiler.Upsert(executionId, toUpsert, out errors);
                    allErrors.MergeErrors(errors);
                }

                if (!allErrors.HasErrors() && toUpsert != null)
                {
                    var outIndex = 1;
                    foreach (var debugOutputTo in toUpsert.DebugOutputs)
                    {
                        var debugItem = new DebugItem();
                        AddDebugItem(new DebugItemStaticDataParams("", outIndex.ToString(CultureInfo.InvariantCulture)), debugItem);
                        AddDebugItem(new DebugItemVariableParams(debugOutputTo), debugItem);
                        _debugOutputs.Add(debugItem);
                        outIndex++;
                    }
                }
            }
            catch (Exception e)
            {
                Dev2Logger.Log.Error("DSFBaseConvert", e);
                allErrors.AddError(e.Message);
            }
            finally
            {
                // Handle Errors
                var hasErrors = allErrors.HasErrors();
                if (hasErrors)
                {
                    DisplayAndWriteError("DsfBaseConvertActivity", allErrors);
                    compiler.UpsertSystemTag(dataObject.DataListID, enSystemTag.Dev2Error, allErrors.MakeDataListReady(), out errors);
                }
                if (dataObject.IsDebugMode())
                {
                    DispatchDebugState(context, StateType.Before);
                    DispatchDebugState(context, StateType.After);
                }
            }
        }
Exemplo n.º 19
0
        internal static enDev2ColumnArgumentDirection GetDev2ColumnArgumentDirection(XmlNode tmpNode)
        {
            var ioDirectionAttribute = tmpNode.Attributes[GlobalConstants.DataListIoColDirection];

            enDev2ColumnArgumentDirection ioDirection;

            ioDirection = ioDirectionAttribute != null ? (enDev2ColumnArgumentDirection)(Dev2EnumConverter.GetEnumFromStringDiscription(ioDirectionAttribute.Value, typeof(enDev2ColumnArgumentDirection)) ?? enDev2ColumnArgumentDirection.Both) : enDev2ColumnArgumentDirection.Both;
            return(ioDirection);
        }