Merge pull request #2 from wymillerlinux/test
Pull in changes from test to master
This commit is contained in:
commit
07dbb422c2
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
BIN
ClassDiagram.pdf
Normal file
BIN
ClassDiagram.pdf
Normal file
Binary file not shown.
@ -5,19 +5,13 @@
|
||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||
xmlns:local="clr-namespace:DeskHubSharp"
|
||||
mc:Ignorable="d"
|
||||
Title="About - DeskHubSharp" Height="450" Width="400" ResizeMode="NoResize">
|
||||
Title="About - DeskHubSharp" Height="300" Width="400" ResizeMode="NoResize">
|
||||
<Grid>
|
||||
<Label x:Name="lbl_title" Content="DeskHubSharp" HorizontalAlignment="Left" Margin="2,10,10,0" VerticalAlignment="Top" FontSize="24" Width="372"/>
|
||||
<Button x:Name="btn_close" Content="Close" HorizontalAlignment="Left" Margin="307,389,0,0" VerticalAlignment="Top" Width="75" Click="btn_close_Click" Background="#FFFFBABA"/>
|
||||
<TextBlock x:Name="txtblk_about1" HorizontalAlignment="Left" Margin="10,57,0,0" TextWrapping="Wrap" VerticalAlignment="Top" Height="64" Width="372"><Run Text="Written and developed by Wyatt J. Miller"/><LineBreak/><Run Text="Copyright 2018, All rights reserved"/><LineBreak/><Run Text="Licensed under the MIT license"/></TextBlock>
|
||||
<TextBlock x:Name="txtblk_about2" HorizontalAlignment="Left" Margin="10,121,0,0" TextWrapping="Wrap" VerticalAlignment="Top" Height="36" Width="372"><Run Text="Using technologies including but not limited to Visual Studio, .NET, Newtonsoft, RestSharp, MailKit/Mimekit and WPF."/><LineBreak/><Run/></TextBlock>
|
||||
<TextBlock HorizontalAlignment="Left" Margin="10,363,0,0" TextWrapping="Wrap" VerticalAlignment="Top" Height="21" Width="372">
|
||||
<!--The following came from the link: https://stackoverflow.com/questions/10238694/example-using-hyperlink-in-wpf-->
|
||||
<Hyperlink NavigateUri="http://github.com/wymillerlinux/DeskhubSharp" RequestNavigate="Hyperlink_RequestNavigate_4" >
|
||||
Want to help with development?
|
||||
</Hyperlink>
|
||||
</TextBlock>
|
||||
<TextBlock HorizontalAlignment="Left" Margin="10,162,0,0" TextWrapping="Wrap" VerticalAlignment="Top" Height="44" Width="364">
|
||||
<Button x:Name="btn_close" Content="Close" HorizontalAlignment="Left" Margin="309,241,0,0" VerticalAlignment="Top" Width="75" Click="btn_close_Click" Background="#FFFFBABA"/>
|
||||
<TextBlock x:Name="txtblk_about1" HorizontalAlignment="Left" Margin="10,81,0,0" TextWrapping="Wrap" VerticalAlignment="Top" Height="64" Width="372"><Run Text="Written and developed by Wyatt J. Miller"/><LineBreak/><Run Text="Copyright 2018, All rights reserved"/><LineBreak/><Run Text="Licensed under the MIT license"/></TextBlock>
|
||||
<TextBlock x:Name="txtblk_about2" HorizontalAlignment="Left" Margin="10,139,0,0" TextWrapping="Wrap" VerticalAlignment="Top" Height="36" Width="372"><Run Text="Using technologies including but not limited to Visual Studio, .NET, Newtonsoft, RestSharp, MailKit/Mimekit and WPF."/><LineBreak/><Run/></TextBlock>
|
||||
<TextBlock HorizontalAlignment="Left" Margin="10,180,0,0" TextWrapping="Wrap" VerticalAlignment="Top" Height="44" Width="364">
|
||||
This project cannot be done without the help of
|
||||
<Hyperlink NavigateUri="https://github.com/johnvelis" RequestNavigate="Hyperlink_RequestNavigate">
|
||||
johnvelis
|
||||
@ -35,5 +29,6 @@
|
||||
tarkowr.
|
||||
</Hyperlink>
|
||||
</TextBlock>
|
||||
<TextBlock HorizontalAlignment="Left" Margin="10,57,0,0" TextWrapping="Wrap" Text="A desktop GitHub application developed in three weeks." VerticalAlignment="Top" Height="19" Width="364"/>
|
||||
</Grid>
|
||||
</Window>
|
||||
|
@ -13,9 +13,6 @@ namespace DeskHubSharp
|
||||
{
|
||||
class EmailBLL
|
||||
{
|
||||
// TODO: finish this class
|
||||
// TODO: debug feedback form
|
||||
|
||||
private string _name;
|
||||
private string _message;
|
||||
private string _emailText;
|
||||
@ -27,6 +24,10 @@ namespace DeskHubSharp
|
||||
_emailText = emailText;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Checks to see if Email is valid to send
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
private bool IsValidated()
|
||||
{
|
||||
if (_name == "")
|
||||
@ -45,10 +46,21 @@ namespace DeskHubSharp
|
||||
err.ShowDialog();
|
||||
return false;
|
||||
}
|
||||
if (_emailText == "")
|
||||
{
|
||||
ErrorWindow err = new ErrorWindow();
|
||||
err.lbl_title.Content = "Oops.";
|
||||
err.txtblk_error.Text = "Please fill in your email.";
|
||||
err.ShowDialog();
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates message for user to send
|
||||
/// </summary>
|
||||
public void CreateMessage()
|
||||
{
|
||||
if (IsValidated())
|
||||
@ -64,13 +76,12 @@ namespace DeskHubSharp
|
||||
message.Subject = $"{_name} requires your attention!";
|
||||
message.Body = new TextPart("plain")
|
||||
{
|
||||
Text = _message + _emailText
|
||||
Text = _message + " " + _emailText
|
||||
};
|
||||
|
||||
using (var client = new SmtpClient())
|
||||
{
|
||||
client.Connect("smtp.gmail.com", 465, SecureSocketOptions.SslOnConnect);
|
||||
// change credentials
|
||||
client.Authenticate(email.FromEmail, email.Password);
|
||||
client.Send(message);
|
||||
client.Disconnect(true);
|
||||
|
49
DeskHubSharp/BusinessLayer/RepoList.cs
Normal file
49
DeskHubSharp/BusinessLayer/RepoList.cs
Normal file
@ -0,0 +1,49 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.ObjectModel;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace DeskHubSharp
|
||||
{
|
||||
class RepoInfo
|
||||
{
|
||||
public RepoInfo()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Return a list for the list box
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public List<string> GetRepoInfoList()
|
||||
{
|
||||
List<string> stuff = new List<string>();
|
||||
|
||||
try
|
||||
{
|
||||
stuff = RequestList.repoDetail.Select(x => x.full_name).ToList();
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
ErrorWindow err = new ErrorWindow();
|
||||
err.txtblk_error.Text = "We couldn't gather any data. Does the user exist?";
|
||||
err.ShowDialog();
|
||||
}
|
||||
|
||||
return stuff;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Return a list for the combo box
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public List<string> GetBranchNameComboBox()
|
||||
{
|
||||
List<string> stuff = RequestList.branchDetail.Select(x => x.name).ToList();
|
||||
return stuff;
|
||||
}
|
||||
}
|
||||
}
|
@ -1,110 +1,73 @@
|
||||
using RestSharp;
|
||||
using System;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Net;
|
||||
using System.Net.Mail;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using Newtonsoft.Json;
|
||||
using System.Collections.ObjectModel;
|
||||
|
||||
namespace DeskHubSharp
|
||||
{
|
||||
class Request
|
||||
public class Request
|
||||
{
|
||||
// TODO: this is rudimentary, fix it
|
||||
// i.e. try catch statements\
|
||||
// TODO: find how to access a list index
|
||||
// TODO: find how to access the deserialized
|
||||
|
||||
private string _apiEndpoint = "https://api.github.com/";
|
||||
private ApiDataService _api;
|
||||
private string _query;
|
||||
|
||||
public List<RepoDetail> RepoDetail { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Override constructor for the class
|
||||
/// </summary>
|
||||
/// <param name="query"></param>
|
||||
public Request(string query)
|
||||
{
|
||||
_query = query;
|
||||
_api = new ApiDataService(_query);
|
||||
}
|
||||
|
||||
//public Request(string query, Object function)
|
||||
//{
|
||||
// _query = query;
|
||||
//}
|
||||
/// <summary>
|
||||
/// Constructor for the class
|
||||
/// </summary>
|
||||
public Request()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Calls API for repo and user data an stores it in RepoList
|
||||
/// Performs the search request
|
||||
/// </summary>
|
||||
public void PerformSearchRequest()
|
||||
{
|
||||
_api.SearchRequest();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Performs the user request
|
||||
/// </summary>
|
||||
public void PerformUserRequest()
|
||||
{
|
||||
_api.UserRequest();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Performs the branch request
|
||||
/// </summary>
|
||||
public void PerformBranchRequest()
|
||||
{
|
||||
_api.BranchRequest();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Performs the local owner request
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public void SearchRequest()
|
||||
public Owner GetUserData()
|
||||
{
|
||||
try
|
||||
Owner owner = new Owner();
|
||||
return owner;
|
||||
}
|
||||
|
||||
public List<string> PerformGetSort()
|
||||
{
|
||||
var client = new RestClient(_apiEndpoint);
|
||||
RestRequest requestRepo = new RestRequest($"users/{_query}/repos", Method.GET);
|
||||
|
||||
var response = client.Execute(requestRepo);
|
||||
var x = response.Content;
|
||||
var deserialized = JsonConvert.DeserializeObject<ObservableCollection<RepoDetail>>(x);
|
||||
|
||||
//ObservableCollection<RepoDetail> test = new ObservableCollection<RepoDetail>()
|
||||
//{
|
||||
// new RepoDetail()
|
||||
// {
|
||||
// Login = "John",
|
||||
// Password = "pw"
|
||||
// }
|
||||
//};
|
||||
|
||||
if (deserialized.Count() == 0)
|
||||
{
|
||||
throw new Exception();
|
||||
}
|
||||
else
|
||||
{
|
||||
RepoList.repoDetail = deserialized;
|
||||
}
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
ErrorWindow err = new ErrorWindow();
|
||||
err.txtblk_error.Text = "We couldn't gather repository data. Please try again";
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Calls API for detailed user data
|
||||
/// </summary>
|
||||
public void UserRequest()
|
||||
{
|
||||
try
|
||||
{
|
||||
var client = new RestClient(_apiEndpoint);
|
||||
|
||||
RestRequest requestUser = new RestRequest($"users/{_query}", Method.GET);
|
||||
|
||||
var response = client.Execute(requestUser);
|
||||
string x = response.Content;
|
||||
var deserailized = JsonConvert.DeserializeObject<User>(x);
|
||||
|
||||
if (deserailized == null)
|
||||
{
|
||||
throw new Exception();
|
||||
}
|
||||
else
|
||||
{
|
||||
RepoList.userDetail = deserailized;
|
||||
}
|
||||
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
ErrorWindow err = new ErrorWindow();
|
||||
err.txtblk_error.Text = "We couldn't gather user data. Please try again.";
|
||||
}
|
||||
|
||||
Sort sort = new Sort();
|
||||
var sortTerms = sort.GetSortTerms();
|
||||
return sortTerms;
|
||||
}
|
||||
|
||||
}
|
||||
|
148
DeskHubSharp/ClassDiagram1.cd
Normal file
148
DeskHubSharp/ClassDiagram1.cd
Normal file
@ -0,0 +1,148 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<ClassDiagram MajorVersion="1" MinorVersion="1">
|
||||
<Class Name="DeskHubSharp.AboutWindow">
|
||||
<Position X="2.25" Y="0.5" Width="1.5" />
|
||||
<TypeIdentifier>
|
||||
<HashCode>AAAABAAAAAQAAAAAACAAAAAAAAAAAAAAAAAAAAAAAAA=</HashCode>
|
||||
<FileName>AboutWindow.xaml.cs</FileName>
|
||||
</TypeIdentifier>
|
||||
<Lollipop Position="0.2" />
|
||||
</Class>
|
||||
<Class Name="DeskHubSharp.DetailWindow">
|
||||
<Position X="0.5" Y="2.5" Width="1.5" />
|
||||
<TypeIdentifier>
|
||||
<HashCode>AAAIhAAAAAQAQAAAQAAAAAAAAAAAAAAAAAAAAAAAAAA=</HashCode>
|
||||
<FileName>DetailWindow.xaml.cs</FileName>
|
||||
</TypeIdentifier>
|
||||
<Lollipop Position="0.2" />
|
||||
</Class>
|
||||
<Class Name="DeskHubSharp.ErrorWindow">
|
||||
<Position X="2.25" Y="3.25" Width="1.5" />
|
||||
<TypeIdentifier>
|
||||
<HashCode>AAAAAAAAAAAAAAAAAAAAAAEAAAAAAAAAAAAAAAAAAAA=</HashCode>
|
||||
<FileName>ErrorWindow.xaml.cs</FileName>
|
||||
</TypeIdentifier>
|
||||
<Lollipop Position="0.2" />
|
||||
</Class>
|
||||
<Class Name="DeskHubSharp.FeedbackWindow">
|
||||
<Position X="0.5" Y="0.5" Width="1.5" />
|
||||
<TypeIdentifier>
|
||||
<HashCode>AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACAAAAEA=</HashCode>
|
||||
<FileName>FeedbackWindow.xaml.cs</FileName>
|
||||
</TypeIdentifier>
|
||||
<Lollipop Position="0.2" />
|
||||
</Class>
|
||||
<Class Name="DeskHubSharp.HelpWindow">
|
||||
<Position X="2.25" Y="7.5" Width="1.5" />
|
||||
<TypeIdentifier>
|
||||
<HashCode>AAAAAAAAAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA=</HashCode>
|
||||
<FileName>HelpWindow.xaml.cs</FileName>
|
||||
</TypeIdentifier>
|
||||
<Lollipop Position="0.2" />
|
||||
</Class>
|
||||
<Class Name="DeskHubSharp.MainWindow">
|
||||
<Position X="0.5" Y="5.5" Width="1.5" />
|
||||
<TypeIdentifier>
|
||||
<HashCode>AAAAhAAAAAAAAAAAQCAQAAAAAAQAAgAAAIAwBEAAAAA=</HashCode>
|
||||
<FileName>MainWindow.xaml.cs</FileName>
|
||||
</TypeIdentifier>
|
||||
<Lollipop Position="0.2" />
|
||||
</Class>
|
||||
<Class Name="DeskHubSharp.SearchWindow">
|
||||
<Position X="2.25" Y="5" Width="1.5" />
|
||||
<TypeIdentifier>
|
||||
<HashCode>AAAAAAAAAAQAAAAAQAAAAAAAAAAAAAAAAAAQAAAAAAA=</HashCode>
|
||||
<FileName>SearchWindow.xaml.cs</FileName>
|
||||
</TypeIdentifier>
|
||||
<Lollipop Position="0.2" />
|
||||
</Class>
|
||||
<Class Name="DeskHubSharp.ApiDataService">
|
||||
<Position X="9.25" Y="0.5" Width="1.5" />
|
||||
<TypeIdentifier>
|
||||
<HashCode>gAAAAgAAAAAEAAAgAAAAAAAAAAAAAAAAAAAAAEAAAAA=</HashCode>
|
||||
<FileName>DAL\ApiDataService.cs</FileName>
|
||||
</TypeIdentifier>
|
||||
<Lollipop Position="0.1" />
|
||||
</Class>
|
||||
<Class Name="DeskHubSharp.Branch">
|
||||
<Position X="4" Y="0.5" Width="1.5" />
|
||||
<Compartments>
|
||||
<Compartment Name="Nested Types" Collapsed="false" />
|
||||
</Compartments>
|
||||
<NestedTypes>
|
||||
<Class Name="DeskHubSharp.Branch.Commit">
|
||||
<TypeIdentifier>
|
||||
<NewMemberFileName>Models\Branch.cs</NewMemberFileName>
|
||||
</TypeIdentifier>
|
||||
</Class>
|
||||
</NestedTypes>
|
||||
<TypeIdentifier>
|
||||
<HashCode>QAAAAAAAAAAAAAAAAAAAAAAAAAAEAAAAAAAAAAAAAAA=</HashCode>
|
||||
<FileName>Models\Branch.cs</FileName>
|
||||
</TypeIdentifier>
|
||||
</Class>
|
||||
<Class Name="DeskHubSharp.EmailBLL">
|
||||
<Position X="5.75" Y="0.5" Width="1.5" />
|
||||
<TypeIdentifier>
|
||||
<HashCode>AAAAIAAAAAAAAAAAAAIAAIAAAAAAAACAEAAAAAAAAAA=</HashCode>
|
||||
<FileName>BusinessLayer\EmailBLL.cs</FileName>
|
||||
</TypeIdentifier>
|
||||
</Class>
|
||||
<Class Name="DeskHubSharp.License">
|
||||
<Position X="7.5" Y="2.25" Width="1.5" />
|
||||
<TypeIdentifier>
|
||||
<HashCode>ACAAAAAAAAAAAAAAAAAEAAAAAAAcAAAAAAAAAAAAAAA=</HashCode>
|
||||
<FileName>Models\License.cs</FileName>
|
||||
</TypeIdentifier>
|
||||
</Class>
|
||||
<Class Name="DeskHubSharp.Owner">
|
||||
<Position X="5.75" Y="3" Width="1.5" />
|
||||
<TypeIdentifier>
|
||||
<HashCode>BGAAAAAAAAAAoAAQAAAAIAAAgAAJAAIUAgAAAAgAMgA=</HashCode>
|
||||
<FileName>Models\Owner.cs</FileName>
|
||||
</TypeIdentifier>
|
||||
</Class>
|
||||
<Class Name="DeskHubSharp.RepoDetail" Collapsed="true">
|
||||
<Position X="7.5" Y="6" Width="1.5" />
|
||||
<TypeIdentifier>
|
||||
<HashCode>BCIwgQSAIRCAkB8B4OwJIEAEyiANIQFYKRKI4AgFngw=</HashCode>
|
||||
<FileName>Models\RepoDetail.cs</FileName>
|
||||
</TypeIdentifier>
|
||||
</Class>
|
||||
<Class Name="DeskHubSharp.RepoInfo">
|
||||
<Position X="7.5" Y="4.25" Width="1.5" />
|
||||
<TypeIdentifier>
|
||||
<HashCode>AAAAAAAAAAABAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA=</HashCode>
|
||||
<FileName>BusinessLayer\RepoList.cs</FileName>
|
||||
</TypeIdentifier>
|
||||
</Class>
|
||||
<Class Name="DeskHubSharp.Request">
|
||||
<Position X="4" Y="3.75" Width="1.5" />
|
||||
<TypeIdentifier>
|
||||
<HashCode>AAAAAAgAAAAgAAAgAgAAAAAACADAAAAAAAAAAAAAAAA=</HashCode>
|
||||
<FileName>BusinessLayer\Request.cs</FileName>
|
||||
</TypeIdentifier>
|
||||
</Class>
|
||||
<Class Name="DeskHubSharp.RequestList">
|
||||
<Position X="9.25" Y="3.5" Width="1.5" />
|
||||
<TypeIdentifier>
|
||||
<HashCode>AAAAAAAAAAAAAAAAAAAAAAAAAAIAAAAQAAAAAIAAAAA=</HashCode>
|
||||
<FileName>Models\RequestList.cs</FileName>
|
||||
</TypeIdentifier>
|
||||
</Class>
|
||||
<Class Name="DeskHubSharp.Sort">
|
||||
<Position X="9.25" Y="5.25" Width="1.5" />
|
||||
<TypeIdentifier>
|
||||
<HashCode>AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACAAAAA=</HashCode>
|
||||
<FileName>Models\Sort.cs</FileName>
|
||||
</TypeIdentifier>
|
||||
</Class>
|
||||
<Interface Name="DeskHubSharp.IDataService">
|
||||
<Position X="7.5" Y="0.5" Width="1.5" />
|
||||
<TypeIdentifier>
|
||||
<HashCode>gAAAAAAAAAAEAAAAAAAAAAAAAAAAAAAAAAAAAEAAAAA=</HashCode>
|
||||
<FileName>DAL\IDataService.cs</FileName>
|
||||
</TypeIdentifier>
|
||||
</Interface>
|
||||
<Font Name="Segoe UI" Size="9" />
|
||||
</ClassDiagram>
|
126
DeskHubSharp/DAL/ApiDataService.cs
Normal file
126
DeskHubSharp/DAL/ApiDataService.cs
Normal file
@ -0,0 +1,126 @@
|
||||
using RestSharp;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Net;
|
||||
using System.Net.Mail;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using Newtonsoft.Json;
|
||||
using System.Collections.ObjectModel;
|
||||
|
||||
namespace DeskHubSharp
|
||||
{
|
||||
class ApiDataService : IDataService
|
||||
{
|
||||
// TODO: this is rudimentary, fix it
|
||||
// i.e. try catch statements\
|
||||
// TODO: Add BranchRequest function
|
||||
|
||||
private string _apiEndpoint;
|
||||
private string _query;
|
||||
|
||||
public List<RepoDetail> RepoDetail { get; set; }
|
||||
|
||||
public ApiDataService(string query)
|
||||
{
|
||||
_query = query;
|
||||
_apiEndpoint = DataConfig.dataConfString;
|
||||
}
|
||||
|
||||
//public Request(string query, Object function)
|
||||
//{
|
||||
// _query = query;
|
||||
//}
|
||||
|
||||
/// <summary>
|
||||
/// Calls API for repo and basic user data
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public void SearchRequest()
|
||||
{
|
||||
try
|
||||
{
|
||||
var client = new RestClient(_apiEndpoint);
|
||||
RestRequest requestRepo = new RestRequest($"users/{_query}/repos", Method.GET);
|
||||
|
||||
var response = client.Execute(requestRepo);
|
||||
var x = response.Content;
|
||||
var deserialized = JsonConvert.DeserializeObject<ObservableCollection<RepoDetail>>(x);
|
||||
|
||||
if (deserialized.Count == 0)
|
||||
{
|
||||
throw new Exception();
|
||||
}
|
||||
else
|
||||
{
|
||||
RequestList.repoDetail = deserialized;
|
||||
}
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
ErrorWindow err = new ErrorWindow();
|
||||
err.txtblk_error.Text = "We couldn't gather repository data. Please try again";
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Calls API for detailed user data
|
||||
/// </summary>
|
||||
public void UserRequest()
|
||||
{
|
||||
try
|
||||
{
|
||||
var client = new RestClient(_apiEndpoint);
|
||||
|
||||
RestRequest requestUser = new RestRequest($"users/{_query}", Method.GET);
|
||||
|
||||
var response = client.Execute(requestUser);
|
||||
string x = response.Content;
|
||||
var deserailized = JsonConvert.DeserializeObject<User>(x);
|
||||
|
||||
if (deserailized == null)
|
||||
{
|
||||
throw new Exception();
|
||||
}
|
||||
else
|
||||
{
|
||||
RequestList.userDetail = deserailized;
|
||||
}
|
||||
|
||||
}
|
||||
catch (NullReferenceException)
|
||||
{
|
||||
ErrorWindow err = new ErrorWindow();
|
||||
err.txtblk_error.Text = "We couldn't gather user data. Please try again.";
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Calls API for detailed branch data
|
||||
/// </summary>
|
||||
public void BranchRequest()
|
||||
{
|
||||
try
|
||||
{
|
||||
var client = new RestClient(_apiEndpoint);
|
||||
|
||||
RestRequest requestUser = new RestRequest($"/repos/{RequestList.userDetail.login}/{_query}/branches", Method.GET);
|
||||
|
||||
var response = client.Execute(requestUser);
|
||||
string x = response.Content;
|
||||
var deserailized = JsonConvert.DeserializeObject<ObservableCollection<Branch>>(x);
|
||||
|
||||
RequestList.branchDetail = deserailized;
|
||||
}
|
||||
catch (NullReferenceException)
|
||||
{
|
||||
ErrorWindow err = new ErrorWindow();
|
||||
err.txtblk_error.Text = "We couldn't gather user data. Please try again.";
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
@ -8,7 +8,11 @@ namespace DeskHubSharp
|
||||
{
|
||||
public interface IDataService
|
||||
{
|
||||
List<Search> ReadAll();
|
||||
void WriteAll(List<Search> user);
|
||||
//List<Search> ReadAll();
|
||||
//void WriteAll(List<Search> user);
|
||||
|
||||
void SearchRequest();
|
||||
void UserRequest();
|
||||
void BranchRequest();
|
||||
}
|
||||
}
|
||||
|
@ -1,66 +0,0 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Xml.Serialization;
|
||||
using System.IO;
|
||||
|
||||
namespace DeskHubSharp
|
||||
{
|
||||
class XmlDataService
|
||||
{
|
||||
private readonly string _dataFilePath;
|
||||
|
||||
public List<User> ReadAll()
|
||||
{
|
||||
List<User> Users = new List<User>();
|
||||
XmlSerializer serializer = new XmlSerializer(typeof(List<User>), new XmlRootAttribute("Users"));
|
||||
|
||||
try
|
||||
{
|
||||
StreamReader reader = new StreamReader(_dataFilePath);
|
||||
using (reader)
|
||||
{
|
||||
Users = (List<User>)serializer.Deserialize(reader);
|
||||
}
|
||||
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
throw;
|
||||
}
|
||||
|
||||
return Users;
|
||||
}
|
||||
|
||||
public void WriteAll(List<User> Users)
|
||||
{
|
||||
XmlSerializer serializer = new XmlSerializer(typeof(List<User>), new XmlRootAttribute("Users"));
|
||||
|
||||
try
|
||||
{
|
||||
StreamWriter writer = new StreamWriter(_dataFilePath);
|
||||
using (writer)
|
||||
{
|
||||
serializer.Serialize(writer, Users);
|
||||
}
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
public XmlDataService()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public XmlDataService(string datafile)
|
||||
{
|
||||
_dataFilePath = datafile;
|
||||
}
|
||||
}
|
||||
}
|
@ -8,6 +8,6 @@ namespace DeskHubSharp
|
||||
{
|
||||
class DataConfig
|
||||
{
|
||||
public string dataConfString = "";
|
||||
public static string dataConfString = "https://api.github.com/";
|
||||
}
|
||||
}
|
||||
|
@ -71,11 +71,14 @@
|
||||
<ApplicationDefinition Include="App.xaml">
|
||||
<Generator>MSBuild:Compile</Generator>
|
||||
</ApplicationDefinition>
|
||||
<Compile Include="BusinessLayer\Request.cs" />
|
||||
<Compile Include="DAL\JsonDataService.cs" />
|
||||
<Compile Include="Models\Branch.cs" />
|
||||
<Compile Include="Models\Email.cs" />
|
||||
<Compile Include="Models\License.cs" />
|
||||
<Compile Include="Models\Owner.cs" />
|
||||
<Compile Include="Models\RepoInfo.cs" />
|
||||
<Compile Include="BusinessLayer\RepoList.cs" />
|
||||
<Compile Include="Models\Sort.cs" />
|
||||
<Compile Include="SearchWindow.xaml.cs">
|
||||
<DependentUpon>SearchWindow.xaml</DependentUpon>
|
||||
</Compile>
|
||||
@ -106,9 +109,8 @@
|
||||
<SubType>Code</SubType>
|
||||
</Compile>
|
||||
<Compile Include="BusinessLayer\EmailBLL.cs" />
|
||||
<Compile Include="BusinessLayer\Request.cs" />
|
||||
<Compile Include="DAL\ApiDataService.cs" />
|
||||
<Compile Include="DAL\IDataService.cs" />
|
||||
<Compile Include="DAL\XmlDataService.cs" />
|
||||
<Compile Include="Data\DataConfig.cs" />
|
||||
<Compile Include="DetailWindow.xaml.cs">
|
||||
<DependentUpon>DetailWindow.xaml</DependentUpon>
|
||||
@ -132,7 +134,7 @@
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="Models\RepoDetail.cs" />
|
||||
<Compile Include="Models\RepoList.cs" />
|
||||
<Compile Include="Models\RequestList.cs" />
|
||||
<Compile Include="Models\Search.cs" />
|
||||
<Compile Include="Models\User.cs" />
|
||||
<Compile Include="Properties\AssemblyInfo.cs">
|
||||
@ -153,6 +155,7 @@
|
||||
<LastGenOutput>Resources.Designer.cs</LastGenOutput>
|
||||
</EmbeddedResource>
|
||||
<None Include="build.cake" />
|
||||
<None Include="ClassDiagram1.cd" />
|
||||
<None Include="packages.config" />
|
||||
<None Include="Properties\Settings.settings">
|
||||
<Generator>SettingsSingleFileGenerator</Generator>
|
||||
|
@ -5,12 +5,18 @@
|
||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||
xmlns:local="clr-namespace:DeskHubSharp"
|
||||
mc:Ignorable="d"
|
||||
Title="Detail - DeskHubSharp" Height="450" Width="800" ResizeMode="NoResize">
|
||||
Title="Detail - DeskHubSharp" Height="450" Width="400" ResizeMode="NoResize">
|
||||
<Grid>
|
||||
<Label x:Name="lbl_reponame" Content="Repository Name" HorizontalAlignment="Left" Margin="10,47,0,0" VerticalAlignment="Top" RenderTransformOrigin="-0.603,-0.2" Width="225" FontSize="16"/>
|
||||
<Label x:Name="lbl_title" Content="Details" HorizontalAlignment="Left" Margin="10,10,0,0" VerticalAlignment="Top" Width="171" FontSize="20"/>
|
||||
<Button x:Name="btn_close" Content="Close" HorizontalAlignment="Left" Margin="707,389,0,0" VerticalAlignment="Top" Width="75" Background="#FFFFABAB" Click="btn_close_Click"/>
|
||||
<Button x:Name="btn_clone" Content="Clone" HorizontalAlignment="Left" Margin="240,54,0,0" VerticalAlignment="Top" Width="75" />
|
||||
|
||||
<Label x:Name="lbl_reponame" Content="Repository Name" HorizontalAlignment="Left" Margin="10,57,0,0" VerticalAlignment="Top" RenderTransformOrigin="-0.603,-0.2" Width="374" FontSize="20"/>
|
||||
<Label x:Name="lbl_title" Content="Details" HorizontalAlignment="Left" Margin="10,10,0,0" VerticalAlignment="Top" Width="81" FontSize="24"/>
|
||||
<Button x:Name="btn_close" Content="Close" HorizontalAlignment="Left" Margin="309,389,0,0" VerticalAlignment="Top" Width="75" Background="#FFFFABAB" Click="btn_close_Click"/>
|
||||
<TextBlock x:Name="txtblk_language" HorizontalAlignment="Left" Margin="13,120,0,0" TextWrapping="Wrap" Text="This repo is mostly some code." VerticalAlignment="Top" Height="25" Width="223" FontSize="14"/>
|
||||
<TextBlock x:Name="txtblk_stargazers" HorizontalAlignment="Left" Margin="13,150,0,0" TextWrapping="Wrap" Text="This repo has 0 stargazers." VerticalAlignment="Top" Height="24" Width="186" FontSize="14"/>
|
||||
<ComboBox x:Name="cmbbox_branches" HorizontalAlignment="Left" Margin="13,389,0,0" VerticalAlignment="Top" Width="120" Height="19"/>
|
||||
<Label x:Name="lbl_branch" Content="What branch do you want to download?" HorizontalAlignment="Left" Margin="13,358,0,0" VerticalAlignment="Top" Width="223" Padding="1,5,5,5" RenderTransformOrigin="0.537,0.517"/>
|
||||
<TextBlock x:Name="txtblk_watchers" HorizontalAlignment="Left" Margin="13,179,0,0" TextWrapping="Wrap" Text="This repo has 0 watchers." VerticalAlignment="Top" Width="209" FontSize="14" Height="24"/>
|
||||
<TextBlock x:Name="txtblk_forks" HorizontalAlignment="Left" Margin="13,208,0,0" TextWrapping="Wrap" Text="This repo has 0 forks." VerticalAlignment="Top" FontSize="14" Height="20" Width="223"/>
|
||||
<Button x:Name="btn_page" Content="GitHub Page" HorizontalAlignment="Left" Margin="13,333,0,0" VerticalAlignment="Top" Width="88" RenderTransformOrigin="0.29,1.69" Click="btn_page_Click"/>
|
||||
<Button x:Name="btn_clone" Content="Clone" HorizontalAlignment="Left" Margin="147,388,0,0" VerticalAlignment="Top" Width="75" Click="btn_clone_Click"/>
|
||||
</Grid>
|
||||
</Window>
|
||||
|
@ -4,6 +4,7 @@ using System.Collections.ObjectModel;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Diagnostics;
|
||||
using System.Windows;
|
||||
using System.Windows.Controls;
|
||||
using System.Windows.Data;
|
||||
@ -21,12 +22,36 @@ namespace DeskHubSharp
|
||||
public partial class DetailWindow : Window
|
||||
{
|
||||
private RepoDetail _repoDetail;
|
||||
private Request _request;
|
||||
private Owner _owner;
|
||||
|
||||
public DetailWindow(RepoDetail repoDetail)
|
||||
{
|
||||
InitializeComponent();
|
||||
|
||||
_repoDetail = repoDetail;
|
||||
_request = new Request(_repoDetail.name);
|
||||
RepoInfo info = new RepoInfo();
|
||||
|
||||
_request.PerformBranchRequest();
|
||||
var stuff = info.GetBranchNameComboBox();
|
||||
|
||||
cmbbox_branches.ItemsSource = stuff;
|
||||
|
||||
if (_repoDetail.language != null)
|
||||
{
|
||||
txtblk_language.Text = $"This repo is mostly {_repoDetail.language} code.";
|
||||
}
|
||||
else
|
||||
{
|
||||
txtblk_language.Text = "This repo doesn't have any code.";
|
||||
}
|
||||
|
||||
lbl_reponame.Content = _repoDetail.full_name;
|
||||
txtblk_stargazers.Text = $"This repo has {_repoDetail.stargazers_count} stargazers.";
|
||||
txtblk_watchers.Text = $"This repo has {_repoDetail.watchers_count} watchers.";
|
||||
txtblk_forks.Text = $"This repo has {_repoDetail.forks_count} forks.";
|
||||
|
||||
|
||||
}
|
||||
|
||||
@ -34,5 +59,27 @@ namespace DeskHubSharp
|
||||
{
|
||||
this.Close();
|
||||
}
|
||||
|
||||
private void btn_clone_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
if (cmbbox_branches.Text == "")
|
||||
{
|
||||
ErrorWindow err = new ErrorWindow();
|
||||
err.txtblk_error.Text = "Please select a branch to clone.";
|
||||
}
|
||||
else
|
||||
{
|
||||
_owner = new Owner();
|
||||
string link = "https://github.com/" + _repoDetail.owner.login + "/" + _repoDetail.name + "/archive/" + cmbbox_branches.Text + ".zip";
|
||||
|
||||
Process.Start(link);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private void btn_page_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
Process.Start($"{_repoDetail.html_url}");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -10,7 +10,7 @@
|
||||
<Grid>
|
||||
<Button x:Name="btn_close" Content="Close" HorizontalAlignment="Left" Margin="307,389,0,0" VerticalAlignment="Top" Width="75" Background="#FFFFBDBD" Click="btn_close_Click"/>
|
||||
<Label x:Name="lbl_title" Content="Need some help?" HorizontalAlignment="Left" Margin="3,10,0,0" VerticalAlignment="Top" FontSize="20"/>
|
||||
<TextBlock HorizontalAlignment="Left" Margin="10,52,0,0" TextWrapping="Wrap" VerticalAlignment="Top" Height="332" Width="372"><Run Text="No worries friend! We have you covered!"/><LineBreak/><Run/><LineBreak/><Run Text="If you have a blank data grid when you first start the program, that's normal! You just have to search for somebody."/><LineBreak/><Run/><LineBreak/><Run Text="Click on the Search button and type away in the name field! If you get an error in response to your search query, that means that user doesn't exist."/><LineBreak/><Run/><LineBreak/><Run Text="If the search finds a user, the data grid will populate. Click on a repository of interest and click on the Detail button to view it in action."/><LineBreak/><Run/><LineBreak/><Run Text="You found a problem with the program? Great! Click on the Feedback button to send an email to me and I will respond to said email as soon as possible."/><LineBreak/><LineBreak/><Run Text="Want to know more about this program? Click on the About program to view stuff."/></TextBlock>
|
||||
<TextBlock HorizontalAlignment="Left" Margin="10,52,0,0" TextWrapping="Wrap" VerticalAlignment="Top" Height="332" Width="372"><Run Text="No worries friend! We have you covered!"/><LineBreak/><Run/><LineBreak/><Run Text="If you have a blank list when you first start the program, that's normal! You just have to search for somebody."/><LineBreak/><Run/><LineBreak/><Run Text="Click on the Search button and type away in the name field! If you get an error in response to your search query, that means that user doesn't exist."/><LineBreak/><Run/><LineBreak/><Run Text="If the search finds a user, the list will populate. Click on a repository of interest and click on the Detail button to view it in action."/><LineBreak/><Run/><LineBreak/><Run Text="You found a problem with the program? Great! Click on the Feedback button to send an email to me and I will respond to said email as soon as possible."/><LineBreak/><LineBreak/><Run Text="Want to know more about this program? Click on the About program to view stuff."/></TextBlock>
|
||||
|
||||
</Grid>
|
||||
</Window>
|
||||
|
@ -7,7 +7,7 @@
|
||||
mc:Ignorable="d"
|
||||
Title="DeskHubSharp" Height="450" Width="805" ResizeMode="NoResize">
|
||||
<Grid>
|
||||
<Button x:Name="btn_search" Content="Search" HorizontalAlignment="Left" Margin="10,389,0,0" VerticalAlignment="Top" Width="75" Background="#FFA1C8FF" Click="btn_search_Click"/>
|
||||
<Button x:Name="btn_searchuser" Content="Search User" HorizontalAlignment="Left" Margin="10,389,0,0" VerticalAlignment="Top" Width="75" Background="#FFA1C8FF" Click="btn_search_Click"/>
|
||||
<Button x:Name="btn_detail" Content="Detail" HorizontalAlignment="Left" Margin="90,389,0,0" VerticalAlignment="Top" Width="75" Background="#FFA1C8FF" Click="btn_detail_Click"/>
|
||||
<Button x:Name="btn_feedback" Content="Feedback" HorizontalAlignment="Left" Margin="170,389,0,0" VerticalAlignment="Top" Width="75" Background="#FFD9A1FF" Click="btn_feedback_Click"/>
|
||||
<Button x:Name="btn_help" Content="Help" HorizontalAlignment="Left" Margin="250,389,0,0" VerticalAlignment="Top" Width="75" Background="#FFFFFF9D" Click="btn_help_Click"/>
|
||||
@ -25,7 +25,11 @@
|
||||
<Label x:Name="lbl_email" Content="Email:" HorizontalAlignment="Left" Margin="563,192,0,0" VerticalAlignment="Top" Padding="2,5,5,5" FontSize="11"/>
|
||||
<Label x:Name="lbl_bio" Content="Bio:" HorizontalAlignment="Left" Margin="563,249,0,0" VerticalAlignment="Top" RenderTransformOrigin="-0.079,0.397" Padding="2,5,5,5"/>
|
||||
<ListBox x:Name="ListBox" HorizontalAlignment="Left" Height="265" Margin="10,10,0,0" VerticalAlignment="Top" Width="519"/>
|
||||
<TextBlock x:Name="txtblk_repocount" HorizontalAlignment="Left" Margin="10,280,0,0" TextWrapping="Wrap" VerticalAlignment="Top" Height="65" Width="519" RenderTransformOrigin="0.496,0.482"/>
|
||||
<TextBlock x:Name="txtblk_repocount" HorizontalAlignment="Left" Margin="10,280,0,0" TextWrapping="Wrap" VerticalAlignment="Top" Height="65" Width="235" RenderTransformOrigin="0.496,0.482"/>
|
||||
<ComboBox x:Name="cmbbox_sort" HorizontalAlignment="Left" Margin="330,280,0,0" VerticalAlignment="Top" Width="199"/>
|
||||
<Button x:Name="btn_sort" Content="Sort" HorizontalAlignment="Left" Margin="250,280,0,0" VerticalAlignment="Top" Width="75" Click="btn_sort_Click" Height="22"/>
|
||||
<Button x:Name="btn_searchrepo" Content="Search Repository" HorizontalAlignment="Left" Margin="250,307,0,0" VerticalAlignment="Top" Width="109" Click="btn_searchrepo_Click"/>
|
||||
<TextBox x:Name="txtbox_searchbox" HorizontalAlignment="Left" Height="20" Margin="364,307,0,0" TextWrapping="Wrap" VerticalAlignment="Top" Width="165" RenderTransformOrigin="0.131,-0.913"/>
|
||||
|
||||
</Grid>
|
||||
</Window>
|
||||
|
@ -22,23 +22,43 @@ namespace DeskHubSharp
|
||||
public partial class MainWindow : Window
|
||||
{
|
||||
private ObservableCollection<RepoDetail> _repoDetail;
|
||||
private User _userDetail;
|
||||
private Request _request;
|
||||
|
||||
public MainWindow()
|
||||
{
|
||||
InitializeComponent();
|
||||
//ShowDataGridItems();
|
||||
_request = new Request();
|
||||
cmbbox_sort.ItemsSource = _request.PerformGetSort();
|
||||
}
|
||||
|
||||
private void btn_detail_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
try
|
||||
{
|
||||
RepoDetail repo = _repoDetail[ListBox.SelectedIndex];
|
||||
DetailWindow detail = new DetailWindow(repo);
|
||||
detail.ShowDialog();
|
||||
detail.Show();
|
||||
}
|
||||
catch (IndexOutOfRangeException)
|
||||
{
|
||||
ShowErrorMessage("Please pick a repository!");
|
||||
}
|
||||
catch (NullReferenceException)
|
||||
{
|
||||
ShowErrorMessage("Please search for a user with the Search button!");
|
||||
}
|
||||
catch (ArgumentOutOfRangeException)
|
||||
{
|
||||
ShowErrorMessage("MEME REVIEW!");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private void btn_exit_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
this.Close();
|
||||
Environment.Exit(0);
|
||||
}
|
||||
|
||||
private void btn_about_Click(object sender, RoutedEventArgs e)
|
||||
@ -62,30 +82,88 @@ namespace DeskHubSharp
|
||||
private void btn_search_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
SearchWindow search = new SearchWindow();
|
||||
RepoInfo info = new RepoInfo();
|
||||
Owner owner = new Owner();
|
||||
search.ShowDialog();
|
||||
var stuff = info.GetRepoInfoDataGrid();
|
||||
_repoDetail = RepoList.repoDetail;
|
||||
ListBox.ItemsSource = stuff;
|
||||
txtblk_username.Text = RepoList.userDetail.login;
|
||||
txtblk_url.Text = RepoList.userDetail.html_url;
|
||||
txtblk_bio.Text = RepoList.userDetail.bio;
|
||||
txtblk_email.Text = RepoList.userDetail.blog;
|
||||
txtblk_realname.Text = RepoList.userDetail.name;
|
||||
txtblk_repocount.Text = $"{RepoList.userDetail.login} has {RepoList.userDetail.public_repos} public repositories.";
|
||||
//img_avatar.Source = RepoList.repoDetail[0].owner.avatar_url;
|
||||
}
|
||||
RepoInfo info = new RepoInfo();
|
||||
_repoDetail = RequestList.repoDetail;
|
||||
|
||||
private void DataGrid_SelectionChanged(object sender, SelectionChangedEventArgs e)
|
||||
var stuff = info.GetRepoInfoList();
|
||||
|
||||
if (stuff.Count == 0)
|
||||
{
|
||||
|
||||
txtblk_username.Text = txtblk_username.Text;
|
||||
txtblk_url.Text = txtblk_url.Text;
|
||||
txtblk_bio.Text = txtblk_bio.Text;
|
||||
txtblk_email.Text = txtblk_email.Text;
|
||||
txtblk_realname.Text = txtblk_realname.Text;
|
||||
}
|
||||
else
|
||||
{
|
||||
_userDetail = RequestList.userDetail;
|
||||
ListBox.ItemsSource = stuff;
|
||||
txtblk_username.Text = _userDetail.login;
|
||||
txtblk_url.Text = _userDetail.html_url;
|
||||
txtblk_bio.Text = _userDetail.bio;
|
||||
txtblk_email.Text = _userDetail.blog;
|
||||
txtblk_realname.Text = _userDetail.name;
|
||||
txtblk_repocount.Text = $"{_userDetail.login} has {_userDetail.public_repos} public repositories.";
|
||||
}
|
||||
}
|
||||
|
||||
//public void ShowDataGridItems()
|
||||
//{
|
||||
// DataGrid.ItemsSource = RepoList.repoDetail;
|
||||
//}
|
||||
public void ShowErrorMessage(string message)
|
||||
{
|
||||
ErrorWindow err = new ErrorWindow();
|
||||
err.txtblk_error.Text = message;
|
||||
err.ShowDialog();
|
||||
}
|
||||
|
||||
private void btn_sort_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
try
|
||||
{
|
||||
string sortTerm = cmbbox_sort.Text;
|
||||
|
||||
if (sortTerm == "A - Z")
|
||||
{
|
||||
var sortedList = _repoDetail.OrderBy(x => x.full_name).ToList();
|
||||
ListBox.ItemsSource = sortedList.Select(x => x.full_name);
|
||||
}
|
||||
if (sortTerm == "Least to most Stars")
|
||||
{
|
||||
var sortedList = _repoDetail.OrderBy(c => c.stargazers_count).ToList();
|
||||
ListBox.ItemsSource = sortedList.Select(x => x.full_name);
|
||||
|
||||
}
|
||||
if (sortTerm == "Least to most Forks")
|
||||
{
|
||||
var sortedList = _repoDetail.OrderBy(c => c.forks_count).ToList();
|
||||
ListBox.ItemsSource = sortedList.Select(x => x.full_name);
|
||||
}
|
||||
if (sortTerm == "Least to most Watchers")
|
||||
{
|
||||
var sortedList = _repoDetail.OrderBy(c => c.watchers_count).ToList();
|
||||
ListBox.ItemsSource = sortedList.Select(x => x.full_name);
|
||||
}
|
||||
}
|
||||
catch (ArgumentNullException)
|
||||
{
|
||||
ShowErrorMessage("A user has not been searched. Please try again.");
|
||||
}
|
||||
}
|
||||
|
||||
private void btn_searchrepo_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
try
|
||||
{
|
||||
string searchTerm = txtbox_searchbox.Text;
|
||||
var searchedList = _repoDetail.Where(c => c.full_name.ToUpper().Contains(searchTerm.ToUpper())).ToList();
|
||||
|
||||
ListBox.ItemsSource = searchedList.Select(x => x.full_name);
|
||||
}
|
||||
catch (ArgumentNullException)
|
||||
{
|
||||
ShowErrorMessage("A user has not been searched. Please try again.");
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
22
DeskHubSharp/Models/Branch.cs
Normal file
22
DeskHubSharp/Models/Branch.cs
Normal file
@ -0,0 +1,22 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace DeskHubSharp
|
||||
{
|
||||
public class Branch
|
||||
{
|
||||
public string name { get; set; }
|
||||
|
||||
public Commit commit { get; set; }
|
||||
|
||||
public class Commit
|
||||
{
|
||||
public string sha { get; set; }
|
||||
public string url { get; set; }
|
||||
}
|
||||
|
||||
}
|
||||
}
|
@ -4,7 +4,7 @@ namespace DeskHubSharp
|
||||
{
|
||||
private string _toEmail = "wjmiller2016@gmail.com";
|
||||
private string _fromEmail = "wjmiller2016@gmail.com";
|
||||
private string _passwordEmail = "password";
|
||||
private string _passwordEmail = "IhaveanAMDRX580";
|
||||
|
||||
public string Password
|
||||
{
|
||||
@ -24,6 +24,9 @@ namespace DeskHubSharp
|
||||
set { _toEmail = value; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Constructor for the Email class
|
||||
/// </summary>
|
||||
public Email()
|
||||
{
|
||||
|
||||
|
@ -6,6 +6,9 @@ using System.Threading.Tasks;
|
||||
|
||||
namespace DeskHubSharp
|
||||
{
|
||||
/// <summary>
|
||||
/// Class from a JSON to a C# converter
|
||||
/// </summary>
|
||||
public class License
|
||||
{
|
||||
/// <summary>
|
||||
|
@ -6,6 +6,9 @@ using System.Threading.Tasks;
|
||||
|
||||
namespace DeskHubSharp
|
||||
{
|
||||
/// <summary>
|
||||
/// Class from a JSON to a C# converter
|
||||
/// </summary>
|
||||
public class Owner
|
||||
{
|
||||
/// <summary>
|
||||
|
@ -2,6 +2,9 @@ using DeskHubSharp;
|
||||
|
||||
namespace DeskHubSharp
|
||||
{
|
||||
|
||||
// TODO: The RepoDetail class is called from the code behind, fix it
|
||||
|
||||
public class RepoDetail
|
||||
{
|
||||
public Owner Owner { get; set; }
|
||||
|
@ -1,25 +0,0 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.ObjectModel;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace DeskHubSharp
|
||||
{
|
||||
class RepoInfo
|
||||
{
|
||||
public RepoInfo()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public List<string> GetRepoInfoDataGrid()
|
||||
{
|
||||
List<string> stuff = RepoList.repoDetail.Select(x => x.full_name).ToList();
|
||||
//stuff =+ RepoList.repoDetail.Select(x => x.name).ToList();
|
||||
return stuff;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
@ -1,22 +0,0 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.ObjectModel;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace DeskHubSharp
|
||||
{
|
||||
class RepoList
|
||||
{
|
||||
private static ObservableCollection<RepoDetail> _repoDetail;
|
||||
|
||||
public static User userDetail { get; set; }
|
||||
|
||||
public static ObservableCollection<RepoDetail> repoDetail
|
||||
{
|
||||
get { return _repoDetail; }
|
||||
set { _repoDetail = value; }
|
||||
}
|
||||
}
|
||||
}
|
27
DeskHubSharp/Models/RequestList.cs
Normal file
27
DeskHubSharp/Models/RequestList.cs
Normal file
@ -0,0 +1,27 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.ObjectModel;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace DeskHubSharp
|
||||
{
|
||||
public class RequestList
|
||||
{
|
||||
/// <summary>
|
||||
/// Stores everything in User, typically from the request
|
||||
/// </summary>
|
||||
public static User userDetail { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Stores everything sent in Branch, typically from request
|
||||
/// </summary>
|
||||
public static ObservableCollection<Branch> branchDetail { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Stores everything sent in RepoDetail, typically from request
|
||||
/// </summary>
|
||||
public static ObservableCollection<RepoDetail> repoDetail { get; set; }
|
||||
}
|
||||
}
|
27
DeskHubSharp/Models/Sort.cs
Normal file
27
DeskHubSharp/Models/Sort.cs
Normal file
@ -0,0 +1,27 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace DeskHubSharp
|
||||
{
|
||||
public class Sort
|
||||
{
|
||||
public Sort()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public List<string> GetSortTerms()
|
||||
{
|
||||
List<string> sortTerms = new List<string>();
|
||||
sortTerms.Add("A - Z");
|
||||
sortTerms.Add("Least to most Stars");
|
||||
sortTerms.Add("Least to most Forks");
|
||||
sortTerms.Add("Least to most Watchers");
|
||||
|
||||
return sortTerms;
|
||||
}
|
||||
}
|
||||
}
|
@ -2,6 +2,8 @@ using System.Collections.Generic;
|
||||
|
||||
namespace DeskHubSharp
|
||||
{
|
||||
|
||||
// The User class is called from the code behind, fix it
|
||||
public class User
|
||||
{
|
||||
public string login { get; set; }
|
||||
|
@ -19,6 +19,9 @@ namespace DeskHubSharp
|
||||
/// </summary>
|
||||
public partial class SearchWindow : Window
|
||||
{
|
||||
|
||||
private Request _request;
|
||||
|
||||
public SearchWindow()
|
||||
{
|
||||
InitializeComponent();
|
||||
@ -31,12 +34,20 @@ namespace DeskHubSharp
|
||||
|
||||
private void btn_search_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
Request request = new Request(txtbox_query.Text);
|
||||
request.SearchRequest();
|
||||
request.UserRequest();
|
||||
//MainWindow main = new MainWindow();
|
||||
//main.ShowDialog();
|
||||
if (txtbox_query.Text == "")
|
||||
{
|
||||
ErrorWindow err = new ErrorWindow();
|
||||
err.txtblk_error.Text = "Please enter a username!";
|
||||
err.ShowDialog();
|
||||
}
|
||||
else
|
||||
{
|
||||
_request = new Request(txtbox_query.Text);
|
||||
_request.PerformSearchRequest();
|
||||
_request.PerformUserRequest();
|
||||
this.Close();
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Binary file not shown.
@ -1 +1 @@
|
||||
5719003caa9368fdbade249bbbe98f747b8af257
|
||||
f6a02c2d6dac7b2ec0bdf4f3374969b628104441
|
||||
|
@ -12,7 +12,7 @@ DEBUG;TRACE
|
||||
C:\Users\Wyatt\Desktop\Source\DeskHubSharp\DeskHubSharp\App.xaml
|
||||
7-86569338
|
||||
|
||||
25696652050
|
||||
27-1010967837
|
||||
20415715258
|
||||
AboutWindow.xaml;DetailWindow.xaml;ErrorWindow.xaml;FeedbackWindow.xaml;HelpWindow.xaml;MainWindow.xaml;SearchWindow.xaml;
|
||||
|
||||
|
@ -12,9 +12,9 @@ DEBUG;TRACE
|
||||
C:\Users\Wyatt\Desktop\Source\DeskHubSharp\DeskHubSharp\App.xaml
|
||||
7-86569338
|
||||
|
||||
29498133693
|
||||
31-1209486194
|
||||
20415715258
|
||||
AboutWindow.xaml;DetailWindow.xaml;ErrorWindow.xaml;FeedbackWindow.xaml;HelpWindow.xaml;MainWindow.xaml;SearchWindow.xaml;
|
||||
|
||||
False
|
||||
True
|
||||
|
||||
|
@ -1,4 +1,4 @@
|
||||
#pragma checksum "..\..\MainWindow.xaml" "{ff1816ec-aa5e-4d10-87f7-6f4963833460}" "0EAA4E5953DD54A83EF84C8979256F95CA55AC47"
|
||||
#pragma checksum "..\..\MainWindow.xaml" "{ff1816ec-aa5e-4d10-87f7-6f4963833460}" "B63AC266B8736D857C4AD5FFCF2522AB3A32FFD8"
|
||||
//------------------------------------------------------------------------------
|
||||
// <auto-generated>
|
||||
// This code was generated by a tool.
|
||||
@ -51,7 +51,7 @@ namespace DeskHubSharp {
|
||||
|
||||
#line 10 "..\..\MainWindow.xaml"
|
||||
[System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1823:AvoidUnusedPrivateFields")]
|
||||
internal System.Windows.Controls.Button btn_search;
|
||||
internal System.Windows.Controls.Button btn_searchuser;
|
||||
|
||||
#line default
|
||||
#line hidden
|
||||
@ -192,6 +192,38 @@ namespace DeskHubSharp {
|
||||
#line default
|
||||
#line hidden
|
||||
|
||||
|
||||
#line 29 "..\..\MainWindow.xaml"
|
||||
[System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1823:AvoidUnusedPrivateFields")]
|
||||
internal System.Windows.Controls.ComboBox cmbbox_sort;
|
||||
|
||||
#line default
|
||||
#line hidden
|
||||
|
||||
|
||||
#line 30 "..\..\MainWindow.xaml"
|
||||
[System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1823:AvoidUnusedPrivateFields")]
|
||||
internal System.Windows.Controls.Button btn_sort;
|
||||
|
||||
#line default
|
||||
#line hidden
|
||||
|
||||
|
||||
#line 31 "..\..\MainWindow.xaml"
|
||||
[System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1823:AvoidUnusedPrivateFields")]
|
||||
internal System.Windows.Controls.Button btn_searchrepo;
|
||||
|
||||
#line default
|
||||
#line hidden
|
||||
|
||||
|
||||
#line 32 "..\..\MainWindow.xaml"
|
||||
[System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1823:AvoidUnusedPrivateFields")]
|
||||
internal System.Windows.Controls.TextBox txtbox_searchbox;
|
||||
|
||||
#line default
|
||||
#line hidden
|
||||
|
||||
private bool _contentLoaded;
|
||||
|
||||
/// <summary>
|
||||
@ -226,10 +258,10 @@ namespace DeskHubSharp {
|
||||
this.window_main = ((DeskHubSharp.MainWindow)(target));
|
||||
return;
|
||||
case 2:
|
||||
this.btn_search = ((System.Windows.Controls.Button)(target));
|
||||
this.btn_searchuser = ((System.Windows.Controls.Button)(target));
|
||||
|
||||
#line 10 "..\..\MainWindow.xaml"
|
||||
this.btn_search.Click += new System.Windows.RoutedEventHandler(this.btn_search_Click);
|
||||
this.btn_searchuser.Click += new System.Windows.RoutedEventHandler(this.btn_search_Click);
|
||||
|
||||
#line default
|
||||
#line hidden
|
||||
@ -315,6 +347,30 @@ namespace DeskHubSharp {
|
||||
case 19:
|
||||
this.txtblk_repocount = ((System.Windows.Controls.TextBlock)(target));
|
||||
return;
|
||||
case 20:
|
||||
this.cmbbox_sort = ((System.Windows.Controls.ComboBox)(target));
|
||||
return;
|
||||
case 21:
|
||||
this.btn_sort = ((System.Windows.Controls.Button)(target));
|
||||
|
||||
#line 30 "..\..\MainWindow.xaml"
|
||||
this.btn_sort.Click += new System.Windows.RoutedEventHandler(this.btn_sort_Click);
|
||||
|
||||
#line default
|
||||
#line hidden
|
||||
return;
|
||||
case 22:
|
||||
this.btn_searchrepo = ((System.Windows.Controls.Button)(target));
|
||||
|
||||
#line 31 "..\..\MainWindow.xaml"
|
||||
this.btn_searchrepo.Click += new System.Windows.RoutedEventHandler(this.btn_searchrepo_Click);
|
||||
|
||||
#line default
|
||||
#line hidden
|
||||
return;
|
||||
case 23:
|
||||
this.txtbox_searchbox = ((System.Windows.Controls.TextBox)(target));
|
||||
return;
|
||||
}
|
||||
this._contentLoaded = true;
|
||||
}
|
||||
|
@ -1,4 +1,4 @@
|
||||
#pragma checksum "..\..\MainWindow.xaml" "{ff1816ec-aa5e-4d10-87f7-6f4963833460}" "0EAA4E5953DD54A83EF84C8979256F95CA55AC47"
|
||||
#pragma checksum "..\..\MainWindow.xaml" "{ff1816ec-aa5e-4d10-87f7-6f4963833460}" "B63AC266B8736D857C4AD5FFCF2522AB3A32FFD8"
|
||||
//------------------------------------------------------------------------------
|
||||
// <auto-generated>
|
||||
// This code was generated by a tool.
|
||||
@ -51,7 +51,7 @@ namespace DeskHubSharp {
|
||||
|
||||
#line 10 "..\..\MainWindow.xaml"
|
||||
[System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1823:AvoidUnusedPrivateFields")]
|
||||
internal System.Windows.Controls.Button btn_search;
|
||||
internal System.Windows.Controls.Button btn_searchuser;
|
||||
|
||||
#line default
|
||||
#line hidden
|
||||
@ -192,6 +192,38 @@ namespace DeskHubSharp {
|
||||
#line default
|
||||
#line hidden
|
||||
|
||||
|
||||
#line 29 "..\..\MainWindow.xaml"
|
||||
[System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1823:AvoidUnusedPrivateFields")]
|
||||
internal System.Windows.Controls.ComboBox cmbbox_sort;
|
||||
|
||||
#line default
|
||||
#line hidden
|
||||
|
||||
|
||||
#line 30 "..\..\MainWindow.xaml"
|
||||
[System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1823:AvoidUnusedPrivateFields")]
|
||||
internal System.Windows.Controls.Button btn_sort;
|
||||
|
||||
#line default
|
||||
#line hidden
|
||||
|
||||
|
||||
#line 31 "..\..\MainWindow.xaml"
|
||||
[System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1823:AvoidUnusedPrivateFields")]
|
||||
internal System.Windows.Controls.Button btn_searchrepo;
|
||||
|
||||
#line default
|
||||
#line hidden
|
||||
|
||||
|
||||
#line 32 "..\..\MainWindow.xaml"
|
||||
[System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1823:AvoidUnusedPrivateFields")]
|
||||
internal System.Windows.Controls.TextBox txtbox_searchbox;
|
||||
|
||||
#line default
|
||||
#line hidden
|
||||
|
||||
private bool _contentLoaded;
|
||||
|
||||
/// <summary>
|
||||
@ -226,10 +258,10 @@ namespace DeskHubSharp {
|
||||
this.window_main = ((DeskHubSharp.MainWindow)(target));
|
||||
return;
|
||||
case 2:
|
||||
this.btn_search = ((System.Windows.Controls.Button)(target));
|
||||
this.btn_searchuser = ((System.Windows.Controls.Button)(target));
|
||||
|
||||
#line 10 "..\..\MainWindow.xaml"
|
||||
this.btn_search.Click += new System.Windows.RoutedEventHandler(this.btn_search_Click);
|
||||
this.btn_searchuser.Click += new System.Windows.RoutedEventHandler(this.btn_search_Click);
|
||||
|
||||
#line default
|
||||
#line hidden
|
||||
@ -315,6 +347,30 @@ namespace DeskHubSharp {
|
||||
case 19:
|
||||
this.txtblk_repocount = ((System.Windows.Controls.TextBlock)(target));
|
||||
return;
|
||||
case 20:
|
||||
this.cmbbox_sort = ((System.Windows.Controls.ComboBox)(target));
|
||||
return;
|
||||
case 21:
|
||||
this.btn_sort = ((System.Windows.Controls.Button)(target));
|
||||
|
||||
#line 30 "..\..\MainWindow.xaml"
|
||||
this.btn_sort.Click += new System.Windows.RoutedEventHandler(this.btn_sort_Click);
|
||||
|
||||
#line default
|
||||
#line hidden
|
||||
return;
|
||||
case 22:
|
||||
this.btn_searchrepo = ((System.Windows.Controls.Button)(target));
|
||||
|
||||
#line 31 "..\..\MainWindow.xaml"
|
||||
this.btn_searchrepo.Click += new System.Windows.RoutedEventHandler(this.btn_searchrepo_Click);
|
||||
|
||||
#line default
|
||||
#line hidden
|
||||
return;
|
||||
case 23:
|
||||
this.txtbox_searchbox = ((System.Windows.Controls.TextBox)(target));
|
||||
return;
|
||||
}
|
||||
this._contentLoaded = true;
|
||||
}
|
||||
|
Reference in New Issue
Block a user