/// <summary>
        /// </summary>
        /// <param name="profileID"></param>
        /// <param name="Token"></param>
        /// <param name="lastUpdateTime"></param>
        /// <returns></returns>
        public async Task <BasicProfile> GetUserLocationsByToken(string profileID, string sessionID, string lastUpdateTime)
        {
            long ProfileID      = Convert.ToInt64(profileID);
            long LastUpdateTime = Convert.ToInt64(lastUpdateTime);

            var retprofile = new BasicProfile();

            List <LiveLocation> tokenizedLocationList =
                await _locRepository.GetLocationDataByToken(ProfileID, sessionID, LastUpdateTime);

            if (tokenizedLocationList == null || tokenizedLocationList.Count == 0)
            {
                ResultsManager.AddResultInfo(retprofile, ResultTypeEnum.Error,
                                             "No Loation details for Profile:" + profileID);
                return(retprofile);
            }

            List <BasicGeoTag> sGeo = tokenizedLocationList.ConvertToBasicGeoTagList();

            retprofile.LastLocs = sGeo;

            BasicGeoTag lastGeoLoc = sGeo[sGeo.Count - 1];

            retprofile.IsSOSOn      = lastGeoLoc.IsSOS.HasValue ? lastGeoLoc.IsSOS.Value : false; //1
            retprofile.IsTrackingOn = !(lastGeoLoc.IsSOS.HasValue ? lastGeoLoc.IsSOS.Value : false) ||
                                      !string.IsNullOrEmpty(lastGeoLoc.Lat);                      //0,1

            return(retprofile);
        }
        public void Remove_profile_removes_the_correct_profile()
        {
            var basicProfile       = new BasicProfile();
            var basicProfile2      = new BasicProfile2();
            var spyProfile         = new SpyProfile();
            var defaultNameProfile = new DefaultNameProfile();

            Translator.AddProfile(basicProfile);
            Translator.AddProfile(basicProfile2);
            Translator.AddProfile(spyProfile);
            Translator.AddProfile(defaultNameProfile);

            // by generic
            Translator.RemoveProfile <BasicProfile>();
            Translator.ApplyUpdates();
            var profiles = Translator.GetAllProfiles().ToList();

            CollectionAssert.DoesNotContain(profiles, basicProfile);
            Assert.AreEqual(3, profiles.Count());

            // by instance
            Translator.RemoveProfile(basicProfile2);
            Translator.ApplyUpdates();
            profiles = Translator.GetAllProfiles().ToList();
            CollectionAssert.DoesNotContain(profiles, basicProfile2);
            Assert.AreEqual(2, profiles.Count());

            // by profile name
            Translator.RemoveProfile(spyProfile.ProfileName);
            Translator.ApplyUpdates();
            profiles = Translator.GetAllProfiles().ToList();
            CollectionAssert.DoesNotContain(profiles, spyProfile);
            Assert.AreEqual(1, profiles.Count());
        }
Exemple #3
0
        public static byte[] GetHeaderPictureByBasicProfile(string referenceKey, int accountType)
        {
            byte[] pictureFound = null;

            BasicProfile profile = new BasicProfile() { ReferenceKey = new Guid(referenceKey), ReferenceType = (AccountType)accountType };

            if (profile.ReferenceType == AccountType.OrganizationAccount)
            {

                pictureFound = OrganizationRepository.GetHeaderPictureByOrganizationAccountKey(profile.ReferenceKey);

            }
            if(profile.ReferenceType== AccountType.UserAccount)
            {
                pictureFound = OrganizationRepository.GetHeaderPictureByUserAccountKey(profile.ReferenceKey);
            }
            if (profile.ReferenceType == AccountType.Group)
            {
                pictureFound = GroupRepository.GetHeaderPictureByGroupKey(profile.ReferenceKey);
            }
            if (profile.ReferenceType == AccountType.Alliance)
            {
                pictureFound = AllianceRepository.GetHeaderPictureByAllianceKey(profile.ReferenceKey);
            }
            return pictureFound;
        }
Exemple #4
0
        public static byte[] GetAvatarPictureByBasicProfile(string referenceKey, int accountType)
        {
            byte[] pictureFound = null;
            AccountType  thisType =  (AccountType) accountType;
            BasicProfile profile = new BasicProfile { ReferenceKey=new Guid(referenceKey) ,  ReferenceType=thisType  };

            if (profile.ReferenceType == AccountType.OrganizationAccount)
            {
                pictureFound = OrganizationAccountRepository.GetAvatarPictureByOrganizationKey(profile.ReferenceKey);
            }
            if(profile.ReferenceType== AccountType.UserAccount)
            {
              //  UserAccountRepository userAccountRepository = new UserAccountRepository();
                pictureFound = UserAccountRepository.GetProfilePictureByAccountKey(profile.ReferenceKey);
            }
            if (profile.ReferenceType == AccountType.Group)
            {
                pictureFound = GroupRepository.GetProfilePictureByGroupKey(profile.ReferenceKey);
            }
            if (profile.ReferenceType == AccountType.Alliance)
            {
                pictureFound = AllianceRepository.GetProfilePictureByAllianceKey(profile.ReferenceKey);
            }
            return pictureFound;
        }
Exemple #5
0
 public async Task <ActionResult <byte[]> > BasicProfileController([FromQuery] string avatarUrl,
                                                                   [FromQuery] string username, [FromQuery] string discriminator, [FromQuery] string level,
                                                                   [FromQuery] string reputation, [FromQuery] string credits, [FromQuery] string rank,
                                                                   [FromQuery] string experience, [FromQuery] float percentage, [FromQuery] string themeColor)
 {
     return(new FileContentResult(await BasicProfile.GenerateAsync(avatarUrl, username,
                                                                   discriminator, level, reputation, credits, rank, experience, percentage, themeColor),
                                  "image/png"));
 }
        public static CompleteProfile GetCompleteProfile(BasicProfile profile)
        {
            CompleteProfile  result = new CompleteProfile();
            BasicProfile basicProfile = new BasicProfile();
            result.BasicProfile=basicProfile;
            using (var db = new FHNWPrototypeDB())
            {
                if (profile.ReferenceType == AccountType.UserAccount)
                {
                    var ua = db.UserAccounts
                                            .Include("User")
                                            .Include("OrganizationAccount.Organization")
                                            .FirstOrDefault(x => x.Key == profile.ReferenceKey);
                    result.BasicProfile.ReferenceKey = ua.Key;
                    result.BasicProfile.ReferenceType = AccountType.UserAccount;
                    result.FullName = ua.User.FirstName + " " + ua.User.LastName;
                    result.Description1 = ua.OrganizationAccount.Name;
                    result.Description2 = ua.OrganizationAccount.Organization.Name;
                }
                if (profile.ReferenceType == AccountType.OrganizationAccount)
                {
                    var oa = db.OrganizationAccounts
                                                    .Include("Organization")
                                                    .FirstOrDefault(x => x.Key == profile.ReferenceKey);
                    result.BasicProfile.ReferenceKey = oa.Key;
                    result.BasicProfile.ReferenceType = AccountType.OrganizationAccount;
                    result.FullName = oa.Name;
                    result.Description1 = oa.Description;
                    result.Description2 = oa.Organization.Name;
                }
                if (profile.ReferenceType == AccountType.Group )
                {
                    var g = db.Groups.FirstOrDefault(x => x.Key == profile.ReferenceKey);
                    result.BasicProfile.ReferenceKey = g.Key;
                    result.BasicProfile.ReferenceType = AccountType.Group;
                    result.FullName = g.Name;
                    result.Description1 = g.Description;
                    result.Description2 = g.Description;
                }
                if (profile.ReferenceType == AccountType.Alliance )
                {
                    var al = db.Groups.FirstOrDefault(x => x.Key == profile.ReferenceKey);
                    result.BasicProfile.ReferenceKey = al.Key;
                    result.BasicProfile.ReferenceType = AccountType.Alliance;
                    result.FullName = al.Name;
                    result.Description1 = al.Description;
                    result.Description2 = al.Description;
                }

            }
            return result;
        }
        public void Get_all_profiles_returns_all_profiles()
        {
            var basicProfile  = new BasicProfile();
            var basicProfile2 = new BasicProfile2();
            var spyProfile    = new SpyProfile();

            Translator.AddProfile(basicProfile);
            Translator.AddProfile(basicProfile2);
            Translator.AddProfile(spyProfile);

            var profiles = Translator.GetAllProfiles().ToList();

            CollectionAssert.Contains(profiles, basicProfile);
            CollectionAssert.Contains(profiles, basicProfile2);
            CollectionAssert.Contains(profiles, spyProfile);
        }
Exemple #8
0
        public override NodeResult Run()
        {
            BasicProfile profile = new BasicProfile();

            profile.DiffType = diffType.Value;
            profile.SyncType = syncType.Value;

            profile.Exclusions.AddRange(exclusions.Value);

            profile.Left  = BuildStorage(leftType.Value, "L.");
            profile.Right = BuildStorage(rightType.Value, "R.");

            try
            {
                // Compute differences and actions
                Diff[] differences = profile.GetDifferences().ToArray();
                global::SmartSync.Common.Action[] actions = differences.Select(d => d.GetAction(profile.SyncType)).ToArray();

                if (actions.Length > 0)
                {
                    // Process actions
                    for (int i = 0; i < actions.Length; i++)
                    {
                        Log.Info("{1} % - {0} ...", actions[i], i * 100 / actions.Length);
                        actions[i].Process();
                    }

                    Log.Info("Flushing data to storage...");
                }

                profile.Dispose();

                Log.Info("Everything is in sync. {0} actions processed.", actions.Length);

                return(NodeResult.Success);
            }
            catch (Exception e)
            {
                Log.Error("Error while trying to sync specified profile: " + e.Message);
                return(NodeResult.Fail);
            }
        }
        public static void RegisterNewSystemAccount(string email, string password, bool isCorporateAccount)
        {
            if (!UserAlreadyExists(email))
            {
                SystemAccount newAccount = new SystemAccount();
                newAccount.Email = email;
                newAccount.Password = password;
                //newAccount.Key = Guid.NewGuid();
               // newAccount.IsConfirmed = true;
                Guid newRecordGuid = Guid.NewGuid();
                if (isCorporateAccount)
                {
                    BasicProfile basicProfile = new BasicProfile() { ReferenceKey = newRecordGuid, ReferenceType = AccountType.OrganizationAccount };
                  //  CompleteProfile completeProfile = new CompleteProfile { BasicProfile=basicProfile  };
                    OrganizationAccount newOrganizationAccount = new OrganizationAccount() { Key=newRecordGuid, Name="OrganizationAccount" };
                    newAccount.Holder = basicProfile ;
                    using (var db = new FHNWPrototypeDB())
                    {
                        db.BasicProfiles.Add(basicProfile);
                        db.SystemAccounts.Add(newAccount);
                        db.OrganizationAccounts.Add(newOrganizationAccount);

                        db.SaveChanges();
                    }
                }
                else
                {
                    BasicProfile basicProfile = new BasicProfile() { ReferenceKey = newRecordGuid, ReferenceType = AccountType.UserAccount  };
                   // CompleteProfile completeProfile = new CompleteProfile { BasicProfile=basicProfile  };
                    UserAccount newUserAccount = new UserAccount() { Key=newRecordGuid };
                    newAccount.Holder = basicProfile ;
                    using (var db = new FHNWPrototypeDB())
                    {
                        db.BasicProfiles.Add(basicProfile);
                        db.SystemAccounts.Add(newAccount);
                        db.UserAccounts.Add(newUserAccount);

                        db.SaveChanges();
                    }
                }
               // newAccount.IsCorporateAccount = isCorporateAccount;
               // newAccount.CreationDateTime = DateTime.Now;

            }
        }
 public static void RegisterLastCheck(BasicProfile profile)
 {
     using (var db = new FHNWPrototypeDB())
     {
         var account = db.SystemAccounts.FirstOrDefault(x => x.Holder.ReferenceKey == profile.ReferenceKey);
         account.LastCheck = DateTime.Now;
         db.SaveChanges();
     }
 }
Exemple #11
0
 private ProfilePage UpdateBasicProfile(BasicProfile basicProfile)
 {
     FirstNameTextField.ClearAndSendKeys(basicProfile.FirstName);
     LastNameTextField.ClearAndSendKeys(basicProfile.LastName);
     return(this);
 }