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(); }
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 { } }
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 { } }