Ejemplo n.º 1
0
            public static Dictionary <string, Dictionary <string, bool?> > CreateDependencyMatrix(string Relation)
            {
                LogHelper.LogApp($"{MethodBase.GetCurrentMethod().Name}");

                Dictionary <string, Dictionary <string, bool?> > _Ret = new Dictionary <string, Dictionary <string, bool?> >();
                List <string>         Attributes         = DPAnalysis.AttributAnalyse_Results[Relation].Select(i => i.AttributeName).ToList();
                List <List <string> > AttributesCombined = RootCombine(Attributes, null, 2);

                AttributesCombined.Sort((a, b) => a.Count.CompareTo(b.Count));

                foreach (List <string> PotKeyComb in AttributesCombined)
                {
                    string PotKeyComb_str = Make_AttributeList(PotKeyComb);
                    _Ret.Add(PotKeyComb_str, new Dictionary <string, bool?>());

                    foreach (string LocDep in Attributes)
                    {
                        if (DPAnalysis.AttributAnalyse_Results_Sort[Relation][LocDep].Count_Attribute > 0)
                        {
                            if (PotKeyComb.Contains(LocDep))
                            {
                                _Ret[PotKeyComb_str].Add(LocDep, (bool?)null);
                            }
                            else
                            {
                                _Ret[PotKeyComb_str].Add(LocDep, CheckDependency(Relation, PotKeyComb, LocDep));
                            }
                        }
                    }
                }

                return(_Ret);
            }
Ejemplo n.º 2
0
            public static Dictionary <string, Dictionary <string, bool?> > CreateDependencyMatrixA(string Relation)
            {
                LogHelper.LogApp($"{MethodBase.GetCurrentMethod().Name}");

                if (DPAnalysis.AttributAnalyse_Results_Sort[Relation].First().Value.Count_Rows > 0)
                {
                    List <Task <DependencyResult> > _task_queue = new List <Task <DependencyResult> >();


                    Dictionary <string, Dictionary <string, bool?> > _Ret = new Dictionary <string, Dictionary <string, bool?> >();
                    List <string>         Attributes         = DPAnalysis.AttributAnalyse_Results[Relation].Select(i => i.AttributeName).ToList();
                    List <List <string> > AttributesCombined = RootCombine(Attributes, null, 2);
                    AttributesCombined.Sort((a, b) => a.Count.CompareTo(b.Count));

                    long count = (long)Attributes.Count * (long)AttributesCombined.Count;
                    long j     = 0;

                    DateTime _task_start = DateTime.Now;

                    foreach (List <string> PotKeyComb in AttributesCombined)
                    {
                        string PotKeyComb_str = Make_AttributeList(PotKeyComb);
                        _Ret.Add(PotKeyComb_str, new Dictionary <string, bool?>());

                        foreach (string LocDep in Attributes)
                        {
                            if (DPAnalysis.AttributAnalyse_Results_Sort[Relation][LocDep].Count_Attribute > 0)
                            {
                                if (PotKeyComb.Contains(LocDep))
                                {
                                    _Ret[PotKeyComb_str].Add(LocDep, (bool?)null);
                                }
                                else
                                {
                                    var _loc_task = Task.Run(async() => await CheckDependencyA(Relation, PotKeyComb, LocDep));
                                    _task_queue.Add(_loc_task);

                                    if (_task_queue.Count >= parallelConnections)
                                    {
                                        LogHelper.LogApp($"{MethodBase.GetCurrentMethod().Name}: Awaiting last {_task_queue.Count} requests... ( {j} / {count} )");
                                        Task.WhenAll(_task_queue).Wait();

                                        foreach (var _t in _task_queue)
                                        {
                                            _Ret[_t.Result.Keys].Add(_t.Result.Dependant, _t.Result.Result);
                                            LogHelper.LogApp($"{MethodBase.GetCurrentMethod().Name}: {Relation} - Checked [{_t.Result.Dependant}] for {_t.Result.Keys}");
                                        }
                                        LogHelper.LogApp($"{MethodBase.GetCurrentMethod().Name}: {_task_queue.Count} Tasks took {DateTime.Now - _task_start}");
                                        _task_queue.Clear();
                                        _task_start = DateTime.Now;
                                    }
                                }
                            }
                            j++;
                        }
                    }

                    LogHelper.LogApp($"{MethodBase.GetCurrentMethod().Name}: Resolving last requests ({_task_queue.Count})... ( {j} / {count} )");
                    Task.WhenAll(_task_queue).Wait();
                    foreach (var _t in _task_queue)
                    {
                        _Ret[_t.Result.Keys].Add(_t.Result.Dependant, _t.Result.Result);
                        LogHelper.LogApp($"{MethodBase.GetCurrentMethod().Name}: {Relation} - Checked [{_t.Result.Dependant}] for {_t.Result.Keys}");
                    }
                    LogHelper.LogApp($"{MethodBase.GetCurrentMethod().Name}: {_task_queue.Count} Tasks took {DateTime.Now - _task_start}");
                    _task_queue.Clear();

                    return(_Ret);
                }
                else
                {
                    return(null);
                }
            }