Skip to content

Commit

Permalink
fixed continuation bug, added handling for TEam Health internal serve…
Browse files Browse the repository at this point in the history
…r error
  • Loading branch information
jackb-dropbox committed Jun 8, 2017
1 parent f49249c commit 2c93fd2
Show file tree
Hide file tree
Showing 2 changed files with 210 additions and 42 deletions.
4 changes: 2 additions & 2 deletions Source/DfBAdminToolkit/Presenter/TeamAuditingPresenter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -695,8 +695,6 @@ private void GetEvents(ITeamAuditingModel model, ITeamAuditingView view, IMainPr
{
timestamp = timestampObj;
}


if (region != "Unknown" || region != "")
{
region = FileUtil.ConvertStateToAbbreviation(region);
Expand Down Expand Up @@ -746,6 +744,8 @@ private void GetEvents(ITeamAuditingModel model, ITeamAuditingView view, IMainPr
EventCount++;
}
}
hasMore = jsonDataCont["has_more"];
cursor = jsonDataCont["cursor"];
}
}
}
Expand Down
248 changes: 208 additions & 40 deletions Source/DfBAdminToolkit/Presenter/TeamHealthPresenter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -132,28 +132,78 @@ private void RefreshHealth(ITeamHealthModel model, IMainPresenter presenter)
activityStartDate = jsonData["start_date"];
if (jsonData["adds"][0] != null)
{
int addsCount = (jsonData["adds"].Count) - 2;
adds = jsonData["adds"][addsCount];
int availableData = 1;
bool complete = false;
while (!complete)
{
if (((jsonData["adds"].Count) - availableData) != null)
{
int addsCount = (jsonData["adds"].Count) - availableData;
adds = jsonData["adds"][addsCount];
complete = true;
}
availableData++;
}
}
if (jsonData["edits"][0] != null)
{
int editsCount = (jsonData["edits"].Count) - 2;
edits = jsonData["edits"][editsCount];
int availableData = 1;
bool complete = false;
while (!complete)
{
if (((jsonData["edits"].Count) - availableData) != null)
{
int editsCount = (jsonData["edits"].Count) - availableData;
edits = jsonData["edits"][editsCount];
complete = true;
}
availableData++;
}
}
if (jsonData["deletes"][0] != null)
{
int deletesCount = (jsonData["deletes"].Count) - 2;
deletes = jsonData["deletes"][deletesCount];
int availableData = 1;
bool complete = false;
while (!complete)
{
if (((jsonData["deletes"].Count) - availableData) != null)
{
int deletesCount = (jsonData["deletes"].Count) - availableData;
deletes = jsonData["deletes"][deletesCount];
complete = true;
}
availableData++;
}
}
if (jsonData["active_shared_folders_7_day"][0] != null)
{
int activeSharedCount = (jsonData["active_shared_folders_7_day"].Count) - 2;
activeSharedFolders7Day = jsonData["active_shared_folders_7_day"][activeSharedCount];
int availableData = 1;
bool complete = false;
while (!complete)
{
if (((jsonData["active_shared_folders_7_day"].Count) - availableData) != null)
{
int activeSharedCount = (jsonData["active_shared_folders_7_day"].Count) - availableData;
activeSharedFolders7Day = jsonData["active_shared_folders_7_day"][activeSharedCount];
complete = true;
}
availableData++;
}
}
if (jsonData["active_users_7_day"][0] != null)
{
int activeUsers = (jsonData["active_users_7_day"].Count) - 2;
activeUsers7Day = jsonData["active_users_7_day"][activeUsers];
int availableData = 1;
bool complete = false;
while (!complete)
{
if (((jsonData["active_users_7_day"].Count) - availableData) != null)
{
int activeUsers = (jsonData["active_users_7_day"].Count) - availableData;
activeUsers7Day = jsonData["active_users_7_day"][activeUsers];
complete = true;
}
availableData++;
}
}
model.Adds = adds.ToString();
model.Edits = edits.ToString();
Expand All @@ -171,41 +221,111 @@ private void RefreshHealth(ITeamHealthModel model, IMainPresenter presenter)

devicesStartDate = jsonData["start_date"];
if (jsonData["active_7_day"] != null)
{
{
if (jsonData["active_7_day"]["windows"][0] != null)
{
int windowsUsers = (jsonData["active_7_day"]["windows"].Count) - 2;
windows = jsonData["active_7_day"]["windows"][windowsUsers];
int availableData = 1;
bool complete = false;
while (!complete)
{
if (((jsonData["active_7_day"]["windows"].Count) - availableData) != null)
{
int windowsUsers = (jsonData["active_7_day"]["windows"].Count) - availableData;
windows = jsonData["active_7_day"]["windows"][windowsUsers];
complete = true;
}
availableData++;
}
}
if (jsonData["active_7_day"]["macos"][0] != null)
{
int macosUsers = (jsonData["active_7_day"]["macos"].Count) - 2;
macos = jsonData["active_7_day"]["macos"][macosUsers];
int availableData = 1;
bool complete = false;
while (!complete)
{
if (((jsonData["active_7_day"]["macos"].Count) - availableData) != null)
{
int macosUsers = (jsonData["active_7_day"]["macos"].Count) - availableData;
macos = jsonData["active_7_day"]["macos"][macosUsers];
complete = true;
}
availableData++;
}
}
if (jsonData["active_7_day"]["linux"][0] != null)
{
int linuxUsers = (jsonData["active_7_day"]["linux"].Count) - 2;
linux = jsonData["active_7_day"]["linux"][linuxUsers];
int availableData = 1;
bool complete = false;
while (!complete)
{
if (((jsonData["active_7_day"]["linux"].Count) - availableData) != null)
{
int linuxUsers = (jsonData["active_7_day"]["linux"].Count) - availableData;
linux = jsonData["active_7_day"]["linux"][linuxUsers];
complete = true;
}
availableData++;
}
}
if (jsonData["active_7_day"]["ios"][0] != null)
{
int iosUsers = (jsonData["active_7_day"]["ios"].Count) - 2;
ios = jsonData["active_7_day"]["ios"][iosUsers];
int availableData = 1;
bool complete = false;
while (!complete)
{
if (((jsonData["active_7_day"]["ios"].Count) - availableData) != null)
{
int iosUsers = (jsonData["active_7_day"]["ios"].Count) - availableData;
ios = jsonData["active_7_day"]["ios"][iosUsers];
complete = true;
}
availableData++;
}
}
if (jsonData["active_7_day"]["android"][0] != null)
{
int androidUsers = (jsonData["active_7_day"]["android"].Count) - 2;
android = jsonData["active_7_day"]["android"][androidUsers];
int availableData = 1;
bool complete = false;
while (!complete)
{
if (((jsonData["active_7_day"]["android"].Count) - availableData) != null)
{
int androidUsers = (jsonData["active_7_day"]["android"].Count) - availableData;
android = jsonData["active_7_day"]["android"][androidUsers];
complete = true;
}
availableData++;
}
}
if (jsonData["active_7_day"]["other"][0] != null)
{
int otherUsers = (jsonData["active_7_day"]["other"].Count) - 2;
other = jsonData["active_7_day"]["other"][otherUsers];
int availableData = 1;
bool complete = false;
while (!complete)
{
if (((jsonData["active_7_day"]["other"].Count) - availableData) != null)
{
int otherUsers = (jsonData["active_7_day"]["other"].Count) - availableData;
other = jsonData["active_7_day"]["other"][otherUsers];
complete = true;
}
availableData++;
}
}
if (jsonData["active_7_day"]["total"][0] != null)
{
int totalUsers = (jsonData["active_7_day"]["total"].Count) - 2;
total = jsonData["active_7_day"]["total"][totalUsers];
int availableData = 1;
bool complete = false;
while (!complete)
{
if (((jsonData["active_7_day"]["total"].Count) - availableData) != null)
{
int totalUsers = (jsonData["active_7_day"]["total"].Count) - availableData;
total = jsonData["active_7_day"]["total"][totalUsers];
complete = true;
}
availableData++;
}
}
}
model.windows = windows.ToString();
Expand All @@ -227,33 +347,81 @@ private void RefreshHealth(ITeamHealthModel model, IMainPresenter presenter)
storageStartDate = jsonData["start_date"];
if (jsonData["total_usage"][0] != null)
{
int totalCount = (jsonData["total_usage"].Count) - 2;
totalStorage = jsonData["total_usage"][totalCount];
double totalStorageDec = FileUtil.FormatFileSizeTB(totalStorage);
model.TotalUsage = totalStorageDec.ToString() + " TB";
int availableData = 1;
bool complete = false;
while (!complete)
{
if (((jsonData["total_usage"].Count) - availableData) != null)
{
int totalCount = (jsonData["total_usage"].Count) - availableData;
totalStorage = jsonData["total_usage"][totalCount];
double totalStorageDec = FileUtil.FormatFileSizeTB(totalStorage);
model.TotalUsage = totalStorageDec.ToString() + " TB";
complete = true;
}
availableData++;
}
}
if (jsonData["shared_usage"][0] != null)
{
int sharedCount = (jsonData["shared_usage"].Count) - 2;
sharedStorage = jsonData["shared_usage"][sharedCount];
double sharedStorageDec = FileUtil.FormatFileSizeTB(sharedStorage);
model.SharedUsage = sharedStorageDec.ToString() + " TB";
int availableData = 1;
bool complete = false;
while (!complete)
{
if (((jsonData["shared_usage"].Count) - availableData) != null)
{
int sharedCount = (jsonData["shared_usage"].Count) - availableData;
sharedStorage = jsonData["shared_usage"][sharedCount];
double sharedStorageDec = FileUtil.FormatFileSizeTB(sharedStorage);
model.SharedUsage = sharedStorageDec.ToString() + " TB";
complete = true;
}
availableData++;
}
}
if (jsonData["unshared_usage"][0] != null)
{
int unsharedCount = (jsonData["unshared_usage"].Count) - 2;
unsharedStorage = jsonData["unshared_usage"][unsharedCount];
double unsharedStorageDec = FileUtil.FormatFileSizeTB(unsharedStorage);
model.UnsharedUsage = unsharedStorageDec.ToString() + " TB";
int availableData = 1;
bool complete = false;
while (!complete)
{
if (((jsonData["unshared_usage"].Count) - availableData) != null)
{
int unsharedCount = (jsonData["unshared_usage"].Count) - availableData;
unsharedStorage = jsonData["unshared_usage"][unsharedCount];
double unsharedStorageDec = FileUtil.FormatFileSizeTB(unsharedStorage);
model.UnsharedUsage = unsharedStorageDec.ToString() + " TB";
complete = true;
}
availableData++;
}
}
if (jsonData["shared_folders"][0] != null)
{
int sharedFolderCount = (jsonData["shared_folders"].Count) - 2;
sharedFolders = jsonData["shared_folders"][sharedFolderCount];
model.SharedFolders = sharedFolders.ToString();
int availableData = 1;
bool complete = false;
while (!complete)
{
if (((jsonData["shared_usage"].Count) - availableData) != null)
{
int sharedFolderCount = (jsonData["shared_folders"].Count) - availableData;
sharedFolders = jsonData["shared_folders"][sharedFolderCount];
model.SharedFolders = sharedFolders.ToString();
complete = true;
}
availableData++;
}
}
}
}
if (responseStorage.StatusCode != HttpStatusCode.OK)
{
//if Dropbox gives back Internal Server error, bug filed from engineering on this
model.TotalUsage = "N/A";
model.SharedUsage = "N/A";
model.UnsharedUsage = "N/A";
model.SharedFolders = "N/A";
}
model.RefreshDateTime = DateTime.Now;
}

Expand Down

0 comments on commit 2c93fd2

Please sign in to comment.