예제 #1
0
        private void exportQueryAsFileButton_Click(object sender, EventArgs e)
        {
            string Filename;
            string Outstring;

            if (thisFormResult.GetType() == typeof(RBACS.UserQueryResult))
            {
                UserQueryResult UQR = (UserQueryResult)thisFormResult;
                Filename  = parentReference.PreferredExportFilepath + "\\" + UQR.AccountName + ".txt";
                Outstring = FileHelperFuctions.ReturnFormattedPersonInfo(UQR, parentReference.GroupNamesAndDescriptionsAll, parentReference.ByTitle);
            }
            else if (thisFormResult.GetType() == typeof(RBACS.GroupingQueryResult))
            {
                GroupingQueryResult GQR = (GroupingQueryResult)thisFormResult;
                Filename  = parentReference.PreferredExportFilepath + "\\" + FileHelperFuctions.ReturnAcceptableFileName(GQR.GroupingName) + ".txt";
                Outstring = FileHelperFuctions.ReturnFormattedGroupInfo(parentReference.UserQueryResults, GQR, parentReference.GroupNamesAndDescriptionsAll);
            }
            else
            {
                Filename = ""; Outstring = "";
            }

            TextWriter QueryText = new StreamWriter(Filename);

            QueryText.Write(Outstring);
            QueryText.Dispose();
        }
예제 #2
0
 private void nNDataGridView_CellContentDoubleClick(object sender, DataGridViewCellEventArgs e)
 {
     if (thisFormResultType == typeof(UserQueryResult))
     {
         int RowNum = e.RowIndex;
         if (RowNum >= 0)
         {
             var              KeyResult = from UQR in parentReference.UserQueryResults where UQR.AccountName == nNDataGridView.Rows[RowNum].Cells[4].Value.ToString() select UQR;
             UserQueryResult  Result    = KeyResult.ToList()[0];
             QueryDetailsForm QDF       = new QueryDetailsForm(Result, parentReference);
             QDF.Show();
         }
     }
     else if (thisFormResultType == typeof(GroupingQueryResult))
     {
         int RowNum = e.RowIndex;
         if (RowNum >= 0)
         {
             var KeyResult = from UQR in parentReference.GroupingQueryResults where UQR.GroupingName == nNDataGridView.Rows[RowNum].Cells[1].Value.ToString() select UQR;
             GroupingQueryResult Result = KeyResult.ToList()[0];
             QueryDetailsForm    QDF    = new QueryDetailsForm(Result, parentReference);
             QDF.Show();
         }
     }
 }
예제 #3
0
        public static List <UserQueryResult> AddPermissionToAllConditionalOnIndex(List <UserQueryResult> UQRListIn, List <string> Permissions, string Permission, List <int> Indexes, int ConditionalityIndex = -1)
        {
            int NewPermissionIndex = Permissions.IndexOf(Permission);

            UserQueryResult[] UQRArrayOut = new UserQueryResult[UQRListIn.Count];
            Parallel.For(0, UQRListIn.Count, i => {
                double[] CurrentArray = UQRListIn[i].ReturnAccessVector().ToArray();
                double[] NextArray    = new double[CurrentArray.Length + 1];
                for (int a = 0; a < NextArray.Length; a++)
                {
                    if (a < NewPermissionIndex)
                    {
                        NextArray[a] = CurrentArray[a];
                    }
                    else if (a == NewPermissionIndex)
                    {
                        //this is used if a list of indices of users is provided
                        if (Indexes.Contains(i))
                        {
                            NextArray[a] = 1;
                        }
                        else
                        {
                            NextArray[a] = 0;
                        }
                        //this is used where a conditional index is specified (ie index of a child group)
                        if (ConditionalityIndex >= 0)
                        {
                            //checks for conditional index in access vector
                            //to be used for nested groups
                            if (ConditionalityIndex > NewPermissionIndex)
                            {
                                //conditionality index is drawn from an updated list of groups
                                //so may need to be decremented when referencing out of a non-updated vector
                                if (CurrentArray[ConditionalityIndex - 1] == 1)
                                {
                                    NextArray[a] = 1;
                                }
                            }
                            else
                            {
                                if (CurrentArray[ConditionalityIndex] == 1)
                                {
                                    NextArray[a] = 1;
                                }
                            }
                        }
                    }
                    else
                    {
                        NextArray[a] = CurrentArray[a - 1];
                    }
                }
                DenseVector NewVector = DenseVector.OfArray(NextArray);
                UQRArrayOut[i]        = new UserQueryResult(UQRListIn[i].Title, UQRListIn[i].Description, UQRListIn[i].Name, UQRListIn[i].AccountName, UQRListIn[i].DistinguishedName, NewVector);
            });
            return(UQRArrayOut.ToList());
        }
예제 #4
0
        public QueryDetailsForm(QueryResult InputQR, RBAC SourceRBAC) : this()
        {
            thisFormResult          = InputQR;
            thisBindingSourceGroups = new BindingSource();
            parentReference         = SourceRBAC;
            if (InputQR.GetType() == typeof(RBACS.UserQueryResult))
            {
                UserQueryResult UQR = (UserQueryResult)InputQR;
                qRName = UQR.AccountName;
                string QRScrip = UQR.Description;
                string QRTitle = UQR.Title;
                Text = $"{qRName} Query Details";
                titlingRichTextBox.Text = $"Name:\t{qRName}\r\nTitle:\t{QRTitle}\r\nDescription:\t{QRScrip}";
                thisGroupsReport        = new GroupReport(HelperFunctions.QueryResultToGroupResults(UQR, parentReference.GroupNamesAndDescriptionsAll), Ordering.Ascending);
                GroupReport GR2 = (GroupReport)thisGroupsReport;
                thisBindingSourceGroups.DataSource = GR2.QRList;
                groupsDataGridView.DataSource      = thisBindingSourceGroups;
                //summaryTextBox.Text = FileHelperFuctions.ReturnFormattedPersonInfo((UserQueryResult)InputQR, SourceRBAC.GroupNamesAndDescriptionsAll, SourceRBAC.ByTitle);
            }
            else if (InputQR.GetType() == typeof(RBACS.GroupingQueryResult))
            {
                GroupingQueryResult GQR = (GroupingQueryResult)InputQR;
                qRName = GQR.GroupingName;
                Text   = $"{qRName} Query Details";
                titlingRichTextBox.Text = $"{GQR.GroupingType}:\t{GQR.GroupingName}\r\nMember Count:\t{GQR.MemberCount}";
                List <UserQueryResult> TempUQRList = new List <UserQueryResult>();
                foreach (string Mem in GQR.Members.Split(','))
                {
                    if (Mem != null)
                    {
                        string MemTrim = Mem.Trim();
                        Parallel.ForEach(parentReference.UserQueryResults, UQR =>
                        {
                            if (UQR.AccountName == MemTrim)
                            {
                                TempUQRList.Add(UQR);
                            }
                        });
                    }
                }

                thisGroupsReport = new GroupRepresentationTFIDFReport(HelperFunctions.QueryListToGroupRepresentationTFIDFList(GQR, parentReference.GroupingQueryResults, parentReference.GroupNamesAndDescriptionsAll), Ordering.Ascending);
                GroupRepresentationTFIDFReport GRR2 = (GroupRepresentationTFIDFReport)thisGroupsReport;
                thisBindingSourceGroups.DataSource = GRR2.QRList;
                groupsDataGridView.DataSource      = thisBindingSourceGroups;
                //summaryTextBox.Text = FileHelperFuctions.ReturnFormattedGroupSummary((GroupingQueryResult)InputQR, SourceRBAC.GroupNamesAndDescriptionsAll);
            }
            else
            {
            }
            thisFormResultType = InputQR.GetType();
            thisBindingSource  = new BindingSource();
            parentReference    = SourceRBAC;
            //InitializeComponent();
        }
예제 #5
0
 public static List <UserQueryResult> UpdatePermissionsByCondition(int TargetPermissionIndex, int ConditionalityPermissionIndex, List <UserQueryResult> UQRListIn)
 {
     UserQueryResult[] UQRArrayOut = new UserQueryResult[UQRListIn.Count];
     Parallel.For(0, UQRListIn.Count, i =>
     {
         double[] InterimArray = UQRListIn[i].ReturnAccessVector().ToArray();
         if (InterimArray[ConditionalityPermissionIndex] == 1)
         {
             InterimArray[TargetPermissionIndex] = 1;
         }
         DenseVector NewVector = DenseVector.OfArray(InterimArray);
         UQRArrayOut[i]        = new UserQueryResult(UQRListIn[i].Title, UQRListIn[i].Description, UQRListIn[i].Name, UQRListIn[i].AccountName, UQRListIn[i].DistinguishedName, NewVector);
     });
     return(UQRArrayOut.ToList());
 }
예제 #6
0
        public static List <QueryResult> DatagridViewSubsetToQueryResultList(DataGridView DGV, int KeyValueColumnIndex, int SubsetColumnIndex, string SubsetValue, List <QueryResult> ReferencedList)
        {
            //takes no notice of selected rows
            List <QueryResult> OutputList = new List <QueryResult>();

            List <DataGridViewRow> RowCollection = (from DataGridViewRow DGVR in DGV.Rows where DGVR.Cells[SubsetColumnIndex].Value.ToString() == SubsetValue select DGVR).ToList();

            if (ReferencedList[0].GetType() == typeof(UserQueryResult))
            {
                foreach (DataGridViewRow ThisRow in RowCollection)
                {
                    string          CompareString = ThisRow.Cells[KeyValueColumnIndex].Value.ToString();
                    UserQueryResult UQR           = null;
                    Parallel.ForEach(ReferencedList, QR => {
                        UserQueryResult CurrentUQR = (UserQueryResult)QR;
                        if (CompareString == CurrentUQR.AccountName)
                        {
                            UQR = CurrentUQR;
                        }
                    });
                    if (UQR != null)
                    {
                        OutputList.Add(UQR);
                    }
                }
            }
            else
            {
                foreach (DataGridViewRow ThisRow in RowCollection)
                {
                    string CompareString    = ThisRow.Cells[KeyValueColumnIndex].Value.ToString();
                    GroupingQueryResult GQR = null;
                    Parallel.ForEach(ReferencedList, QR => {
                        GroupingQueryResult CurrentGQR = (GroupingQueryResult)QR;
                        if (CompareString == CurrentGQR.GroupingName)
                        {
                            GQR = CurrentGQR;
                        }
                    });
                    if (GQR != null)
                    {
                        OutputList.Add(GQR);
                    }
                }
            }
            return(OutputList);
        }
예제 #7
0
        private void kNNAsFileButton_Click(object sender, EventArgs e)
        {
            string FileName;
            string FileContent = "";

            if (thisFormResultType == typeof(UserQueryResult))
            {
                UserQueryResult      UQR     = (UserQueryResult)thisFormResult;
                List <UserKNNResult> UKRList = AllKNNResults.Cast <UserKNNResult>().ToList();
                FileName = $"{parentReference.PreferredExportFilepath}\\{UQR.Name} {kTextBox.Text} Nearest Neighbours.txt";
                int i = 1;
                foreach (UserKNNResult UKR in UKRList)
                {
                    FileContent = FileContent + FileHelperFuctions.FirstSecondEtc(i) + $" Nearest Neighbour to {UQR.AccountName}, Distance of {UKR.Distance}:\r\n\r\n#########################################################\r\n"
                                  + FileHelperFuctions.ReturnFormattedPersonInfo(new UserQueryResult(UKR.Title, UKR.Description, UKR.Name, UKR.AccountName, UKR.DistinguishedName, UKR.ReturnAccessVector()), parentReference.GroupNamesAndDescriptionsAll, parentReference.ByTitle);
                    i++;
                }

                TextWriter UTextWr = new StreamWriter(FileName);
                UTextWr.Write(FileContent);
                UTextWr.Dispose();
            }
            else if (thisFormResultType == typeof(GroupingQueryResult))
            {
                //only puts out single file at this point
                //don't see why multiple files would even be desirable for KNN Results

                GroupingQueryResult      GQR     = (GroupingQueryResult)thisFormResult;
                List <GroupingKNNResult> GKRList = AllKNNResults.Cast <GroupingKNNResult>().ToList();
                FileName = $"{parentReference.PreferredExportFilepath}\\{FileHelperFuctions.ReturnAcceptableFileName(GQR.GroupingName)} {kTextBox.Text} Nearest Neighbours.txt";
                int i2 = 1;
                foreach (GroupingKNNResult GKR in GKRList)
                {
                    FileContent = FileContent + FileHelperFuctions.FirstSecondEtc(i2) + $" Nearest Neighbour to {GQR.GroupingName}, Distance of {GKR.Distance}:\r\n\r\n#########################################################\r\n"
                                  + FileHelperFuctions.ReturnFormattedGroupSummary(new GroupingQueryResult(GKR), parentReference.GroupNamesAndDescriptionsAll);
                    i2++;
                }

                TextWriter GTextWr = new StreamWriter(FileName);
                GTextWr.Write(FileContent);
                GTextWr.Dispose();
            }
            else
            {
            }
        }
예제 #8
0
        private void kNNAsCSVButton_Click(object sender, EventArgs e)
        {
            string CSVString = FileHelperFuctions.ReturnCSVString(nNDataGridView);
            string FileName;

            if (thisFormResultType == typeof(UserQueryResult))
            {
                UserQueryResult UQR = (UserQueryResult)thisFormResult;
                FileName = $"{parentReference.PreferredExportFilepath}\\{UQR.Name} {kTextBox.Text} Nearest Neighbours.csv";
                File.WriteAllText(FileName, CSVString);
            }
            else if (thisFormResultType == typeof(GroupingQueryResult))
            {
                GroupingQueryResult GQR = (GroupingQueryResult)thisFormResult;
                FileName = $"{parentReference.PreferredExportFilepath}\\{FileHelperFuctions.ReturnAcceptableFileName(GQR.GroupingName)} {kTextBox.Text} Nearest Neighbours.csv";
                File.WriteAllText(FileName, CSVString);
            }
            else
            {
            }
        }
예제 #9
0
        public static string ReturnFormattedPersonInfo(UserQueryResult UQR, List <Tuple <string, string> > AllADGroupsList, bool TitleNotDescription = true)
        {
            if (AllADGroupsList.Count != UQR.ReturnAccessVector().Count)
            {
                throw new ArgumentOutOfRangeException();
            }
            string Outstring = UQR.AccountName;

            while (Outstring.Length < 80)
            {
                Outstring = Outstring + " ";
            }
            if (TitleNotDescription)
            {
                Outstring = Outstring + UQR.Title;
            }
            else
            {
                Outstring = Outstring + UQR.Description;
            }
            Outstring = $"{Outstring}\r\n{UQR.DistinguishedName}\r\n------------------------------------------------------------------------------------------------------------------------\r\n\r\n";
            Vector AccVect = UQR.ReturnAccessVector();

            for (int i = 0; i < AccVect.Count; i++)
            {
                if (AccVect[i] > 0)
                {
                    string TempString = AllADGroupsList[i].Item1;
                    while (TempString.Length < 80)
                    {
                        TempString = TempString + " ";
                    }
                    TempString = TempString + AllADGroupsList[i].Item2;
                    Outstring  = Outstring + TempString + "\r\n";
                }
            }
            Outstring = Outstring + "\r\n";
            return(Outstring);
        }
예제 #10
0
 public UserKNNResult(UserQueryResult UQR) : base(UQR.Title, UQR.Description, UQR.Name, UQR.AccountName, UQR.DistinguishedName, UQR.ReturnAccessVector())
 {
 }
예제 #11
0
 public UserClusteringResult(UserQueryResult UQR, string ClusterID, int ClusterIndex) : base(UQR.Title, UQR.Description, UQR.Name, UQR.AccountName, UQR.DistinguishedName, UQR.ReturnAccessVector())
 {
     clusterID    = ClusterID;
     clusterIndex = ClusterIndex;
 }
예제 #12
0
        public static List <QueryResult> DatagridViewToQueryResultList(DataGridView DGV, int KeyValueColumnIndex, List <QueryResult> ReferencedList)
        {
            List <QueryResult> OutputList = new List <QueryResult>();

            if (DGV.SelectedRows.Count > 0)
            {
                if (ReferencedList[0].GetType() == typeof(UserQueryResult))
                {
                    foreach (DataGridViewRow ThisRow in DGV.SelectedRows)
                    {
                        UserQueryResult UQR           = null;
                        string          CompareString = ThisRow.Cells[KeyValueColumnIndex].Value.ToString();
                        Parallel.ForEach(ReferencedList, QR => {
                            UserQueryResult CurrentUQR = (UserQueryResult)QR;

                            if (CompareString == CurrentUQR.AccountName)
                            {
                                UQR = CurrentUQR;
                            }
                        });
                        if (UQR != null)
                        {
                            OutputList.Add(UQR);
                        }
                    }
                }
                else
                {
                    foreach (DataGridViewRow ThisRow in DGV.SelectedRows)
                    {
                        GroupingQueryResult GQR = null;
                        string CompareString    = ThisRow.Cells[KeyValueColumnIndex].Value.ToString();
                        Parallel.ForEach(ReferencedList, QR => {
                            GroupingQueryResult CurrentGQR = (GroupingQueryResult)QR;

                            if (CompareString == CurrentGQR.GroupingName)
                            {
                                GQR = CurrentGQR;
                            }
                        });
                        if (GQR != null)
                        {
                            OutputList.Add(GQR);
                        }
                    }
                }
                return(OutputList);
            }
            else
            {
                if (ReferencedList[0].GetType() == typeof(UserQueryResult))
                {
                    foreach (DataGridViewRow ThisRow in DGV.Rows)
                    {
                        string          CompareString = ThisRow.Cells[KeyValueColumnIndex].Value.ToString();
                        UserQueryResult UQR           = null;
                        Parallel.ForEach(ReferencedList, QR => {
                            UserQueryResult CurrentUQR = (UserQueryResult)QR;
                            if (CompareString == CurrentUQR.AccountName)
                            {
                                UQR = CurrentUQR;
                            }
                        });
                        if (UQR != null)
                        {
                            OutputList.Add(UQR);
                        }
                    }
                }
                else
                {
                    foreach (DataGridViewRow ThisRow in DGV.Rows)
                    {
                        string CompareString    = ThisRow.Cells[KeyValueColumnIndex].Value.ToString();
                        GroupingQueryResult GQR = null;
                        Parallel.ForEach(ReferencedList, QR => {
                            GroupingQueryResult CurrentGQR = (GroupingQueryResult)QR;
                            if (CompareString == CurrentGQR.GroupingName)
                            {
                                GQR = CurrentGQR;
                            }
                        });
                        if (GQR != null)
                        {
                            OutputList.Add(GQR);
                        }
                    }
                }
                return(OutputList);
            }
        }
예제 #13
0
 private QueryResult uQtoQR(UserQueryResult QR)
 {
     return((QueryResult)QR);
 }
예제 #14
0
        private void nearestNeighboursButton_Click(object sender, EventArgs e)
        {
            nNDataGridView.AutoGenerateColumns = true;
            bool KSpecified = true;
            int  K;
            List <iKNNResult>          AllResults = new List <iKNNResult>();
            ConcurrentBag <iKNNResult> ResultBag  = new ConcurrentBag <iKNNResult>();

            try { K = Convert.ToInt32(kTextBox.Text); }
            catch
            {
                KSpecified    = false;
                kTextBox.Text = "All";
                Application.DoEvents();
                K = -1;
            }
            if (thisFormResultType == typeof(UserQueryResult))
            {
                UserQueryResult      UQR     = (UserQueryResult)thisFormResult;
                List <UserKNNResult> UKRList = new List <UserKNNResult>();
                Parallel.ForEach <UserQueryResult>(parentReference.UserQueryResults, CurrentUQR => {
                    if (CurrentUQR.AccountName != UQR.AccountName)
                    {
                        UserKNNResult UKR      = new UserKNNResult(CurrentUQR);
                        double CurrentDistance = HelperFunctions.GetEuclideanDistance(UQR.ReturnAccessVector(), CurrentUQR.ReturnAccessVector());
                        UKR.AssignKNNDistanceFromX(CurrentDistance);
                        ResultBag.Add(UKR);
                    }
                });
                UKRList         = ResultBag.Cast <UserKNNResult>().ToList <UserKNNResult>();
                AllResults      = UKRList.OrderBy(o => o.Distance).ToList().Cast <iKNNResult>().ToList();
                thisQueryReport = new UserKNNReport(AllResults.Cast <UserKNNResult>().ToList(), Ordering.Ascending);
            }
            else if (thisFormResultType == typeof(GroupingQueryResult))
            {
                GroupingQueryResult      GQR     = (GroupingQueryResult)thisFormResult;
                List <GroupingKNNResult> GKRList = new List <GroupingKNNResult>();
                Parallel.ForEach <GroupingQueryResult>(parentReference.GroupingQueryResults, CurrentGQR => {
                    if (CurrentGQR.GroupingName != GQR.GroupingName)
                    {
                        GroupingKNNResult GKR = new GroupingKNNResult(CurrentGQR);
                        double CurrentDistance;
                        if (parentReference.ClusterByRelativeCount)
                        {
                            CurrentDistance = HelperFunctions.GetEuclideanDistance(GQR.ReturnAccessVector(), CurrentGQR.ReturnAccessVector());
                        }
                        else
                        {
                            CurrentDistance = HelperFunctions.GetEuclideanDistance(GQR.ReturnTF_IDFVector(), CurrentGQR.ReturnTF_IDFVector());
                        }
                        GKR.AssignKNNDistanceFromX(CurrentDistance);
                        ResultBag.Add(GKR);
                    }
                });
                GKRList         = ResultBag.Cast <GroupingKNNResult>().ToList();
                AllResults      = GKRList.OrderBy(o => o.Distance).ToList().Cast <iKNNResult>().ToList();
                thisQueryReport = new GroupingKNNReport(AllResults.Cast <GroupingKNNResult>().ToList(), Ordering.Ascending);
            }
            else
            {
            }

            if (KSpecified && K <= AllResults.Count)
            {
                List <iKNNResult> Outlist = new List <iKNNResult>();
                for (int i = 0; i < K; i++)
                {
                    Outlist.Add(AllResults[i]);
                }
                //AllKNNResults = Outlist;
                if (thisFormResultType == typeof(UserQueryResult))
                {
                    thisQueryReport = new UserKNNReport(Outlist.Cast <UserKNNResult>().ToList(), Ordering.Ascending);
                }
                else if (thisFormResultType == typeof(GroupingQueryResult))
                {
                    thisQueryReport = new GroupingKNNReport(Outlist.Cast <GroupingKNNResult>().ToList(), Ordering.Ascending);
                }
                else
                {
                }
            }
            else
            {
                AllKNNResults = AllResults;
            }
            if (thisFormResultType == typeof(UserQueryResult))
            {
                UserKNNReport ReportPointer = (UserKNNReport)thisQueryReport;
                thisBindingSource.DataSource = ReportPointer.QRList;
                //thisBindingSource.DataSource = (UserKNNReport)thisQueryReport..Cast<UserKNNResult>().ToList();
                nNDataGridView.DataSource = thisBindingSource;
            }
            else if (thisFormResultType == typeof(GroupingQueryResult))
            {
                GroupingKNNReport ReportPointer = (GroupingKNNReport)thisQueryReport;
                thisBindingSource.DataSource = ReportPointer.QRList;

                nNDataGridView.DataSource = thisBindingSource;
            }
            else
            {
            }
        }
예제 #15
0
        public ClusteringOutput(List <QueryResult> QRList, RBAC RBACRef)
        {
            thisFormResultType = QRList[0].GetType();
            parentReference    = RBACRef;
            ConcurrentBag <Tuple <string, DenseVector> > InputList = new ConcurrentBag <Tuple <string, DenseVector> >();

            if (QRList[0].GetType() == typeof(UserQueryResult))
            {
                Parallel.ForEach <QueryResult>(QRList, QR =>
                {
                    UserQueryResult UQR = (UserQueryResult)QR;
                    Tuple <string, DenseVector> TupleIn = new Tuple <string, DenseVector>(UQR.AccountName, (DenseVector)UQR.ReturnAccessVector());
                    InputList.Add(TupleIn);
                });
            }
            else if (QRList[0].GetType() == typeof(GroupingQueryResult))
            {
                Parallel.ForEach <QueryResult>(QRList, QR =>
                {
                    GroupingQueryResult GQR = (GroupingQueryResult)QR;
                    DenseVector VectorA;
                    if (parentReference.ClusterByRelativeCount)
                    {
                        VectorA = (DenseVector)GQR.ReturnAccessVector();
                    }
                    else
                    {
                        VectorA = (DenseVector)GQR.ReturnTF_IDFVector();
                    }
                    Tuple <string, DenseVector> TupleIn = new Tuple <string, DenseVector>(GQR.GroupingName, VectorA);
                    InputList.Add(TupleIn);
                });
            }
            else
            {
            }
            //add options on algo configtab on main form later
            if (parentReference.ClusteringAlgoType == typeof(HACAlgo))
            {
                thisAlgo = new HACAlgo(InputList.OrderBy(o => o.Item1).ToList(), parentReference.PreferredDistanceStyle, parentReference.HACStoppingMetric, parentReference.PreferredStoppingStyle);
            }
            else
            {
                thisAlgo = new KMeansPlusPlus(InputList.OrderBy(o => o.Item1).ToList(), parentReference.KMeansValue, parentReference.PreferredKMeansStoppingStyle, parentReference.KMeansMaxIter);
            }
            parentReference.statusLabelChanger($"Initialising {thisAlgo.GetType().ToString().Split('.')[1]}, please be patient");
            thisAlgo.InitialiseClusters();

            while (!thisAlgo.Stopped)
            {
                thisAlgo.IterateOnce();
                if (!thisAlgo.Stopped)
                {
                    parentReference.statusLabelChanger($"Running {thisAlgo.GetType().ToString().Split('.')[1]}, iteration {thisAlgo.Iterator}");
                }
            }
            //set all centroids as means in case mapping of clusters is required further
            //down the line:

            if (QRList[0].ReturnAccessVector().Count > 500)
            {
                thisAlgo.SetCentroidsAsMeansHighDimensionality();
            }
            else
            {
                thisAlgo.SetCentroidsAsMeans();
            }
            parentReference.statusLabelChanger("Creating Data View");

            ConcurrentBag <QueryResult> ResultsBag = new ConcurrentBag <QueryResult>();

            if (thisFormResultType == typeof(UserQueryResult))
            {
                foreach (Cluster Clust in thisAlgo.Clusters)
                {
                    Parallel.ForEach <Tuple <string, DenseVector> >(Clust.MemberList, Member => {
                        UserQueryResult Target = (UserQueryResult)(from UQR in QRList.Cast <UserQueryResult>() where UQR.AccountName == Member.Item1 select UQR).ToList()[0];
                        ResultsBag.Add(new UserClusteringResult(Target, Clust.ClusterID, Clust.ListPosition));
                    });
                }
                clusteringResultList = ResultsBag.Cast <UserClusteringResult>().OrderBy(o => o.ClusterIndex).ToList <QueryResult>();
            }
            else if (thisFormResultType == typeof(GroupingQueryResult))
            {
                foreach (Cluster Clust in thisAlgo.Clusters)
                {
                    Parallel.ForEach <Tuple <string, DenseVector> >(Clust.MemberList, Member => {
                        GroupingQueryResult Target = (GroupingQueryResult)(from GQR in QRList.Cast <GroupingQueryResult>().ToList() where GQR.GroupingName == Member.Item1 select GQR).ToList <GroupingQueryResult>()[0];
                        ResultsBag.Add(new GroupingClusteringResult(Target, Clust.ClusterID, Clust.ListPosition));
                    });
                }
                clusteringResultList = ResultsBag.Cast <GroupingClusteringResult>().OrderBy(o => o.ClusterIndex).ToList <QueryResult>();
            }
            else
            {
            }
            parentReference.statusLabelChanger("Idle");

            InitializeComponent();
            this.Text = $"Clustering Results from {thisAlgo.Iterator} Iterations, using {thisAlgo.GetType().ToString().Split('.')[1]}, {thisAlgo.Clusters.Count} Clusters";


            thisBindingSource = new BindingSource();
            if (thisFormResultType == typeof(UserQueryResult))
            {
                //needs a bit of casting to allow datagridview to access type-specific public properties
                thisQR = new UserClusteringReport(clusteringResultList.Cast <UserClusteringResult>().ToList(), Ordering.Ascending);
                UserClusteringReport ReportReference = (UserClusteringReport)thisQR;
                thisBindingSource.DataSource    = ReportReference.QRList;
                clustersDataGridView.DataSource = thisBindingSource;
            }
            else
            {
                thisQR = new GroupingClusteringReport(clusteringResultList.Cast <GroupingClusteringResult>().ToList(), Ordering.Ascending);
                GroupingClusteringReport ReportReference = (GroupingClusteringReport)thisQR;
                thisBindingSource.DataSource    = ReportReference.QRList;
                clustersDataGridView.DataSource = thisBindingSource;
            }
        }