Exemplo n.º 1
0
        public void DeleteProfile(ProfileTableEntity profile)
        {
            _dataContext.MyProfilesTable.DeleteOnSubmit(profile);
            _dataContext.SubmitChanges();

            AssignCurrentProfile();
        }
Exemplo n.º 2
0
        public ProfileTableEntity ConvertProfile(MembershipServiceRef.Profile profile)
        {
            var outProfile = new ProfileTableEntity();

            outProfile.ProfileId    = profile.ProfileID.ToString();
            outProfile.CountryCode  = profile.RegionCode;
            outProfile.MobileNumber = profile.MobileNumber;

            outProfile.FBGroupName = profile.FBGroupName;
            outProfile.FBGroupId   = profile.FBGroupID;

            outProfile.CanEmail  = profile.CanMail;
            outProfile.CanSMS    = profile.CanSMS;
            outProfile.CanFBPost = profile.CanPost;
            //newProfile.CanArchiveEvidence = profile.CanArchive; //TODO
            //outProfile.ArchiveFolder = profile.LiveDetails != null ? profile.LiveDetails.ArchivalFolder : string.Empty;

            outProfile.CountryCode = profile.RegionCode;

            outProfile.LocationConsent        = profile.LocationConsent;
            outProfile.PostLocationConsent    = Globals.CurrentProfile.PostLocationConsent;
            outProfile.IsTrackingStatusSynced = Globals.CurrentProfile.IsTrackingStatusSynced;
            outProfile.IsSOSStatusSynced      = Globals.CurrentProfile.IsSOSStatusSynced;
            outProfile.MapView      = Globals.CurrentProfile.MapView;
            outProfile.LastSynced   = DateTime.Now;
            outProfile.IsDataSynced = true;//TODO - Check

            return(outProfile);
        }
Exemplo n.º 3
0
        public MembershipServiceRef.Profile ConvertProfile(ProfileTableEntity profile)
        {
            var outProfile = new MembershipServiceRef.Profile();

            outProfile.ProfileID = Convert.ToInt64(profile.ProfileId);

            outProfile.FBGroupName  = profile.FBGroupName;
            outProfile.FBGroupID    = profile.FBGroupId;
            outProfile.RegionCode   = profile.CountryCode;
            outProfile.MobileNumber = profile.MobileNumber;

            outProfile.CanMail = profile.CanEmail;
            outProfile.CanSMS  = profile.CanSMS;
            outProfile.CanPost = profile.CanFBPost;

            outProfile.NotificationUri = profile.NotificationUri;

            //outProfile.CanArchive = profile.CanArchiveEvidence; //TODO String -> bool
            //outProfile.ArchiveFolder = profile.ArchivalFolder;

            outProfile.LocationConsent = profile.LocationConsent;


            return(outProfile);
        }
Exemplo n.º 4
0
        public void AddProfile(ProfileTableEntity newProfile)
        {
            _dataContext.MyProfilesTable.InsertOnSubmit(newProfile);
            _dataContext.SubmitChanges();

            this.CurrentProfile = newProfile;
        }
Exemplo n.º 5
0
        public void UpdateProfile(string profileId, ProfileTableEntity profile)
        {
            var localProfile = (from ProfileTableEntity p in _dataContext.MyProfilesTable
                                where p.ProfileId == profileId
                                select p).FirstOrDefault <ProfileTableEntity>();

            if (localProfile != null)
            {
                localProfile.ProfileId    = profile.ProfileId;
                localProfile.CountryCode  = profile.CountryCode;
                localProfile.MobileNumber = profile.MobileNumber;
                //localProfile.TinyUri = profile.TinyUri;

                localProfile.FBGroupName = profile.FBGroupName;
                localProfile.FBGroupId   = profile.FBGroupId;

                localProfile.CanEmail           = profile.CanEmail;
                localProfile.CanSMS             = profile.CanSMS;
                localProfile.CanFBPost          = profile.CanFBPost;
                localProfile.CanArchiveEvidence = profile.CanArchiveEvidence;
                localProfile.ArchiveFolder      = profile.ArchiveFolder;

                localProfile.MessageTemplate = profile.MessageTemplate;

                localProfile.LocationConsent = profile.LocationConsent;
                if (!Globals.IsRegisteredUser)
                {
                    localProfile.IsDataSynced = true;
                }
                else
                {
                    localProfile.IsDataSynced = profile.IsDataSynced;
                }
                localProfile.PostLocationConsent    = profile.PostLocationConsent;
                localProfile.IsSOSStatusSynced      = profile.IsSOSStatusSynced;
                localProfile.IsTrackingStatusSynced = profile.IsTrackingStatusSynced;
                localProfile.MapView          = profile.MapView;
                localProfile.CountryCode      = profile.CountryCode;
                localProfile.CountryName      = profile.CountryName;
                localProfile.AmbulanceContact = profile.AmbulanceContact;
                localProfile.PoliceContact    = profile.PoliceContact;
                localProfile.FireContact      = profile.FireContact;
                localProfile.MaxPhonedigits   = profile.MaxPhonedigits;
                //localProfile.NotificationUri = profile.NotificationUri;

                _dataContext.SubmitChanges();

                App.MyProfiles.CurrentProfile = localProfile;
            }
        }
Exemplo n.º 6
0
 public void UpdateIsDataSynced(bool value)
 {
     try
     {
         ProfileTableEntity profile = this.CurrentProfile;
         if (profile != null && value != profile.IsDataSynced)
         {
             profile.IsDataSynced = value;
             this.UpdateProfile(CurrentProfile.ProfileId, profile);
         }
     }
     catch (Exception)
     {
         Deployment.Current.Dispatcher.BeginInvoke(() => Globals.DisplayToast(CustomMessage.UnableToSaveSettingText, "basicWrap", "Oops!"));
     }
 }
Exemplo n.º 7
0
        public void SaveEmergencyNumbers(CountryCodes countryDetails)
        {
            try
            {
                ProfileTableEntity profile      = this.CurrentProfile;
                string             oldProfileId = profile.ProfileId;
                profile.CountryCode      = countryDetails.IsdCode;
                profile.CountryName      = countryDetails.CountryName;
                profile.AmbulanceContact = countryDetails.Ambulance;
                profile.PoliceContact    = countryDetails.Police;
                profile.FireContact      = countryDetails.Fire;
                profile.MaxPhonedigits   = countryDetails.MaxPhoneDigits;

                //Update the local storage with the new setting value
                this.UpdateProfile(oldProfileId, profile);
            }
            catch (Exception)
            {
                Deployment.Current.Dispatcher.BeginInvoke(() => Globals.DisplayToast(CustomMessage.UnableToSaveSettingText, "basicWrap", "Oops!"));
            }
        }
Exemplo n.º 8
0
        public void CreateDefaultProfile()
        {
            ProfileTableEntity profile = new ProfileTableEntity();

            profile.ProfileId              = "0";
            profile.MobileNumber           = "+000000000000";
            profile.CanEmail               = true;
            profile.CanSMS                 = true;
            profile.CanFBPost              = false;
            profile.LocationConsent        = true;
            profile.PostLocationConsent    = true;
            profile.MapView                = MapCartographicMode.Road;
            profile.IsSOSStatusSynced      = true;
            profile.IsTrackingStatusSynced = true;
            profile.MessageTemplate        = Constants.MessageTemplateText;
            profile.IsDataSynced           = true;
            profile.CountryCode            = "+91";
            profile.PoliceContact          = "100";
            profile.AmbulanceContact       = "108";
            profile.FireContact            = "101";
            AddProfile(profile);
        }
Exemplo n.º 9
0
        public void SaveCurrentProfileSetting(ProfileSetting setting, string value, bool skipIsDataSync = false)
        {
            try
            {
                ProfileTableEntity profile      = this.CurrentProfile;
                string             oldProfileId = profile.ProfileId;
                switch (setting)
                {
                case ProfileSetting.ProfileId:
                    profile.ProfileId = value;
                    break;

                case ProfileSetting.MobileNumber:
                    profile.MobileNumber = value;
                    break;

                case ProfileSetting.LocationServicePref:
                    profile.LocationConsent = Convert.ToBoolean(value);
                    break;

                case ProfileSetting.PostLocationServicePref:
                    profile.PostLocationConsent = Convert.ToBoolean(value);
                    break;

                case ProfileSetting.SosStatusSynced:
                    profile.IsSOSStatusSynced = Convert.ToBoolean(value);
                    break;

                case ProfileSetting.TrackingStatusSynced:
                    profile.IsTrackingStatusSynced = Convert.ToBoolean(value);
                    break;

                case ProfileSetting.MapView:
                    profile.MapView = (MapCartographicMode)Enum.Parse(typeof(MapCartographicMode), value, true);
                    break;

                case ProfileSetting.MessageTemplatePref:
                    profile.MessageTemplate = value;
                    break;

                case ProfileSetting.CanSendSMS:
                    profile.CanSMS = Convert.ToBoolean(value);
                    break;

                case ProfileSetting.CanSendEmail:
                    profile.CanEmail = Convert.ToBoolean(value);
                    break;

                case ProfileSetting.CanSendFBPost:
                    profile.CanFBPost = Convert.ToBoolean(value);
                    break;

                case ProfileSetting.FBGroupId:
                    profile.FBGroupId = value;
                    break;

                case ProfileSetting.FBGroupName:
                    profile.FBGroupName = value;
                    break;

                case ProfileSetting.SessionToken:
                    profile.SessionToken = value;
                    break;

                case ProfileSetting.SetPrimeBuddy:
                    App.MyBuddies.SetPrimeBuddy(profile.ProfileId, value);
                    break;

                case ProfileSetting.TrackingStatus:
                    if (!Convert.ToBoolean(value) && !this.CurrentProfile.IsSOSOn)
                    {
                        PhoneApplicationService.Current.UserIdleDetectionMode = IdleDetectionMode.Enabled;
                    }
                    else
                    {
                        PhoneApplicationService.Current.UserIdleDetectionMode = IdleDetectionMode.Disabled;
                    }

                    profile.IsTrackingOn = Convert.ToBoolean(value);
                    break;

                case ProfileSetting.SOSStatus:
                    if (!Convert.ToBoolean(value) && !this.CurrentProfile.IsTrackingOn)
                    {
                        PhoneApplicationService.Current.UserIdleDetectionMode = IdleDetectionMode.Enabled;
                    }
                    else
                    {
                        PhoneApplicationService.Current.UserIdleDetectionMode = IdleDetectionMode.Disabled;
                    }
                    profile.IsSOSOn = Convert.ToBoolean(value);
                    break;

                case ProfileSetting.CountryCode:
                    profile.CountryCode = value;
                    break;

                case ProfileSetting.PoliceContact:
                    profile.PoliceContact = value;
                    break;

                case ProfileSetting.AmbulanceContact:
                    profile.AmbulanceContact = value;
                    break;

                case ProfileSetting.FireContact:
                    profile.FireContact = value;
                    break;

                case ProfileSetting.CountryName:
                    profile.CountryName = value;
                    break;

                case ProfileSetting.MaxPhonedigits:
                    profile.MaxPhonedigits = value;
                    break;

                case ProfileSetting.NotificationUri:
                    profile.NotificationUri = value;
                    break;

                default:
                    break;
                }

                // Update the local storage with the new setting value
                this.UpdateProfile(oldProfileId, profile);

                // Set DataSyncedToServer status to false, if the key is not in the below list
                if (Globals.IsRegisteredUser &&
                    !(setting == ProfileSetting.ProfileId || setting == ProfileSetting.PostLocationServicePref ||
                      setting == ProfileSetting.MapView || setting == ProfileSetting.SessionToken ||
                      setting == ProfileSetting.TrackingStatus || setting == ProfileSetting.SOSStatus ||
                      setting == ProfileSetting.MessageTemplatePref ||   //TODO: Remove, if message is configurable by user.
                      setting == ProfileSetting.TrackingStatusSynced || setting == ProfileSetting.SosStatusSynced ||
                      skipIsDataSync))
                {
                    UpdateIsDataSynced(false);
                }
            }
            catch (Exception)
            {
                Deployment.Current.Dispatcher.BeginInvoke(() => Globals.DisplayToast(CustomMessage.UnableToSaveSettingText, "basicWrap", "Oops!"));
            }
        }