// Token: 0x06001076 RID: 4214 RVA: 0x00014F70 File Offset: 0x00013170
        public static PublicProfileView Deserialize(Stream bytes)
        {
            int num = Int32Proxy.Deserialize(bytes);
            PublicProfileView publicProfileView = new PublicProfileView();

            publicProfileView.AccessLevel = EnumProxy <MemberAccessLevel> .Deserialize(bytes);

            publicProfileView.Cmid = Int32Proxy.Deserialize(bytes);
            publicProfileView.EmailAddressStatus = EnumProxy <EmailAddressStatus> .Deserialize(bytes);

            if ((num & 1) != 0)
            {
                publicProfileView.FacebookId = StringProxy.Deserialize(bytes);
            }
            if ((num & 2) != 0)
            {
                publicProfileView.GroupTag = StringProxy.Deserialize(bytes);
            }
            publicProfileView.IsChatDisabled = BooleanProxy.Deserialize(bytes);
            publicProfileView.LastLoginDate  = DateTimeProxy.Deserialize(bytes);
            if ((num & 4) != 0)
            {
                publicProfileView.Name = StringProxy.Deserialize(bytes);
            }
            return(publicProfileView);
        }
Пример #2
0
        public MemberView NewMember()
        {
            var cmid          = Interlocked.Increment(ref _nextCmid);
            var publicProfile = new PublicProfileView(
                cmid,
                "Player",
                MemberAccessLevel.Default,
                false,
                DateTime.UtcNow,
                EmailAddressStatus.Unverified,
                "-1"
                );

            var memberWallet = new MemberWalletView(
                cmid,
                _ctx.Configuration.Wallet.StartingCredits,
                _ctx.Configuration.Wallet.StartingPoints,
                DateTime.MaxValue,
                DateTime.MaxValue
                );

            var memberInventories = new List <ItemInventoryView>
            {
                new ItemInventoryView(1, null, -1, cmid),
                new ItemInventoryView(12, null, -1, cmid)
            };

            //TODO: Create helper function for conversion of this stuff.
            var memberItems = new List <int>();

            for (int i = 0; i < memberInventories.Count; i++)
            {
                memberItems.Add(memberInventories[i].ItemId);
            }

            var memberLoadout = new LoadoutView
            {
                Cmid        = cmid,
                MeleeWeapon = 1,
                Weapon1     = 12
            };

            var member = new MemberView(
                publicProfile,
                memberWallet,
                memberItems
                );

            // Save the member.
            Db.Profiles.Save(publicProfile);
            Db.Wallets.Save(memberWallet);
            Db.Inventories.Save(cmid, memberInventories);
            Db.Loadouts.Save(memberLoadout);

            Db.SetNextCmid(_nextCmid);

            return(member);
        }
Пример #3
0
 // Token: 0x06000A77 RID: 2679 RVA: 0x00043748 File Offset: 0x00041948
 public CommUser(PublicProfileView profile)
 {
     if (profile != null)
     {
         this.IsFriend         = PlayerDataManager.IsFriend(profile.Cmid);
         this.IsFacebookFriend = PlayerDataManager.IsFacebookFriend(profile.Cmid);
         this.Cmid             = profile.Cmid;
         this.AccessLevel      = profile.AccessLevel;
         this.Name             = ((!string.IsNullOrEmpty(profile.GroupTag)) ? ("[" + profile.GroupTag + "] " + profile.Name) : profile.Name);
     }
 }
Пример #4
0
        public void Save(PublicProfileView view)
        {
            if (view == null)
            {
                throw new ArgumentNullException(nameof(view));
            }
            var cmid = view.Cmid;

            if (cmid <= 0)
            {
                throw new ArgumentException("CMID of PublicProfileView must be greater than 0.");
            }

            var path = Path.Combine(ROOT_DIR, cmid + ".json");
            var json = JsonConvert.SerializeObject(view);

            File.WriteAllText(path, json);
        }
Пример #5
0
        public static void Serialize(Stream stream, PublicProfileView instance)
        {
            int mask = 0;

            using (var bytes = new MemoryStream())
            {
                EnumProxy <MemberAccessLevel> .Serialize(bytes, instance.AccessLevel);

                Int32Proxy.Serialize(bytes, instance.Cmid);
                EnumProxy <EmailAddressStatus> .Serialize(bytes, instance.EmailAddressStatus);

                if (instance.FacebookId != null)
                {
                    StringProxy.Serialize(bytes, instance.FacebookId);
                }
                else
                {
                    mask |= 1;
                }
                if (instance.GroupTag != null)
                {
                    StringProxy.Serialize(bytes, instance.GroupTag);
                }
                else
                {
                    mask |= 2;
                }

                BooleanProxy.Serialize(bytes, instance.IsChatDisabled);
                DateTimeProxy.Serialize(bytes, instance.LastLoginDate);

                if (instance.Name != null)
                {
                    StringProxy.Serialize(bytes, instance.Name);
                }
                else
                {
                    mask |= 4;
                }

                Int32Proxy.Serialize(stream, ~mask);
                bytes.WriteTo(stream);
            }
        }
Пример #6
0
 public static bool TryGetFriend(int cmid, out PublicProfileView view)
 {
     return(Instance._friends.TryGetValue(cmid, out view) && view != null);
 }
Пример #7
0
 public void AddFriend(PublicProfileView view)
 {
     _friends[view.Cmid] = view;
 }
        public async Task <RecommendProfileView> GetViewMatchProfile(int recommendId)
        {
            try
            {
                logger.Info($"{ GetType().Name}  {  ExtensionUtility.GetCurrentMethod() }  input: {recommendId} UserIPAddress: { _userIPAddress.GetUserIP().Result }");

                var profileUrl = "";

                var profileRecommended = await _appDbContext.RecommandLeaders.Where(x => x.RecommendedProfileID == 0 || x.RecommendedProfileID == null).ToListAsync();

                foreach (var item in profileRecommended)
                {
                    var linkedinUrl = new Profile();
                    var TwitterUrl  = new Profile();
                    var email       = new UserInfo();
                    var mobile      = new UserInfo();
                    if (item.LinkedinURL != null)
                    {
                        linkedinUrl = await _appDbContext.Profiles.Where(x => x.LinkedInUrl == item.LinkedinURL).FirstOrDefaultAsync();
                    }
                    if (item.TwitterURL != null)
                    {
                        TwitterUrl = await _appDbContext.Profiles.Where(x => x.TwitterUrl == item.TwitterURL).FirstOrDefaultAsync();
                    }

                    if (item.Email != null)
                    {
                        email = await _appDbContext.UserInfos.Where(x => x.Email == item.Email).FirstOrDefaultAsync();
                    }

                    if (item.TwitterURL != null)
                    {
                        mobile = await _appDbContext.UserInfos.Where(x => x.Mobile == item.ContactNumber).FirstOrDefaultAsync();
                    }

                    if ((item.LinkedinURL != null && linkedinUrl?.LinkedInUrl != null) || (item.TwitterURL != null && TwitterUrl?.TwitterUrl != null) || (item.Email != null && email?.Email != null) || (item.ContactNumber != null && mobile?.Mobile != null))
                    {
                        item.RecommendedProfileID = email.Email != null ? email.Id
                                                    : mobile.Mobile != null ? mobile.Id
                                                    : linkedinUrl.LinkedInUrl != null ? linkedinUrl.Id
                                                    : TwitterUrl.TwitterUrl != null ? TwitterUrl.Id : 0;

                        await _appDbContext.SaveChangesAsync();
                    }
                }

                var data = new RecommendProfileView();

                var recommendUser = await _appDbContext.RecommandLeaders.Where(x => x.ID == recommendId).FirstOrDefaultAsync();

                var linkedinUrlVal = new Profile();
                var TwitterUrlVal  = new Profile();
                var emailVal       = new UserInfo();
                var mobileVal      = new UserInfo();

                if (recommendUser.LinkedinURL != null)
                {
                    linkedinUrlVal = await _appDbContext.Profiles.Where(x => x.LinkedInUrl == recommendUser.LinkedinURL).FirstOrDefaultAsync();
                }
                if (recommendUser.TwitterURL != null)
                {
                    TwitterUrlVal = await _appDbContext.Profiles.Where(x => x.TwitterUrl == recommendUser.TwitterURL).FirstOrDefaultAsync();
                }

                if (recommendUser.Email != null)
                {
                    emailVal = await _appDbContext.UserInfos.Where(x => x.Email == recommendUser.Email).FirstOrDefaultAsync();
                }

                if (recommendUser.ContactNumber != null)
                {
                    mobileVal = await _appDbContext.UserInfos.Where(x => x.Mobile == recommendUser.ContactNumber).FirstOrDefaultAsync();
                }

                if (linkedinUrlVal?.LinkedInUrl != null || TwitterUrlVal?.TwitterUrl != null || emailVal?.Email != null || mobileVal?.Mobile != null)
                {
                    profileUrl = "https://stagingplatform.uaeglp.gov.ae/";
                }

                var fullname = recommendUser.FullName != null?recommendUser.FullName.Trim().Split(new char[0]) : null;

                List <Profile> matchProfiles = new List <Profile>();
                if (fullname != null)
                {
                    if (fullname.Length == 1)
                    {
                        matchProfiles = await _appDbContext.Profiles.Where(x => x.FirstNameEn.StartsWith(fullname[0]) || x.LastNameEn.StartsWith(fullname[0])).ToListAsync();
                    }
                    else if (fullname.Length == 2)
                    {
                        matchProfiles = await _appDbContext.Profiles.Where(x => x.FirstNameEn.StartsWith(fullname[0]) || x.FirstNameEn.StartsWith(fullname[1]) ||
                                                                           x.LastNameEn.StartsWith(fullname[0]) || x.LastNameEn.StartsWith(fullname[1])).ToListAsync();
                    }
                    else if (fullname.Length == 3)
                    {
                        matchProfiles = await _appDbContext.Profiles.Where(x => x.FirstNameEn.StartsWith(fullname[0]) || x.FirstNameEn.StartsWith(fullname[1]) || x.FirstNameEn.StartsWith(fullname[2]) ||
                                                                           x.LastNameEn.StartsWith(fullname[0]) || x.LastNameEn.StartsWith(fullname[1]) || x.LastNameEn.StartsWith(fullname[2])).ToListAsync();
                    }
                    else if (fullname.Length == 4)
                    {
                        matchProfiles = await _appDbContext.Profiles.Where(x => x.FirstNameEn.StartsWith(fullname[0]) || x.FirstNameEn.StartsWith(fullname[1]) || x.FirstNameEn.StartsWith(fullname[2]) || x.FirstNameEn.StartsWith(fullname[3]) ||
                                                                           x.LastNameEn.StartsWith(fullname[0]) || x.LastNameEn.StartsWith(fullname[1]) || x.LastNameEn.StartsWith(fullname[2]) || x.LastNameEn.StartsWith(fullname[3])).ToListAsync();
                    }
                }
                //var matchProfile = await _appDbContext.Profiles.Where(x => recommendUser.FullName.Contains(x.FirstNameEn) ||
                //recommendUser.FullName.Contains(x.LastNameEn)).ToListAsync();
                //var matchProfile = await _appDbContext.Profiles.FromSqlRaw($"SELECT * FROM dbo.Profile where soundex(firstNameEn) = soundex('{recommendUser.FullName}')").ToListAsync();
                //var matchProfile = await _appDbContext.Profiles.FromSqlRaw($"select  * from dbo.Profile where difference(soundex(FirstNameEN + ' ' + LastNameEN),soundex('{recommendUser.FullName}')) = 4").ToListAsync();

                List <PublicProfileView> matchProfileDetails = new List <PublicProfileView>();
                foreach (var item in matchProfiles)
                {
                    var profile = await _appDbContext.Profiles.FirstOrDefaultAsync(k => k.Id == item.Id);

                    var workExperience = await _appDbContext.ProfileWorkExperiences.Include(k => k.Title)
                                         .Where(k => k.ProfileId == item.Id).OrderByDescending(y => y.DateFrom).FirstOrDefaultAsync();

                    var userDetails = await _appDbContext.Users.FirstOrDefaultAsync(k => k.Id == item.Id);

                    PublicProfileView user = new PublicProfileView()
                    {
                        Id              = profile.Id,
                        FirstNameAr     = profile.FirstNameAr,
                        FirstNameEn     = profile.FirstNameEn,
                        LastNameAr      = profile.LastNameAr,
                        LastNameEn      = profile.LastNameEn,
                        SecondNameAr    = profile.SecondNameAr,
                        SecondNameEn    = profile.SecondNameEn,
                        ThirdNameAr     = profile.ThirdNameAr,
                        ThirdNameEn     = profile.ThirdNameEn,
                        Designation     = workExperience?.Title?.TitleEn,
                        DesignationAr   = workExperience?.Title?.TitleAr,
                        UserImageFileId = userDetails.OriginalImageFileId ?? 0
                    };

                    matchProfileDetails.Add(user);
                }

                if (matchProfiles != null)
                {
                    data = new RecommendProfileView()
                    {
                        RecommendMatchProfileList = matchProfileDetails,
                        RecommendViewProfileURL   = profileUrl
                    };
                }

                return(data);
            }
            catch (Exception ex)
            {
                logger.Error(ex);
                throw ex;
            }
        }