public async Task <bool> check(plotSecurity temp) { if ((temp.latitude != "") && (temp.longitude != "") && (temp.range != "")) { await setCurrentGeo(); if (!checkGeo(temp.latitude, temp.longitude, temp.range)) { return(false); } } if (temp.ssid != "") { ssid = setCurrentNetwork(); if (!checkNetwork(temp.ssid)) { return(false); } } /*if (temp.password != "") * { * if (!checkPassword(temp.password)) * return false; * }*/ if (registeredDevice != 0) { if (!await checkRegisteredDevice()) { return(false); } } return(true); }
public static async Task <bool> deleteFileSecurity(plotSecurity temp) { try { TableOperation deleteSecurityOperation = TableOperation.Delete(temp); TableResult finalSecurityResult = await FileSecurityTable.ExecuteAsync(deleteSecurityOperation); return(true); } catch { } return(true); }
private async void updateBtn_Click(object sender, RoutedEventArgs e) { if (enableComponent) { enableComponent = false; plotSecurity temp = null; if (teamName != "") { temp = new plotSecurity(teamName); } else { temp = new plotSecurity(helper.getUsername() + accessKey); } if (geoToggle.IsOn) { temp.setGeo(latitude.Text, longitude.Text, range.Value.ToString()); } if (networkToggle.IsOn) { temp.setSSID(ssid.Text); } /* if (passwordToggle.IsOn) * { * temp.setPassword(password.Password); * } */ if (extraToggle.IsOn) { if (ASHWIDcheckbox.IsChecked == true) { temp.registeredDevice = 1; } } if (teamName != "") { await users.updatePlotSecurity(temp); } else { await users.updateFileSecurity(temp); helper.setKey(accessKey); } enableComponent = true; navigationHelper.GoBack(); } }
public static async Task <bool> updateFileSecurity(plotSecurity temp) { try { TableOperation insertOperation = TableOperation.InsertOrReplace(temp); TableResult result = await FileSecurityTable.ExecuteAsync(insertOperation); return(true); } catch { return(false); } }
private async void download_Click(object sender, RoutedEventArgs e) { if (helper.checkInternetConnection()) { if (enableComponent) { plotSecurity temp = await users.fetchPlotSecurity(teamName); try { FolderPicker picker = new FolderPicker(); picker.FileTypeFilter.Add("*"); StorageFolder folder = await picker.PickSingleFolderAsync(); displayLoading("Verifying ..."); List <object> listSelected = list.SelectedItems.ToList <object>(); plotSecurity current = new plotSecurity(); if (await current.check(temp)) { int total = listSelected.Count; int cur = 0; //helper.popup(listSelected.Count.ToString(), ""); foreach (files data in listSelected) { displayLoading("Downloading \n Files:" + cur + "/" + total + "..."); await users.downloadFile(data.getHost(), data.getFilename(), folder); list.SelectedItems.Remove(data); cur++; } disableLoading(); helper.popup("The requested file has been downloaded and saved successfully", "Downloaded"); } else { disableLoading(); helper.popup("Access denied", "Access denied"); } } catch { } } } else { helper.popup("Check your internet connection", "NO INTERNET"); } }
private async void currentGeoCheckBox_Checked(object sender, RoutedEventArgs e) { plotSecurity temp = new plotSecurity(); try { await temp.setCurrentGeo(); latitude.Text = temp.latitude; longitude.Text = temp.longitude; } catch { helper.popup("Error in fetching the device location. Try again later", "LOCATION FAILED"); } }
public static async Task <bool> deleteTeam(plots temp) { try { List <plots> list = await helper.retrivePlotTeamDataLocal(temp.getTeamName()); List <linking> linkingList = await helper.retriveLinkTeamDataLocal(temp.getTeamName()); plotSecurity security = await fetchPlotSecurity(temp.getTeamName()); foreach (plots data in list) { TableOperation deletePlotOperation = TableOperation.Delete(data); TableResult finalPlotResult = await plotsTable.ExecuteAsync(deletePlotOperation); } foreach (linking link in linkingList) { TableOperation deleteLinkOperation = TableOperation.Delete(link); TableResult finalLinkResult = await linkingTable.ExecuteAsync(deleteLinkOperation); } TableOperation deleteSecurityOperation = TableOperation.Delete(security); TableResult finalSecurityResult = await plotSecurityTable.ExecuteAsync(deleteSecurityOperation); await helper.deletePlotDataLocal(temp.getTeamName()); StorageFile file = await helper.getDownloadTeamProfileFile(temp.getTeamName()); await file.DeleteAsync(); await deleteTeamProfile(temp.getTeamName()); users user = await fetchUser(helper.getUsername()); user.decrementPlotCount(); await replaceUser(user); return(true); } catch { return(false); } }
protected async override void OnNavigatedTo(NavigationEventArgs e) { try { List <string> list = e.Parameter as List <string>; if (list[0] != "profile") { teamName = list[1]; plotSecurity temp = await users.fetchPlotSecurity(teamName); if (temp.latitude != "" && temp.longitude != "" && temp.range != "") { latitude.Text = temp.latitude; longitude.Text = temp.longitude; int Range = 0; int.TryParse(temp.range, out Range); range.Value = Range; geoToggle.IsOn = true; } /*if (temp.password != "") { * password.Password = temp.password; * passwordToggle.IsOn = true; * }*/ if (temp.ssid != "") { ssid.Text = temp.ssid; networkToggle.IsOn = true; } if (temp.registeredDevice == 1) { ASHWIDcheckbox.IsChecked = true; extraToggle.IsOn = true; } checkToggle(); } else { accessKey = list[1]; plotSecurity temp = await users.fetchFileSecurity(helper.getUsername() + accessKey); if (temp == null) { temp = new plotSecurity(helper.getUsername() + accessKey); } if (temp.latitude != "" && temp.longitude != "" && temp.range != "") { latitude.Text = temp.latitude; longitude.Text = temp.longitude; int Range = 0; int.TryParse(temp.range, out Range); range.Value = Range; geoToggle.IsOn = true; } /*if (temp.password != "") { * password.Password = temp.password; * passwordToggle.IsOn = true; * }*/ if (temp.ssid != "") { ssid.Text = temp.ssid; networkToggle.IsOn = true; } if (temp.registeredDevice == 1) { ASHWIDcheckbox.IsChecked = true; extraToggle.IsOn = true; } checkToggle(); } } catch (Exception s) { helper.popup(s.ToString(), ""); } navigationHelper.OnNavigatedTo(e); enableComponent = true; }
public async Task <bool> getFileFromKey() { if (enableComponent) { if (helper.checkInternetConnection()) { if (DownloadFile.Content.ToString() != "Download") { if (helper.checkInternetConnection()) { if (host.Text != "" && accessKey.Text != "") { try { displayLoading("Fetching details..."); if (await users.fetchAccessKeys(host.Text, accessKey.Text) == null) { helper.popup("You have entered a invalid access key!\nEnter a valid access key", "INCORRECT ACCESS KEY"); disableLoading(); return(false); } plotSecurity security = await users.fetchFileSecurity(host.Text + accessKey.Text); plotSecurity currentSecurity = new plotSecurity(); if (security != null) { if (await currentSecurity.check(security)) { disableLoading(); DownloadFile.Content = "Download"; host.IsEnabled = false; accessKey.IsEnabled = false; preview.Visibility = Visibility.Visible; } else { disableLoading(); helper.popup("Access denied", "ACCESS DENIED"); } } else { disableLoading(); DownloadFile.Content = "Download"; host.IsEnabled = false; accessKey.IsEnabled = false; preview.Visibility = Visibility.Visible; } } catch { disableLoading(); helper.popup("You have entered a invalid access code\nEnter a valid access code.", "INVALID ACCESS CODE"); } } else { disableLoading(); helper.popup("Complete the details required to get a file", "INCOMPLETE"); } } else { disableLoading(); helper.popup("Please check your internet connection", "Connection failed"); } disableLoading(); } else { FolderPicker picker = new FolderPicker(); picker.FileTypeFilter.Add("*"); StorageFolder folder = await picker.PickSingleFolderAsync(); List <accessKeys> tempList = await users.fetchAccessKeys(host.Text, accessKey.Text); int current = 0, total = tempList.Count; displayLoading("Downloading..."); StorageFolder finalFolder = await folder.CreateFolderAsync("PLoT Access key - (" + accessKey.Text + ")", CreationCollisionOption.GenerateUniqueName); foreach (accessKeys temp in tempList) { displayLoading("Downloading files...\nFile: " + current.ToString() + "/" + total); await users.downloadFile(temp.host, temp.RowKey, finalFolder); current++; } disableLoading(); helper.popup("All the files are successfully downloaded and saved!", "DOWNLOAD COMPLETE"); navigationHelper.GoBack(); } } else { helper.popup("Check your internet connection", "NO INTERNET"); } } return(true); }