コード例 #1
0
        public Guid?SetGuidFromInt(int?id, object obj)
        {
            ISession session = NHibernateContext.Current().Session;

            Guid?guid = null;

            using (var tx = session.BeginTransaction())
            {
                string type = obj.GetType().Name;
                //var count = session.CreateSQLQuery("SELECT COUNT(*) FROM idconvertion i WHERE i.type = :type").SetString("type", type).UniqueResult();
                //var result = session.CreateQuery("INSERT INTO idconvertion VALUES (:count, :type, :guid)")
                //    .SetInt32("count", (int)count+1).SetGuid("guid", obj.GlobalId).SetString("type", type).UniqueResult();
                //var count = session.QueryOver<IdConvertion>().Where(a => a.Type == obj.GetType().Name).RowCount();
                IdConvertion temp = new IdConvertion();
                temp.GuidId = Guid.NewGuid();
                if (id != null)
                {
                    temp.IntId = (int)id;
                }
                else
                {
                    var count = session.QueryOver <IdConvertion>().Where(a => a.Type == obj.GetType().Name).RowCount();
                    temp.IntId = ++count;
                }
                temp.Type = obj.GetType().Name;
                session.Save(temp);
                tx.Commit();

                guid = temp.GuidId;
            }
            return(guid);
        }
コード例 #2
0
        public int?SetIntFromGuid(BodyArchitect.Service.V2.Model.BAGlobalObject obj)
        {
            ISession session = NHibernateContext.Current().Session;

            int?intId = null;

            using (var tx = session.BeginTransaction())
            {
                string type = obj.GetType().Name;
                //var count = session.CreateSQLQuery("SELECT COUNT(*) FROM idconvertion i WHERE i.type = :type").SetString("type", type).UniqueResult();
                //var result = session.CreateQuery("INSERT INTO idconvertion VALUES (:count, :type, :guid)")
                //    .SetInt32("count", (int)count+1).SetGuid("guid", obj.GlobalId).SetString("type", type).UniqueResult();
                var          count = session.QueryOver <IdConvertion>().Where(a => a.Type == obj.GetType().Name).RowCount();
                IdConvertion temp  = new IdConvertion();
                temp.GuidId = obj.GlobalId;
                temp.IntId  = ++count;
                temp.Type   = obj.GetType().Name;
                session.Save(temp);
                //session.Save(
                tx.Commit();

                intId = temp.IntId;
            }
            return(intId);
        }
コード例 #3
0
        public void DeleteOrphandExerciseRecords(DeleteOldProfilesParam param)
        {
            Serie serie = null;
            ExerciseProfileData profileData = null;
            var unusedProfiles = NHibernateContext.Current().Session.QueryOver <ExerciseProfileData>().JoinAlias(x => x.Serie, () => serie)
                                 .JoinAlias(x => serie.ExerciseProfileData, () => profileData)
                                 .Where(x => profileData.GlobalId != x.GlobalId).List();

            if (!param.OnlyShowUsers)
            {
                using (var trans = NHibernateContext.Current().Session.BeginSaveTransaction())
                {
                    foreach (var unusedProfile in unusedProfiles)
                    {
                        try
                        {
                            if (unusedProfile.GlobalId != unusedProfile.Serie.ExerciseProfileData.GlobalId)
                            {
                                NHibernateContext.Current().Session.Delete(unusedProfile);
                            }
                        }
                        catch (Exception ex)
                        {
                            BodyArchitect.Logger.ExceptionHandler.Default.Process(ex);
                            throw;
                        }
                    }
                    trans.Commit();
                }
            }
        }
コード例 #4
0
        public IList <UserDTO> DeleteOldProfiles(DeleteOldProfilesParam param)
        {
            //ProfileStatistics stat = null;
            //BAPoints point = null;
            //var unusedProfiles =
            //    NHibernateContext.Current().Session.QueryOver<Profile>().JoinAlias(x => x.Statistics, () => stat).JoinAlias(x => x.BAPoints, () => point)
            //        .Where(x => stat.TrainingDaysCount == 0 && stat.WorkoutPlansCount == 0 &&
            //            stat.SupplementsDefinitionsCount == 0 && stat.LastLoginDate < DateTime.Now.AddMonths(-8)
            //            && !x.IsDeleted && x.UserName != "Admin" && x.BAPoints.Count==0).List();
            var unusedProfiles = NHibernateContext.Current()
                                 .Session.Query <Profile>()
                                 .Where(x => x.Statistics.TrainingDaysCount == 0 && x.Statistics.WorkoutPlansCount == 0 &&
                                        x.Statistics.SupplementsDefinitionsCount == 0 &&
                                        x.Statistics.LastLoginDate < DateTime.Now.AddMonths(-8) &&
                                        !x.IsDeleted && x.UserName != "Admin" && !x.BAPoints.Any()).ToList();

            if (!param.OnlyShowUsers)
            {
                ServiceConfiguration configuration = new ServiceConfiguration();
                ProfileService       service       = new ProfileService(NHibernateContext.Current().Session, null, configuration, null, null, null);
                foreach (var unusedProfile in unusedProfiles)
                {
                    try
                    {
                        using (var trans = NHibernateContext.Current().Session.BeginSaveTransaction())
                        {
                            service.deleteProfile(NHibernateContext.Current().Session, unusedProfile);
                            if (unusedProfile.Picture != null)
                            {
                                PictureService pictureService = new PictureService(NHibernateContext.Current().Session, null, configuration);
                                pictureService.DeletePicture(unusedProfile.Picture);
                            }
                            trans.Commit();
                        }
                    }
                    catch (Exception ex)
                    {
                        BodyArchitect.Logger.ExceptionHandler.Default.Process(ex);
                        throw;
                    }
                }
            }
            return(unusedProfiles.Map <IList <UserDTO> >());
        }
コード例 #5
0
 private static object createServices(Type t)
 {
     if (t == typeof(ISession))
     {
         return(NHibernateFactory.OpenSession());
     }
     else if (t == typeof(LoadingGuidEntityResolver <Exercise>))
     {
         return(new LoadingGuidEntityResolver <Exercise>(NHibernateContext.Current().Session));
     }
     else if (t == typeof(LoadingGuidEntityResolver <Suplement>))
     {
         return(new LoadingGuidEntityResolver <Suplement>(NHibernateContext.Current().Session));
     }
     else if (t == typeof(LoadingGuidEntityResolver <Activity>))
     {
         return(new LoadingGuidEntityResolver <Activity>(NHibernateContext.Current().Session));
     }
     else if (t == typeof(LoadingGuidEntityResolver <Customer>))
     {
         return(new LoadingGuidEntityResolver <Customer>(NHibernateContext.Current().Session));
     }
     else if (t == typeof(LoadingGuidEntityResolver <ScheduleEntryReservation>))
     {
         return(new LoadingGuidEntityResolver <ScheduleEntryReservation>(NHibernateContext.Current().Session));
     }
     else if (t == typeof(LoadingGuidEntityResolver <CustomerGroup>))
     {
         return(new LoadingGuidEntityResolver <CustomerGroup>(NHibernateContext.Current().Session));
     }
     else if (t == typeof(LoadingGuidEntityResolver <Profile>))
     {
         return(new LoadingGuidEntityResolver <Profile>(NHibernateContext.Current().Session));
     }
     else if (t == typeof(LoadingGuidEntityResolver <MyTraining>))
     {
         return(new LoadingGuidEntityResolver <MyTraining>(NHibernateContext.Current().Session));
     }
     else if (t == typeof(LoadingGuidEntityResolver <MyPlace>))
     {
         return(new LoadingGuidEntityResolver <MyPlace>(NHibernateContext.Current().Session));
     }
     return(null);
 }
コード例 #6
0
        public Guid?GetGuidFromInt(BodyArchitect.Service.Model.GetProfileInformationCriteria obj)
        {
            ISession session = NHibernateContext.Current().Session;
            Guid?    guid;

            using (var tx = session.BeginTransaction())
            {
                var result = session.QueryOver <IdConvertion>().Where(b => b.IntId == obj.UserId).And(c => c.Type == obj.GetType().Name).SingleOrDefault();
                tx.Commit();
                if (result != null)
                {
                    guid = result.GuidId;
                }
                else
                {
                    guid = null;
                }
            }
            return(guid);
        }
コード例 #7
0
        public Guid?GetGuidFromInt(int?id, object obj)
        {
            ISession session = NHibernateContext.Current().Session;
            Guid?    guid;

            using (var tx = session.BeginTransaction())
            {
                var result = session.QueryOver <IdConvertion>().Where(b => b.IntId == id).And(c => c.Type == obj.GetType().Name).SingleOrDefault();
                tx.Commit();
                if (result != null)
                {
                    guid = result.GuidId;
                }
                else
                {
                    guid = null;
                }
            }
            return(guid);
        }
コード例 #8
0
        public int?GetIntFromGuid(Guid guid)
        {
            ISession session = NHibernateContext.Current().Session;
            int?     intId;

            using (var tx = session.BeginTransaction())
            {
                //intId = (int?)session.CreateSQLQuery("SELECT i.intid FROM idconvertions i WHERE i.guidid = :guid")
                //    .SetString("guid", guid.ToString()).UniqueResult();
                var result = session.QueryOver <IdConvertion>().Where(b => b.GuidId == guid).SingleOrDefault();
                tx.Commit();
                if (result != null)
                {
                    intId = result.IntId;
                }
                else
                {
                    intId = null;
                }
            }
            return(intId);
        }
コード例 #9
0
        public string Register(string deviceid, string uri)
        {
            if (!String.IsNullOrWhiteSpace(deviceid))
            {
                var session = NHibernateContext.Current().Session;
                using (var tx = session.BeginGetTransaction())
                {
                    var res    = session.QueryOver <WP7PushNotification>().Where(x => x.DeviceID == deviceid);
                    var device = res.SingleOrDefault();

                    if (device != null)
                    {
                        // Do we need to update the URI?
                        if (device.URI != uri)
                        {
                            device.URI = uri;
                        }
                    }
                    else
                    {
                        device = new WP7PushNotification()
                        {
                            DeviceID = deviceid,
                            URI      = uri,
                            Added    = DateTime.Now,
                            Modified = DateTime.Now
                        };

                        session.SaveOrUpdate(device);
                    }

                    tx.Commit();
                }
            }
            return(deviceid);
        }
コード例 #10
0
        public IList <PictureInfoDTO> DeleteUnusedImages(DeleteOldProfilesParam param)
        {
            var            profilesWithImages  = NHibernateContext.Current().Session.QueryOver <Profile>().Where(x => x.Picture != null).List();
            var            customersWithImages = NHibernateContext.Current().Session.QueryOver <Customer>().Where(x => x.Picture != null).List();
            List <Picture> pictures            = new List <Picture>();

            pictures.AddRange(profilesWithImages.Select(x => x.Picture));
            pictures.AddRange(customersWithImages.Select(x => x.Picture));

            List <PictureInfoDTO> notUsed      = new List <PictureInfoDTO>();
            var dictionaryImages               = pictures.ToDictionary(x => x.PictureId.ToString());
            ServiceConfiguration configuration = new ServiceConfiguration();
            var files = Directory.GetFiles(configuration.ImagesFolder);

            foreach (var file in files)
            {
                var filename = Path.GetFileName(file);
                if (string.IsNullOrEmpty(Path.GetExtension(filename)))
                {
                    bool isUsed = dictionaryImages.ContainsKey(filename);
                    if (!isUsed)
                    {
                        notUsed.Add(new PictureInfoDTO(new Guid(filename), ""));
                    }
                }
            }
            if (!param.OnlyShowUsers)
            {
                foreach (var pictureInfoDto in notUsed)
                {
                    PictureService pictureService = new PictureService(NHibernateContext.Current().Session, null, configuration);
                    pictureService.DeletePicture(pictureInfoDto.Map <Picture>());
                }
            }
            return(notUsed);
        }
コード例 #11
0
        public void SendMessage(string topic, string message, SendMessageMode mode, List <int> countriesId)
        {
            var session = NHibernateContext.Current().Session;

            using (var trans = session.BeginTransaction())
            {
                //get admin
                var             admin    = session.QueryOver <Profile>().Where(x => x.UserName == "Admin").SingleOrDefault();
                IList <Profile> profiles = null;
                if (mode == SendMessageMode.All)
                {
                    profiles = session.QueryOver <Profile>().Where(x => !x.IsDeleted && x.GlobalId != admin.GlobalId).List();
                }
                else if (mode == SendMessageMode.SelectedCountries)
                {
                    profiles = session.QueryOver <Profile>().Where(x => !x.IsDeleted && x.GlobalId != admin.GlobalId).WhereRestrictionOn(x => x.CountryId).IsIn(countriesId).List();
                }
                else
                {
                    profiles = session.QueryOver <Profile>().Where(x => !x.IsDeleted && x.GlobalId != admin.GlobalId).WhereRestrictionOn(x => x.CountryId).Not.IsIn(countriesId).List();
                }
                foreach (var profile in profiles)
                {
                    var msg = new Message();
                    msg.Content     = message;
                    msg.Topic       = topic;
                    msg.Sender      = admin;
                    msg.Receiver    = profile;
                    msg.CreatedDate = DateTime.UtcNow;
                    msg.Priority    = (Model.MessagePriority)MessagePriority.System;
                    session.Save(msg);
                }

                trans.Commit();
            }
        }
コード例 #12
0
        public ProfileInformationDTO GetProfileInformation(Token token, GetProfileInformationCriteria criteria)
        {
            BodyArchitect.Service.V2.InternalBodyArchitectService service = new V2.InternalBodyArchitectService(NHibernateContext.Current().Session);
            V2.Model.Token v2token = new V2.Model.Token(token.SessionId, token.Language);
            V2.Model.GetProfileInformationCriteria v2Crit = new V2.Model.GetProfileInformationCriteria();
            //v2Crit.UserId
            int? tempId;
            Guid?tempGuid;

            if ((tempGuid = h.GetGuidFromInt(criteria)) == null)
            {
                tempGuid = null;
            }
            v2Crit.UserId = tempGuid;
            var res = service.GetProfileInformation(v2token, v2Crit);

            ProfileInformationDTO profile = new ProfileInformationDTO();

            profile.AboutInformation = res.AboutInformation;
            profile.Birthday         = res.Birthday;

            foreach (V2.Model.UserSearchDTO u in res.FavoriteUsers)
            {
                UserSearchDTO a = new UserSearchDTO();
                a.CountryId = u.CountryId;
                //a.CreationDate = u.CreationDate;
                SetProperty(a, "CreationDate", u.CreationDate);
                a.Gender = (BodyArchitect.Service.Model.Gender)u.Gender;
                //a.Id = u.GlobalId;
                tempId = null;
                if ((tempId = h.GetIntFromGuid(u.GlobalId)) == null)
                {
                    tempId = h.SetIntFromGuid(u);
                }
                if (tempId != null)
                {
                    a.Id = (int)tempId;
                }
                else
                {
                    throw new ArgumentException("Id not assigned to guid", u.GlobalId.ToString());
                }

                //a.IsDeleted = u.IsDeleted;
                SetProperty(a, "IsDeleted", u.IsDeleted);
                //a.Picture = u.Picture;
                a.Picture = new PictureInfoDTO();
                if (u.Picture != null)
                {
                    a.Picture.Hash      = u.Picture.Hash;
                    a.Picture.PictureId = u.Picture.PictureId;
                    a.Picture.SessionId = u.Picture.SessionId;
                }
                else
                {
                    a.Picture = null;
                }
                a.Privacy.BirthdayDate          = (BodyArchitect.Service.Model.Privacy)u.Privacy.BirthdayDate;
                a.Privacy.CalendarView          = (BodyArchitect.Service.Model.Privacy)u.Privacy.CalendarView;
                a.Privacy.Friends               = (BodyArchitect.Service.Model.Privacy)u.Privacy.Friends;
                a.Privacy.Searchable            = u.Privacy.Searchable;
                a.Privacy.Sizes                 = (BodyArchitect.Service.Model.Privacy)u.Privacy.Sizes;
                a.Statistics.A6WEntriesCount    = u.Statistics.A6WEntriesCount;
                a.Statistics.A6WFullCyclesCount = u.Statistics.A6WFullCyclesCount;
                a.Statistics.BlogCommentsCount  = u.Statistics.TrainingDayCommentsCount;
                a.Statistics.BlogEntriesCount   = u.Statistics.BlogEntriesCount;
                a.Statistics.FollowersCount     = u.Statistics.FollowersCount;
                a.Statistics.FriendsCount       = u.Statistics.FriendsCount;
                //a.Statistics.Id
                if ((tempId = h.GetIntFromGuid(u.Statistics.GlobalId)) == null)
                {
                    tempId = h.SetIntFromGuid(u.Statistics);
                }
                if (tempId != null)
                {
                    a.Id = (int)tempId;
                }
                else
                {
                    throw new ArgumentException("Id not assigned to guid", u.Statistics.GlobalId.ToString());
                }
                //a.Statistics.IsNew
                a.Statistics.LastEntryDate                = u.Statistics.LastEntryDate;
                a.Statistics.LastLoginDate                = u.Statistics.LastLoginDate;
                a.Statistics.LoginsCount                  = u.Statistics.LoginsCount;
                a.Statistics.MyBlogCommentsCount          = u.Statistics.MyTrainingDayCommentsCount;
                a.Statistics.SizeEntriesCount             = u.Statistics.SizeEntriesCount;
                a.Statistics.StrengthTrainingEntriesCount = u.Statistics.StrengthTrainingEntriesCount;
                a.Statistics.SupplementEntriesCount       = u.Statistics.SupplementEntriesCount;
                a.Statistics.Tag = u.Statistics.Tag;
                a.Statistics.TrainingDaysCount = u.Statistics.TrainingDaysCount;
                a.Statistics.VotingsCount      = u.Statistics.VotingsCount;
                a.Statistics.WorkoutPlansCount = u.Statistics.WorkoutPlansCount;
                a.UserName = u.UserName;
                profile.FavoriteUsers.Add(a);
            }


            //profile.Friends = res.Friends;
            foreach (V2.Model.UserSearchDTO u in res.Friends)
            {
                UserSearchDTO a = new UserSearchDTO();
                a.CountryId = u.CountryId;
                //a.CreationDate = u.CreationDate;
                SetProperty(a, "CreationDate", u.CreationDate);
                a.Gender = (BodyArchitect.Service.Model.Gender)u.Gender;
                //a.Id = u.GlobalId;
                tempId = null;
                if ((tempId = h.GetIntFromGuid(u.GlobalId)) == null)
                {
                    tempId = h.SetIntFromGuid(u);
                }
                if (tempId != null)
                {
                    a.Id = (int)tempId;
                }
                else
                {
                    throw new ArgumentException("Id not assigned to guid", u.GlobalId.ToString());
                }

                //a.IsDeleted = u.IsDeleted;
                SetProperty(a, "IsDeleted", u.IsDeleted);
                //a.Picture = u.Picture;
                a.Picture = new PictureInfoDTO();
                if (u.Picture != null)
                {
                    a.Picture.Hash      = u.Picture.Hash;
                    a.Picture.PictureId = u.Picture.PictureId;
                    a.Picture.SessionId = u.Picture.SessionId;
                }
                else
                {
                    a.Picture = null;
                }
                a.Privacy.BirthdayDate          = (BodyArchitect.Service.Model.Privacy)u.Privacy.BirthdayDate;
                a.Privacy.CalendarView          = (BodyArchitect.Service.Model.Privacy)u.Privacy.CalendarView;
                a.Privacy.Friends               = (BodyArchitect.Service.Model.Privacy)u.Privacy.Friends;
                a.Privacy.Searchable            = u.Privacy.Searchable;
                a.Privacy.Sizes                 = (BodyArchitect.Service.Model.Privacy)u.Privacy.Sizes;
                a.Statistics.A6WEntriesCount    = u.Statistics.A6WEntriesCount;
                a.Statistics.A6WFullCyclesCount = u.Statistics.A6WFullCyclesCount;
                a.Statistics.BlogCommentsCount  = u.Statistics.TrainingDayCommentsCount;
                a.Statistics.BlogEntriesCount   = u.Statistics.BlogEntriesCount;
                a.Statistics.FollowersCount     = u.Statistics.FollowersCount;
                a.Statistics.FriendsCount       = u.Statistics.FriendsCount;
                //a.Statistics.Id
                if ((tempId = h.GetIntFromGuid(u.Statistics.GlobalId)) == null)
                {
                    tempId = h.SetIntFromGuid(u.Statistics);
                }
                if (tempId != null)
                {
                    a.Id = (int)tempId;
                }
                else
                {
                    throw new ArgumentException("Id not assigned to guid", u.Statistics.GlobalId.ToString());
                }
                //a.Statistics.IsNew
                a.Statistics.LastEntryDate                = u.Statistics.LastEntryDate;
                a.Statistics.LastLoginDate                = u.Statistics.LastLoginDate;
                a.Statistics.LoginsCount                  = u.Statistics.LoginsCount;
                a.Statistics.MyBlogCommentsCount          = u.Statistics.MyTrainingDayCommentsCount;
                a.Statistics.SizeEntriesCount             = u.Statistics.SizeEntriesCount;
                a.Statistics.StrengthTrainingEntriesCount = u.Statistics.StrengthTrainingEntriesCount;
                a.Statistics.SupplementEntriesCount       = u.Statistics.SupplementEntriesCount;
                a.Statistics.Tag = u.Statistics.Tag;
                a.Statistics.TrainingDaysCount = u.Statistics.TrainingDaysCount;
                a.Statistics.VotingsCount      = u.Statistics.VotingsCount;
                a.Statistics.WorkoutPlansCount = u.Statistics.WorkoutPlansCount;
                a.UserName = u.UserName;
                profile.FavoriteUsers.Add(a);
            }

            //profile.Invitations =  res.Invitations;
            foreach (V2.Model.FriendInvitationDTO c in res.Invitations)
            {
                Model.FriendInvitationDTO a = new FriendInvitationDTO();
                a.CreatedDateTime   = c.CreatedDateTime;
                a.InvitationType    = (BodyArchitect.Service.Model.InvitationType)c.InvitationType;
                a.Invited.CountryId = c.Invited.CountryId;
                //a.Invited.Id
                SetProperty(a.Invited, "CreationDate", c.Invited.CreationDate);
                a.Invited.Gender = (BodyArchitect.Service.Model.Gender)c.Invited.Gender;
                //a.Id = c.Invited.GlobalId;
                tempId = null;
                if ((tempId = h.GetIntFromGuid(c.Invited.GlobalId)) == null)
                {
                    tempId = h.SetIntFromGuid(c.Invited);
                }
                if (tempId != null)
                {
                    a.Invited.Id = (int)tempId;
                }
                else
                {
                    throw new ArgumentException("Id not assigned to guid", c.Invited.GlobalId.ToString());
                }

                //a.IsDeleted = c.Invited.IsDeleted;
                SetProperty(a.Invited, "IsDeleted", c.Invited.IsDeleted);
                //a.Picture = c.Invited.Picture;
                a.Invited.Picture = new PictureInfoDTO();
                if (c.Invited.Picture != null)
                {
                    a.Invited.Picture.Hash      = c.Invited.Picture.Hash;
                    a.Invited.Picture.PictureId = c.Invited.Picture.PictureId;
                    a.Invited.Picture.SessionId = c.Invited.Picture.SessionId;
                }
                else
                {
                    a.Invited.Picture = null;
                }
                a.Invited.Privacy.BirthdayDate = (BodyArchitect.Service.Model.Privacy)c.Invited.Privacy.BirthdayDate;
                a.Invited.Privacy.CalendarView = (BodyArchitect.Service.Model.Privacy)c.Invited.Privacy.CalendarView;
                a.Invited.Privacy.Friends      = (BodyArchitect.Service.Model.Privacy)c.Invited.Privacy.Friends;
                a.Invited.Privacy.Searchable   = c.Invited.Privacy.Searchable;
                a.Invited.Privacy.Sizes        = (BodyArchitect.Service.Model.Privacy)c.Invited.Privacy.Sizes;
                a.Invited.UserName             = c.Invited.UserName;



                a.Inviter.CountryId = c.Inviter.CountryId;
                //a.Inviter.Id
                SetProperty(a.Inviter, "CreationDate", c.Inviter.CreationDate);
                a.Inviter.Gender = (BodyArchitect.Service.Model.Gender)c.Inviter.Gender;
                //a.Id = c.Inviter.GlobalId;
                tempId = null;
                if ((tempId = h.GetIntFromGuid(c.Inviter.GlobalId)) == null)
                {
                    tempId = h.SetIntFromGuid(c.Inviter);
                }
                if (tempId != null)
                {
                    a.Inviter.Id = (int)tempId;
                }
                else
                {
                    throw new ArgumentException("Id not assigned to guid", c.Inviter.GlobalId.ToString());
                }

                //a.IsDeleted = c.Inviter.IsDeleted;
                SetProperty(a.Inviter, "IsDeleted", c.Inviter.IsDeleted);
                //a.Picture = c.Inviter.Picture;
                a.Inviter.Picture = new PictureInfoDTO();
                if (c.Inviter.Picture != null)
                {
                    a.Inviter.Picture.Hash      = c.Inviter.Picture.Hash;
                    a.Inviter.Picture.PictureId = c.Inviter.Picture.PictureId;
                    a.Inviter.Picture.SessionId = c.Inviter.Picture.SessionId;
                }
                else
                {
                    a.Inviter.Picture = null;
                }
                a.Inviter.Privacy.BirthdayDate = (BodyArchitect.Service.Model.Privacy)c.Inviter.Privacy.BirthdayDate;
                a.Inviter.Privacy.CalendarView = (BodyArchitect.Service.Model.Privacy)c.Inviter.Privacy.CalendarView;
                a.Inviter.Privacy.Friends      = (BodyArchitect.Service.Model.Privacy)c.Inviter.Privacy.Friends;
                a.Inviter.Privacy.Searchable   = c.Inviter.Privacy.Searchable;
                a.Inviter.Privacy.Sizes        = (BodyArchitect.Service.Model.Privacy)c.Inviter.Privacy.Sizes;
                a.Inviter.UserName             = c.Inviter.UserName;

                a.Message = c.Message;
                profile.Invitations.Add(a);
            }


            profile.IsActivated       = res.IsActivated;
            profile.LastLogin         = res.LastLogin;
            profile.Messages          = null; //?
            profile.RetrievedDateTime = res.RetrievedDateTime;
            //profile.Settings = res.Settings;

            profile.Settings = new ProfileSettingsDTO();
            tempId           = null;
            if ((tempId = h.GetIntFromGuid(res.Settings.GlobalId)) == null)
            {
                tempId = h.SetIntFromGuid(res.Settings);
            }
            if (tempId != null)
            {
                profile.Settings.Id = (int)tempId;
            }
            else
            {
                throw new ArgumentException("Id not assigned to guid", res.Settings.GlobalId.ToString());
            }
            //profile.Role = res.Profile.
            profile.Settings.AutomaticUpdateMeasurements = res.Settings.AutomaticUpdateMeasurements;
            //profile.Settings.Id = res.Profile.Settings.GlobalId;

            //SetProperty(profile.Settings, "IsNew", res.Profile.Settings.IsNew);
            //profile.Settings.IsNew = res.Profile.Settings.IsNew;
            //TODO:check notifications
            profile.Settings.NotificationBlogCommentAdded      = res.Settings.NotificationBlogCommentAdded != BodyArchitect.Service.V2.Model.ProfileNotification.None;
            profile.Settings.NotificationExerciseVoted         = res.Settings.NotificationVoted != BodyArchitect.Service.V2.Model.ProfileNotification.None; //??
            profile.Settings.NotificationFriendChangedCalendar = res.Settings.NotificationFriendChangedCalendar != BodyArchitect.Service.V2.Model.ProfileNotification.None;
            profile.Settings.NotificationWorkoutPlanVoted      = res.Settings.NotificationVoted != BodyArchitect.Service.V2.Model.ProfileNotification.None; //??

            profile.User           = new UserSearchDTO();
            profile.User.CountryId = res.User.CountryId;
            SetProperty(profile.User, "CreationDate", res.User.CreationDate);
            profile.User.Gender = (BodyArchitect.Service.Model.Gender)res.User.Gender;
            //a.Id = res.User.GlobalId;
            tempId = null;
            if ((tempId = h.GetIntFromGuid(res.User.GlobalId)) == null)
            {
                tempId = h.SetIntFromGuid(res.User);
            }
            if (tempId != null)
            {
                profile.User.Id = (int)tempId;
            }
            else
            {
                throw new ArgumentException("Id not assigned to guid", res.User.GlobalId.ToString());
            }

            //a.IsDeleted = res.User.IsDeleted;
            SetProperty(profile.User, "IsDeleted", res.User.IsDeleted);
            //a.Picture = res.User.Picture;
            profile.User.Picture = new PictureInfoDTO();
            if (res.User.Picture != null)
            {
                profile.User.Picture.Hash      = res.User.Picture.Hash;
                profile.User.Picture.PictureId = res.User.Picture.PictureId;
                profile.User.Picture.SessionId = res.User.Picture.SessionId;
            }
            else
            {
                profile.User.Picture = null;
            }
            profile.User.Privacy.BirthdayDate = (BodyArchitect.Service.Model.Privacy)res.User.Privacy.BirthdayDate;
            profile.User.Privacy.CalendarView = (BodyArchitect.Service.Model.Privacy)res.User.Privacy.CalendarView;
            profile.User.Privacy.Friends      = (BodyArchitect.Service.Model.Privacy)res.User.Privacy.Friends;
            profile.User.Privacy.Searchable   = res.User.Privacy.Searchable;
            profile.User.Privacy.Sizes        = (BodyArchitect.Service.Model.Privacy)res.User.Privacy.Sizes;
            profile.User.UserName             = res.User.UserName;


            profile.Wymiary = new WymiaryDTO();
            if (res.Wymiary != null)
            {
                profile.Wymiary.DateTime = res.Wymiary.Time.DateTime;

                profile.Wymiary.Height = (int)res.Wymiary.Height;   //possible loss of data
                tempId = null;
                if ((tempId = h.GetIntFromGuid(res.Wymiary.GlobalId)) == null)
                {
                    tempId = h.SetIntFromGuid(res.Wymiary);
                }
                if (tempId != null)
                {
                    profile.Wymiary.Id = (int)tempId;
                }
                else
                {
                    throw new ArgumentException("Id not assigned to guid", res.Wymiary.GlobalId.ToString());
                }
                //profile.Wymiary.IsEmpty = res.Wymiary.IsEmpty; //READ ONLY
                profile.Wymiary.IsNaCzczo = false;  //res.Wymiary.????
                //profile.Wymiary.IsNew = res.Wymiary.IsNew;    //READ ONLY
                profile.Wymiary.Klatka       = (float)res.Wymiary.Klatka;
                profile.Wymiary.LeftBiceps   = (float)res.Wymiary.LeftBiceps;
                profile.Wymiary.LeftForearm  = (float)res.Wymiary.LeftForearm;
                profile.Wymiary.LeftUdo      = (float)res.Wymiary.LeftUdo;
                profile.Wymiary.Pas          = (float)res.Wymiary.Pas;
                profile.Wymiary.RightBiceps  = (float)res.Wymiary.RightBiceps;
                profile.Wymiary.RightForearm = (float)res.Wymiary.RightForearm;
                profile.Wymiary.RightUdo     = (float)res.Wymiary.RightUdo;
                profile.Wymiary.Tag          = res.Wymiary.Tag;
                profile.Wymiary.Weight       = (float)res.Wymiary.Weight;
            }
            return(profile);
        }
コード例 #13
0
        public PagedResult <ExerciseDTO> GetExercises(Token token, ExerciseSearchCriteria searchCriteria, PartialRetrievingInfo retrievingInfo)
        {
            BodyArchitect.Service.V2.InternalBodyArchitectService service = new V2.InternalBodyArchitectService(NHibernateContext.Current().Session);
            V2.Model.Token v2token = new V2.Model.Token(token.SessionId, token.Language);
            V2.Model.ExerciseSearchCriteria crit = new V2.Model.ExerciseSearchCriteria();
            V2.Model.PartialRetrievingInfo  nfo  = new V2.Model.PartialRetrievingInfo();
            crit = Mapper.Map <V2.Model.ExerciseSearchCriteria>(searchCriteria);
            nfo  = Mapper.Map <V2.Model.PartialRetrievingInfo>(retrievingInfo);

            var res = service.GetExercises(v2token, crit, nfo);
            var ret = Mapper.Map <V2.Model.PagedResult <V2.Model.ExerciseDTO>, PagedResult <ExerciseDTO> >(res);

            return(ret);
        }
コード例 #14
0
        public TrainingDayDTO SaveTrainingDay(Token token, TrainingDayDTO day)
        {
            BodyArchitect.Service.V2.InternalBodyArchitectService service = new V2.InternalBodyArchitectService(NHibernateContext.Current().Session);

            //var test=service.SaveTrainingDay(token,);
            throw new NotImplementedException();
        }