private void StoreOngoingCalculation(TSPCalculation calculation)
        {
            // File name format: Username-Calc#.txt
            string fileName = calculation.UserID + "-Calc" + calculation.Number + ".txt";

            using (StreamWriter writer = new StreamWriter(new IsolatedStorageFileStream(fileName, FileMode.Create, FileAccess.Write, IsoFile)))
            {
                writer.WriteLine("Calculation " + calculation.Number);
                writer.WriteLine("Parameters:");
                for (int i = 0; i < calculation.CitiesToVisit.Length; i++)
                {
                    writer.WriteLine((i + 1) + " " + calculation.CitiesToVisit[i].Name);
                }
                writer.Close();
            }
            using (StreamReader reader = new StreamReader(new IsolatedStorageFileStream(fileName, FileMode.Open, FileAccess.Read, IsoFile)))
            {
                string line = "";

                while ((line = reader.ReadLine()) != null)
                {
                    Debug.WriteLine(line);
                }
                reader.Close();
            }
        }
        public void AddCalculation(string userID, City[] citiesToVisit)
        {
            UserDB.Instance.GetUser(userID).NumCalculations++;

            TSPCalculation calculation = new TSPCalculation(citiesToVisit, userID, UserDB.Instance.GetUser(userID).NumCalculations);

            UserDB.Instance.GetUser(userID).ActiveCalculations.Add(calculation);

            StoreOngoingCalculation(calculation);

            calculation.Start();

            MoveCalculationToFinished(userID, calculation.Number);
            StoreFinishedCalculation(calculation);
            UserDB.Instance.StoreUser(UserDB.Instance.GetUser(userID));
            NotifyClient(userID, calculation.Number);
            UserDB.Instance.GetUser(userID).FinishedCalculations.Clear();
        }
        private void StoreFinishedCalculation(TSPCalculation calculation)
        {
            // File name format: Username-Calc#.txt
            string fileName = calculation.UserID + "-Calc" + calculation.Number + ".txt";

            using (StreamWriter writer = new StreamWriter(new IsolatedStorageFileStream(fileName, FileMode.Append, FileAccess.Write, IsoFile)))
            {
                writer.WriteLine("Shortest path: " + calculation.Result);
                writer.Close();
            }
            using (StreamReader reader = new StreamReader(new IsolatedStorageFileStream(fileName, FileMode.Open, FileAccess.Read, IsoFile)))
            {
                string line = "";

                while ((line = reader.ReadLine()) != null)
                {
                    Debug.WriteLine(line);
                }
                reader.Close();
            }
        }