private async void onLaunch()
        {
            StorageFolder folder = Windows.Storage.ApplicationData.Current.LocalFolder;
            StorageFile sampleFile = await folder.GetFileAsync("sample.txt");

            string testlol = await Windows.Storage.FileIO.ReadTextAsync(sampleFile);
            string he = testlol;
            Outputbox.Text = he;
            StorageFolder folder2 = Windows.Storage.ApplicationData.Current.LocalFolder;
            StorageFile sampleFile2 = await folder2.GetFileAsync("data.txt");

            string testlol2 = await Windows.Storage.FileIO.ReadTextAsync(sampleFile2);
            data = new Paper();
            data = JsonConvert.DeserializeObject<Paper>(testlol2);
            
        }
        /// <summary>
        /// Invoked when this page is about to be displayed in a Frame.
        /// </summary>
        /// <param name="e">Event data that describes how this page was reached.
        /// This parameter is typically used to configure the page.</param>
         private async void onLaunch()
        {
            
            try
            {
                MainFragment.Visibility = Windows.UI.Xaml.Visibility.Visible;
                ListFragment.Visibility = Windows.UI.Xaml.Visibility.Visible;
                TitleBar.Visibility = Windows.UI.Xaml.Visibility.Visible;
                StorageFolder folder = Windows.Storage.ApplicationData.Current.LocalFolder;
                StorageFile sampleFile = await folder.GetFileAsync("sample.txt");

                string testlol = await Windows.Storage.FileIO.ReadTextAsync(sampleFile);
                string he = testlol;
                List<int> index = new List<int>();
                List<string> paperData = new List<string>();
                List<string> paperDataFinal = new List<string>();
                //lol.Source = new Uri("http://akshit.xyz/resultsggsipu");
                HttpClient client = new HttpClient();
                string a = await client.GetStringAsync("http://akshit.xyz/resultsggsipu/dbinteraction/dbConnection.php?" + he);
                for (int i = 0; i < a.Length; i++)
                {
                    if (a[i] == 's')
                    {
                        if (a[i + 1] == '0')
                        {
                            index.Add(i);
                        }
                        if (a[i + 1] == '1')
                        {
                            index.Add(i);
                        }
                        if (a[i + 1] == '2')
                        {
                            index.Add(i);
                        }
                        if (a[i + 1] == '3')
                        {
                            index.Add(i);
                        }
                        if (a[i + 1] == '4')
                        {
                            index.Add(i);
                        }
                        if (a[i + 1] == '5')
                        {
                            index.Add(i);
                        }
                        if (a[i + 1] == '6')
                        {
                            index.Add(i);
                        }
                        if (a[i + 1] == '7')
                        {
                            index.Add(i);
                        }

                    }

                }
                int j = 9, k;
                for (j = 0; j < index.Count - 1; j++)
                {
                    paperData.Add(a.Substring(index[j] + 5, ((index[j + 1] - 8) - index[j])));
                }
                string test = a.Substring(index[j] + 5);
                paperData.Add(test.Substring(0, test.Length - 3));
                string mainData = a.Substring(0, index[0] - 11) + "}";
                hi = JsonConvert.DeserializeObject<Result>(mainData);
                Paper data = new Paper();

                data.s0 = new List<List<S0>>();

                foreach (string hell in paperData)
                {
                    k = 0;

                    for (j = 0; j < hell.Length; j++)
                    {
                        if (hell[j] == '}')
                        {
                            paperDataFinal.Add(hell.Substring(k, j - k + 1));
                            k = j + 2;
                        }
                    }
                    List<S0> fine = new List<S0>();
                    foreach (string temp2 in paperDataFinal)
                    {
                        S0 appy = new S0();
                        appy = JsonConvert.DeserializeObject<S0>(temp2);
                        fine.Add(appy);
                    }
                    paperDataFinal.Clear();
                    data.s0.Add(fine);
                }
                secondList.DataContext = data.s0[data.s0.Count - 1];
                string lol123 = JsonConvert.SerializeObject(data);
                StorageFolder folder2 = Windows.Storage.ApplicationData.Current.LocalFolder;
                StorageFile sampleFile2 =
                await folder.CreateFileAsync("data.txt", CreationCollisionOption.ReplaceExisting);
                await Windows.Storage.FileIO.WriteTextAsync(sampleFile2,lol123);
                
            }

            catch(Exception e) 
            {
                MainFragment.Visibility = Windows.UI.Xaml.Visibility.Collapsed;
                ListFragment.Visibility = Windows.UI.Xaml.Visibility.Collapsed;
                TitleBar.Visibility = Windows.UI.Xaml.Visibility.Collapsed;
                Error.Visibility = Windows.UI.Xaml.Visibility.Visible;
                ErrorBlock.Text="This app is made for Indraprasth University, Delhi, India students only! Either enter a valid roll no as provided by the university or check your internet connection. If problem persists kindly contact the developer";
                exc = e.Message;
            }
             
            //TextBlock total = new TextBlock();
            //total.Text = "Total Marks";
             
        }
Exemplo n.º 3
0
 private async void onLaunch()
 {
     
     StorageFolder folder = Windows.Storage.ApplicationData.Current.LocalFolder;
     StorageFile sampleFile = await folder.GetFileAsync("data.txt");
     string testlol = await Windows.Storage.FileIO.ReadTextAsync(sampleFile);
     Paper data = new Paper();
     data = JsonConvert.DeserializeObject<Paper>(testlol);
     //now we plot some graphs
     //there are by default 8 garphs declared in xaml visibilty of all collapsed
     //as we will we encounter more data they will become visible and get binded with data
     List<forGraph> myList = new List<forGraph>();
     int inter = 0;
     int f = 0;
     foreach (List<S0> bbh in data.s0)
     {
         f = 0;
         myList = new List<forGraph>();//so that a nw list is made everytime
         foreach (S0 bh in bbh)
         {
             f++;
             forGraph temp23 = new forGraph();
             temp23.Subject = f.ToString();
             temp23.Marks = bh.total;
             myList.Add(temp23);
         }
         if (inter == 0)
         {
             LineChart.Visibility = Windows.UI.Xaml.Visibility.Visible;
             (LineChart.Series[0] as LineSeries).ItemsSource = myList;
         }
         else if (inter == 1)
         {
             LineChart2.Visibility = Windows.UI.Xaml.Visibility.Visible;
             (LineChart2.Series[0] as LineSeries).ItemsSource = myList;
         }
         else if (inter == 2)
         {
             LineChart3.Visibility = Windows.UI.Xaml.Visibility.Visible;
             (LineChart3.Series[0] as LineSeries).ItemsSource = myList;
         }
         else if (inter == 3)
         {
             LineChart4.Visibility = Windows.UI.Xaml.Visibility.Visible;
             (LineChart4.Series[0] as LineSeries).ItemsSource = myList;
         }
         else if (inter == 4)
         {
             LineChart5.Visibility = Windows.UI.Xaml.Visibility.Visible;
             (LineChart5.Series[0] as LineSeries).ItemsSource = myList;
         }
         else if (inter == 5)
         {
             LineChart6.Visibility = Windows.UI.Xaml.Visibility.Visible;
             (LineChart6.Series[0] as LineSeries).ItemsSource = myList;
         }
         else if (inter == 6)
         {
             LineChart7.Visibility = Windows.UI.Xaml.Visibility.Visible;
             (LineChart7.Series[0] as LineSeries).ItemsSource = myList;
         }
         else if (inter == 7)
         {
             LineChart8.Visibility = Windows.UI.Xaml.Visibility.Visible;
             (LineChart8.Series[0] as LineSeries).ItemsSource = myList;
         }          
         inter++;    
     }
     
 }
        private async void box_LostFocus(object sender, RoutedEventArgs e)
        {
            string he = box.Text;
            List<int> index = new List<int>();
            List<string> paperData = new List<string>();
            List<string> paperDataFinal = new List<string>();
            //lol.Source = new Uri("http://akshit.xyz/resultsggsipu");
            HttpClient client = new HttpClient();
            string a = await client.GetStringAsync("http://akshit.xyz/resultsggsipu/dbinteraction/dbConnection.php?" + he);
            for (int i = 0; i < a.Length; i++)
            {
                if (a[i] == 's')
                {
                    if (a[i + 1] == '0')
                    {
                        index.Add(i);
                    }
                    if (a[i + 1] == '1')
                    {
                        index.Add(i);
                    }
                    if (a[i + 1] == '2')
                    {
                        index.Add(i);
                    }
                    if (a[i + 1] == '3')
                    {
                        index.Add(i);
                    }
                    if (a[i + 1] == '4')
                    {
                        index.Add(i);
                    }
                    if (a[i + 1] == '5')
                    {
                        index.Add(i);
                    }
                    if (a[i + 1] == '6')
                    {
                        index.Add(i);
                    }
                    if (a[i + 1] == '7')
                    {
                        index.Add(i);
                    }

                }

            }
            int j = 9, k;
            for (j = 0; j < index.Count - 1; j++)
            {
                paperData.Add(a.Substring(index[j] + 5, ((index[j + 1] - 8) - index[j])));
            }
            string test = a.Substring(index[j] + 5);
            paperData.Add(test.Substring(0, test.Length - 3));
            string mainData = a.Substring(0, index[0] - 11) + "}";
            Result hi = JsonConvert.DeserializeObject<Result>(mainData);
            data2 = new Paper();

            data2.s0 = new List<List<S0>>();

            foreach (string hell in paperData)
            {
                k = 0;

                for (j = 0; j < hell.Length; j++)
                {
                    if (hell[j] == '}')
                    {
                        paperDataFinal.Add(hell.Substring(k, j - k + 1));
                        k = j + 2;
                    }
                }
                List<S0> fine = new List<S0>();
                foreach (string temp2 in paperDataFinal)
                {
                    S0 appy = new S0();
                    appy = JsonConvert.DeserializeObject<S0>(temp2);
                    fine.Add(appy);
                }
                paperDataFinal.Clear();
                data2.s0.Add(fine);
            }
            lol();
            lol2();
            //List<List<forGraph>> mySuperList = new List<List<forGraph>>();

            //foreach (S0 bh in bbh)
            //{

            //    forGraph temp23 = new forGraph();
            //    temp23.Subject = f.ToString();
            //    temp23.Marks = bh.total;
            //    myList.Add(temp23);
            //}


            //if (inter == 0)
            //{
            //    LineChart.Visibility = Windows.UI.Xaml.Visibility.Visible;
            //    (LineChart.Series[0] as LineSeries).ItemsSource = myList;
            //}
            //else if (inter == 1)
            //{
            //    LineChart2.Visibility = Windows.UI.Xaml.Visibility.Visible;
            //    (LineChart2.Series[0] as LineSeries).ItemsSource = myList;
            //}
            //else if (inter == 2)
            //{
            //    LineChart3.Visibility = Windows.UI.Xaml.Visibility.Visible;
            //    (LineChart3.Series[0] as LineSeries).ItemsSource = myList;
            //}
            //else if (inter == 3)
            //{
            //    LineChart4.Visibility = Windows.UI.Xaml.Visibility.Visible;
            //    (LineChart4.Series[0] as LineSeries).ItemsSource = myList;
            //}
            //else if (inter == 4)
            //{
            //    LineChart5.Visibility = Windows.UI.Xaml.Visibility.Visible;
            //    (LineChart5.Series[0] as LineSeries).ItemsSource = myList;
            //}
            //else if (inter == 5)
            //{
            //    LineChart6.Visibility = Windows.UI.Xaml.Visibility.Visible;
            //    (LineChart6.Series[0] as LineSeries).ItemsSource = myList;
            //}
            //else if (inter == 6)
            //{
            //    LineChart7.Visibility = Windows.UI.Xaml.Visibility.Visible;
            //    (LineChart7.Series[0] as LineSeries).ItemsSource = myList;
            //}
            //else if (inter == 7)
            //{
            //    LineChart8.Visibility = Windows.UI.Xaml.Visibility.Visible;
            //    (LineChart8.Series[0] as LineSeries).ItemsSource = myList;
            //}

        }