示例#1
0
        private void SendFollowersBirthdaysNotifications(int UserID)
        {
            ProfileFollower followers = new ProfileFollower();
            ComboUser NotifiedUser = new ComboUser();
            NotifiedUser.GetUserByUserId(UserID);
            followers.GetProfileFollowersByUserID(UserID);
            for (int i = 0; i < followers.RowCount; i++)
            {
                ComboUser current = new ComboUser();
                current.GetUserByUserId(followers.ComboFollowerID);

                List<Models.ComboUser> info = current.DefaultView.Table.AsEnumerable().Select(row =>
                {
                    return new Models.ComboUser
                    {
                        ComboUserID = Convert.ToInt32(row["ComboUserID"]),
                        UserName = row["UserName"].ToString(),
                        DisplayName = row["DisplayName"].ToString(),
                        Password = row["Password"].ToString(),
                        Email = row["Email"].ToString(),
                        Bio = row["Bio"].ToString(),
                        ProfileImgID = row.IsNull("ProfileImgID") ? 0 : Convert.ToInt32(row["ProfileImgID"]),
                        CoverImgID = row.IsNull("CoverImgID") ? 0 : Convert.ToInt32(row["CoverImgID"]),
                        GenderID = row.IsNull("GenderID") ? 0 : Convert.ToInt32(row["GenderID"]),
                        IsActivated = row.IsNull("IsActivated") ? false : Convert.ToBoolean(row["IsActivated"]),
                        ExternalIDType = row.IsNull("ExternalIDType") ? 0 : Convert.ToInt32(row["ExternalIDType"]),
                        ExternalID = row["ExternalID"].ToString(),
                        DeviceID = row["DeviceID"].ToString(),
                        ProfilePic = row["ProfilePic"].ToString(),
                        CoverPic = row["CoverPic"].ToString(),
                        UserRankID = Convert.ToInt32(row["UserRankID"]),
                        BirthDate = row.IsNull("BirthDate") ? DateTime.MinValue : Convert.ToDateTime(row["BirthDate"]),
                        Country = row["Country"].ToString(),
                        Phone = row["Phone"].ToString(),
                        Website = row["Website"].ToString(),
                        CountryFlagPath = row["CountryFlagPath"].ToString(),
                        Location = row["Location"].ToString(),
                        IsPrivateAccount = row.IsNull("IsPrivateAccount") ? false : Convert.ToBoolean(row["IsPrivateAccount"]),
                    };
                }).ToList();

                ComboNotification notification = new ComboNotification();
                notification.AddNew();
                notification.ComboUserID = NotifiedUser.ComboUserID;
                notification.NotificationType = (int)Combo.Models.NotificationType.FOLLOWER_BIRTHDAY; // like
                notification.NotificationDate = DateTime.UtcNow;
                notification.NotificationBody = Newtonsoft.Json.JsonConvert.SerializeObject(info);
                notification.IsRead = false;
                notification.Save();

                List<Models.ComboNotification> notificationJson = notification.DefaultView.Table.AsEnumerable().Select(row =>
                {
                    return new Models.ComboNotification
                    {
                        ComboNotificationID = Convert.ToInt32(row["ComboNotificationID"]),
                        ComboUserID = Convert.ToInt32(row["ComboUserID"]),
                        IsRead = Convert.ToBoolean(row["IsRead"]),
                        NotificationBody = row["NotificationBody"].ToString(),
                        NotificationDate = Convert.ToDateTime(row["NotificationDate"].ToString()).Subtract(new DateTime(1970, 1, 1)).TotalSeconds,
                        NotificationType = Convert.ToInt32(row["NotificationType"])
                    };
                }).ToList();

                SendGCMNotification(Newtonsoft.Json.JsonConvert.SerializeObject(notificationJson), NotifiedUser.DeviceID);

                followers.MoveNext();
            }
        }
示例#2
0
        public void GetProfileFollowers(int userID, int pageIndex)
        {
            Models.ComboResponse _response = new Models.ComboResponse();
            _response.bool_result = true;
            _response.ErrorCode = 0;
            _response.ErrorMsg = "";

            ProfileFollower user = new ProfileFollower();
            user.GetProfileFollowersByUserID(userID);
            List<Models.ComboUser> Users = user.DefaultView.Table.AsEnumerable().Select(row =>
            {
                return new Models.ComboUser
                {
                    ComboUserID = Convert.ToInt32(row["ComboUserID"]),
                    UserName = row["UserName"].ToString(),
                    DisplayName = row["DisplayName"].ToString(),
                    Password = row["Password"].ToString(),
                    Email = row["Email"].ToString(),
                    Bio = row["Bio"].ToString(),
                    ProfileImgID = row.IsNull("ProfileImgID") ? 0 : Convert.ToInt32(row["ProfileImgID"]),
                    CoverImgID = row.IsNull("CoverImgID") ? 0 : Convert.ToInt32(row["CoverImgID"]),
                    GenderID = row.IsNull("GenderID") ? 0 : Convert.ToInt32(row["GenderID"]),
                    IsActivated = row.IsNull("IsActivated") ? false : Convert.ToBoolean(row["IsActivated"]),
                    ExternalIDType = row.IsNull("ExternalIDType") ? 0 : Convert.ToInt32(row["ExternalIDType"]),
                    ExternalID = row["ExternalID"].ToString(),
                    DeviceID = row["DeviceID"].ToString(),
                    ActivationCode = row.IsNull("ActivationCode") ? Guid.Empty : new Guid(row["ActivationCode"].ToString()),
                    PassResetCode = row.IsNull("PassResetCode") ? Guid.Empty : new Guid(row["PassResetCode"].ToString()),
                    ProfilePic = row["ProfilePic"].ToString(),
                };
            }).Skip(pageIndex * FollowersPageSize).Take(FollowersPageSize).ToList();

            _response.Entity = Users;
            SetContentResult(_response);
            //return _response;
        }