Skip to content
This repository has been archived by the owner on Sep 30, 2022. It is now read-only.

Commit

Permalink
Verson 1.6.5 RELEASE
Browse files Browse the repository at this point in the history
Added Pit Scouting Excel Export (so we can share data w/ other teams easily)
  • Loading branch information
shreystechtips committed Apr 19, 2019
1 parent c1dc0e5 commit a400e8c
Show file tree
Hide file tree
Showing 10 changed files with 139 additions and 77 deletions.
2 changes: 1 addition & 1 deletion Droid/NRGScoutingApp.Droid.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
<AotAssemblies>True</AotAssemblies>
<EnableLLVM>True</EnableLLVM>
<AndroidLinkMode>None</AndroidLinkMode>
<ReleaseVersion>1.6</ReleaseVersion>
<ReleaseVersion>1.6.5</ReleaseVersion>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
Expand Down
2 changes: 1 addition & 1 deletion Droid/Properties/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.NRG.ScoutingApp.NRG_Scouting" android:versionCode="9" android:versionName="1.6" android:installLocation="auto">
<manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.NRG.ScoutingApp.NRG_Scouting" android:versionCode="10" android:versionName="1.6.5" android:installLocation="auto">
<uses-sdk android:minSdkVersion="21" android:targetSdkVersion="27" />
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
Expand Down
2 changes: 1 addition & 1 deletion MobileAppService/NRGScoutingApp.MobileAppService.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

<PropertyGroup>
<TargetFramework>netcoreapp2.0</TargetFramework>
<ReleaseVersion>1.6</ReleaseVersion>
<ReleaseVersion>1.6.5</ReleaseVersion>
</PropertyGroup>

<ItemGroup>
Expand Down
2 changes: 1 addition & 1 deletion NRGScoutingApp.sln
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ Global
SolutionGuid = {5D08523F-70D7-41E2-B656-B2C13AAE7A31}
EndGlobalSection
GlobalSection(MonoDevelopProperties) = preSolution
version = 1.6
version = 1.6.5
Policies = $0
$0.DotNetNamingPolicy = $1
$1.DirectoryNamespaceAssociation = PrefixedHierarchical
Expand Down
26 changes: 17 additions & 9 deletions NRGScoutingApp/Helper Classes/CSVRanker.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,17 @@ public class CSVRanker {

public string matchCalc (JObject match) {
this.match = match;
String total = this.match["team"] + "," +
this.match["matchNum"] + "," +
MatchFormat.matchSideFromEnum ((int) this.match["side"]) + ","; //Side
String total;
try
{
total = this.match["team"] + "," +
this.match["matchNum"] + "," +
MatchFormat.matchSideFromEnum((int)this.match["side"]) + ","; //Side
}
catch
{
total = ",,,";
}
total += pickCalc ((int) MatchFormat.CHOOSE_RANK_TYPE.pick1) + "," + //Hatch
numCalc ((int) MatchFormat.CHOOSE_RANK_TYPE.pick1) + "," +
pickCalc ((int) MatchFormat.CHOOSE_RANK_TYPE.pick2) + "," + //Cargo
Expand Down Expand Up @@ -60,7 +68,7 @@ private String climbCalc () {
return total;
}

private double dropCalc (int levelEnum) {
private String dropCalc (int levelEnum) {
double totalData = 0;
int reps = 0;
int eventReps = 0;
Expand Down Expand Up @@ -88,9 +96,9 @@ private double dropCalc (int levelEnum) {
}

if (eventReps > 0) {
return totalData / eventReps;
return (totalData / eventReps).ToString();
} else {
return Double.NaN;
return "";
}

}
Expand All @@ -116,7 +124,7 @@ private double numCalc (int sortType) {
return total;
}

private double pickCalc (int sortType) {
private String pickCalc (int sortType) {
double total = 0;
int reps = 0;
int eventReps = 0;
Expand All @@ -142,9 +150,9 @@ private double pickCalc (int sortType) {

}
if (eventReps > 0) {
return total / eventReps;
return (total / eventReps).ToString();
} else {
return Double.NaN;
return "";
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion NRGScoutingApp/Helper Classes/Ranker.cs
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ public JArray getDataAsJArray () {
}

/*
* This is the order in which the array is ordered
* This is the order in which the array is ordered
* overall, cargoTime, hatchTime, climb, lvl1, lvl2, lvl3
*/
public String[] returnTeamTimes (string team) {
Expand Down
2 changes: 1 addition & 1 deletion NRGScoutingApp/NRGScoutingApp.shproj
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<ProjectGuid>{81F276C2-6F61-4860-86CB-EA7F6D086DFB}</ProjectGuid>
<ReleaseVersion>1.6</ReleaseVersion>
<ReleaseVersion>1.6.5</ReleaseVersion>
</PropertyGroup>
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
<Import Project="$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)\CodeSharing\Microsoft.CodeSharing.Common.Default.props" />
Expand Down
172 changes: 113 additions & 59 deletions NRGScoutingApp/Pages/Data Handling/ExportDialog.xaml.cs
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
using System;
using System.IO;
using System.Net;
using System.Text;
using System.Threading.Tasks;
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
using Plugin.Clipboard;
using Plugin.Permissions;
using Plugin.Permissions.Abstractions;
using Rg.Plugins.Popup.Services;
using Xamarin.Essentials;
using Xamarin.Forms;
using System.Text;
using System.Net;
using Plugin.Permissions.Abstractions;
using Plugin.Permissions;

namespace NRGScoutingApp {
public partial class ExportDialog {
Expand All @@ -21,6 +21,7 @@ public ExportDialog () {
}

private string excelFileBase = "scoutDataExport_" + DateTime.Now.Month + "_" + DateTime.Now.Day + "_" + DateTime.Now.Hour + ":" + DateTime.Now.Minute + ":" + DateTime.Now.Second;
private string pitFileBase = "pitDataExport_" + DateTime.Now.Month + "_" + DateTime.Now.Day + "_" + DateTime.Now.Hour + ":" + DateTime.Now.Minute + ":" + DateTime.Now.Second;
private string exportText = "";
private string csvString = "";
void cancelClicked (object sender, System.EventArgs e) {
Expand Down Expand Up @@ -51,77 +52,61 @@ async void copyClicked (object sender, System.EventArgs e) {
} else {
await DisplayAlert ("Oops!", "No " + ConstantVars.exportTypes[3] + " data", "OK");
}
}
else if (action.Equals(ConstantVars.exportTypes[4]))
{
await pasteRequest();
} else if (action.Equals (ConstantVars.exportTypes[4])) {
await pasteRequest ();
}
if (!action.Equals (ConstantVars.exportTypes[0])) {
await PopupNavigation.Instance.PopAsync (true);
}
}

async private Task pasteRequest() {
String temp = exportText.Replace("&","and");
var s = new WebClient();
async private Task pasteRequest () {
String temp = exportText.Replace ("&", "and");
var s = new WebClient ();
String action = "";
while (String.IsNullOrWhiteSpace(action))
{
action = await DisplayActionSheet("Choose PasteBin Export Type:", ConstantVars.exportTypes[0], null, ConstantVars.exportTypes[1], ConstantVars.exportTypes[2], ConstantVars.exportTypes[3]);
while (String.IsNullOrWhiteSpace (action)) {
action = await DisplayActionSheet ("Choose PasteBin Export Type:", ConstantVars.exportTypes[0], null, ConstantVars.exportTypes[1], ConstantVars.exportTypes[2], ConstantVars.exportTypes[3]);
}
if (action.Equals(ConstantVars.exportTypes[1]))
{
if (action.Equals (ConstantVars.exportTypes[1])) {
temp = this.exportText;
}
else if (action.Equals(ConstantVars.exportTypes[2]))
{
JObject datas = JObject.Parse(temp);
if (datas.ContainsKey("Matches"))
{
temp = JsonConvert.SerializeObject(new JObject(new JProperty("Matches", (JArray)datas["Matches"])));
}
else
{
await DisplayAlert("Oops!", "No " + ConstantVars.exportTypes[2] + " data", "OK");
}
}
else if (action.Equals(ConstantVars.exportTypes[3]))
{
JObject datas = JObject.Parse(temp);
if (datas.ContainsKey("PitNotes"))
{
temp = JsonConvert.SerializeObject(new JObject(new JProperty("PitNotes", (JArray)datas["PitNotes"])));
} else if (action.Equals (ConstantVars.exportTypes[2])) {
JObject datas = JObject.Parse (temp);
if (datas.ContainsKey ("Matches")) {
temp = JsonConvert.SerializeObject (new JObject (new JProperty ("Matches", (JArray) datas["Matches"])));
} else {
await DisplayAlert ("Oops!", "No " + ConstantVars.exportTypes[2] + " data", "OK");
}
else
{
await DisplayAlert("Oops!", "No " + ConstantVars.exportTypes[3] + " data", "OK");
} else if (action.Equals (ConstantVars.exportTypes[3])) {
JObject datas = JObject.Parse (temp);
if (datas.ContainsKey ("PitNotes")) {
temp = JsonConvert.SerializeObject (new JObject (new JProperty ("PitNotes", (JArray) datas["PitNotes"])));
} else {
await DisplayAlert ("Oops!", "No " + ConstantVars.exportTypes[3] + " data", "OK");
}
}

try
{
WebRequest req = WebRequest.Create("http://pastebin.com/api/api_post.php");
try {
WebRequest req = WebRequest.Create ("http://pastebin.com/api/api_post.php");

req.Method = "POST";
req.ContentType = "application/x-www-form-urlencoded";

string postData = "api_option=" + "paste" + "&api_paste_code=" + temp + "&api_dev_key=" + "add_api_key";
byte[] byteArray = Encoding.UTF8.GetBytes(postData);
byte[] byteArray = Encoding.UTF8.GetBytes (postData);
req.ContentLength = byteArray.Length;

Stream ds = req.GetRequestStream();
ds.Write(byteArray, 0, byteArray.Length);
ds.Close();
WebResponse wr = req.GetResponse();
ds = wr.GetResponseStream();
StreamReader reader = new StreamReader(ds);
Stream ds = req.GetRequestStream ();
ds.Write (byteArray, 0, byteArray.Length);
ds.Close ();
WebResponse wr = req.GetResponse ();
ds = wr.GetResponseStream ();
StreamReader reader = new StreamReader (ds);

String ret = await reader.ReadToEndAsync();
CrossClipboard.Current.SetText(ret);
await DisplayAlert("Success", "Pastebin Link Copied to Clipboard", "OK");
}
catch {
await DisplayAlert("Error", "No Internet!", "OK");
String ret = await reader.ReadToEndAsync ();
CrossClipboard.Current.SetText (ret);
await DisplayAlert ("Success", "Pastebin Link Copied to Clipboard", "OK");
} catch {
await DisplayAlert ("Error", "No Internet!", "OK");
}
}

Expand All @@ -136,7 +121,76 @@ await Share.RequestAsync (new ShareTextRequest {
}

async void Rank_Clicked (object sender, System.EventArgs e) {
await RankText ();
String action = "";
while (String.IsNullOrWhiteSpace (action)) {
action = await DisplayActionSheet ("Choose PasteBin Export Type:", ConstantVars.exportTypes[0], null, "Match", "Pit");
}
if (action.Equals ("Match")) {
await RankText ();
} else if (action.Equals ("Pit")) {
await PitText ();
}

}

private async Task PitText () {
await Task.Run (async () => {
Ranker rank = new Ranker (Preferences.Get ("matchEventsString", ""));
csvString = "Team";
foreach (String s in ConstantVars.QUESTIONS) {
csvString += "," + s;
}
csvString += "\n";
JObject tempJSON;
JArray pits;
if (!String.IsNullOrWhiteSpace (Preferences.Get ("matchEventsString", ""))) {
try {
tempJSON = JObject.Parse (Preferences.Get ("matchEventsString", ""));
} catch (NullReferenceException) {
System.Diagnostics.Debug.WriteLine ("Caught NullRepEx for ranker JObject");
tempJSON = new JObject ();
}
} else {
tempJSON = new JObject (new JProperty ("PitNotes"));
}
if (tempJSON.ContainsKey ("PitNotes")) {
pits = (JArray) tempJSON["PitNotes"];
} else {
pits = new JArray ();
}
for (int i = 0; i < pits.Count; i++) {
csvString += pits[i]["team"];
for (int j = 0; j < ConstantVars.QUESTIONS.Length; j++) {
try {
String ss = (pits[i]["q" + j]).ToString().Replace("\n", "");
csvString += "," + ss;
} catch {
csvString += ",";
}
}
csvString += "\n";
}
string path = Environment.GetFolderPath (Environment.SpecialFolder.MyDocuments);
File.WriteAllText (path + "/" + pitFileBase + ".csv", csvString);
});
switch (Device.RuntimePlatform)
{
case Device.iOS:
string path = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments);
await Share.RequestAsync(new ShareTextRequest
{
Uri = "file://" + path + "/" + pitFileBase + ".csv",
Title = "Share Pit"
});
break;
default:
//var response = await CrossPermissions.Current.RequestPermissionsAsync(Permission.Storage);
//String fileDir = Path.Combine(Android.OS.Environment.GetExternalStoragePublicDirectory(Android.OS.Environment.DirectoryDownloads).ToString(), excelFileBase + ".csv");
//File.WriteAllText(fileDir, "");
//File.WriteAllText(fileDir, csvString);
break;

}
}
private async Task RankText () {
initCSV ();
Expand All @@ -150,10 +204,10 @@ await Share.RequestAsync (new ShareTextRequest {
});
break;
default:
var response = await CrossPermissions.Current.RequestPermissionsAsync(Permission.Storage);
String fileDir = Path.Combine(Android.OS.Environment.GetExternalStoragePublicDirectory(Android.OS.Environment.DirectoryDownloads).ToString(), excelFileBase + ".csv");
File.WriteAllText(fileDir, "");
File.WriteAllText(fileDir, csvString);
//var response = await CrossPermissions.Current.RequestPermissionsAsync(Permission.Storage);
//String fileDir = Path.Combine(Android.OS.Environment.GetExternalStoragePublicDirectory(Android.OS.Environment.DirectoryDownloads).ToString(), excelFileBase + ".csv");
//File.WriteAllText(fileDir, "");
//File.WriteAllText(fileDir, csvString);
break;

}
Expand Down
4 changes: 2 additions & 2 deletions iOS/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
<key>CFBundleIdentifier</key>
<string>com.NRG.ScoutingApp.2019</string>
<key>CFBundleVersion</key>
<string>1.6</string>
<string>1.6.5</string>
<key>LSRequiresIPhoneOS</key>
<true/>
<key>MinimumOSVersion</key>
Expand Down Expand Up @@ -44,6 +44,6 @@
<key>UIViewControllerBasedStatusBarAppearance</key>
<false/>
<key>CFBundleShortVersionString</key>
<string>1.6</string>
<string>1.6.5</string>
</dict>
</plist>
2 changes: 1 addition & 1 deletion iOS/NRGScoutingApp.iOS.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
<RootNamespace>NRGScoutingApp.iOS</RootNamespace>
<AssemblyName>NRGScoutingApp.iOS</AssemblyName>
<IPhoneResourcePrefix>Resources</IPhoneResourcePrefix>
<ReleaseVersion>1.6</ReleaseVersion>
<ReleaseVersion>1.6.5</ReleaseVersion>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|iPhoneSimulator' ">
<DebugSymbols>true</DebugSymbols>
Expand Down

0 comments on commit a400e8c

Please sign in to comment.