Example #1
0
        public LocateBuddyViewModel()
        {
            _dataContext = new SOSDataContext(SOSDataContext.DBConnectionString);

            //if (_dataContext.LocateBuddiesTable.Count() <= 0)
            //    this.LocateBuddies = new ObservableCollection<LocateBuddyTableEntity>();
        }
Example #2
0
        private async void GetLocationAddressAsync(ObservableCollection <GeoTag> locationTag, string profileId)
        {
            try
            {
                string address = await Utility.GetCombOfBingAndGMapsAddress(locationTag[0].Lat, locationTag[0].Long);

                if (this.LocateBuddies.Any(b => b.BuddyProfileId == profileId))
                {
                    this.LocateBuddies.First(b => b.BuddyProfileId == profileId).LastLocation = "@ " + address + " - " + new DateTime(locationTag[0].TimeStamp).ToString("dd/MM/yyyy HH:mm:ss");

                    using (var dataContext = new SOSDataContext(SOSDataContext.DBConnectionString))
                    {
                        if (dataContext.LocateBuddiesTable.Count() > 0)
                        {
                            //TODO: Bug - if uses Single, then it is throwing error. This means there are multiple entries in LocateBuddies with Same buddyId
                            dataContext.LocateBuddiesTable.First(b => b.BuddyProfileId == profileId).LastLocation = "( was at " + address + " - " + new DateTime(locationTag[0].TimeStamp).ToString("dd/MM/yyyy HH:mm:ss") + ")";
                            dataContext.SubmitChanges();
                        }
                    }
                }
            }
            catch
            {
                //absorb exception occurred while getting address
            }
        }
Example #3
0
        /// <summary>
        /// Constructor for the Application object.
        /// </summary>
        public App()
        {
            // Global handler for uncaught exceptions.
            UnhandledException += Application_UnhandledException;

            // Standard XAML initialization
            InitializeComponent();
            this.MergeCustomColors();
            // Phone-specific initialization
            InitializePhoneApplication();

            // Language display initialization
            InitializeLanguage();

            // Show graphics profiling information while debugging.
            if (Debugger.IsAttached)
            {
                // Display the current frame rate counters.
                Application.Current.Host.Settings.EnableFrameRateCounter = true;

                // Show the areas of the app that are being redrawn in each frame.
                //Application.Current.Host.Settings.EnableRedrawRegions = true;

                // Enable non-production analysis visualization mode,
                // which shows areas of a page that are handed off to GPU with a colored overlay.
                //Application.Current.Host.Settings.EnableCacheVisualization = true;

                // Prevent the screen from turning off while under the debugger by disabling
                // the application's idle detection.
                // Caution:- Use this under debug mode only. Application that disables user idle detection will continue to run
                // and consume battery power when the user is not using the phone.
                //PhoneApplicationService.Current.UserIdleDetectionMode = IdleDetectionMode.Disabled;
            }

            using (SOSDataContext db = new SOSDataContext(SOSDataContext.DBConnectionString))
            {
                int     APP_VERSION    = 1; //sometimes Constants.APP_VERSION was not initiating to default value and thus was causing problems. Vijay will look for that. For now, have declared it here.
                var     nameHelper     = new AssemblyName(Assembly.GetExecutingAssembly().FullName);
                Version currentVersion = nameHelper.Version;
                APP_VERSION = int.Parse(currentVersion.Major.ToString("00") + currentVersion.Minor.ToString("00") + currentVersion.Build.ToString("00") + currentVersion.Revision.ToString("00"));
                if (db.DatabaseExists() == false)
                {
                    db.CreateDatabase();
                    DatabaseSchemaUpdater dbUpdater = db.CreateDatabaseSchemaUpdater();
                    dbUpdater.DatabaseSchemaVersion = APP_VERSION;
                    dbUpdater.Execute();
                }
                else
                {
                    DatabaseSchemaUpdater dbUpdater = db.CreateDatabaseSchemaUpdater();

                    if (dbUpdater.DatabaseSchemaVersion < APP_VERSION)
                    {
                        if (dbUpdater.DatabaseSchemaVersion == 1)
                        {
                            dbUpdater.AddColumn <GroupTableEntity>("LastLocation");
                            dbUpdater.AddColumn <ProfileTableEntity>("PoliceContact");
                            dbUpdater.AddColumn <ProfileTableEntity>("AmbulanceContact");
                            dbUpdater.AddColumn <ProfileTableEntity>("FireContact");
                            dbUpdater.AddColumn <ProfileTableEntity>("MaxPhonedigits");
                            dbUpdater.AddColumn <ProfileTableEntity>("CountryName");

                            dbUpdater.AddColumn <ProfileTableEntity>("NotificationUri");
                        }
                        else if (dbUpdater.DatabaseSchemaVersion == 1000003)
                        //update columns for next DatabaseSchemaVersion
                        {
                            dbUpdater.AddColumn <ProfileTableEntity>("NotificationUri");
                        }
                        else if (dbUpdater.DatabaseSchemaVersion == 2000000) //update columns for next DatabaseSchemaVersion
                        {
                            dbUpdater.AddColumn <ProfileTableEntity>("NotificationUri");
                        }
                        // Add the new database version.
                        dbUpdater.DatabaseSchemaVersion = APP_VERSION;

                        // Perform the database update in a single transaction.
                        dbUpdater.Execute();
                    }
                }
            }
        }
Example #4
0
 public UserViewModel()
 {
     _dataContext = new SOSDataContext(SOSDataContext.DBConnectionString);
 }