Ejemplo n.º 1
0
        private void InsertToCollection(IEnumerable <string> listToAdd, ModelItem modelItem)
        {
            var modelProperty = modelItem.Properties["ResultsCollection"];

            if (modelProperty != null)
            {
                ModelItemCollection mic = modelProperty.Collection;

                if (mic != null)
                {
                    List <DataSplitDTO> listOfValidRows = ResultsCollection.Where(c => !c.CanRemove()).ToList();
                    if (listOfValidRows.Count > 0)
                    {
                        DataSplitDTO dataSplitDto = ResultsCollection.Last(c => !c.CanRemove());
                        int          startIndex   = ResultsCollection.IndexOf(dataSplitDto) + 1;
                        foreach (string s in listToAdd)
                        {
                            mic.Insert(startIndex, new DataSplitDTO(s, ResultsCollection[startIndex - 1].SplitType, ResultsCollection[startIndex - 1].At, startIndex + 1));
                            startIndex++;
                        }
                        CleanUpCollection(mic, modelItem, startIndex);
                    }
                    else
                    {
                        AddToCollection(listToAdd, modelItem);
                    }
                }
            }
        }
        void InsertToCollection(IEnumerable <string> listToAdd, ModelItem modelItem)
        {
            var modelProperty = modelItem.Properties["ResultsCollection"];

            if (modelProperty == null)
            {
                return;
            }
            var mic = modelProperty.Collection;

            if (mic == null)
            {
                return;
            }
            var listOfValidRows = ResultsCollection.Where(c => !c.CanRemove()).ToList();

            if (listOfValidRows.Count > 0)
            {
                FindRecordsTO findRecordsTo = ResultsCollection.Last(c => !c.CanRemove());
                var           startIndex    = ResultsCollection.IndexOf(findRecordsTo) + 1;
                foreach (var s in listToAdd)
                {
                    mic.Insert(startIndex, new FindRecordsTO(s, ResultsCollection[startIndex - 1].SearchType, startIndex + 1));
                    startIndex++;
                }
                CleanUpCollection(mic, modelItem, startIndex);
            }
            else
            {
                AddToCollection(listToAdd, modelItem);
            }
        }
Ejemplo n.º 3
0
 public ItemsWindow(ResultsCollection resultsCollection)
 {
     InitializeComponent();
     c = resultsCollection;
     dataGrid.Items.Clear();
     dataGrid.ItemsSource = c._collection;
     this.Show();
 }
Ejemplo n.º 4
0
 public override int GetHashCode()
 {
     unchecked
     {
         var hashCode = base.GetHashCode();
         hashCode = (hashCode * 397) ^ (ResultsCollection != null ? ResultsCollection.GetHashCode() : 0);
         hashCode = (hashCode * 397) ^ (SourceString != null ? SourceString.GetHashCode() : 0);
         hashCode = (hashCode * 397) ^ _isDebugMode.GetHashCode();
         return(hashCode);
     }
 }
Ejemplo n.º 5
0
        public bool Equals(DsfXPathActivity other)
        {
            if (ReferenceEquals(null, other))
            {
                return(false);
            }

            if (ReferenceEquals(this, other))
            {
                return(true);
            }

            return(base.Equals(other) &&
                   ResultsCollection.SequenceEqual(other.ResultsCollection) &&
                   string.Equals(SourceString, other.SourceString));
        }
Ejemplo n.º 6
0
        private void Config()
        {
            ParametersCollection.Add(ObjectDistanceLabel);
            ParametersCollection.Add(ObjectDistanceTextBox);

            ParametersCollection.Add(ObjectSpeedLabel);
            ParametersCollection.Add(ObjectSpeedTextBox);

            ParametersCollection.Add(SignalSpeedLabel);
            ParametersCollection.Add(SignalSpeedTextBox);

            ParametersCollection.Add(MomentInTimeLabel);
            ParametersCollection.Add(MomentInTimeTextBox);


            ResultsCollection.Add(ResultDistanceLabel);
            ResultsCollection.Add(ResultDistanceTextBox);
        }
Ejemplo n.º 7
0
        public override void UpdateForEachOutputs(IList <Tuple <string, string> > updates)
        {
            if (updates != null)
            {
                foreach (Tuple <string, string> t in updates)
                {
                    // locate all updates for this tuple
                    Tuple <string, string> t1 = t;
                    var items = ResultsCollection.Where(c => !string.IsNullOrEmpty(c.OutputVariable) && c.OutputVariable.Equals(t1.Item1));

                    // issues updates
                    foreach (var a in items)
                    {
                        a.OutputVariable = t.Item2;
                    }
                }
            }
        }
Ejemplo n.º 8
0
        public override void UpdateForEachInputs(IList <Tuple <string, string> > updates)
        {
            if (updates != null)
            {
                foreach (Tuple <string, string> t in updates)
                {
                    // locate all updates for this tuple
                    var t1    = t;
                    var items = ResultsCollection.Where(c => !string.IsNullOrEmpty(c.XPath) && c.XPath.Equals(t1.Item1));

                    // issues updates
                    foreach (var a in items)
                    {
                        a.XPath = t.Item2;
                    }

                    if (SourceString == t.Item1)
                    {
                        SourceString = t.Item2;
                    }
                }
            }
        }
        public override void UpdateForEachInputs(IList <Tuple <string, string> > updates)
        {
            if (updates != null)
            {
                foreach (Tuple <string, string> t in updates)
                {
                    // locate all updates for this tuple
                    Tuple <string, string> t1 = t;
                    var items = ResultsCollection.Where(c => !string.IsNullOrEmpty(c.SearchCriteria) && c.SearchCriteria.Equals(t1.Item1));

                    // issues updates
                    foreach (var a in items)
                    {
                        a.SearchCriteria = t.Item2;
                    }

                    if (FieldsToSearch == t.Item1)
                    {
                        FieldsToSearch = t.Item2;
                    }
                }
            }
        }
Ejemplo n.º 10
0
 public MainWindow()
 {
     InitializeComponent();
     this.DataContext = this;
     // Listen to Serial Port events
     ResultsCollection.Add(new TestResultsModel {
         IsSelected = false, Parameter = "STM-IMU", Result = string.Empty
     });
     ResultsCollection.Add(new TestResultsModel {
         IsSelected = false, Parameter = "STM-RTC", Result = string.Empty
     });
     // ResultsCollection.Add(new TestResultsModel { IsSelected = false, Parameter = "STM-Internal Battery", Result = string.Empty });
     ResultsCollection.Add(new TestResultsModel {
         IsSelected = false, Parameter = "STM-External Battery", Result = string.Empty
     });
     ResultsCollection.Add(new TestResultsModel {
         IsSelected = false, Parameter = "STM-CAN1", Result = string.Empty
     });
     ResultsCollection.Add(new TestResultsModel {
         IsSelected = false, Parameter = "STM-CAN2", Result = string.Empty
     });
     ResultsCollection.Add(new TestResultsModel {
         IsSelected = false, Parameter = "STM-Ignition", Result = string.Empty
     });
     ResultsCollection.Add(new TestResultsModel {
         IsSelected = false, Parameter = "WP-IMEI", Result = string.Empty
     });
     ResultsCollection.Add(new TestResultsModel {
         IsSelected = false, Parameter = "WP-SIM", Result = string.Empty
     });
     ResultsCollection.Add(new TestResultsModel {
         IsSelected = false, Parameter = "WP-GPS", Result = string.Empty
     });
     ResultsCollection.Add(new TestResultsModel {
         IsSelected = false, Parameter = "WP-Digital Inputs", Result = string.Empty
     });
 }
        protected override void ExecuteTool(IDSFDataObject dataObject, int update)
        {
            var env = dataObject.Environment;

            InitializeDebug(dataObject);
            var allErrors = new ErrorResultTO();

            try
            {
                IList <string> toSearch     = FieldsToSearch.Split(',').Select(a => a.Trim()).ToList();
                var            scalarValues = toSearch.Where(DataListUtil.IsValueScalar).ToList();
                if (scalarValues.Any())
                {
                    throw new Exception("Scalars are not allowed. Please check the following:" + Environment.NewLine + string.Join(Environment.NewLine, scalarValues));
                }
                List <int> results = new List <int>();
                if (dataObject.IsDebugMode())
                {
                    AddDebugInputValues(dataObject, toSearch, ref allErrors, update);
                }

                bool hasEvaled = false;
                foreach (var searchvar in toSearch)
                {
                    Func <DataASTMutable.WarewolfAtom, bool> func = null;
                    foreach (FindRecordsTO to in ResultsCollection.Where(a => !String.IsNullOrEmpty(a.SearchType)))
                    {
                        if (to.From.Length > 0 && String.IsNullOrEmpty(to.To) ||
                            to.To.Length > 0 && String.IsNullOrEmpty(to.From))
                        {
                            throw new Exception("From and to Must be populated");
                        }
                        ValidateRequiredFields(to, out errorsTo);
                        var right = env.EvalAsList(to.SearchCriteria, update);
                        IEnumerable <DataASTMutable.WarewolfAtom> from    = new List <DataASTMutable.WarewolfAtom>();
                        IEnumerable <DataASTMutable.WarewolfAtom> tovalue = new List <DataASTMutable.WarewolfAtom>();

                        if (!String.IsNullOrEmpty(to.From))
                        {
                            @from = env.EvalAsList(to.From, update);
                        }
                        if (!String.IsNullOrEmpty(to.To))
                        {
                            tovalue = env.EvalAsList(to.To, update);
                        }
                        if (func == null)
                        {
                            func = CreateFuncFromOperator(to.SearchType, right, @from, tovalue);
                        }
                        else
                        {
                            func = RequireAllTrue ? CombineFuncAnd(func, to.SearchType, right, @from, tovalue) : CombineFuncOr(func, to.SearchType, right, @from, tovalue);
                        }
                    }
                    var output = env.EnvalWhere(dataObject.Environment.ToStar(searchvar), func, update);

                    if (RequireAllFieldsToMatch && hasEvaled)
                    {
                        results = results.Intersect(output).ToList();
                    }
                    else
                    {
                        results = results.Union(output).ToList();
                    }
                    hasEvaled = true;
                }
                if (!results.Any())
                {
                    results.Add(-1);
                }
                var res = String.Join(",", results.Distinct());
                env.Assign(Result, res, update);
                if (dataObject.IsDebugMode())
                {
                    AddDebugOutputItem(new DebugEvalResult(Result, "", dataObject.Environment, update));
                }
            }
            catch (Exception exception)
            {
                Dev2Logger.Log.Error("DSFRecordsMultipleCriteria", exception);
                allErrors.AddError(exception.Message);
            }
            finally
            {
                var hasErrors = allErrors.HasErrors();
                if (hasErrors)
                {
                    DisplayAndWriteError("DsfFindRecordsMultipleCriteriaActivity", allErrors);
                    var errorString = allErrors.MakeDisplayReady();
                    dataObject.Environment.AddError(errorString);
                    dataObject.Environment.Assign(Result, "-1", update);
                    if (dataObject.IsDebugMode())
                    {
                        AddDebugOutputItem(new DebugEvalResult(Result, "", dataObject.Environment, update));
                    }
                }

                if (dataObject.IsDebugMode())
                {
                    DispatchDebugState(dataObject, StateType.Before, update);
                    DispatchDebugState(dataObject, StateType.After, update);
                }
            }
        }
Ejemplo n.º 12
0
 public override List <string> GetOutputs()
 {
     return(ResultsCollection.Select(dto => dto.OutputVariable).ToList());
 }
Ejemplo n.º 13
0
 public int GetCollectionCount()
 {
     return(ResultsCollection.Count(caseConvertTo => !caseConvertTo.CanRemove()));
 }
Ejemplo n.º 14
0
        public override IList <DsfForEachItem> GetForEachOutputs()
        {
            var items = ResultsCollection.Where(c => !string.IsNullOrEmpty(c.OutputVariable)).Select(c => c.OutputVariable).ToArray();

            return(GetForEachItems(items));
        }
Ejemplo n.º 15
0
        public override IList <DsfForEachItem> GetForEachInputs()
        {
            var items = new[] { SourceString }.Union(ResultsCollection.Where(c => !string.IsNullOrEmpty(c.At)).Select(c => c.At)).ToArray();

            return(GetForEachItems(items));
        }
Ejemplo n.º 16
0
        public MockDatabase()
        {
            User user1 = new User
            {
                Id           = 1,
                UniversityId = "s0000001",
                FirstName    = "Connagh",
                LastName     = "Muldoon",
                Email        = "*****@*****.**",
                PhoneNumber  = "01452699316",
                DateOfBirth  = new DateTime(1995, 06, 01),
                Role         = UserRole.Student,
                Graduated    = false
            };
            User user2 = new User
            {
                Id           = 2,
                UniversityId = "s0000002",
                FirstName    = "Thomas",
                LastName     = "Clark",
                Email        = "*****@*****.**",
                PhoneNumber  = "01452234765",
                DateOfBirth  = new DateTime(1995, 02, 23),
                Role         = UserRole.Student,
                Enrollments  = new List <Identifier>()
            };
            User user3 = new User
            {
                Id           = 3,
                UniversityId = "s0000003",
                FirstName    = "Abu",
                LastName     = "Alam",
                Email        = "*****@*****.**",
                PhoneNumber  = "01452543876",
                DateOfBirth  = new DateTime(1988, 08, 12),
                Role         = UserRole.Lecturer
            };

            Module module1 = new Module
            {
                Id          = 1,
                ModuleTitle = "Applied Ass Kicking",
                ModuleCode  = "CT1337"
            };

            ModuleRun moduleRun1 = new ModuleRun
            {
                Id       = 1,
                Lecturer = user3.ToIdentifier(),
                Module   = module1.ToIdentifier()
            };

            module1.ModuleRuns = new List <Identifier>()
            {
                moduleRun1.ToIdentifier()
            };

            Assignment assignment1 = new Assignment
            {
                Id             = 1,
                AssignmentName = "1. Chew Bubblegum",
                ModuleRun      = moduleRun1.ToIdentifier()
            };

            moduleRun1.Assignments = new List <Identifier>()
            {
                assignment1.ToIdentifier()
            };

            Course course1 = new Course
            {
                Id           = 1,
                Title        = "Computing - BSc W/Hons",
                CourseLeader = user3.ToIdentifier(),
                ModuleRuns   = new List <Identifier>()
                {
                    moduleRun1.ToIdentifier()
                },
                Students = new List <Identifier>()
                {
                    user1.ToIdentifier()
                }
            };

            Result result1 = new Result()
            {
                Id         = 1,
                Assignment = assignment1.ToIdentifier(),
                Grade      = 74,
                Student    = user1.ToIdentifier()
            };

            assignment1.Results = new List <Identifier>()
            {
                result1.ToIdentifier()
            };

            user1.Enrollments = new List <Identifier>()
            {
                moduleRun1.ToIdentifier()
            };
            user1.Course      = new Identifier(course1);
            user3.Enrollments = new List <Identifier>()
            {
                moduleRun1.ToIdentifier()
            };
            user3.Course = new Identifier(course1);

            UsersCollection.Add(user1);
            UsersCollection.Add(user2);
            UsersCollection.Add(user3);
            ModulesCollection.Add(module1);
            ModuleRunsCollection.Add(moduleRun1);
            AssignmentsCollection.Add(assignment1);
            ResultsCollection.Add(result1);
            CoursesCollection.Add(course1);
        }
Ejemplo n.º 17
0
        protected override void ExecuteTool(IDSFDataObject dataObject, int update)
        {
            _indexCounter = 1;

            ErrorResultTO        allErrors = new ErrorResultTO();
            var                  env       = dataObject.Environment;
            WarewolfListIterator iter      = new WarewolfListIterator();

            InitializeDebug(dataObject);
            try
            {
                var sourceString = SourceString ?? "";
                if (dataObject.IsDebugMode())
                {
                    AddDebugInputItem(new DebugEvalResult(sourceString, "String to Split", env, update));
                    AddDebugInputItem(new DebugItemStaticDataParams(ReverseOrder ? "Backward" : "Forward", "Process Direction"));
                    AddDebugInputItem(new DebugItemStaticDataParams(SkipBlankRows ? "Yes" : "No", "Skip blank rows"));
                    AddDebug(ResultsCollection, dataObject.Environment, update);
                }
                var res = new WarewolfIterator(env.Eval(sourceString, update));
                iter.AddVariableToIterateOn(res);
                IDictionary <string, int> positions = new Dictionary <string, int>();
                CleanArguments(ResultsCollection);
                ResultsCollection.ToList().ForEach(a =>
                {
                    if (!positions.ContainsKey(a.OutputVariable))
                    {
                        positions.Add(a.OutputVariable, update == 0 ? 1 : update);
                    }
                    IsSingleValueRule.ApplyIsSingleValueRule(a.OutputVariable, allErrors);
                });
                bool singleInnerIteration = ArePureScalarTargets(ResultsCollection);
                var  resultsEnumerator    = ResultsCollection.GetEnumerator();
                var  debugDictionary      = new List <string>();
                while (res.HasMoreData())
                {
                    const int OpCnt = 0;

                    var item = res.GetNextValue(); // item is the thing we split on
                    if (!string.IsNullOrEmpty(item))
                    {
                        string val = item;

                        var blankRows = new List <int>();
                        if (SkipBlankRows)
                        {
                            var strings         = val.Split(new[] { Environment.NewLine, "\r", "\n" }, StringSplitOptions.RemoveEmptyEntries);
                            var newSourceString = string.Join(Environment.NewLine, strings);
                            val = newSourceString;
                        }
                        else
                        {
                            var strings = val.Split(new[] { Environment.NewLine }, StringSplitOptions.None);
                            for (int blankRow = 0; blankRow < strings.Length; blankRow++)
                            {
                                if (String.IsNullOrEmpty(strings[blankRow]))
                                {
                                    blankRows.Add(blankRow);
                                }
                            }
                        }

                        ErrorResultTO  errors;
                        IDev2Tokenizer tokenizer = CreateSplitPattern(ref val, ResultsCollection, env, out errors, update);
                        allErrors.MergeErrors(errors);

                        if (!allErrors.HasErrors())
                        {
                            if (tokenizer != null)
                            {
                                int pos = 0;
                                int end = ResultsCollection.Count - 1;

                                // track used tokens so we can adjust flushing ;)
                                while (tokenizer.HasMoreOps())
                                {
                                    var currentval = resultsEnumerator.MoveNext();
                                    if (!currentval)
                                    {
                                        if (singleInnerIteration)
                                        {
                                            break;
                                        }
                                        resultsEnumerator.Reset();
                                        resultsEnumerator.MoveNext();
                                    }
                                    string tmp = tokenizer.NextToken();

                                    if (tmp.StartsWith(Environment.NewLine) && !SkipBlankRows)
                                    {
                                        resultsEnumerator.Reset();
                                        while (resultsEnumerator.MoveNext())
                                        {
                                            var tovar = resultsEnumerator.Current.OutputVariable;
                                            if (!String.IsNullOrEmpty(tovar))
                                            {
                                                var assignToVar = ExecutionEnvironment.ConvertToIndex(tovar, positions[tovar]);
                                                env.AssignWithFrame(new AssignValue(assignToVar, ""), update);
                                                positions[tovar] = positions[tovar] + 1;
                                            }
                                        }
                                        resultsEnumerator.Reset();
                                        resultsEnumerator.MoveNext();
                                    }
                                    if (blankRows.Contains(OpCnt) && blankRows.Count != 0)
                                    {
                                        tmp = tmp.Replace(Environment.NewLine, "");
                                        while (pos != end + 1)
                                        {
                                            pos++;
                                        }
                                    }
                                    var outputVar = resultsEnumerator.Current.OutputVariable;

                                    if (!String.IsNullOrEmpty(outputVar))
                                    {
                                        var assignVar = ExecutionEnvironment.ConvertToIndex(outputVar, positions[outputVar]);
                                        if (ExecutionEnvironment.IsRecordsetIdentifier(assignVar))
                                        {
                                            env.AssignWithFrame(new AssignValue(assignVar, tmp), update);
                                        }
                                        else if (ExecutionEnvironment.IsScalar(assignVar) && positions[outputVar] == 1)
                                        {
                                            env.AssignWithFrame(new AssignValue(assignVar, tmp), update);
                                        }
                                        else
                                        {
                                            env.AssignWithFrame(new AssignValue(assignVar, tmp), update);
                                        }
                                        positions[outputVar] = positions[outputVar] + 1;
                                    }
                                    if (dataObject.IsDebugMode())
                                    {
                                        var debugItem   = new DebugItem();
                                        var outputVarTo = resultsEnumerator.Current.OutputVariable;
                                        AddDebugItem(new DebugEvalResult(outputVarTo, "", env, update), debugItem);
                                        if (!debugDictionary.Contains(outputVarTo))
                                        {
                                            debugDictionary.Add(outputVarTo);
                                        }
                                    }
                                    if (pos == end)
                                    {
                                    }
                                    else
                                    {
                                        pos++;
                                    }
                                }
                            }
                        }
                    }
                    env.CommitAssign();
                    if (singleInnerIteration)
                    {
                        break;
                    }
                }

                if (dataObject.IsDebugMode())
                {
                    var outputIndex = 1;
                    foreach (var varDebug in debugDictionary)
                    {
                        var debugItem = new DebugItem();
                        AddDebugItem(new DebugItemStaticDataParams("", outputIndex.ToString(CultureInfo.InvariantCulture)), debugItem);
                        var dataSplitUsesStarForOutput = varDebug.Replace("().", "(*).");
                        AddDebugItem(new DebugEvalResult(dataSplitUsesStarForOutput, "", env, update), debugItem);
                        _debugOutputs.Add(debugItem);
                        outputIndex++;
                    }
                }
            }
            catch (Exception e)
            {
                Dev2Logger.Error("DSFDataSplit", e);
                allErrors.AddError(e.Message);
            }
            finally
            {
                // Handle Errors
                var hasErrors = allErrors.HasErrors();
                if (hasErrors)
                {
                    DisplayAndWriteError("DsfDataSplitActivity", allErrors);
                    var errorString = allErrors.MakeDisplayReady();
                    dataObject.Environment.AddError(errorString);
                }

                if (dataObject.IsDebugMode())
                {
                    DispatchDebugState(dataObject, StateType.Before, update);
                    DispatchDebugState(dataObject, StateType.After, update);
                }
            }
        }
        public override IList <DsfForEachItem> GetForEachInputs()
        {
            var items = new[] { FieldsToSearch }.Union(ResultsCollection.Where(c => !string.IsNullOrEmpty(c.SearchCriteria)).Select(c => c.SearchCriteria)).ToArray();

            return(GetForEachItems(items));
        }
Ejemplo n.º 19
0
 public int GetCollectionCount() => ResultsCollection.Count(xPathDto => !xPathDto.CanRemove());
Ejemplo n.º 20
0
 public override List <string> GetOutputs() => ResultsCollection?.Select(dto => dto.OutputVariable).ToList() ?? new List <string>();
Ejemplo n.º 21
0
        public void Config()
        {
            GenerateParameters(0);

            #region ADDING ADDITIONAL PARAMETERS CONTROLS TO THE TAB
            AdditionalParametersCollection.Add(SamplingFrequencyLabel);
            AdditionalParametersCollection.Add(SamplingFrequencyTextBox);

            AdditionalParametersCollection.Add(ReconstructionFrequencyLabel);
            AdditionalParametersCollection.Add(ReconstructionFrequencyTextBox);

            AdditionalParametersCollection.Add(QuantLevelAmountLabel);
            AdditionalParametersCollection.Add(QuantLevelAmountTextBox);

            AdditionalParametersCollection.Add(SeenSamplesLabel);
            AdditionalParametersCollection.Add(SeenSamplesTextBox);
            #endregion

            #region ADDING PARAMETERS FOR THE RESULTS
            FilterParameters.Add(MAmountLabel);
            FilterParameters.Add(MAmountTextBox);

            //FilterParameters.Add(FilterSamplingFrequencyLabel);
            //FilterParameters.Add(FilterSamplingFrequencyTextBox);

            FilterParameters.Add(CutOffSamplingFrequencyLabel);
            FilterParameters.Add(CutOffSamplingFrequencyTextBox);

            FilterParameters.Add(WindowLabel);
            FilterParameters.Add(WindowComboBox);

            FilterParameters.Add(FilterLabel);
            FilterParameters.Add(FilterComboBox);
            #endregion


            #region ADDING RESULTS CONTROLS TO THE TAB
            ResultsCollection.Add(AverageLabel);
            ResultsCollection.Add(AverageTextBox);

            ResultsCollection.Add(AbsAverageLabel);
            ResultsCollection.Add(AbsAverageTextBox);

            ResultsCollection.Add(RootMeanSquareLabel);
            ResultsCollection.Add(RootMeanSquareTextBox);

            ResultsCollection.Add(VariationLabel);
            ResultsCollection.Add(VariationTextBox);

            ResultsCollection.Add(AveragePowerLabel);
            ResultsCollection.Add(AveragePowerTextBox);
            #endregion

            #region ADDING SINC SERULTS CONTROLS TO THE TAB
            SincResultsCollection.Add(MeanSquareErrorLabel);
            SincResultsCollection.Add(MeanSquareErrorTextBox);

            SincResultsCollection.Add(RatioLabel);
            SincResultsCollection.Add(RatioTextBox);

            SincResultsCollection.Add(MaxRatioLabel);
            SincResultsCollection.Add(MaxRatioTextBox);

            SincResultsCollection.Add(MaxDiffrenceLabel);
            SincResultsCollection.Add(MaxDiffrenceTextBox);
            #endregion
        }
Ejemplo n.º 22
0
        // ReSharper restore RedundantOverridenMember

        protected override void OnExecute(NativeActivityContext context)
        {
            _debugInputs  = new List <DebugItem>();
            _debugOutputs = new List <DebugItem>();
            _indexCounter = 1;
            IDSFDataObject    dataObject = context.GetExtension <IDSFDataObject>();
            IDataListCompiler compiler   = DataListFactory.CreateDataListCompiler();
            Guid          dlId           = dataObject.DataListID;
            ErrorResultTO allErrors      = new ErrorResultTO();
            ErrorResultTO errors;

            _datalistString = compiler.ConvertFrom(dataObject.DataListID, DataListFormat.CreateFormat(GlobalConstants._Studio_XML), Dev2.DataList.Contract.enTranslationDepth.Shape, out errors).ToString();

            InitializeDebug(dataObject);
            try
            {
                var sourceString = SourceString ?? "";
                IBinaryDataListEntry expressionsEntry = compiler.Evaluate(dlId, enActionType.User, sourceString, false, out errors);

                if (dataObject.IsDebugMode())
                {
                    AddDebugInputItem(new DebugItemVariableParams(sourceString, "String to Split", expressionsEntry, dlId));
                    AddDebugInputItem(new DebugItemStaticDataParams(ReverseOrder ? "Backward" : "Forward", "Process Direction"));
                    AddDebugInputItem(new DebugItemStaticDataParams(SkipBlankRows ? "Yes" : "No", "Skip blank rows"));
                }
                CleanArguments(ResultsCollection);
                ResultsCollection.ToList().ForEach(a => IsSingleValueRule.ApplyIsSingleValueRule(a.OutputVariable, allErrors));
                if (ResultsCollection.Count > 0)
                {
                    if (dataObject.IsDebugMode())
                    {
                        AddDebug(ResultsCollection, compiler, dlId);
                    }

                    CheckIndex(sourceString);
                    allErrors.MergeErrors(errors);
                    IDev2DataListEvaluateIterator itr = Dev2ValueObjectFactory.CreateEvaluateIterator(expressionsEntry);
                    IDev2DataListUpsertPayloadBuilder <string> toUpsert = Dev2DataListBuilderFactory.CreateStringDataListUpsertBuilder(true);
                    bool singleInnerIteration = ArePureScalarTargets(ResultsCollection);
                    bool exit = false;
                    while (itr.HasMoreRecords())
                    {
                        IList <IBinaryDataListItem> cols = itr.FetchNextRowData();
                        foreach (IBinaryDataListItem c in cols)
                        {
                            // set up live flushing iterator details
                            toUpsert.HasLiveFlushing      = true;
                            toUpsert.LiveFlushingLocation = dlId;

#pragma warning disable 219
                            int opCnt = 0;
#pragma warning restore 219
                            if (!string.IsNullOrEmpty(c.TheValue))
                            {
                                string val       = c.TheValue;
                                var    blankRows = new List <int>();
                                if (SkipBlankRows)
                                {
                                    var strings         = val.Split(new[] { Environment.NewLine, "\r", "\n" }, StringSplitOptions.RemoveEmptyEntries);
                                    var newSourceString = string.Join(Environment.NewLine, strings);
                                    val = newSourceString;
                                }
                                else
                                {
                                    var strings = val.Split(new[] { Environment.NewLine }, StringSplitOptions.None);
                                    for (int blankRow = 0; blankRow < strings.Length; blankRow++)
                                    {
                                        if (String.IsNullOrEmpty(strings[blankRow]))
                                        {
                                            blankRows.Add(blankRow);
                                        }
                                    }
                                }

                                IDev2Tokenizer tokenizer = CreateSplitPattern(ref val, ResultsCollection, compiler, dlId, out errors);
                                allErrors.MergeErrors(errors);

                                if (!allErrors.HasErrors())
                                {
                                    if (tokenizer != null)
                                    {
                                        int pos = 0;
                                        int end = (ResultsCollection.Count - 1);

                                        // track used tokens so we can adjust flushing ;)
                                        HashSet <string> usedTokens = new HashSet <string>();

                                        while (tokenizer.HasMoreOps() && !exit)
                                        {
                                            string tmp = tokenizer.NextToken();
                                            if (blankRows.Contains(opCnt) && blankRows.Count != 0)
                                            {
                                                tmp = tmp.Replace(Environment.NewLine, "");
                                                while (pos != end + 1)
                                                {
                                                    UpdateOutputVariableWithValue(pos, usedTokens, toUpsert, "");
                                                    pos++;
                                                }
                                                pos = CompletedRow(usedTokens, toUpsert, singleInnerIteration, ref opCnt, ref exit);
                                            }
                                            UpdateOutputVariableWithValue(pos, usedTokens, toUpsert, tmp);

                                            // Per pass
                                            if (pos == end)
                                            {
                                                //row has been processed
                                                pos = CompletedRow(usedTokens, toUpsert, singleInnerIteration, ref opCnt, ref exit);
                                            }
                                            else
                                            {
                                                pos++;
                                            }
                                        }

                                        // flush the final frame ;)

                                        toUpsert.FlushIterationFrame();
                                        toUpsert = Dev2DataListBuilderFactory.CreateStringDataListUpsertBuilder(true);
                                    }
                                }
                            }
                        }
                    }
                    if (dataObject.IsDebugMode() && !allErrors.HasErrors())
                    {
                        AddResultToDebug(compiler, dlId);
                    }
                }
            }
            catch (Exception e)
            {
                Dev2Logger.Log.Error("DSFDataSplit", e);
                allErrors.AddError(e.Message);
            }
            finally
            {
                // Handle Errors
                var hasErrors = allErrors.HasErrors();
                if (hasErrors)
                {
                    DisplayAndWriteError("DsfDataSplitActivity", allErrors);
                    compiler.UpsertSystemTag(dlId, enSystemTag.Dev2Error, allErrors.MakeDataListReady(), out errors);
                }

                if (dataObject.IsDebugMode())
                {
                    if (hasErrors)
                    {
                        AddResultToDebug(compiler, dlId);
                    }
                    DispatchDebugState(context, StateType.Before);
                    DispatchDebugState(context, StateType.After);
                }
            }
        }
Ejemplo n.º 23
0
 private void FlashTestProcess_Exited(object sender, System.EventArgs e)
 {
     IsProcessRunning = false;
     try
     {
         Process[] process = Process.GetProcesses();
         process.Where(x => x.Id == ProcessId).FirstOrDefault()?.Kill();
         var         appSettings = ConfigurationManager.AppSettings;
         List <char> res         = new List <char>();
         if (File.Exists(appSettings["TempFileName"]))
         {
             var data = File.ReadAllLines(appSettings["TempFileName"]);
             IMEINo = data[0];
             SimNo  = data[1];
             res    = data[2].ToArray().ToList();
             //res = data[2].Split(',').ToList();
         }
         for (int i = 0; i < Convert.ToInt32(appSettings["TotalNoOfParams"]); i++)
         {
             if (res != null && res.Count > 0 && res?[i] == '1')
             {
                 ResultsCollection[i].IsSelected = true;
                 ResultsCollection[i].Result     = "Pass.";
                 if (i == (int)Params.WP_IMEI)
                 {
                     if (IMEINo != null && IMEINo.Length == 14)
                     {
                         ResultsCollection[i].Result = "Pass. IMEI=" + IMEINo;
                     }
                     else
                     {
                         ResultsCollection[i].Result     = "Fail.";
                         ResultsCollection[i].IsSelected = false;
                     }
                 }
                 if (i == (int)Params.WP_SIM)
                 {
                     if (SimNo != null && SimNo.Length == 19)
                     {
                         ResultsCollection[i].Result = "Pass. SIM No=" + SimNo;
                     }
                     else
                     {
                         ResultsCollection[i].Result     = "Fail.";
                         ResultsCollection[i].IsSelected = false;
                     }
                 }
             }
             else
             {
                 ResultsCollection[i].IsSelected = false;
                 ResultsCollection[i].Result     = "Fail.";
             }
         }
         TestResult = ResultsCollection.All(x => x.IsSelected == true) ? "Pass" : "Fail";
         if (ConsoleMonitorData.Contains(appSettings["RetryText"]))
         {
             MessageBox.Show(" Please check the connections and retry", "Flash Error", MessageBoxButton.OK);
         }
         if (IMEINo != null)
         {
             File.WriteAllText("Logs/" + IMEINo + ".txt", ConsoleMonitorData);
         }
         else
         {
             File.WriteAllText("Logs/" + DateTime.Now.ToString("yyyy-MM-dd HH-mm-ss") + ".txt", ConsoleMonitorData);
         }
         eventHandled.TrySetResult(true);
     }
     catch (Exception ex)
     {
         Debug.WriteLine(ex.ToString());
     }
 }
 public int GetCollectionCount()
 {
     return(ResultsCollection.Count(findRecordsTo => !findRecordsTo.CanRemove()));
 }
Ejemplo n.º 25
0
 private List <Result> ParseRootCollection(ResultsCollection resultsCollection)
 {
     return(ParseCollection(resultsCollection.Values));
 }